author | coleenp |
Thu, 10 Jan 2019 15:13:51 -0500 | |
changeset 53244 | 9807daeb47c4 |
parent 52857 | 7e268f863ff0 |
child 53652 | 262afafdb266 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52857
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:
52857
diff
changeset
|
25 |
#ifndef SHARE_CODE_COMPILEDIC_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52857
diff
changeset
|
26 |
#define SHARE_CODE_COMPILEDIC_HPP |
7397 | 27 |
|
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
22234
diff
changeset
|
28 |
#include "code/nativeInst.hpp" |
7397 | 29 |
#include "interpreter/linkResolver.hpp" |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
30 |
#include "oops/compiledICHolder.hpp" |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
31 |
#include "runtime/safepointVerifiers.hpp" |
7397 | 32 |
|
1 | 33 |
//----------------------------------------------------------------------------- |
34 |
// The CompiledIC represents a compiled inline cache. |
|
35 |
// |
|
36 |
// In order to make patching of the inline cache MT-safe, we only allow the following |
|
37 |
// transitions (when not at a safepoint): |
|
38 |
// |
|
39 |
// |
|
40 |
// [1] --<-- Clean -->--- [1] |
|
41 |
// / (null) \ |
|
42 |
// / \ /-<-\ |
|
43 |
// / [2] \ / \ |
|
44 |
// Interpreted ---------> Monomorphic | [3] |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
45 |
// (CompiledICHolder*) (Klass*) | |
1 | 46 |
// \ / \ / |
47 |
// [4] \ / [4] \->-/ |
|
48 |
// \->- Megamorphic -<-/ |
|
48557 | 49 |
// (CompiledICHolder*) |
1 | 50 |
// |
48557 | 51 |
// The text in parentheses () refers to the value of the inline cache receiver (mov instruction) |
1 | 52 |
// |
48557 | 53 |
// The numbers in square brackets refer to the kind of transition: |
1 | 54 |
// [1]: Initial fixup. Receiver it found from debug information |
55 |
// [2]: Compilation of a method |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
56 |
// [3]: Recompilation of a method (note: only entry is changed. The Klass* must stay the same) |
1 | 57 |
// [4]: Inline cache miss. We go directly to megamorphic call. |
58 |
// |
|
59 |
// The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe |
|
60 |
// transition is made to a stub. |
|
61 |
// |
|
62 |
class CompiledIC; |
|
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
63 |
class CompiledICProtectionBehaviour; |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
64 |
class CompiledMethod; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
65 |
class ICStub; |
1 | 66 |
|
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
67 |
class CompiledICLocker: public StackObj { |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
68 |
CompiledMethod* _method; |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
69 |
CompiledICProtectionBehaviour* _behaviour; |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
70 |
bool _locked; |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
71 |
NoSafepointVerifier _nsv; |
52384
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
72 |
|
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
73 |
public: |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
74 |
CompiledICLocker(CompiledMethod* method); |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
75 |
~CompiledICLocker(); |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
76 |
static bool is_safe(CompiledMethod* method); |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
77 |
static bool is_safe(address code); |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
78 |
}; |
d6dc479bcdd3
8212681: Refactor IC locking to use a fine grained CompiledICLocker
eosterlund
parents:
51333
diff
changeset
|
79 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
80 |
class CompiledICInfo : public StackObj { |
1 | 81 |
private: |
82 |
address _entry; // entry point for call |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
83 |
void* _cached_value; // Value of cached_value (either in stub or inline cache) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
84 |
bool _is_icholder; // Is the cached value a CompiledICHolder* |
1 | 85 |
bool _is_optimized; // it is an optimized virtual call (i.e., can be statically bound) |
86 |
bool _to_interpreter; // Call it to interpreter |
|
42650 | 87 |
bool _to_aot; // Call it to aot code |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
88 |
bool _release_icholder; |
1 | 89 |
public: |
90 |
address entry() const { return _entry; } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
91 |
Metadata* cached_metadata() const { assert(!_is_icholder, ""); return (Metadata*)_cached_value; } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
92 |
CompiledICHolder* claim_cached_icholder() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
93 |
assert(_is_icholder, ""); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
94 |
assert(_cached_value != NULL, "must be non-NULL"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
95 |
_release_icholder = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
96 |
CompiledICHolder* icholder = (CompiledICHolder*)_cached_value; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
97 |
icholder->claim(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
98 |
return icholder; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
99 |
} |
1 | 100 |
bool is_optimized() const { return _is_optimized; } |
42650 | 101 |
bool to_interpreter() const { return _to_interpreter; } |
102 |
bool to_aot() const { return _to_aot; } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
103 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
104 |
void set_compiled_entry(address entry, Klass* klass, bool is_optimized) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
105 |
_entry = entry; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
106 |
_cached_value = (void*)klass; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
107 |
_to_interpreter = false; |
42650 | 108 |
_to_aot = false; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
109 |
_is_icholder = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
110 |
_is_optimized = is_optimized; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
111 |
_release_icholder = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
112 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
113 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
114 |
void set_interpreter_entry(address entry, Method* method) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
115 |
_entry = entry; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
116 |
_cached_value = (void*)method; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
117 |
_to_interpreter = true; |
42650 | 118 |
_to_aot = false; |
119 |
_is_icholder = false; |
|
120 |
_is_optimized = true; |
|
121 |
_release_icholder = false; |
|
122 |
} |
|
123 |
||
124 |
void set_aot_entry(address entry, Method* method) { |
|
125 |
_entry = entry; |
|
126 |
_cached_value = (void*)method; |
|
127 |
_to_interpreter = false; |
|
128 |
_to_aot = true; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
129 |
_is_icholder = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
130 |
_is_optimized = true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
131 |
_release_icholder = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
132 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
133 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
134 |
void set_icholder_entry(address entry, CompiledICHolder* icholder) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
135 |
_entry = entry; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
136 |
_cached_value = (void*)icholder; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
137 |
_to_interpreter = true; |
42650 | 138 |
_to_aot = false; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
139 |
_is_icholder = true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
140 |
_is_optimized = false; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
141 |
_release_icholder = true; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
142 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
143 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
144 |
CompiledICInfo(): _entry(NULL), _cached_value(NULL), _is_icholder(false), |
51333
f6641fcf7b7e
8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents:
50416
diff
changeset
|
145 |
_is_optimized(false), _to_interpreter(false), _to_aot(false), _release_icholder(false) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
146 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
147 |
~CompiledICInfo() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
148 |
// In rare cases the info is computed but not used, so release any |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
149 |
// CompiledICHolder* that was created |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
150 |
if (_release_icholder) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
151 |
assert(_is_icholder, "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
152 |
CompiledICHolder* icholder = (CompiledICHolder*)_cached_value; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
153 |
icholder->claim(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
154 |
delete icholder; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
155 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
156 |
} |
1 | 157 |
}; |
158 |
||
42650 | 159 |
class NativeCallWrapper: public ResourceObj { |
160 |
public: |
|
161 |
virtual address destination() const = 0; |
|
162 |
virtual address instruction_address() const = 0; |
|
163 |
virtual address next_instruction_address() const = 0; |
|
164 |
virtual address return_address() const = 0; |
|
165 |
virtual address get_resolve_call_stub(bool is_optimized) const = 0; |
|
166 |
virtual void set_destination_mt_safe(address dest) = 0; |
|
167 |
virtual void set_to_interpreted(const methodHandle& method, CompiledICInfo& info) = 0; |
|
168 |
virtual void verify() const = 0; |
|
169 |
virtual void verify_resolve_call(address dest) const = 0; |
|
170 |
||
171 |
virtual bool is_call_to_interpreted(address dest) const = 0; |
|
172 |
virtual bool is_safe_for_patching() const = 0; |
|
173 |
||
174 |
virtual NativeInstruction* get_load_instruction(virtual_call_Relocation* r) const = 0; |
|
175 |
||
176 |
virtual void *get_data(NativeInstruction* instruction) const = 0; |
|
177 |
virtual void set_data(NativeInstruction* instruction, intptr_t data) = 0; |
|
178 |
}; |
|
179 |
||
1 | 180 |
class CompiledIC: public ResourceObj { |
181 |
friend class InlineCacheBuffer; |
|
182 |
friend class ICStub; |
|
183 |
||
184 |
private: |
|
42650 | 185 |
NativeCallWrapper* _call; |
186 |
NativeInstruction* _value; // patchable value cell for this IC |
|
1 | 187 |
bool _is_optimized; // an optimized virtual call (i.e., no compiled IC) |
42650 | 188 |
CompiledMethod* _method; |
1 | 189 |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33593
diff
changeset
|
190 |
CompiledIC(CompiledMethod* cm, NativeCall* ic_call); |
25486
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
191 |
CompiledIC(RelocIterator* iter); |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
192 |
|
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
193 |
void initialize_from_iter(RelocIterator* iter); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
194 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
195 |
static bool is_icholder_entry(address entry); |
1 | 196 |
|
197 |
// low-level inline-cache manipulation. Cannot be accessed directly, since it might not be MT-safe |
|
198 |
// to change an inline-cache. These changes the underlying inline-cache directly. They *newer* make |
|
199 |
// changes to a transition stub. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
200 |
void internal_set_ic_destination(address entry_point, bool is_icstub, void* cache, bool is_icholder); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
201 |
void set_ic_destination(ICStub* stub); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
202 |
void set_ic_destination(address entry_point) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
203 |
assert(_is_optimized, "use set_ic_destination_and_value instead"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
204 |
internal_set_ic_destination(entry_point, false, NULL, false); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
205 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
206 |
// This only for use by ICStubs where the type of the value isn't known |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
207 |
void set_ic_destination_and_value(address entry_point, void* value) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
208 |
internal_set_ic_destination(entry_point, false, value, is_icholder_entry(entry_point)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
209 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
210 |
void set_ic_destination_and_value(address entry_point, Metadata* value) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
211 |
internal_set_ic_destination(entry_point, false, value, false); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
212 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
213 |
void set_ic_destination_and_value(address entry_point, CompiledICHolder* value) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
214 |
internal_set_ic_destination(entry_point, false, value, true); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
215 |
} |
1 | 216 |
|
217 |
// Reads the location of the transition stub. This will fail with an assertion, if no transition stub is |
|
218 |
// associated with the inline cache. |
|
219 |
address stub_address() const; |
|
220 |
bool is_in_transition_state() const; // Use InlineCacheBuffer |
|
221 |
||
222 |
public: |
|
223 |
// conversion (machine PC to CompiledIC*) |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33593
diff
changeset
|
224 |
friend CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr); |
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33593
diff
changeset
|
225 |
friend CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site); |
1 | 226 |
friend CompiledIC* CompiledIC_at(Relocation* call_site); |
25486
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
227 |
friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter); |
1 | 228 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
229 |
// This is used to release CompiledICHolder*s from nmethods that |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
230 |
// are about to be freed. The callsite might contain other stale |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
231 |
// values of other kinds so it must be careful. |
42650 | 232 |
static void cleanup_call_site(virtual_call_Relocation* call_site, const CompiledMethod* cm); |
233 |
static bool is_icholder_call_site(virtual_call_Relocation* call_site, const CompiledMethod* cm); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
234 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
235 |
// Return the cached_metadata/destination associated with this inline cache. If the cache currently points |
1 | 236 |
// to a transition stub, it will read the values from the transition stub. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
237 |
void* cached_value() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
238 |
CompiledICHolder* cached_icholder() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
239 |
assert(is_icholder_call(), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
240 |
return (CompiledICHolder*) cached_value(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
241 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
242 |
Metadata* cached_metadata() const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
243 |
assert(!is_icholder_call(), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
244 |
return (Metadata*) cached_value(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
245 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
246 |
|
42650 | 247 |
void* get_data() const { |
248 |
return _call->get_data(_value); |
|
249 |
} |
|
250 |
||
251 |
void set_data(intptr_t data) { |
|
252 |
_call->set_data(_value, data); |
|
253 |
} |
|
254 |
||
1 | 255 |
address ic_destination() const; |
256 |
||
257 |
bool is_optimized() const { return _is_optimized; } |
|
258 |
||
259 |
// State |
|
260 |
bool is_clean() const; |
|
261 |
bool is_megamorphic() const; |
|
262 |
bool is_call_to_compiled() const; |
|
263 |
bool is_call_to_interpreted() const; |
|
264 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
265 |
bool is_icholder_call() const; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
266 |
|
42650 | 267 |
address end_of_call() { return _call->return_address(); } |
1 | 268 |
|
269 |
// MT-safe patching of inline caches. Note: Only safe to call is_xxx when holding the CompiledIC_ock |
|
270 |
// so you are guaranteed that no patching takes place. The same goes for verify. |
|
271 |
// |
|
272 |
// Note: We do not provide any direct access to the stub code, to prevent parts of the code |
|
273 |
// to manipulate the inline cache in MT-unsafe ways. |
|
274 |
// |
|
275 |
// They all takes a TRAP argument, since they can cause a GC if the inline-cache buffer is full. |
|
276 |
// |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
277 |
bool set_to_clean(bool in_use = true); |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
278 |
bool set_to_monomorphic(CompiledICInfo& info); |
26912
19021f626ad2
8058737: CodeCache::find_blob fails with 'unsafe access to zombie method'
thartmann
parents:
25716
diff
changeset
|
279 |
void clear_ic_stub(); |
20072 | 280 |
|
281 |
// Returns true if successful and false otherwise. The call can fail if memory |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
282 |
// allocation in the code cache fails, or ic stub refill is required. |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
283 |
bool set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, bool& needs_ic_stub_refill, TRAPS); |
1 | 284 |
|
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
42650
diff
changeset
|
285 |
static void compute_monomorphic_entry(const methodHandle& method, Klass* receiver_klass, |
42650 | 286 |
bool is_optimized, bool static_bound, bool caller_is_nmethod, |
287 |
CompiledICInfo& info, TRAPS); |
|
1 | 288 |
|
289 |
// Location |
|
42650 | 290 |
address instruction_address() const { return _call->instruction_address(); } |
1 | 291 |
|
292 |
// Misc |
|
293 |
void print() PRODUCT_RETURN; |
|
294 |
void print_compiled_ic() PRODUCT_RETURN; |
|
295 |
void verify() PRODUCT_RETURN; |
|
296 |
}; |
|
297 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33593
diff
changeset
|
298 |
inline CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
299 |
CompiledIC* c_ic = new CompiledIC(nm, nativeCall_before(return_addr)); |
1 | 300 |
c_ic->verify(); |
301 |
return c_ic; |
|
302 |
} |
|
303 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33593
diff
changeset
|
304 |
inline CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
305 |
CompiledIC* c_ic = new CompiledIC(nm, nativeCall_at(call_site)); |
1 | 306 |
c_ic->verify(); |
307 |
return c_ic; |
|
308 |
} |
|
309 |
||
310 |
inline CompiledIC* CompiledIC_at(Relocation* call_site) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
311 |
assert(call_site->type() == relocInfo::virtual_call_type || |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
312 |
call_site->type() == relocInfo::opt_virtual_call_type, "wrong reloc. info"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
313 |
CompiledIC* c_ic = new CompiledIC(call_site->code(), nativeCall_at(call_site->addr())); |
1 | 314 |
c_ic->verify(); |
315 |
return c_ic; |
|
316 |
} |
|
317 |
||
25486
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
318 |
inline CompiledIC* CompiledIC_at(RelocIterator* reloc_iter) { |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
319 |
assert(reloc_iter->type() == relocInfo::virtual_call_type || |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
320 |
reloc_iter->type() == relocInfo::opt_virtual_call_type, "wrong reloc. info"); |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
321 |
CompiledIC* c_ic = new CompiledIC(reloc_iter); |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
322 |
c_ic->verify(); |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
323 |
return c_ic; |
be44827be5e7
8047362: Add a version of CompiledIC_at that doesn't create a new RelocIterator
stefank
parents:
22234
diff
changeset
|
324 |
} |
1 | 325 |
|
326 |
//----------------------------------------------------------------------------- |
|
327 |
// The CompiledStaticCall represents a call to a static method in the compiled |
|
328 |
// |
|
329 |
// Transition diagram of a static call site is somewhat simpler than for an inlined cache: |
|
330 |
// |
|
331 |
// |
|
332 |
// -----<----- Clean ----->----- |
|
333 |
// / \ |
|
334 |
// / \ |
|
335 |
// compilled code <------------> interpreted code |
|
336 |
// |
|
337 |
// Clean: Calls directly to runtime method for fixup |
|
338 |
// Compiled code: Calls directly to compiled code |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
339 |
// Interpreted code: Calls to stub that set Method* reference |
1 | 340 |
// |
341 |
// |
|
342 |
||
343 |
class StaticCallInfo { |
|
344 |
private: |
|
345 |
address _entry; // Entrypoint |
|
346 |
methodHandle _callee; // Callee (used when calling interpreter) |
|
347 |
bool _to_interpreter; // call to interpreted method (otherwise compiled) |
|
42650 | 348 |
bool _to_aot; // call to aot method (otherwise compiled) |
1 | 349 |
|
350 |
friend class CompiledStaticCall; |
|
42650 | 351 |
friend class CompiledDirectStaticCall; |
352 |
friend class CompiledPltStaticCall; |
|
1 | 353 |
public: |
354 |
address entry() const { return _entry; } |
|
355 |
methodHandle callee() const { return _callee; } |
|
356 |
}; |
|
357 |
||
42650 | 358 |
class CompiledStaticCall : public ResourceObj { |
1 | 359 |
public: |
17094
29c4955396d2
8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
13728
diff
changeset
|
360 |
// Code |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
32466
diff
changeset
|
361 |
static address emit_to_interp_stub(CodeBuffer &cbuf, address mark = NULL); |
17094
29c4955396d2
8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
13728
diff
changeset
|
362 |
static int to_interp_stub_size(); |
48487 | 363 |
static int to_trampoline_stub_size(); |
17094
29c4955396d2
8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
13728
diff
changeset
|
364 |
static int reloc_to_interp_stub(); |
42650 | 365 |
static void emit_to_aot_stub(CodeBuffer &cbuf, address mark = NULL); |
366 |
static int to_aot_stub_size(); |
|
367 |
static int reloc_to_aot_stub(); |
|
17094
29c4955396d2
8003853: specify offset of IC load in java_to_interp stub
dlong
parents:
13728
diff
changeset
|
368 |
|
42650 | 369 |
// Compute entry point given a method |
370 |
static void compute_entry(const methodHandle& m, bool caller_is_nmethod, StaticCallInfo& info); |
|
371 |
||
372 |
public: |
|
373 |
// Clean static call (will force resolving on next use) |
|
374 |
virtual address destination() const = 0; |
|
1 | 375 |
|
376 |
// Clean static call (will force resolving on next use) |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52384
diff
changeset
|
377 |
bool set_to_clean(bool in_use = true); |
1 | 378 |
|
379 |
// Set state. The entry must be the same, as computed by compute_entry. |
|
380 |
// Computation and setting is split up, since the actions are separate during |
|
381 |
// a OptoRuntime::resolve_xxx. |
|
382 |
void set(const StaticCallInfo& info); |
|
383 |
||
42650 | 384 |
// State |
385 |
bool is_clean() const; |
|
386 |
bool is_call_to_compiled() const; |
|
387 |
virtual bool is_call_to_interpreted() const = 0; |
|
388 |
||
389 |
virtual address instruction_address() const = 0; |
|
390 |
protected: |
|
391 |
virtual address resolve_call_stub() const = 0; |
|
392 |
virtual void set_destination_mt_safe(address dest) = 0; |
|
393 |
#if INCLUDE_AOT |
|
394 |
virtual void set_to_far(const methodHandle& callee, address entry) = 0; |
|
395 |
#endif |
|
396 |
virtual void set_to_interpreted(const methodHandle& callee, address entry) = 0; |
|
397 |
virtual const char* name() const = 0; |
|
398 |
||
399 |
void set_to_compiled(address entry); |
|
400 |
}; |
|
401 |
||
402 |
class CompiledDirectStaticCall : public CompiledStaticCall { |
|
403 |
private: |
|
404 |
friend class CompiledIC; |
|
405 |
friend class DirectNativeCallWrapper; |
|
406 |
||
407 |
// Also used by CompiledIC |
|
408 |
void set_to_interpreted(const methodHandle& callee, address entry); |
|
409 |
#if INCLUDE_AOT |
|
410 |
void set_to_far(const methodHandle& callee, address entry); |
|
411 |
#endif |
|
412 |
address instruction_address() const { return _call->instruction_address(); } |
|
413 |
void set_destination_mt_safe(address dest) { _call->set_destination_mt_safe(dest); } |
|
414 |
||
415 |
NativeCall* _call; |
|
416 |
||
417 |
CompiledDirectStaticCall(NativeCall* call) : _call(call) {} |
|
418 |
||
419 |
public: |
|
420 |
static inline CompiledDirectStaticCall* before(address return_addr) { |
|
421 |
CompiledDirectStaticCall* st = new CompiledDirectStaticCall(nativeCall_before(return_addr)); |
|
422 |
st->verify(); |
|
423 |
return st; |
|
424 |
} |
|
425 |
||
426 |
static inline CompiledDirectStaticCall* at(address native_call) { |
|
427 |
CompiledDirectStaticCall* st = new CompiledDirectStaticCall(nativeCall_at(native_call)); |
|
428 |
st->verify(); |
|
429 |
return st; |
|
430 |
} |
|
431 |
||
432 |
static inline CompiledDirectStaticCall* at(Relocation* call_site) { |
|
433 |
return at(call_site->addr()); |
|
434 |
} |
|
435 |
||
436 |
// Delegation |
|
437 |
address destination() const { return _call->destination(); } |
|
438 |
||
439 |
// State |
|
440 |
virtual bool is_call_to_interpreted() const; |
|
441 |
bool is_call_to_far() const; |
|
1 | 442 |
|
443 |
// Stub support |
|
42650 | 444 |
static address find_stub_for(address instruction, bool is_aot); |
445 |
address find_stub(bool is_aot); |
|
1 | 446 |
static void set_stub_to_clean(static_stub_Relocation* static_stub); |
447 |
||
448 |
// Misc. |
|
449 |
void print() PRODUCT_RETURN; |
|
450 |
void verify() PRODUCT_RETURN; |
|
42650 | 451 |
|
452 |
protected: |
|
453 |
virtual address resolve_call_stub() const; |
|
454 |
virtual const char* name() const { return "CompiledDirectStaticCall"; } |
|
1 | 455 |
}; |
456 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52857
diff
changeset
|
457 |
#endif // SHARE_CODE_COMPILEDIC_HPP |