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