Wed, 21 Jan 2015 12:38:11 +0100
8068013: [TESTBUG] Aix support in hotspot jtreg tests
Reviewed-by: ctornqvi, fzhinkin, farvidsson
dlong@5000 | 1 | /* |
drchase@6680 | 2 | * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
dlong@5000 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dlong@5000 | 4 | * |
dlong@5000 | 5 | * This code is free software; you can redistribute it and/or modify it |
dlong@5000 | 6 | * under the terms of the GNU General Public License version 2 only, as |
dlong@5000 | 7 | * published by the Free Software Foundation. |
dlong@5000 | 8 | * |
dlong@5000 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
dlong@5000 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dlong@5000 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dlong@5000 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
dlong@5000 | 13 | * accompanied this code). |
dlong@5000 | 14 | * |
dlong@5000 | 15 | * You should have received a copy of the GNU General Public License version |
dlong@5000 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
dlong@5000 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dlong@5000 | 18 | * |
dlong@5000 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dlong@5000 | 20 | * or visit www.oracle.com if you need additional information or have any |
dlong@5000 | 21 | * questions. |
dlong@5000 | 22 | * |
dlong@5000 | 23 | */ |
dlong@5000 | 24 | |
dlong@5000 | 25 | #include "precompiled.hpp" |
dlong@5000 | 26 | #include "asm/macroAssembler.inline.hpp" |
dlong@5000 | 27 | #include "code/compiledIC.hpp" |
dlong@5000 | 28 | #include "code/icBuffer.hpp" |
dlong@5000 | 29 | #include "code/nmethod.hpp" |
dlong@5000 | 30 | #include "memory/resourceArea.hpp" |
dlong@5000 | 31 | #include "runtime/mutexLocker.hpp" |
dlong@5000 | 32 | #include "runtime/safepoint.hpp" |
dlong@5000 | 33 | |
dlong@5000 | 34 | // Release the CompiledICHolder* associated with this call site is there is one. |
dlong@5000 | 35 | void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { |
dlong@5000 | 36 | // This call site might have become stale so inspect it carefully. |
dlong@5000 | 37 | NativeCall* call = nativeCall_at(call_site->addr()); |
dlong@5000 | 38 | if (is_icholder_entry(call->destination())) { |
dlong@5000 | 39 | NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); |
dlong@5000 | 40 | InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); |
dlong@5000 | 41 | } |
dlong@5000 | 42 | } |
dlong@5000 | 43 | |
dlong@5000 | 44 | bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { |
dlong@5000 | 45 | // This call site might have become stale so inspect it carefully. |
dlong@5000 | 46 | NativeCall* call = nativeCall_at(call_site->addr()); |
dlong@5000 | 47 | return is_icholder_entry(call->destination()); |
dlong@5000 | 48 | } |
dlong@5000 | 49 | |
dlong@5000 | 50 | // ---------------------------------------------------------------------------- |
dlong@5000 | 51 | |
dlong@5000 | 52 | #define __ _masm. |
dlong@5000 | 53 | void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { |
dlong@5000 | 54 | // Stub is fixed up when the corresponding call is converted from |
dlong@5000 | 55 | // calling compiled code to calling interpreted code. |
dlong@5000 | 56 | // movq rbx, 0 |
dlong@5000 | 57 | // jmp -5 # to self |
dlong@5000 | 58 | |
dlong@5000 | 59 | address mark = cbuf.insts_mark(); // Get mark within main instrs section. |
dlong@5000 | 60 | |
dlong@5000 | 61 | // Note that the code buffer's insts_mark is always relative to insts. |
dlong@5000 | 62 | // That's why we must use the macroassembler to generate a stub. |
dlong@5000 | 63 | MacroAssembler _masm(&cbuf); |
dlong@5000 | 64 | |
dlong@5000 | 65 | address base = |
dlong@5000 | 66 | __ start_a_stub(to_interp_stub_size()*2); |
dlong@5000 | 67 | if (base == NULL) return; // CodeBuffer::expand failed. |
dlong@5000 | 68 | // Static stub relocation stores the instruction address of the call. |
dlong@5000 | 69 | __ relocate(static_stub_Relocation::spec(mark), Assembler::imm_operand); |
dlong@5000 | 70 | // Static stub relocation also tags the Method* in the code-stream. |
dlong@5000 | 71 | __ mov_metadata(rbx, (Metadata*) NULL); // Method is zapped till fixup time. |
dlong@5000 | 72 | // This is recognized as unresolved by relocs/nativeinst/ic code. |
dlong@5000 | 73 | __ jump(RuntimeAddress(__ pc())); |
dlong@5000 | 74 | |
dlong@5000 | 75 | // Update current stubs pointer and restore insts_end. |
dlong@5000 | 76 | __ end_a_stub(); |
dlong@5000 | 77 | } |
dlong@5000 | 78 | #undef __ |
dlong@5000 | 79 | |
dlong@5000 | 80 | int CompiledStaticCall::to_interp_stub_size() { |
dlong@5000 | 81 | return NOT_LP64(10) // movl; jmp |
dlong@5000 | 82 | LP64_ONLY(15); // movq (1+1+8); jmp (1+4) |
dlong@5000 | 83 | } |
dlong@5000 | 84 | |
dlong@5000 | 85 | // Relocation entries for call stub, compiled java to interpreter. |
dlong@5000 | 86 | int CompiledStaticCall::reloc_to_interp_stub() { |
dlong@5000 | 87 | return 4; // 3 in emit_to_interp_stub + 1 in emit_call |
dlong@5000 | 88 | } |
dlong@5000 | 89 | |
dlong@5000 | 90 | void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) { |
dlong@5000 | 91 | address stub = find_stub(); |
dlong@5000 | 92 | guarantee(stub != NULL, "stub not found"); |
dlong@5000 | 93 | |
dlong@5000 | 94 | if (TraceICs) { |
dlong@5000 | 95 | ResourceMark rm; |
dlong@5000 | 96 | tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s", |
drchase@6680 | 97 | p2i(instruction_address()), |
dlong@5000 | 98 | callee->name_and_sig_as_C_string()); |
dlong@5000 | 99 | } |
dlong@5000 | 100 | |
dlong@5000 | 101 | // Creation also verifies the object. |
dlong@5000 | 102 | NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); |
dlong@5000 | 103 | NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); |
dlong@5000 | 104 | |
dlong@5000 | 105 | assert(method_holder->data() == 0 || method_holder->data() == (intptr_t)callee(), |
dlong@5000 | 106 | "a) MT-unsafe modification of inline cache"); |
dlong@5000 | 107 | assert(jump->jump_destination() == (address)-1 || jump->jump_destination() == entry, |
dlong@5000 | 108 | "b) MT-unsafe modification of inline cache"); |
dlong@5000 | 109 | |
dlong@5000 | 110 | // Update stub. |
dlong@5000 | 111 | method_holder->set_data((intptr_t)callee()); |
dlong@5000 | 112 | jump->set_jump_destination(entry); |
dlong@5000 | 113 | |
dlong@5000 | 114 | // Update jump to call. |
dlong@5000 | 115 | set_destination_mt_safe(stub); |
dlong@5000 | 116 | } |
dlong@5000 | 117 | |
dlong@5000 | 118 | void CompiledStaticCall::set_stub_to_clean(static_stub_Relocation* static_stub) { |
dlong@5000 | 119 | assert (CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), "mt unsafe call"); |
dlong@5000 | 120 | // Reset stub. |
dlong@5000 | 121 | address stub = static_stub->addr(); |
dlong@5000 | 122 | assert(stub != NULL, "stub not found"); |
dlong@5000 | 123 | // Creation also verifies the object. |
dlong@5000 | 124 | NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); |
dlong@5000 | 125 | NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); |
dlong@5000 | 126 | method_holder->set_data(0); |
dlong@5000 | 127 | jump->set_jump_destination((address)-1); |
dlong@5000 | 128 | } |
dlong@5000 | 129 | |
dlong@5000 | 130 | //----------------------------------------------------------------------------- |
dlong@5000 | 131 | // Non-product mode code |
dlong@5000 | 132 | #ifndef PRODUCT |
dlong@5000 | 133 | |
dlong@5000 | 134 | void CompiledStaticCall::verify() { |
dlong@5000 | 135 | // Verify call. |
dlong@5000 | 136 | NativeCall::verify(); |
dlong@5000 | 137 | if (os::is_MP()) { |
dlong@5000 | 138 | verify_alignment(); |
dlong@5000 | 139 | } |
dlong@5000 | 140 | |
dlong@5000 | 141 | // Verify stub. |
dlong@5000 | 142 | address stub = find_stub(); |
dlong@5000 | 143 | assert(stub != NULL, "no stub found for static call"); |
dlong@5000 | 144 | // Creation also verifies the object. |
dlong@5000 | 145 | NativeMovConstReg* method_holder = nativeMovConstReg_at(stub); |
dlong@5000 | 146 | NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); |
dlong@5000 | 147 | |
dlong@5000 | 148 | // Verify state. |
dlong@5000 | 149 | assert(is_clean() || is_call_to_compiled() || is_call_to_interpreted(), "sanity check"); |
dlong@5000 | 150 | } |
dlong@5000 | 151 | |
dlong@5000 | 152 | #endif // !PRODUCT |