Thu, 27 May 2010 19:08:38 -0700
6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair
duke@435 | 1 | /* |
trims@1907 | 2 | * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | #include "incls/_precompiled.incl" |
duke@435 | 26 | #include "incls/_icBuffer.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | |
duke@435 | 29 | DEF_STUB_INTERFACE(ICStub); |
duke@435 | 30 | |
duke@435 | 31 | StubQueue* InlineCacheBuffer::_buffer = NULL; |
duke@435 | 32 | ICStub* InlineCacheBuffer::_next_stub = NULL; |
duke@435 | 33 | |
duke@435 | 34 | |
duke@435 | 35 | void ICStub::finalize() { |
duke@435 | 36 | if (!is_empty()) { |
duke@435 | 37 | ResourceMark rm; |
duke@435 | 38 | CompiledIC *ic = CompiledIC_at(ic_site()); |
duke@435 | 39 | assert(CodeCache::find_nmethod(ic->instruction_address()) != NULL, "inline cache in non-nmethod?"); |
duke@435 | 40 | |
duke@435 | 41 | assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer"); |
duke@435 | 42 | ic->set_cached_oop(cached_oop()); |
duke@435 | 43 | ic->set_ic_destination(destination()); |
duke@435 | 44 | } |
duke@435 | 45 | } |
duke@435 | 46 | |
duke@435 | 47 | |
duke@435 | 48 | address ICStub::destination() const { |
duke@435 | 49 | return InlineCacheBuffer::ic_buffer_entry_point(code_begin()); |
duke@435 | 50 | } |
duke@435 | 51 | |
duke@435 | 52 | oop ICStub::cached_oop() const { |
duke@435 | 53 | return InlineCacheBuffer::ic_buffer_cached_oop(code_begin()); |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | |
duke@435 | 57 | void ICStub::set_stub(CompiledIC *ic, oop cached_value, address dest_addr) { |
duke@435 | 58 | // We cannot store a pointer to the 'ic' object, since it is resource allocated. Instead we |
duke@435 | 59 | // store the location of the inline cache. Then we have enough information recreate the CompiledIC |
duke@435 | 60 | // object when we need to remove the stub. |
duke@435 | 61 | _ic_site = ic->instruction_address(); |
duke@435 | 62 | |
duke@435 | 63 | // Assemble new stub |
duke@435 | 64 | InlineCacheBuffer::assemble_ic_buffer_code(code_begin(), cached_value, dest_addr); |
duke@435 | 65 | assert(destination() == dest_addr, "can recover destination"); |
duke@435 | 66 | assert(cached_oop() == cached_value, "can recover destination"); |
duke@435 | 67 | } |
duke@435 | 68 | |
duke@435 | 69 | |
duke@435 | 70 | void ICStub::clear() { |
duke@435 | 71 | _ic_site = NULL; |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | |
duke@435 | 75 | #ifndef PRODUCT |
duke@435 | 76 | // anybody calling to this stub will trap |
duke@435 | 77 | |
duke@435 | 78 | void ICStub::verify() { |
duke@435 | 79 | } |
duke@435 | 80 | |
duke@435 | 81 | void ICStub::print() { |
duke@435 | 82 | tty->print_cr("ICStub: site: " INTPTR_FORMAT, _ic_site); |
duke@435 | 83 | } |
duke@435 | 84 | #endif |
duke@435 | 85 | |
duke@435 | 86 | //----------------------------------------------------------------------------------------------- |
duke@435 | 87 | // Implementation of InlineCacheBuffer |
duke@435 | 88 | |
duke@435 | 89 | void InlineCacheBuffer::init_next_stub() { |
duke@435 | 90 | ICStub* ic_stub = (ICStub*)buffer()->request_committed (ic_stub_code_size()); |
duke@435 | 91 | assert (ic_stub != NULL, "no room for a single stub"); |
duke@435 | 92 | set_next_stub(ic_stub); |
duke@435 | 93 | } |
duke@435 | 94 | |
duke@435 | 95 | void InlineCacheBuffer::initialize() { |
duke@435 | 96 | if (_buffer != NULL) return; // already initialized |
duke@435 | 97 | _buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer"); |
duke@435 | 98 | assert (_buffer != NULL, "cannot allocate InlineCacheBuffer"); |
duke@435 | 99 | init_next_stub(); |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | |
duke@435 | 103 | ICStub* InlineCacheBuffer::new_ic_stub() { |
duke@435 | 104 | while (true) { |
duke@435 | 105 | ICStub* ic_stub = (ICStub*)buffer()->request_committed(ic_stub_code_size()); |
duke@435 | 106 | if (ic_stub != NULL) { |
duke@435 | 107 | return ic_stub; |
duke@435 | 108 | } |
duke@435 | 109 | // we ran out of inline cache buffer space; must enter safepoint. |
duke@435 | 110 | // We do this by forcing a safepoint |
duke@435 | 111 | EXCEPTION_MARK; |
duke@435 | 112 | |
duke@435 | 113 | VM_ForceSafepoint vfs; |
duke@435 | 114 | VMThread::execute(&vfs); |
duke@435 | 115 | // We could potential get an async. exception at this point. |
duke@435 | 116 | // In that case we will rethrow it to ourselvs. |
duke@435 | 117 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 118 | oop exception = PENDING_EXCEPTION; |
duke@435 | 119 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 120 | Thread::send_async_exception(JavaThread::current()->threadObj(), exception); |
duke@435 | 121 | } |
duke@435 | 122 | } |
duke@435 | 123 | ShouldNotReachHere(); |
duke@435 | 124 | return NULL; |
duke@435 | 125 | } |
duke@435 | 126 | |
duke@435 | 127 | |
duke@435 | 128 | void InlineCacheBuffer::update_inline_caches() { |
duke@435 | 129 | if (buffer()->number_of_stubs() > 1) { |
duke@435 | 130 | if (TraceICBuffer) { |
duke@435 | 131 | tty->print_cr("[updating inline caches with %d stubs]", buffer()->number_of_stubs()); |
duke@435 | 132 | } |
duke@435 | 133 | buffer()->remove_all(); |
duke@435 | 134 | init_next_stub(); |
duke@435 | 135 | } |
duke@435 | 136 | } |
duke@435 | 137 | |
duke@435 | 138 | |
duke@435 | 139 | bool InlineCacheBuffer::contains(address instruction_address) { |
duke@435 | 140 | return buffer()->contains(instruction_address); |
duke@435 | 141 | } |
duke@435 | 142 | |
duke@435 | 143 | |
duke@435 | 144 | bool InlineCacheBuffer::is_empty() { |
duke@435 | 145 | return buffer()->number_of_stubs() == 1; // always has sentinel |
duke@435 | 146 | } |
duke@435 | 147 | |
duke@435 | 148 | |
duke@435 | 149 | void InlineCacheBuffer_init() { |
duke@435 | 150 | InlineCacheBuffer::initialize(); |
duke@435 | 151 | } |
duke@435 | 152 | |
duke@435 | 153 | |
duke@435 | 154 | void InlineCacheBuffer::create_transition_stub(CompiledIC *ic, oop cached_oop, address entry) { |
duke@435 | 155 | assert(!SafepointSynchronize::is_at_safepoint(), "should not be called during a safepoint"); |
duke@435 | 156 | assert (CompiledIC_lock->is_locked(), ""); |
duke@435 | 157 | assert(cached_oop == NULL || cached_oop->is_perm(), "must belong to perm. space"); |
duke@435 | 158 | if (TraceICBuffer) { tty->print_cr(" create transition stub for " INTPTR_FORMAT, ic->instruction_address()); } |
duke@435 | 159 | |
duke@435 | 160 | // If an transition stub is already associate with the inline cache, then we remove the association. |
duke@435 | 161 | if (ic->is_in_transition_state()) { |
duke@435 | 162 | ICStub* old_stub = ICStub_from_destination_address(ic->stub_address()); |
duke@435 | 163 | old_stub->clear(); |
duke@435 | 164 | } |
duke@435 | 165 | |
duke@435 | 166 | // allocate and initialize new "out-of-line" inline-cache |
duke@435 | 167 | ICStub* ic_stub = get_next_stub(); |
duke@435 | 168 | ic_stub->set_stub(ic, cached_oop, entry); |
duke@435 | 169 | |
duke@435 | 170 | // Update inline cache in nmethod to point to new "out-of-line" allocated inline cache |
duke@435 | 171 | ic->set_ic_destination(ic_stub->code_begin()); |
duke@435 | 172 | |
duke@435 | 173 | set_next_stub(new_ic_stub()); // can cause safepoint synchronization |
duke@435 | 174 | } |
duke@435 | 175 | |
duke@435 | 176 | |
duke@435 | 177 | address InlineCacheBuffer::ic_destination_for(CompiledIC *ic) { |
duke@435 | 178 | ICStub* stub = ICStub_from_destination_address(ic->stub_address()); |
duke@435 | 179 | return stub->destination(); |
duke@435 | 180 | } |
duke@435 | 181 | |
duke@435 | 182 | |
duke@435 | 183 | oop InlineCacheBuffer::cached_oop_for(CompiledIC *ic) { |
duke@435 | 184 | ICStub* stub = ICStub_from_destination_address(ic->stub_address()); |
duke@435 | 185 | return stub->cached_oop(); |
duke@435 | 186 | } |