author | twisti |
Mon, 26 Nov 2012 17:25:11 -0800 | |
changeset 14621 | fd9265ab0f67 |
parent 13952 | e3cf184080bc |
child 17000 | 11bf92e571a2 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
2 |
* Copyright (c) 1998, 2012, 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:
4754
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4754
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:
4754
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/systemDictionary.hpp" |
|
27 |
#include "compiler/compileLog.hpp" |
|
28 |
#include "oops/objArrayKlass.hpp" |
|
29 |
#include "opto/addnode.hpp" |
|
30 |
#include "opto/memnode.hpp" |
|
31 |
#include "opto/mulnode.hpp" |
|
32 |
#include "opto/parse.hpp" |
|
33 |
#include "opto/rootnode.hpp" |
|
34 |
#include "opto/runtime.hpp" |
|
35 |
#include "runtime/sharedRuntime.hpp" |
|
1 | 36 |
|
37 |
//------------------------------make_dtrace_method_entry_exit ---------------- |
|
38 |
// Dtrace -- record entry or exit of a method if compiled with dtrace support |
|
39 |
void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) { |
|
40 |
const TypeFunc *call_type = OptoRuntime::dtrace_method_entry_exit_Type(); |
|
41 |
address call_address = is_entry ? CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry) : |
|
42 |
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit); |
|
43 |
const char *call_name = is_entry ? "dtrace_method_entry" : "dtrace_method_exit"; |
|
44 |
||
45 |
// Get base of thread-local storage area |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
46 |
Node* thread = _gvn.transform( new (C) ThreadLocalNode() ); |
1 | 47 |
|
48 |
// Get method |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
49 |
const TypePtr* method_type = TypeMetadataPtr::make(method); |
590
2954744d7bba
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
1
diff
changeset
|
50 |
Node *method_node = _gvn.transform( ConNode::make(C, method_type) ); |
1 | 51 |
|
52 |
kill_dead_locals(); |
|
53 |
||
54 |
// For some reason, this call reads only raw memory. |
|
55 |
const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; |
|
56 |
make_runtime_call(RC_LEAF | RC_NARROW_MEM, |
|
57 |
call_type, call_address, |
|
58 |
call_name, raw_adr_type, |
|
59 |
thread, method_node); |
|
60 |
} |
|
61 |
||
62 |
||
63 |
//============================================================================= |
|
64 |
//------------------------------do_checkcast----------------------------------- |
|
65 |
void Parse::do_checkcast() { |
|
66 |
bool will_link; |
|
67 |
ciKlass* klass = iter().get_klass(will_link); |
|
68 |
||
69 |
Node *obj = peek(); |
|
70 |
||
71 |
// Throw uncommon trap if class is not loaded or the value we are casting |
|
72 |
// _from_ is not loaded, and value is not null. If the value _is_ NULL, |
|
73 |
// then the checkcast does nothing. |
|
11570
25f3e9348905
7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents:
11439
diff
changeset
|
74 |
const TypeOopPtr *tp = _gvn.type(obj)->isa_oopptr(); |
25f3e9348905
7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents:
11439
diff
changeset
|
75 |
if (!will_link || (tp && tp->klass() && !tp->klass()->is_loaded())) { |
1 | 76 |
if (C->log() != NULL) { |
77 |
if (!will_link) { |
|
78 |
C->log()->elem("assert_null reason='checkcast' klass='%d'", |
|
79 |
C->log()->identify(klass)); |
|
80 |
} |
|
11570
25f3e9348905
7123910: Some CTW tests crash VM: is_loaded() && that->is_loaded()
roland
parents:
11439
diff
changeset
|
81 |
if (tp && tp->klass() && !tp->klass()->is_loaded()) { |
1 | 82 |
// %%% Cannot happen? |
83 |
C->log()->elem("assert_null reason='checkcast source' klass='%d'", |
|
84 |
C->log()->identify(tp->klass())); |
|
85 |
} |
|
86 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
87 |
null_assert(obj); |
1 | 88 |
assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" ); |
89 |
if (!stopped()) { |
|
90 |
profile_null_checkcast(); |
|
91 |
} |
|
92 |
return; |
|
93 |
} |
|
94 |
||
95 |
Node *res = gen_checkcast(obj, makecon(TypeKlassPtr::make(klass)) ); |
|
96 |
||
97 |
// Pop from stack AFTER gen_checkcast because it can uncommon trap and |
|
98 |
// the debug info has to be correct. |
|
99 |
pop(); |
|
100 |
push(res); |
|
101 |
} |
|
102 |
||
103 |
||
104 |
//------------------------------do_instanceof---------------------------------- |
|
105 |
void Parse::do_instanceof() { |
|
106 |
if (stopped()) return; |
|
107 |
// We would like to return false if class is not loaded, emitting a |
|
108 |
// dependency, but Java requires instanceof to load its operand. |
|
109 |
||
110 |
// Throw uncommon trap if class is not loaded |
|
111 |
bool will_link; |
|
112 |
ciKlass* klass = iter().get_klass(will_link); |
|
113 |
||
114 |
if (!will_link) { |
|
115 |
if (C->log() != NULL) { |
|
116 |
C->log()->elem("assert_null reason='instanceof' klass='%d'", |
|
117 |
C->log()->identify(klass)); |
|
118 |
} |
|
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
119 |
null_assert(peek()); |
1 | 120 |
assert( stopped() || _gvn.type(peek())->higher_equal(TypePtr::NULL_PTR), "what's left behind is null" ); |
121 |
if (!stopped()) { |
|
122 |
// The object is now known to be null. |
|
123 |
// Shortcut the effect of gen_instanceof and return "false" directly. |
|
124 |
pop(); // pop the null |
|
125 |
push(_gvn.intcon(0)); // push false answer |
|
126 |
} |
|
127 |
return; |
|
128 |
} |
|
129 |
||
130 |
// Push the bool result back on stack |
|
6416
d49b65c9425a
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
5925
diff
changeset
|
131 |
Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass))); |
d49b65c9425a
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
5925
diff
changeset
|
132 |
|
d49b65c9425a
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
5925
diff
changeset
|
133 |
// Pop from stack AFTER gen_instanceof because it can uncommon trap. |
d49b65c9425a
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
5925
diff
changeset
|
134 |
pop(); |
d49b65c9425a
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
5925
diff
changeset
|
135 |
push(res); |
1 | 136 |
} |
137 |
||
138 |
//------------------------------array_store_check------------------------------ |
|
139 |
// pull array from stack and check that the store is valid |
|
140 |
void Parse::array_store_check() { |
|
141 |
||
14621
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
142 |
// Shorthand access to array store elements without popping them. |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
143 |
Node *obj = peek(0); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
144 |
Node *idx = peek(1); |
fd9265ab0f67
7172640: C2: instrinsic implementations in LibraryCallKit should use argument() instead of pop()
twisti
parents:
13952
diff
changeset
|
145 |
Node *ary = peek(2); |
1 | 146 |
|
147 |
if (_gvn.type(obj) == TypePtr::NULL_PTR) { |
|
148 |
// There's never a type check on null values. |
|
149 |
// This cutout lets us avoid the uncommon_trap(Reason_array_check) |
|
150 |
// below, which turns into a performance liability if the |
|
151 |
// gen_checkcast folds up completely. |
|
152 |
return; |
|
153 |
} |
|
154 |
||
155 |
// Extract the array klass type |
|
156 |
int klass_offset = oopDesc::klass_offset_in_bytes(); |
|
157 |
Node* p = basic_plus_adr( ary, ary, klass_offset ); |
|
158 |
// p's type is array-of-OOPS plus klass_offset |
|
590
2954744d7bba
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
1
diff
changeset
|
159 |
Node* array_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS) ); |
1 | 160 |
// Get the array klass |
161 |
const TypeKlassPtr *tak = _gvn.type(array_klass)->is_klassptr(); |
|
162 |
||
163 |
// array_klass's type is generally INexact array-of-oop. Heroically |
|
164 |
// cast the array klass to EXACT array and uncommon-trap if the cast |
|
165 |
// fails. |
|
166 |
bool always_see_exact_class = false; |
|
167 |
if (MonomorphicArrayCheck |
|
168 |
&& !too_many_traps(Deoptimization::Reason_array_check)) { |
|
169 |
always_see_exact_class = true; |
|
170 |
// (If no MDO at all, hope for the best, until a trap actually occurs.) |
|
171 |
} |
|
172 |
||
173 |
// Is the array klass is exactly its defined type? |
|
174 |
if (always_see_exact_class && !tak->klass_is_exact()) { |
|
175 |
// Make a constant out of the inexact array klass |
|
176 |
const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr(); |
|
177 |
Node* con = makecon(extak); |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
178 |
Node* cmp = _gvn.transform(new (C) CmpPNode( array_klass, con )); |
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
179 |
Node* bol = _gvn.transform(new (C) BoolNode( cmp, BoolTest::eq )); |
1 | 180 |
Node* ctrl= control(); |
181 |
{ BuildCutout unless(this, bol, PROB_MAX); |
|
182 |
uncommon_trap(Deoptimization::Reason_array_check, |
|
183 |
Deoptimization::Action_maybe_recompile, |
|
184 |
tak->klass()); |
|
185 |
} |
|
186 |
if (stopped()) { // MUST uncommon-trap? |
|
187 |
set_control(ctrl); // Then Don't Do It, just fall into the normal checking |
|
188 |
} else { // Cast array klass to exactness: |
|
189 |
// Use the exact constant value we know it is. |
|
190 |
replace_in_map(array_klass,con); |
|
191 |
CompileLog* log = C->log(); |
|
192 |
if (log != NULL) { |
|
193 |
log->elem("cast_up reason='monomorphic_array' from='%d' to='(exact)'", |
|
194 |
log->identify(tak->klass())); |
|
195 |
} |
|
196 |
array_klass = con; // Use cast value moving forward |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
// Come here for polymorphic array klasses |
|
201 |
||
202 |
// Extract the array element class |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13895
diff
changeset
|
203 |
int element_klass_offset = in_bytes(ObjArrayKlass::element_klass_offset()); |
1 | 204 |
Node *p2 = basic_plus_adr(array_klass, array_klass, element_klass_offset); |
590
2954744d7bba
6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents:
1
diff
changeset
|
205 |
Node *a_e_klass = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p2, tak) ); |
1 | 206 |
|
207 |
// Check (the hard way) and throw if not a subklass. |
|
208 |
// Result is ignored, we just need the CFG effects. |
|
209 |
gen_checkcast( obj, a_e_klass ); |
|
210 |
} |
|
211 |
||
212 |
||
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
213 |
void Parse::emit_guard_for_new(ciInstanceKlass* klass) { |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
214 |
// Emit guarded new |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
215 |
// if (klass->_init_thread != current_thread || |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
216 |
// klass->_init_state != being_initialized) |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
217 |
// uncommon_trap |
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
218 |
Node* cur_thread = _gvn.transform( new (C) ThreadLocalNode() ); |
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
219 |
Node* merge = new (C) RegionNode(3); |
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
220 |
_gvn.set_type(merge, Type::CONTROL); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
221 |
Node* kls = makecon(TypeKlassPtr::make(klass)); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
222 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
223 |
Node* init_thread_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_thread_offset())); |
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
224 |
Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
225 |
Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
226 |
Node *tst = Bool( CmpP( init_thread, cur_thread), BoolTest::eq); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
227 |
IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
228 |
set_control(IfTrue(iff)); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
229 |
merge->set_req(1, IfFalse(iff)); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
230 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
231 |
Node* init_state_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_state_offset())); |
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
232 |
adr_node = basic_plus_adr(kls, kls, init_state_offset); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
233 |
// Use T_BOOLEAN for InstanceKlass::_init_state so the compiler |
11407
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
7397
diff
changeset
|
234 |
// can generate code to load it as unsigned byte. |
5399831730cd
7117052: instanceKlass::_init_state can be u1 type
coleenp
parents:
7397
diff
changeset
|
235 |
Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
236 |
Node* being_init = _gvn.intcon(InstanceKlass::being_initialized); |
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
237 |
tst = Bool( CmpI( init_state, being_init), BoolTest::eq); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
238 |
iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
239 |
set_control(IfTrue(iff)); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
240 |
merge->set_req(2, IfFalse(iff)); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
241 |
|
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
242 |
PreserveJVMState pjvms(this); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
243 |
record_for_igvn(merge); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
244 |
set_control(merge); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
245 |
|
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
246 |
uncommon_trap(Deoptimization::Reason_uninitialized, |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
247 |
Deoptimization::Action_reinterpret, |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
248 |
klass); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
249 |
} |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
250 |
|
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
251 |
|
1 | 252 |
//------------------------------do_new----------------------------------------- |
253 |
void Parse::do_new() { |
|
254 |
kill_dead_locals(); |
|
255 |
||
256 |
bool will_link; |
|
257 |
ciInstanceKlass* klass = iter().get_klass(will_link)->as_instance_klass(); |
|
258 |
assert(will_link, "_new: typeflow responsibility"); |
|
259 |
||
260 |
// Should initialize, or throw an InstantiationError? |
|
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
261 |
if (!klass->is_initialized() && !klass->is_being_initialized() || |
1 | 262 |
klass->is_abstract() || klass->is_interface() || |
263 |
klass->name() == ciSymbol::java_lang_Class() || |
|
264 |
iter().is_unresolved_klass()) { |
|
265 |
uncommon_trap(Deoptimization::Reason_uninitialized, |
|
266 |
Deoptimization::Action_reinterpret, |
|
267 |
klass); |
|
268 |
return; |
|
269 |
} |
|
5925
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
270 |
if (klass->is_being_initialized()) { |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
271 |
emit_guard_for_new(klass); |
a30fef61d0b7
6958668: repeated uncommon trapping for new of klass which is being initialized
never
parents:
5547
diff
changeset
|
272 |
} |
1 | 273 |
|
274 |
Node* kls = makecon(TypeKlassPtr::make(klass)); |
|
275 |
Node* obj = new_instance(kls); |
|
276 |
||
277 |
// Push resultant oop onto stack |
|
278 |
push(obj); |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
279 |
|
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
280 |
// Keep track of whether opportunities exist for StringBuilder |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
281 |
// optimizations. |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
282 |
if (OptimizeStringConcat && |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
283 |
(klass == C->env()->StringBuilder_klass() || |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
284 |
klass == C->env()->StringBuffer_klass())) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
285 |
C->set_has_stringbuilder(true); |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
3261
diff
changeset
|
286 |
} |
1 | 287 |
} |
288 |
||
289 |
#ifndef PRODUCT |
|
290 |
//------------------------------dump_map_adr_mem------------------------------- |
|
291 |
// Debug dump of the mapping from address types to MergeMemNode indices. |
|
292 |
void Parse::dump_map_adr_mem() const { |
|
293 |
tty->print_cr("--- Mapping from address types to memory Nodes ---"); |
|
294 |
MergeMemNode *mem = map() == NULL ? NULL : (map()->memory()->is_MergeMem() ? |
|
295 |
map()->memory()->as_MergeMem() : NULL); |
|
296 |
for (uint i = 0; i < (uint)C->num_alias_types(); i++) { |
|
297 |
C->alias_type(i)->print_on(tty); |
|
298 |
tty->print("\t"); |
|
299 |
// Node mapping, if any |
|
300 |
if (mem && i < mem->req() && mem->in(i) && mem->in(i) != mem->empty_memory()) { |
|
301 |
mem->in(i)->dump(); |
|
302 |
} else { |
|
303 |
tty->cr(); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
#endif |
|
309 |
||
310 |
||
311 |
//============================================================================= |
|
312 |
// |
|
313 |
// parser methods for profiling |
|
314 |
||
315 |
||
316 |
//----------------------test_counter_against_threshold ------------------------ |
|
317 |
void Parse::test_counter_against_threshold(Node* cnt, int limit) { |
|
318 |
// Test the counter against the limit and uncommon trap if greater. |
|
319 |
||
320 |
// This code is largely copied from the range check code in |
|
321 |
// array_addressing() |
|
322 |
||
323 |
// Test invocation count vs threshold |
|
324 |
Node *threshold = makecon(TypeInt::make(limit)); |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
325 |
Node *chk = _gvn.transform( new (C) CmpUNode( cnt, threshold) ); |
1 | 326 |
BoolTest::mask btest = BoolTest::lt; |
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
327 |
Node *tst = _gvn.transform( new (C) BoolNode( chk, btest) ); |
1 | 328 |
// Branch to failure if threshold exceeded |
329 |
{ BuildCutout unless(this, tst, PROB_ALWAYS); |
|
330 |
uncommon_trap(Deoptimization::Reason_age, |
|
331 |
Deoptimization::Action_maybe_recompile); |
|
332 |
} |
|
333 |
} |
|
334 |
||
335 |
//----------------------increment_and_test_invocation_counter------------------- |
|
336 |
void Parse::increment_and_test_invocation_counter(int limit) { |
|
337 |
if (!count_invocations()) return; |
|
338 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
339 |
// Get the Method* node. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
340 |
const TypePtr* adr_type = TypeMetadataPtr::make(method()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
341 |
Node *method_node = makecon(adr_type); |
1 | 342 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
343 |
// Load the interpreter_invocation_counter from the Method*. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
344 |
int offset = Method::interpreter_invocation_counter_offset_in_bytes(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
345 |
Node* adr_node = basic_plus_adr(method_node, method_node, offset); |
1 | 346 |
Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type); |
347 |
||
348 |
test_counter_against_threshold(cnt, limit); |
|
349 |
||
350 |
// Add one to the counter and store |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
351 |
Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(1))); |
1 | 352 |
store_to_memory( NULL, adr_node, incr, T_INT, adr_type ); |
353 |
} |
|
354 |
||
355 |
//----------------------------method_data_addressing--------------------------- |
|
356 |
Node* Parse::method_data_addressing(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
357 |
// Get offset within MethodData* of the data array |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
358 |
ByteSize data_offset = MethodData::data_offset(); |
1 | 359 |
|
360 |
// Get cell offset of the ProfileData within data array |
|
361 |
int cell_offset = md->dp_to_di(data->dp()); |
|
362 |
||
363 |
// Add in counter_offset, the # of bytes into the ProfileData of counter or flag |
|
364 |
int offset = in_bytes(data_offset) + cell_offset + in_bytes(counter_offset); |
|
365 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
11570
diff
changeset
|
366 |
const TypePtr* adr_type = TypeMetadataPtr::make(md); |
1 | 367 |
Node* mdo = makecon(adr_type); |
368 |
Node* ptr = basic_plus_adr(mdo, mdo, offset); |
|
369 |
||
370 |
if (stride != 0) { |
|
371 |
Node* str = _gvn.MakeConX(stride); |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
372 |
Node* scale = _gvn.transform( new (C) MulXNode( idx, str ) ); |
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
373 |
ptr = _gvn.transform( new (C) AddPNode( mdo, ptr, scale ) ); |
1 | 374 |
} |
375 |
||
376 |
return ptr; |
|
377 |
} |
|
378 |
||
379 |
//--------------------------increment_md_counter_at---------------------------- |
|
380 |
void Parse::increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, Node* idx, uint stride) { |
|
381 |
Node* adr_node = method_data_addressing(md, data, counter_offset, idx, stride); |
|
382 |
||
383 |
const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); |
|
384 |
Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type); |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
385 |
Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(DataLayout::counter_increment))); |
1 | 386 |
store_to_memory(NULL, adr_node, incr, T_INT, adr_type ); |
387 |
} |
|
388 |
||
389 |
//--------------------------test_for_osr_md_counter_at------------------------- |
|
390 |
void Parse::test_for_osr_md_counter_at(ciMethodData* md, ciProfileData* data, ByteSize counter_offset, int limit) { |
|
391 |
Node* adr_node = method_data_addressing(md, data, counter_offset); |
|
392 |
||
393 |
const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); |
|
394 |
Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type); |
|
395 |
||
396 |
test_counter_against_threshold(cnt, limit); |
|
397 |
} |
|
398 |
||
399 |
//-------------------------------set_md_flag_at-------------------------------- |
|
400 |
void Parse::set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_constant) { |
|
401 |
Node* adr_node = method_data_addressing(md, data, DataLayout::flags_offset()); |
|
402 |
||
403 |
const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); |
|
404 |
Node* flags = make_load(NULL, adr_node, TypeInt::BYTE, T_BYTE, adr_type); |
|
13895
f6dfe4123709
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
13728
diff
changeset
|
405 |
Node* incr = _gvn.transform(new (C) OrINode(flags, _gvn.intcon(flag_constant))); |
1 | 406 |
store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type); |
407 |
} |
|
408 |
||
409 |
//----------------------------profile_taken_branch----------------------------- |
|
410 |
void Parse::profile_taken_branch(int target_bci, bool force_update) { |
|
411 |
// This is a potential osr_site if we have a backedge. |
|
412 |
int cur_bci = bci(); |
|
413 |
bool osr_site = |
|
414 |
(target_bci <= cur_bci) && count_invocations() && UseOnStackReplacement; |
|
415 |
||
416 |
// If we are going to OSR, restart at the target bytecode. |
|
417 |
set_bci(target_bci); |
|
418 |
||
419 |
// To do: factor out the the limit calculations below. These duplicate |
|
420 |
// the similar limit calculations in the interpreter. |
|
421 |
||
422 |
if (method_data_update() || force_update) { |
|
423 |
ciMethodData* md = method()->method_data(); |
|
424 |
assert(md != NULL, "expected valid ciMethodData"); |
|
425 |
ciProfileData* data = md->bci_to_data(cur_bci); |
|
426 |
assert(data->is_JumpData(), "need JumpData for taken branch"); |
|
427 |
increment_md_counter_at(md, data, JumpData::taken_offset()); |
|
428 |
} |
|
429 |
||
430 |
// In the new tiered system this is all we need to do. In the old |
|
431 |
// (c2 based) tiered sytem we must do the code below. |
|
432 |
#ifndef TIERED |
|
433 |
if (method_data_update()) { |
|
434 |
ciMethodData* md = method()->method_data(); |
|
435 |
if (osr_site) { |
|
436 |
ciProfileData* data = md->bci_to_data(cur_bci); |
|
437 |
int limit = (CompileThreshold |
|
438 |
* (OnStackReplacePercentage - InterpreterProfilePercentage)) / 100; |
|
439 |
test_for_osr_md_counter_at(md, data, JumpData::taken_offset(), limit); |
|
440 |
} |
|
441 |
} else { |
|
442 |
// With method data update off, use the invocation counter to trigger an |
|
443 |
// OSR compilation, as done in the interpreter. |
|
444 |
if (osr_site) { |
|
445 |
int limit = (CompileThreshold * OnStackReplacePercentage) / 100; |
|
446 |
increment_and_test_invocation_counter(limit); |
|
447 |
} |
|
448 |
} |
|
449 |
#endif // TIERED |
|
450 |
||
451 |
// Restore the original bytecode. |
|
452 |
set_bci(cur_bci); |
|
453 |
} |
|
454 |
||
455 |
//--------------------------profile_not_taken_branch--------------------------- |
|
456 |
void Parse::profile_not_taken_branch(bool force_update) { |
|
457 |
||
458 |
if (method_data_update() || force_update) { |
|
459 |
ciMethodData* md = method()->method_data(); |
|
460 |
assert(md != NULL, "expected valid ciMethodData"); |
|
461 |
ciProfileData* data = md->bci_to_data(bci()); |
|
462 |
assert(data->is_BranchData(), "need BranchData for not taken branch"); |
|
463 |
increment_md_counter_at(md, data, BranchData::not_taken_offset()); |
|
464 |
} |
|
465 |
||
466 |
} |
|
467 |
||
468 |
//---------------------------------profile_call-------------------------------- |
|
469 |
void Parse::profile_call(Node* receiver) { |
|
470 |
if (!method_data_update()) return; |
|
471 |
||
472 |
switch (bc()) { |
|
473 |
case Bytecodes::_invokevirtual: |
|
474 |
case Bytecodes::_invokeinterface: |
|
475 |
profile_receiver_type(receiver); |
|
476 |
break; |
|
477 |
case Bytecodes::_invokestatic: |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
670
diff
changeset
|
478 |
case Bytecodes::_invokedynamic: |
1 | 479 |
case Bytecodes::_invokespecial: |
4754
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
480 |
profile_generic_call(); |
1 | 481 |
break; |
482 |
default: fatal("unexpected call bytecode"); |
|
483 |
} |
|
484 |
} |
|
485 |
||
486 |
//------------------------------profile_generic_call--------------------------- |
|
487 |
void Parse::profile_generic_call() { |
|
488 |
assert(method_data_update(), "must be generating profile code"); |
|
489 |
||
490 |
ciMethodData* md = method()->method_data(); |
|
491 |
assert(md != NULL, "expected valid ciMethodData"); |
|
492 |
ciProfileData* data = md->bci_to_data(bci()); |
|
493 |
assert(data->is_CounterData(), "need CounterData for not taken branch"); |
|
494 |
increment_md_counter_at(md, data, CounterData::count_offset()); |
|
495 |
} |
|
496 |
||
497 |
//-----------------------------profile_receiver_type--------------------------- |
|
498 |
void Parse::profile_receiver_type(Node* receiver) { |
|
499 |
assert(method_data_update(), "must be generating profile code"); |
|
500 |
||
501 |
ciMethodData* md = method()->method_data(); |
|
502 |
assert(md != NULL, "expected valid ciMethodData"); |
|
503 |
ciProfileData* data = md->bci_to_data(bci()); |
|
504 |
assert(data->is_ReceiverTypeData(), "need ReceiverTypeData here"); |
|
4754
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
505 |
|
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
506 |
// Skip if we aren't tracking receivers |
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
507 |
if (TypeProfileWidth < 1) { |
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
508 |
increment_md_counter_at(md, data, CounterData::count_offset()); |
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
509 |
return; |
8aef16f24e16
6614597: Performance variability in jvm2008 xml.validation
kvn
parents:
4450
diff
changeset
|
510 |
} |
1 | 511 |
ciReceiverTypeData* rdata = (ciReceiverTypeData*)data->as_ReceiverTypeData(); |
512 |
||
513 |
Node* method_data = method_data_addressing(md, rdata, in_ByteSize(0)); |
|
514 |
||
515 |
// Using an adr_type of TypePtr::BOTTOM to work around anti-dep problems. |
|
516 |
// A better solution might be to use TypeRawPtr::BOTTOM with RC_NARROW_MEM. |
|
517 |
make_runtime_call(RC_LEAF, OptoRuntime::profile_receiver_type_Type(), |
|
518 |
CAST_FROM_FN_PTR(address, |
|
519 |
OptoRuntime::profile_receiver_type_C), |
|
520 |
"profile_receiver_type_C", |
|
521 |
TypePtr::BOTTOM, |
|
522 |
method_data, receiver); |
|
523 |
} |
|
524 |
||
525 |
//---------------------------------profile_ret--------------------------------- |
|
526 |
void Parse::profile_ret(int target_bci) { |
|
527 |
if (!method_data_update()) return; |
|
528 |
||
529 |
// Skip if we aren't tracking ret targets |
|
530 |
if (TypeProfileWidth < 1) return; |
|
531 |
||
532 |
ciMethodData* md = method()->method_data(); |
|
533 |
assert(md != NULL, "expected valid ciMethodData"); |
|
534 |
ciProfileData* data = md->bci_to_data(bci()); |
|
535 |
assert(data->is_RetData(), "need RetData for ret"); |
|
536 |
ciRetData* ret_data = (ciRetData*)data->as_RetData(); |
|
537 |
||
538 |
// Look for the target_bci is already in the table |
|
539 |
uint row; |
|
540 |
bool table_full = true; |
|
541 |
for (row = 0; row < ret_data->row_limit(); row++) { |
|
542 |
int key = ret_data->bci(row); |
|
543 |
table_full &= (key != RetData::no_bci); |
|
544 |
if (key == target_bci) break; |
|
545 |
} |
|
546 |
||
547 |
if (row >= ret_data->row_limit()) { |
|
548 |
// The target_bci was not found in the table. |
|
549 |
if (!table_full) { |
|
550 |
// XXX: Make slow call to update RetData |
|
551 |
} |
|
552 |
return; |
|
553 |
} |
|
554 |
||
555 |
// the target_bci is already in the table |
|
556 |
increment_md_counter_at(md, data, RetData::bci_count_offset(row)); |
|
557 |
} |
|
558 |
||
559 |
//--------------------------profile_null_checkcast---------------------------- |
|
560 |
void Parse::profile_null_checkcast() { |
|
561 |
// Set the null-seen flag, done in conjunction with the usual null check. We |
|
562 |
// never unset the flag, so this is a one-way switch. |
|
563 |
if (!method_data_update()) return; |
|
564 |
||
565 |
ciMethodData* md = method()->method_data(); |
|
566 |
assert(md != NULL, "expected valid ciMethodData"); |
|
567 |
ciProfileData* data = md->bci_to_data(bci()); |
|
568 |
assert(data->is_BitData(), "need BitData for checkcast"); |
|
569 |
set_md_flag_at(md, data, BitData::null_seen_byte_constant()); |
|
570 |
} |
|
571 |
||
572 |
//-----------------------------profile_switch_case----------------------------- |
|
573 |
void Parse::profile_switch_case(int table_index) { |
|
574 |
if (!method_data_update()) return; |
|
575 |
||
576 |
ciMethodData* md = method()->method_data(); |
|
577 |
assert(md != NULL, "expected valid ciMethodData"); |
|
578 |
||
579 |
ciProfileData* data = md->bci_to_data(bci()); |
|
580 |
assert(data->is_MultiBranchData(), "need MultiBranchData for switch case"); |
|
581 |
if (table_index >= 0) { |
|
582 |
increment_md_counter_at(md, data, MultiBranchData::case_count_offset(table_index)); |
|
583 |
} else { |
|
584 |
increment_md_counter_at(md, data, MultiBranchData::default_count_offset()); |
|
585 |
} |
|
586 |
} |