author | jlaskey |
Thu, 14 Nov 2019 12:33:47 -0400 | |
branch | jlaskey-prng |
changeset 59084 | b8fb85ee91e9 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52896
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52896
diff
changeset
|
25 |
#ifndef SHARE_CODE_ICBUFFER_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52896
diff
changeset
|
26 |
#define SHARE_CODE_ICBUFFER_HPP |
7397 | 27 |
|
13887
89b873bcc55b
7200163: add CodeComments functionality to assember stubs
kvn
parents:
13728
diff
changeset
|
28 |
#include "asm/codeBuffer.hpp" |
7397 | 29 |
#include "code/stubs.hpp" |
30 |
#include "interpreter/bytecodes.hpp" |
|
31 |
#include "memory/allocation.hpp" |
|
52896
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
32 |
#include "runtime/safepointVerifiers.hpp" |
46625 | 33 |
#include "utilities/align.hpp" |
52896
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
34 |
#include "utilities/debug.hpp" |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
47216
diff
changeset
|
35 |
#include "utilities/macros.hpp" |
7397 | 36 |
|
1 | 37 |
// |
38 |
// For CompiledIC's: |
|
39 |
// |
|
40 |
// In cases where we do not have MT-safe state transformation, |
|
41 |
// we go to a transition state, using ICStubs. At a safepoint, |
|
42 |
// the inline caches are transferred from the transitional code: |
|
43 |
// |
|
44 |
// instruction_address --> 01 set xxx_oop, Ginline_cache_klass |
|
45 |
// 23 jump_to Gtemp, yyyy |
|
46 |
// 4 nop |
|
47 |
||
48 |
class ICStub: public Stub { |
|
49 |
private: |
|
50 |
int _size; // total size of the stub incl. code |
|
51 |
address _ic_site; // points at call instruction of owning ic-buffer |
|
52 |
/* stub code follows here */ |
|
53 |
protected: |
|
54 |
friend class ICStubInterface; |
|
55 |
// This will be called only by ICStubInterface |
|
13887
89b873bcc55b
7200163: add CodeComments functionality to assember stubs
kvn
parents:
13728
diff
changeset
|
56 |
void initialize(int size, |
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
13887
diff
changeset
|
57 |
CodeStrings strings) { _size = size; _ic_site = NULL; } |
1 | 58 |
void finalize(); // called when a method is removed |
59 |
||
60 |
// General info |
|
61 |
int size() const { return _size; } |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
22234
diff
changeset
|
62 |
static int code_size_to_size(int code_size) { return align_up((int)sizeof(ICStub), CodeEntryAlignment) + code_size; } |
1 | 63 |
|
64 |
public: |
|
65 |
// Creation |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
66 |
void set_stub(CompiledIC *ic, void* cached_value, address dest_addr); |
1 | 67 |
|
68 |
// Code info |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
22234
diff
changeset
|
69 |
address code_begin() const { return (address)this + align_up(sizeof(ICStub), CodeEntryAlignment); } |
1 | 70 |
address code_end() const { return (address)this + size(); } |
71 |
||
72 |
// Call site info |
|
73 |
address ic_site() const { return _ic_site; } |
|
74 |
void clear(); |
|
75 |
bool is_empty() const { return _ic_site == NULL; } |
|
76 |
||
77 |
// stub info |
|
78 |
address destination() const; // destination of jump instruction |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
79 |
void* cached_value() const; // cached_value for stub |
1 | 80 |
|
81 |
// Debugging |
|
82 |
void verify() PRODUCT_RETURN; |
|
83 |
void print() PRODUCT_RETURN; |
|
84 |
||
85 |
// Creation |
|
86 |
friend ICStub* ICStub_from_destination_address(address destination_address); |
|
87 |
}; |
|
88 |
||
89 |
// ICStub Creation |
|
90 |
inline ICStub* ICStub_from_destination_address(address destination_address) { |
|
46620
750c6edff33b
8178500: Replace usages of round_to and round_down with align_up and align_down
stefank
parents:
22234
diff
changeset
|
91 |
ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment)); |
1 | 92 |
#ifdef ASSERT |
93 |
stub->verify(); |
|
94 |
#endif |
|
95 |
return stub; |
|
96 |
} |
|
97 |
||
52896
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
98 |
#ifdef ASSERT |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
99 |
// The ICRefillVerifier class is a stack allocated RAII object used to |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
100 |
// detect if a failed IC transition that required IC stub refilling has |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
101 |
// been accidentally missed. It is up to the caller to in that case |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
102 |
// refill IC stubs. |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
103 |
class ICRefillVerifier: StackObj { |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
104 |
bool _refill_requested; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
105 |
bool _refill_remembered; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
106 |
|
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
107 |
public: |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
108 |
ICRefillVerifier(); |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
109 |
~ICRefillVerifier(); |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
110 |
|
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
111 |
void request_refill() { _refill_requested = true; } |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
112 |
void request_remembered() { _refill_remembered = true; } |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
113 |
}; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
114 |
|
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
115 |
// The ICRefillVerifierMark is used to set the thread's current |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
116 |
// ICRefillVerifier to a provided one. This is useful in particular |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
117 |
// when transitioning IC stubs in parallel and refilling from the |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
118 |
// master thread invoking the IC stub transitioning code. |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
119 |
class ICRefillVerifierMark: StackObj { |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
120 |
public: |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
121 |
ICRefillVerifierMark(ICRefillVerifier* verifier); |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
122 |
~ICRefillVerifierMark(); |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
123 |
}; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
124 |
#else |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
125 |
class ICRefillVerifier: StackObj { |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
126 |
public: |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
127 |
ICRefillVerifier() {} |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
128 |
}; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
129 |
class ICRefillVerifierMark: StackObj { |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
130 |
public: |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
131 |
ICRefillVerifierMark(ICRefillVerifier* verifier) {} |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
132 |
}; |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
133 |
#endif |
98408c7c0b73
8214936: assert(_needs_refill == 0) failed: Forgot to handle a failed IC transition requiring IC stubs
eosterlund
parents:
52857
diff
changeset
|
134 |
|
1 | 135 |
class InlineCacheBuffer: public AllStatic { |
136 |
private: |
|
137 |
// friends |
|
138 |
friend class ICStub; |
|
139 |
||
140 |
static int ic_stub_code_size(); |
|
141 |
||
142 |
static StubQueue* _buffer; |
|
143 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
144 |
static CompiledICHolder* _pending_released; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
145 |
static int _pending_count; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
146 |
|
1 | 147 |
static StubQueue* buffer() { return _buffer; } |
148 |
||
149 |
static ICStub* new_ic_stub(); |
|
150 |
||
151 |
// Machine-dependent implementation of ICBuffer |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
152 |
static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point); |
1 | 153 |
static address ic_buffer_entry_point (address code_begin); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
154 |
static void* ic_buffer_cached_value (address code_begin); |
1 | 155 |
|
156 |
public: |
|
157 |
||
158 |
// Initialization; must be called before first usage |
|
159 |
static void initialize(); |
|
160 |
||
161 |
// Access |
|
162 |
static bool contains(address instruction_address); |
|
163 |
||
164 |
// removes the ICStubs after backpatching |
|
165 |
static void update_inline_caches(); |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
47216
diff
changeset
|
166 |
static void refill_ic_stubs(); |
1 | 167 |
|
168 |
// for debugging |
|
169 |
static bool is_empty(); |
|
170 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
171 |
static void release_pending_icholders(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
172 |
static void queue_for_release(CompiledICHolder* icholder); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
173 |
static int pending_icholder_count() { return _pending_count; } |
1 | 174 |
|
175 |
// New interface |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
47216
diff
changeset
|
176 |
static bool create_transition_stub(CompiledIC *ic, void* cached_value, address entry); |
1 | 177 |
static address ic_destination_for(CompiledIC *ic); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
178 |
static void* cached_value_for(CompiledIC *ic); |
1 | 179 |
}; |
7397 | 180 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52896
diff
changeset
|
181 |
#endif // SHARE_CODE_ICBUFFER_HPP |