annotate src/hotspot/cpu/x86/icBuffer_x86.cpp @ 55984:3a3e4e473622

8222637: Obsolete NeedsDeoptSuspend Reviewed-by: dlong, coleenp, dholmes
author rehn
date Fri, 26 Apr 2019 10:18:47 +0200
parents 1f304d0c888b
children
rev   line source
duke@1 1 /*
stefank@29081 2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #include "precompiled.hpp"
twisti@14626 26 #include "asm/macroAssembler.hpp"
twisti@14626 27 #include "asm/macroAssembler.inline.hpp"
stefank@7397 28 #include "code/icBuffer.hpp"
pliden@30764 29 #include "gc/shared/collectedHeap.inline.hpp"
stefank@7397 30 #include "interpreter/bytecodes.hpp"
stefank@7397 31 #include "memory/resourceArea.hpp"
stefank@7397 32 #include "nativeInst_x86.hpp"
stefank@7397 33 #include "oops/oop.inline.hpp"
duke@1 34
duke@1 35 int InlineCacheBuffer::ic_stub_code_size() {
kvn@42650 36 // Worst case, if destination is not a near call:
kvn@42650 37 // lea rax, lit1
kvn@42650 38 // lea scratch, lit2
kvn@42650 39 // jmp scratch
kvn@42650 40
kvn@42650 41 // Best case
kvn@42650 42 // lea rax, lit1
kvn@42650 43 // jmp lit2
kvn@42650 44
kvn@42650 45 int best = NativeMovConstReg::instruction_size + NativeJump::instruction_size;
kvn@42650 46 int worst = 2 * NativeMovConstReg::instruction_size + 3;
kvn@42650 47 return MAX2(best, worst);
duke@1 48 }
duke@1 49
duke@1 50
duke@1 51
coleenp@13728 52 void InlineCacheBuffer::assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point) {
duke@1 53 ResourceMark rm;
duke@1 54 CodeBuffer code(code_begin, ic_stub_code_size());
duke@1 55 MacroAssembler* masm = new MacroAssembler(&code);
coleenp@13728 56 // note: even though the code contains an embedded value, we do not need reloc info
duke@1 57 // because
coleenp@13728 58 // (1) the value is old (i.e., doesn't matter for scavenges)
duke@1 59 // (2) these ICStubs are removed *before* a GC happens, so the roots disappear
coleenp@13728 60 // assert(cached_value == NULL || cached_oop->is_perm(), "must be perm oop");
coleenp@13728 61 masm->lea(rax, AddressLiteral((address) cached_value, relocInfo::metadata_type));
duke@1 62 masm->jump(ExternalAddress(entry_point));
duke@1 63 }
duke@1 64
duke@1 65
duke@1 66 address InlineCacheBuffer::ic_buffer_entry_point(address code_begin) {
duke@1 67 NativeMovConstReg* move = nativeMovConstReg_at(code_begin); // creation also verifies the object
kvn@42650 68 address jmp = move->next_instruction_address();
kvn@42650 69 NativeInstruction* ni = nativeInstruction_at(jmp);
kvn@42650 70 if (ni->is_jump()) {
kvn@42650 71 NativeJump* jump = nativeJump_at(jmp);
kvn@42650 72 return jump->jump_destination();
kvn@42650 73 } else {
kvn@42650 74 assert(ni->is_far_jump(), "unexpected instruction");
kvn@42650 75 NativeFarJump* jump = nativeFarJump_at(jmp);
kvn@42650 76 return jump->jump_destination();
kvn@42650 77 }
duke@1 78 }
duke@1 79
duke@1 80
coleenp@13728 81 void* InlineCacheBuffer::ic_buffer_cached_value(address code_begin) {
duke@1 82 // creation also verifies the object
duke@1 83 NativeMovConstReg* move = nativeMovConstReg_at(code_begin);
duke@1 84 // Verifies the jump
kvn@42650 85 address jmp = move->next_instruction_address();
kvn@42650 86 NativeInstruction* ni = nativeInstruction_at(jmp);
kvn@42650 87 if (ni->is_jump()) {
kvn@42650 88 NativeJump* jump = nativeJump_at(jmp);
kvn@42650 89 } else {
kvn@42650 90 assert(ni->is_far_jump(), "unexpected instruction");
kvn@42650 91 NativeFarJump* jump = nativeFarJump_at(jmp);
kvn@42650 92 }
coleenp@13728 93 void* o = (void*)move->data();
coleenp@13728 94 return o;
duke@1 95 }