Fri, 08 Nov 2013 01:13:11 -0800
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
Reviewed-by: kvn, iveresov
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 1997, 2012, 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 | |
stefank@2314 | 25 | #ifndef SHARE_VM_CODE_ICBUFFER_HPP |
stefank@2314 | 26 | #define SHARE_VM_CODE_ICBUFFER_HPP |
stefank@2314 | 27 | |
kvn@4107 | 28 | #include "asm/codeBuffer.hpp" |
stefank@2314 | 29 | #include "code/stubs.hpp" |
stefank@2314 | 30 | #include "interpreter/bytecodes.hpp" |
stefank@2314 | 31 | #include "memory/allocation.hpp" |
stefank@2314 | 32 | |
duke@435 | 33 | // |
duke@435 | 34 | // For CompiledIC's: |
duke@435 | 35 | // |
duke@435 | 36 | // In cases where we do not have MT-safe state transformation, |
duke@435 | 37 | // we go to a transition state, using ICStubs. At a safepoint, |
duke@435 | 38 | // the inline caches are transferred from the transitional code: |
duke@435 | 39 | // |
duke@435 | 40 | // instruction_address --> 01 set xxx_oop, Ginline_cache_klass |
duke@435 | 41 | // 23 jump_to Gtemp, yyyy |
duke@435 | 42 | // 4 nop |
duke@435 | 43 | |
duke@435 | 44 | class ICStub: public Stub { |
duke@435 | 45 | private: |
duke@435 | 46 | int _size; // total size of the stub incl. code |
duke@435 | 47 | address _ic_site; // points at call instruction of owning ic-buffer |
duke@435 | 48 | /* stub code follows here */ |
duke@435 | 49 | protected: |
duke@435 | 50 | friend class ICStubInterface; |
duke@435 | 51 | // This will be called only by ICStubInterface |
kvn@4107 | 52 | void initialize(int size, |
roland@4767 | 53 | CodeStrings strings) { _size = size; _ic_site = NULL; } |
duke@435 | 54 | void finalize(); // called when a method is removed |
duke@435 | 55 | |
duke@435 | 56 | // General info |
duke@435 | 57 | int size() const { return _size; } |
duke@435 | 58 | static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; } |
duke@435 | 59 | |
duke@435 | 60 | public: |
duke@435 | 61 | // Creation |
coleenp@4037 | 62 | void set_stub(CompiledIC *ic, void* cached_value, address dest_addr); |
duke@435 | 63 | |
duke@435 | 64 | // Code info |
duke@435 | 65 | address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); } |
duke@435 | 66 | address code_end() const { return (address)this + size(); } |
duke@435 | 67 | |
duke@435 | 68 | // Call site info |
duke@435 | 69 | address ic_site() const { return _ic_site; } |
duke@435 | 70 | void clear(); |
duke@435 | 71 | bool is_empty() const { return _ic_site == NULL; } |
duke@435 | 72 | |
duke@435 | 73 | // stub info |
duke@435 | 74 | address destination() const; // destination of jump instruction |
coleenp@4037 | 75 | void* cached_value() const; // cached_value for stub |
duke@435 | 76 | |
duke@435 | 77 | // Debugging |
duke@435 | 78 | void verify() PRODUCT_RETURN; |
duke@435 | 79 | void print() PRODUCT_RETURN; |
duke@435 | 80 | |
duke@435 | 81 | // Creation |
duke@435 | 82 | friend ICStub* ICStub_from_destination_address(address destination_address); |
duke@435 | 83 | }; |
duke@435 | 84 | |
duke@435 | 85 | // ICStub Creation |
duke@435 | 86 | inline ICStub* ICStub_from_destination_address(address destination_address) { |
duke@435 | 87 | ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment)); |
duke@435 | 88 | #ifdef ASSERT |
duke@435 | 89 | stub->verify(); |
duke@435 | 90 | #endif |
duke@435 | 91 | return stub; |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | class InlineCacheBuffer: public AllStatic { |
duke@435 | 95 | private: |
duke@435 | 96 | // friends |
duke@435 | 97 | friend class ICStub; |
duke@435 | 98 | |
duke@435 | 99 | static int ic_stub_code_size(); |
duke@435 | 100 | |
duke@435 | 101 | static StubQueue* _buffer; |
duke@435 | 102 | static ICStub* _next_stub; |
duke@435 | 103 | |
coleenp@4037 | 104 | static CompiledICHolder* _pending_released; |
coleenp@4037 | 105 | static int _pending_count; |
coleenp@4037 | 106 | |
duke@435 | 107 | static StubQueue* buffer() { return _buffer; } |
duke@435 | 108 | static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; } |
duke@435 | 109 | static ICStub* get_next_stub() { return _next_stub; } |
duke@435 | 110 | |
duke@435 | 111 | static void init_next_stub(); |
duke@435 | 112 | |
duke@435 | 113 | static ICStub* new_ic_stub(); |
duke@435 | 114 | |
duke@435 | 115 | |
duke@435 | 116 | // Machine-dependent implementation of ICBuffer |
coleenp@4037 | 117 | static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point); |
duke@435 | 118 | static address ic_buffer_entry_point (address code_begin); |
coleenp@4037 | 119 | static void* ic_buffer_cached_value (address code_begin); |
duke@435 | 120 | |
duke@435 | 121 | public: |
duke@435 | 122 | |
duke@435 | 123 | // Initialization; must be called before first usage |
duke@435 | 124 | static void initialize(); |
duke@435 | 125 | |
duke@435 | 126 | // Access |
duke@435 | 127 | static bool contains(address instruction_address); |
duke@435 | 128 | |
duke@435 | 129 | // removes the ICStubs after backpatching |
duke@435 | 130 | static void update_inline_caches(); |
duke@435 | 131 | |
duke@435 | 132 | // for debugging |
duke@435 | 133 | static bool is_empty(); |
duke@435 | 134 | |
coleenp@4037 | 135 | static void release_pending_icholders(); |
coleenp@4037 | 136 | static void queue_for_release(CompiledICHolder* icholder); |
coleenp@4037 | 137 | static int pending_icholder_count() { return _pending_count; } |
duke@435 | 138 | |
duke@435 | 139 | // New interface |
coleenp@4037 | 140 | static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry); |
duke@435 | 141 | static address ic_destination_for(CompiledIC *ic); |
coleenp@4037 | 142 | static void* cached_value_for(CompiledIC *ic); |
duke@435 | 143 | }; |
stefank@2314 | 144 | |
stefank@2314 | 145 | #endif // SHARE_VM_CODE_ICBUFFER_HPP |