Mercurial > hg > truffle
annotate src/share/vm/opto/parse2.cpp @ 6972:bd7a7ce2e264
6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 12 Nov 2012 14:03:53 -0800 |
parents | 8e47bac5643a |
children | beebba0acc11 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6206
diff
changeset
|
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1213
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1213
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1213
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "ci/ciMethodData.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "classfile/vmSymbols.hpp" | |
29 #include "compiler/compileLog.hpp" | |
30 #include "interpreter/linkResolver.hpp" | |
31 #include "memory/universe.inline.hpp" | |
32 #include "opto/addnode.hpp" | |
33 #include "opto/divnode.hpp" | |
34 #include "opto/idealGraphPrinter.hpp" | |
35 #include "opto/matcher.hpp" | |
36 #include "opto/memnode.hpp" | |
37 #include "opto/mulnode.hpp" | |
38 #include "opto/parse.hpp" | |
39 #include "opto/runtime.hpp" | |
40 #include "runtime/deoptimization.hpp" | |
41 #include "runtime/sharedRuntime.hpp" | |
0 | 42 |
43 extern int explicit_null_checks_inserted, | |
44 explicit_null_checks_elided; | |
45 | |
46 //---------------------------------array_load---------------------------------- | |
47 void Parse::array_load(BasicType elem_type) { | |
48 const Type* elem = Type::TOP; | |
49 Node* adr = array_addressing(elem_type, 0, &elem); | |
605 | 50 if (stopped()) return; // guaranteed null or range check |
0 | 51 _sp -= 2; // Pop array and index |
52 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); | |
53 Node* ld = make_load(control(), adr, elem, elem_type, adr_type); | |
54 push(ld); | |
55 } | |
56 | |
57 | |
58 //--------------------------------array_store---------------------------------- | |
59 void Parse::array_store(BasicType elem_type) { | |
60 Node* adr = array_addressing(elem_type, 1); | |
605 | 61 if (stopped()) return; // guaranteed null or range check |
0 | 62 Node* val = pop(); |
63 _sp -= 2; // Pop array and index | |
64 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); | |
65 store_to_memory(control(), adr, val, elem_type, adr_type); | |
66 } | |
67 | |
68 | |
69 //------------------------------array_addressing------------------------------- | |
70 // Pull array and index from the stack. Compute pointer-to-element. | |
71 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { | |
72 Node *idx = peek(0+vals); // Get from stack without popping | |
73 Node *ary = peek(1+vals); // in case of exception | |
74 | |
75 // Null check the array base, with correct stack contents | |
76 ary = do_null_check(ary, T_ARRAY); | |
77 // Compile-time detect of null-exception? | |
78 if (stopped()) return top(); | |
79 | |
80 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr(); | |
81 const TypeInt* sizetype = arytype->size(); | |
82 const Type* elemtype = arytype->elem(); | |
83 | |
84 if (UseUniqueSubclasses && result2 != NULL) { | |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
129
diff
changeset
|
85 const Type* el = elemtype->make_ptr(); |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
129
diff
changeset
|
86 if (el && el->isa_instptr()) { |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
129
diff
changeset
|
87 const TypeInstPtr* toop = el->is_instptr(); |
0 | 88 if (toop->klass()->as_instance_klass()->unique_concrete_subklass()) { |
89 // If we load from "AbstractClass[]" we must see "ConcreteSubClass". | |
90 const Type* subklass = Type::get_const_type(toop->klass()); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
37
diff
changeset
|
91 elemtype = subklass->join(el); |
0 | 92 } |
93 } | |
94 } | |
95 | |
96 // Check for big class initializers with all constant offsets | |
97 // feeding into a known-size array. | |
98 const TypeInt* idxtype = _gvn.type(idx)->is_int(); | |
99 // See if the highest idx value is less than the lowest array bound, | |
100 // and if the idx value cannot be negative: | |
101 bool need_range_check = true; | |
102 if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) { | |
103 need_range_check = false; | |
104 if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'"); | |
105 } | |
106 | |
107 if (!arytype->klass()->is_loaded()) { | |
108 // Only fails for some -Xcomp runs | |
109 // The class is unloaded. We have to run this bytecode in the interpreter. | |
110 uncommon_trap(Deoptimization::Reason_unloaded, | |
111 Deoptimization::Action_reinterpret, | |
112 arytype->klass(), "!loaded array"); | |
113 return top(); | |
114 } | |
115 | |
116 // Do the range check | |
117 if (GenerateRangeChecks && need_range_check) { | |
129
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
118 Node* tst; |
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
119 if (sizetype->_hi <= 0) { |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
120 // The greatest array bound is negative, so we can conclude that we're |
129
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
121 // compiling unreachable code, but the unsigned compare trick used below |
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
122 // only works with non-negative lengths. Instead, hack "tst" to be zero so |
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
123 // the uncommon_trap path will always be taken. |
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
124 tst = _gvn.intcon(0); |
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
125 } else { |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
126 // Range is constant in array-oop, so we can use the original state of mem |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
127 Node* len = load_array_length(ary); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
128 |
129
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
129 // Test length vs index (standard trick using unsigned compare) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
130 Node* chk = _gvn.transform( new (C) CmpUNode(idx, len) ); |
129
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
131 BoolTest::mask btest = BoolTest::lt; |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
132 tst = _gvn.transform( new (C) BoolNode(chk, btest) ); |
129
c0939256690b
6646019: array subscript expressions become top() with -d64
rasbold
parents:
113
diff
changeset
|
133 } |
0 | 134 // Branch to failure if out of bounds |
135 { BuildCutout unless(this, tst, PROB_MAX); | |
136 if (C->allow_range_check_smearing()) { | |
137 // Do not use builtin_throw, since range checks are sometimes | |
138 // made more stringent by an optimistic transformation. | |
139 // This creates "tentative" range checks at this point, | |
140 // which are not guaranteed to throw exceptions. | |
141 // See IfNode::Ideal, is_range_check, adjust_check. | |
142 uncommon_trap(Deoptimization::Reason_range_check, | |
143 Deoptimization::Action_make_not_entrant, | |
144 NULL, "range_check"); | |
145 } else { | |
146 // If we have already recompiled with the range-check-widening | |
147 // heroic optimization turned off, then we must really be throwing | |
148 // range check exceptions. | |
149 builtin_throw(Deoptimization::Reason_range_check, idx); | |
150 } | |
151 } | |
152 } | |
153 // Check for always knowing you are throwing a range-check exception | |
154 if (stopped()) return top(); | |
155 | |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
156 Node* ptr = array_element_address(ary, idx, type, sizetype); |
0 | 157 |
158 if (result2 != NULL) *result2 = elemtype; | |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
159 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
160 assert(ptr != top(), "top should go hand-in-hand with stopped"); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
254
diff
changeset
|
161 |
0 | 162 return ptr; |
163 } | |
164 | |
165 | |
166 // returns IfNode | |
167 IfNode* Parse::jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
168 Node *cmp = _gvn.transform( new (C) CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32 |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
169 Node *tst = _gvn.transform( new (C) BoolNode( cmp, mask)); |
0 | 170 IfNode *iff = create_and_map_if( control(), tst, ((mask == BoolTest::eq) ? PROB_STATIC_INFREQUENT : PROB_FAIR), COUNT_UNKNOWN ); |
171 return iff; | |
172 } | |
173 | |
174 // return Region node | |
175 Node* Parse::jump_if_join(Node* iffalse, Node* iftrue) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
176 Node *region = new (C) RegionNode(3); // 2 results |
0 | 177 record_for_igvn(region); |
178 region->init_req(1, iffalse); | |
179 region->init_req(2, iftrue ); | |
180 _gvn.set_type(region, Type::CONTROL); | |
181 region = _gvn.transform(region); | |
182 set_control (region); | |
183 return region; | |
184 } | |
185 | |
186 | |
187 //------------------------------helper for tableswitch------------------------- | |
188 void Parse::jump_if_true_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { | |
189 // True branch, use existing map info | |
190 { PreserveJVMState pjvms(this); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
191 Node *iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); |
0 | 192 set_control( iftrue ); |
193 profile_switch_case(prof_table_index); | |
194 merge_new_path(dest_bci_if_true); | |
195 } | |
196 | |
197 // False branch | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
198 Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); |
0 | 199 set_control( iffalse ); |
200 } | |
201 | |
202 void Parse::jump_if_false_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { | |
203 // True branch, use existing map info | |
204 { PreserveJVMState pjvms(this); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
205 Node *iffalse = _gvn.transform( new (C) IfFalseNode (iff) ); |
0 | 206 set_control( iffalse ); |
207 profile_switch_case(prof_table_index); | |
208 merge_new_path(dest_bci_if_true); | |
209 } | |
210 | |
211 // False branch | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
212 Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff) ); |
0 | 213 set_control( iftrue ); |
214 } | |
215 | |
216 void Parse::jump_if_always_fork(int dest_bci, int prof_table_index) { | |
217 // False branch, use existing map and control() | |
218 profile_switch_case(prof_table_index); | |
219 merge_new_path(dest_bci); | |
220 } | |
221 | |
222 | |
223 extern "C" { | |
224 static int jint_cmp(const void *i, const void *j) { | |
225 int a = *(jint *)i; | |
226 int b = *(jint *)j; | |
227 return a > b ? 1 : a < b ? -1 : 0; | |
228 } | |
229 } | |
230 | |
231 | |
232 // Default value for methodData switch indexing. Must be a negative value to avoid | |
233 // conflict with any legal switch index. | |
234 #define NullTableIndex -1 | |
235 | |
236 class SwitchRange : public StackObj { | |
237 // a range of integers coupled with a bci destination | |
238 jint _lo; // inclusive lower limit | |
239 jint _hi; // inclusive upper limit | |
240 int _dest; | |
241 int _table_index; // index into method data table | |
242 | |
243 public: | |
244 jint lo() const { return _lo; } | |
245 jint hi() const { return _hi; } | |
246 int dest() const { return _dest; } | |
247 int table_index() const { return _table_index; } | |
248 bool is_singleton() const { return _lo == _hi; } | |
249 | |
250 void setRange(jint lo, jint hi, int dest, int table_index) { | |
251 assert(lo <= hi, "must be a non-empty range"); | |
252 _lo = lo, _hi = hi; _dest = dest; _table_index = table_index; | |
253 } | |
254 bool adjoinRange(jint lo, jint hi, int dest, int table_index) { | |
255 assert(lo <= hi, "must be a non-empty range"); | |
256 if (lo == _hi+1 && dest == _dest && table_index == _table_index) { | |
257 _hi = hi; | |
258 return true; | |
259 } | |
260 return false; | |
261 } | |
262 | |
263 void set (jint value, int dest, int table_index) { | |
264 setRange(value, value, dest, table_index); | |
265 } | |
266 bool adjoin(jint value, int dest, int table_index) { | |
267 return adjoinRange(value, value, dest, table_index); | |
268 } | |
269 | |
270 void print(ciEnv* env) { | |
271 if (is_singleton()) | |
272 tty->print(" {%d}=>%d", lo(), dest()); | |
273 else if (lo() == min_jint) | |
274 tty->print(" {..%d}=>%d", hi(), dest()); | |
275 else if (hi() == max_jint) | |
276 tty->print(" {%d..}=>%d", lo(), dest()); | |
277 else | |
278 tty->print(" {%d..%d}=>%d", lo(), hi(), dest()); | |
279 } | |
280 }; | |
281 | |
282 | |
283 //-------------------------------do_tableswitch-------------------------------- | |
284 void Parse::do_tableswitch() { | |
285 Node* lookup = pop(); | |
286 | |
287 // Get information about tableswitch | |
288 int default_dest = iter().get_dest_table(0); | |
289 int lo_index = iter().get_int_table(1); | |
290 int hi_index = iter().get_int_table(2); | |
291 int len = hi_index - lo_index + 1; | |
292 | |
293 if (len < 1) { | |
294 // If this is a backward branch, add safepoint | |
295 maybe_add_safepoint(default_dest); | |
296 merge(default_dest); | |
297 return; | |
298 } | |
299 | |
300 // generate decision tree, using trichotomy when possible | |
301 int rnum = len+2; | |
302 bool makes_backward_branch = false; | |
303 SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum); | |
304 int rp = -1; | |
305 if (lo_index != min_jint) { | |
306 ranges[++rp].setRange(min_jint, lo_index-1, default_dest, NullTableIndex); | |
307 } | |
308 for (int j = 0; j < len; j++) { | |
309 jint match_int = lo_index+j; | |
310 int dest = iter().get_dest_table(j+3); | |
311 makes_backward_branch |= (dest <= bci()); | |
312 int table_index = method_data_update() ? j : NullTableIndex; | |
313 if (rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index)) { | |
314 ranges[++rp].set(match_int, dest, table_index); | |
315 } | |
316 } | |
317 jint highest = lo_index+(len-1); | |
318 assert(ranges[rp].hi() == highest, ""); | |
319 if (highest != max_jint | |
320 && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex)) { | |
321 ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex); | |
322 } | |
323 assert(rp < len+2, "not too many ranges"); | |
324 | |
325 // Safepoint in case if backward branch observed | |
326 if( makes_backward_branch && UseLoopSafepoints ) | |
327 add_safepoint(); | |
328 | |
329 jump_switch_ranges(lookup, &ranges[0], &ranges[rp]); | |
330 } | |
331 | |
332 | |
333 //------------------------------do_lookupswitch-------------------------------- | |
334 void Parse::do_lookupswitch() { | |
335 Node *lookup = pop(); // lookup value | |
336 // Get information about lookupswitch | |
337 int default_dest = iter().get_dest_table(0); | |
338 int len = iter().get_int_table(1); | |
339 | |
340 if (len < 1) { // If this is a backward branch, add safepoint | |
341 maybe_add_safepoint(default_dest); | |
342 merge(default_dest); | |
343 return; | |
344 } | |
345 | |
346 // generate decision tree, using trichotomy when possible | |
347 jint* table = NEW_RESOURCE_ARRAY(jint, len*2); | |
348 { | |
349 for( int j = 0; j < len; j++ ) { | |
350 table[j+j+0] = iter().get_int_table(2+j+j); | |
351 table[j+j+1] = iter().get_dest_table(2+j+j+1); | |
352 } | |
353 qsort( table, len, 2*sizeof(table[0]), jint_cmp ); | |
354 } | |
355 | |
356 int rnum = len*2+1; | |
357 bool makes_backward_branch = false; | |
358 SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum); | |
359 int rp = -1; | |
360 for( int j = 0; j < len; j++ ) { | |
361 jint match_int = table[j+j+0]; | |
362 int dest = table[j+j+1]; | |
363 int next_lo = rp < 0 ? min_jint : ranges[rp].hi()+1; | |
364 int table_index = method_data_update() ? j : NullTableIndex; | |
365 makes_backward_branch |= (dest <= bci()); | |
366 if( match_int != next_lo ) { | |
367 ranges[++rp].setRange(next_lo, match_int-1, default_dest, NullTableIndex); | |
368 } | |
369 if( rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index) ) { | |
370 ranges[++rp].set(match_int, dest, table_index); | |
371 } | |
372 } | |
373 jint highest = table[2*(len-1)]; | |
374 assert(ranges[rp].hi() == highest, ""); | |
375 if( highest != max_jint | |
376 && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex) ) { | |
377 ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex); | |
378 } | |
379 assert(rp < rnum, "not too many ranges"); | |
380 | |
381 // Safepoint in case backward branch observed | |
382 if( makes_backward_branch && UseLoopSafepoints ) | |
383 add_safepoint(); | |
384 | |
385 jump_switch_ranges(lookup, &ranges[0], &ranges[rp]); | |
386 } | |
387 | |
388 //----------------------------create_jump_tables------------------------------- | |
389 bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) { | |
390 // Are jumptables enabled | |
391 if (!UseJumpTables) return false; | |
392 | |
393 // Are jumptables supported | |
394 if (!Matcher::has_match_rule(Op_Jump)) return false; | |
395 | |
396 // Don't make jump table if profiling | |
397 if (method_data_update()) return false; | |
398 | |
399 // Decide if a guard is needed to lop off big ranges at either (or | |
400 // both) end(s) of the input set. We'll call this the default target | |
401 // even though we can't be sure that it is the true "default". | |
402 | |
403 bool needs_guard = false; | |
404 int default_dest; | |
405 int64 total_outlier_size = 0; | |
406 int64 hi_size = ((int64)hi->hi()) - ((int64)hi->lo()) + 1; | |
407 int64 lo_size = ((int64)lo->hi()) - ((int64)lo->lo()) + 1; | |
408 | |
409 if (lo->dest() == hi->dest()) { | |
410 total_outlier_size = hi_size + lo_size; | |
411 default_dest = lo->dest(); | |
412 } else if (lo_size > hi_size) { | |
413 total_outlier_size = lo_size; | |
414 default_dest = lo->dest(); | |
415 } else { | |
416 total_outlier_size = hi_size; | |
417 default_dest = hi->dest(); | |
418 } | |
419 | |
420 // If a guard test will eliminate very sparse end ranges, then | |
421 // it is worth the cost of an extra jump. | |
422 if (total_outlier_size > (MaxJumpTableSparseness * 4)) { | |
423 needs_guard = true; | |
424 if (default_dest == lo->dest()) lo++; | |
425 if (default_dest == hi->dest()) hi--; | |
426 } | |
427 | |
428 // Find the total number of cases and ranges | |
429 int64 num_cases = ((int64)hi->hi()) - ((int64)lo->lo()) + 1; | |
430 int num_range = hi - lo + 1; | |
431 | |
432 // Don't create table if: too large, too small, or too sparse. | |
433 if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize) | |
434 return false; | |
435 if (num_cases > (MaxJumpTableSparseness * num_range)) | |
436 return false; | |
437 | |
438 // Normalize table lookups to zero | |
439 int lowval = lo->lo(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
440 key_val = _gvn.transform( new (C) SubINode(key_val, _gvn.intcon(lowval)) ); |
0 | 441 |
442 // Generate a guard to protect against input keyvals that aren't | |
443 // in the switch domain. | |
444 if (needs_guard) { | |
445 Node* size = _gvn.intcon(num_cases); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
446 Node* cmp = _gvn.transform( new (C) CmpUNode(key_val, size) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
447 Node* tst = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ge) ); |
0 | 448 IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN); |
449 jump_if_true_fork(iff, default_dest, NullTableIndex); | |
450 } | |
451 | |
452 // Create an ideal node JumpTable that has projections | |
453 // of all possible ranges for a switch statement | |
454 // The key_val input must be converted to a pointer offset and scaled. | |
455 // Compare Parse::array_addressing above. | |
456 #ifdef _LP64 | |
457 // Clean the 32-bit int into a real 64-bit offset. | |
458 // Otherwise, the jint value 0 might turn into an offset of 0x0800000000. | |
459 const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
460 key_val = _gvn.transform( new (C) ConvI2LNode(key_val, lkeytype) ); |
0 | 461 #endif |
462 // Shift the value by wordsize so we have an index into the table, rather | |
463 // than a switch value | |
464 Node *shiftWord = _gvn.MakeConX(wordSize); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
465 key_val = _gvn.transform( new (C) MulXNode( key_val, shiftWord)); |
0 | 466 |
467 // Create the JumpNode | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
468 Node* jtn = _gvn.transform( new (C) JumpNode(control(), key_val, num_cases) ); |
0 | 469 |
470 // These are the switch destinations hanging off the jumpnode | |
471 int i = 0; | |
472 for (SwitchRange* r = lo; r <= hi; r++) { | |
473 for (int j = r->lo(); j <= r->hi(); j++, i++) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
474 Node* input = _gvn.transform(new (C) JumpProjNode(jtn, i, r->dest(), j - lowval)); |
0 | 475 { |
476 PreserveJVMState pjvms(this); | |
477 set_control(input); | |
478 jump_if_always_fork(r->dest(), r->table_index()); | |
479 } | |
480 } | |
481 } | |
482 assert(i == num_cases, "miscount of cases"); | |
483 stop_and_kill_map(); // no more uses for this JVMS | |
484 return true; | |
485 } | |
486 | |
487 //----------------------------jump_switch_ranges------------------------------- | |
488 void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) { | |
489 Block* switch_block = block(); | |
490 | |
491 if (switch_depth == 0) { | |
492 // Do special processing for the top-level call. | |
493 assert(lo->lo() == min_jint, "initial range must exhaust Type::INT"); | |
494 assert(hi->hi() == max_jint, "initial range must exhaust Type::INT"); | |
495 | |
496 // Decrement pred-numbers for the unique set of nodes. | |
497 #ifdef ASSERT | |
498 // Ensure that the block's successors are a (duplicate-free) set. | |
499 int successors_counted = 0; // block occurrences in [hi..lo] | |
500 int unique_successors = switch_block->num_successors(); | |
501 for (int i = 0; i < unique_successors; i++) { | |
502 Block* target = switch_block->successor_at(i); | |
503 | |
504 // Check that the set of successors is the same in both places. | |
505 int successors_found = 0; | |
506 for (SwitchRange* p = lo; p <= hi; p++) { | |
507 if (p->dest() == target->start()) successors_found++; | |
508 } | |
509 assert(successors_found > 0, "successor must be known"); | |
510 successors_counted += successors_found; | |
511 } | |
512 assert(successors_counted == (hi-lo)+1, "no unexpected successors"); | |
513 #endif | |
514 | |
515 // Maybe prune the inputs, based on the type of key_val. | |
516 jint min_val = min_jint; | |
517 jint max_val = max_jint; | |
518 const TypeInt* ti = key_val->bottom_type()->isa_int(); | |
519 if (ti != NULL) { | |
520 min_val = ti->_lo; | |
521 max_val = ti->_hi; | |
522 assert(min_val <= max_val, "invalid int type"); | |
523 } | |
524 while (lo->hi() < min_val) lo++; | |
525 if (lo->lo() < min_val) lo->setRange(min_val, lo->hi(), lo->dest(), lo->table_index()); | |
526 while (hi->lo() > max_val) hi--; | |
527 if (hi->hi() > max_val) hi->setRange(hi->lo(), max_val, hi->dest(), hi->table_index()); | |
528 } | |
529 | |
530 #ifndef PRODUCT | |
531 if (switch_depth == 0) { | |
532 _max_switch_depth = 0; | |
533 _est_switch_depth = log2_intptr((hi-lo+1)-1)+1; | |
534 } | |
535 #endif | |
536 | |
537 assert(lo <= hi, "must be a non-empty set of ranges"); | |
538 if (lo == hi) { | |
539 jump_if_always_fork(lo->dest(), lo->table_index()); | |
540 } else { | |
541 assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges"); | |
542 assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges"); | |
543 | |
544 if (create_jump_tables(key_val, lo, hi)) return; | |
545 | |
546 int nr = hi - lo + 1; | |
547 | |
548 SwitchRange* mid = lo + nr/2; | |
549 // if there is an easy choice, pivot at a singleton: | |
550 if (nr > 3 && !mid->is_singleton() && (mid-1)->is_singleton()) mid--; | |
551 | |
552 assert(lo < mid && mid <= hi, "good pivot choice"); | |
553 assert(nr != 2 || mid == hi, "should pick higher of 2"); | |
554 assert(nr != 3 || mid == hi-1, "should pick middle of 3"); | |
555 | |
556 Node *test_val = _gvn.intcon(mid->lo()); | |
557 | |
558 if (mid->is_singleton()) { | |
559 IfNode *iff_ne = jump_if_fork_int(key_val, test_val, BoolTest::ne); | |
560 jump_if_false_fork(iff_ne, mid->dest(), mid->table_index()); | |
561 | |
562 // Special Case: If there are exactly three ranges, and the high | |
563 // and low range each go to the same place, omit the "gt" test, | |
564 // since it will not discriminate anything. | |
565 bool eq_test_only = (hi == lo+2 && hi->dest() == lo->dest()); | |
566 if (eq_test_only) { | |
567 assert(mid == hi-1, ""); | |
568 } | |
569 | |
570 // if there is a higher range, test for it and process it: | |
571 if (mid < hi && !eq_test_only) { | |
572 // two comparisons of same values--should enable 1 test for 2 branches | |
573 // Use BoolTest::le instead of BoolTest::gt | |
574 IfNode *iff_le = jump_if_fork_int(key_val, test_val, BoolTest::le); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
575 Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_le) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
576 Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_le) ); |
0 | 577 { PreserveJVMState pjvms(this); |
578 set_control(iffalse); | |
579 jump_switch_ranges(key_val, mid+1, hi, switch_depth+1); | |
580 } | |
581 set_control(iftrue); | |
582 } | |
583 | |
584 } else { | |
585 // mid is a range, not a singleton, so treat mid..hi as a unit | |
586 IfNode *iff_ge = jump_if_fork_int(key_val, test_val, BoolTest::ge); | |
587 | |
588 // if there is a higher range, test for it and process it: | |
589 if (mid == hi) { | |
590 jump_if_true_fork(iff_ge, mid->dest(), mid->table_index()); | |
591 } else { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
592 Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_ge) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
593 Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_ge) ); |
0 | 594 { PreserveJVMState pjvms(this); |
595 set_control(iftrue); | |
596 jump_switch_ranges(key_val, mid, hi, switch_depth+1); | |
597 } | |
598 set_control(iffalse); | |
599 } | |
600 } | |
601 | |
602 // in any case, process the lower range | |
603 jump_switch_ranges(key_val, lo, mid-1, switch_depth+1); | |
604 } | |
605 | |
606 // Decrease pred_count for each successor after all is done. | |
607 if (switch_depth == 0) { | |
608 int unique_successors = switch_block->num_successors(); | |
609 for (int i = 0; i < unique_successors; i++) { | |
610 Block* target = switch_block->successor_at(i); | |
611 // Throw away the pre-allocated path for each unique successor. | |
612 target->next_path_num(); | |
613 } | |
614 } | |
615 | |
616 #ifndef PRODUCT | |
617 _max_switch_depth = MAX2(switch_depth, _max_switch_depth); | |
618 if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) { | |
619 SwitchRange* r; | |
620 int nsing = 0; | |
621 for( r = lo; r <= hi; r++ ) { | |
622 if( r->is_singleton() ) nsing++; | |
623 } | |
624 tty->print(">>> "); | |
625 _method->print_short_name(); | |
626 tty->print_cr(" switch decision tree"); | |
627 tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d", | |
628 hi-lo+1, nsing, _max_switch_depth, _est_switch_depth); | |
629 if (_max_switch_depth > _est_switch_depth) { | |
630 tty->print_cr("******** BAD SWITCH DEPTH ********"); | |
631 } | |
632 tty->print(" "); | |
633 for( r = lo; r <= hi; r++ ) { | |
634 r->print(env()); | |
635 } | |
636 tty->print_cr(""); | |
637 } | |
638 #endif | |
639 } | |
640 | |
641 void Parse::modf() { | |
642 Node *f2 = pop(); | |
643 Node *f1 = pop(); | |
644 Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(), | |
645 CAST_FROM_FN_PTR(address, SharedRuntime::frem), | |
646 "frem", NULL, //no memory effects | |
647 f1, f2); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
648 Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); |
0 | 649 |
650 push(res); | |
651 } | |
652 | |
653 void Parse::modd() { | |
654 Node *d2 = pop_pair(); | |
655 Node *d1 = pop_pair(); | |
656 Node* c = make_runtime_call(RC_LEAF, OptoRuntime::Math_DD_D_Type(), | |
657 CAST_FROM_FN_PTR(address, SharedRuntime::drem), | |
658 "drem", NULL, //no memory effects | |
659 d1, top(), d2, top()); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
660 Node* res_d = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); |
0 | 661 |
662 #ifdef ASSERT | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
663 Node* res_top = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 1)); |
0 | 664 assert(res_top == top(), "second value must be top"); |
665 #endif | |
666 | |
667 push_pair(res_d); | |
668 } | |
669 | |
670 void Parse::l2f() { | |
671 Node* f2 = pop(); | |
672 Node* f1 = pop(); | |
673 Node* c = make_runtime_call(RC_LEAF, OptoRuntime::l2f_Type(), | |
674 CAST_FROM_FN_PTR(address, SharedRuntime::l2f), | |
675 "l2f", NULL, //no memory effects | |
676 f1, f2); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
677 Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); |
0 | 678 |
679 push(res); | |
680 } | |
681 | |
682 void Parse::do_irem() { | |
683 // Must keep both values on the expression-stack during null-check | |
684 do_null_check(peek(), T_INT); | |
685 // Compile-time detect of null-exception? | |
686 if (stopped()) return; | |
687 | |
688 Node* b = pop(); | |
689 Node* a = pop(); | |
690 | |
691 const Type *t = _gvn.type(b); | |
692 if (t != Type::TOP) { | |
693 const TypeInt *ti = t->is_int(); | |
694 if (ti->is_con()) { | |
695 int divisor = ti->get_con(); | |
696 // check for positive power of 2 | |
697 if (divisor > 0 && | |
698 (divisor & ~(divisor-1)) == divisor) { | |
699 // yes ! | |
700 Node *mask = _gvn.intcon((divisor - 1)); | |
701 // Sigh, must handle negative dividends | |
702 Node *zero = _gvn.intcon(0); | |
703 IfNode *ifff = jump_if_fork_int(a, zero, BoolTest::lt); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
704 Node *iff = _gvn.transform( new (C) IfFalseNode(ifff) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
705 Node *ift = _gvn.transform( new (C) IfTrueNode (ifff) ); |
0 | 706 Node *reg = jump_if_join(ift, iff); |
707 Node *phi = PhiNode::make(reg, NULL, TypeInt::INT); | |
708 // Negative path; negate/and/negate | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
709 Node *neg = _gvn.transform( new (C) SubINode(zero, a) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
710 Node *andn= _gvn.transform( new (C) AndINode(neg, mask) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
711 Node *negn= _gvn.transform( new (C) SubINode(zero, andn) ); |
0 | 712 phi->init_req(1, negn); |
713 // Fast positive case | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
714 Node *andx = _gvn.transform( new (C) AndINode(a, mask) ); |
0 | 715 phi->init_req(2, andx); |
716 // Push the merge | |
717 push( _gvn.transform(phi) ); | |
718 return; | |
719 } | |
720 } | |
721 } | |
722 // Default case | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
723 push( _gvn.transform( new (C) ModINode(control(),a,b) ) ); |
0 | 724 } |
725 | |
726 // Handle jsr and jsr_w bytecode | |
727 void Parse::do_jsr() { | |
728 assert(bc() == Bytecodes::_jsr || bc() == Bytecodes::_jsr_w, "wrong bytecode"); | |
729 | |
730 // Store information about current state, tagged with new _jsr_bci | |
731 int return_bci = iter().next_bci(); | |
732 int jsr_bci = (bc() == Bytecodes::_jsr) ? iter().get_dest() : iter().get_far_dest(); | |
733 | |
734 // Update method data | |
735 profile_taken_branch(jsr_bci); | |
736 | |
737 // The way we do things now, there is only one successor block | |
738 // for the jsr, because the target code is cloned by ciTypeFlow. | |
739 Block* target = successor_for_bci(jsr_bci); | |
740 | |
741 // What got pushed? | |
742 const Type* ret_addr = target->peek(); | |
743 assert(ret_addr->singleton(), "must be a constant (cloned jsr body)"); | |
744 | |
745 // Effect on jsr on stack | |
746 push(_gvn.makecon(ret_addr)); | |
747 | |
748 // Flow to the jsr. | |
749 merge(jsr_bci); | |
750 } | |
751 | |
752 // Handle ret bytecode | |
753 void Parse::do_ret() { | |
754 // Find to whom we return. | |
755 assert(block()->num_successors() == 1, "a ret can only go one place now"); | |
756 Block* target = block()->successor_at(0); | |
757 assert(!target->is_ready(), "our arrival must be expected"); | |
758 profile_ret(target->flow()->start()); | |
759 int pnum = target->next_path_num(); | |
760 merge_common(target, pnum); | |
761 } | |
762 | |
763 //--------------------------dynamic_branch_prediction-------------------------- | |
764 // Try to gather dynamic branch prediction behavior. Return a probability | |
765 // of the branch being taken and set the "cnt" field. Returns a -1.0 | |
766 // if we need to use static prediction for some reason. | |
767 float Parse::dynamic_branch_prediction(float &cnt) { | |
768 ResourceMark rm; | |
769 | |
770 cnt = COUNT_UNKNOWN; | |
771 | |
772 // Use MethodData information if it is available | |
773 // FIXME: free the ProfileData structure | |
774 ciMethodData* methodData = method()->method_data(); | |
775 if (!methodData->is_mature()) return PROB_UNKNOWN; | |
776 ciProfileData* data = methodData->bci_to_data(bci()); | |
777 if (!data->is_JumpData()) return PROB_UNKNOWN; | |
778 | |
779 // get taken and not taken values | |
780 int taken = data->as_JumpData()->taken(); | |
781 int not_taken = 0; | |
782 if (data->is_BranchData()) { | |
783 not_taken = data->as_BranchData()->not_taken(); | |
784 } | |
785 | |
786 // scale the counts to be commensurate with invocation counts: | |
787 taken = method()->scale_count(taken); | |
788 not_taken = method()->scale_count(not_taken); | |
789 | |
2481
3a808be061ff
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
iveresov
parents:
2426
diff
changeset
|
790 // Give up if too few (or too many, in which case the sum will overflow) counts to be meaningful. |
3a808be061ff
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
iveresov
parents:
2426
diff
changeset
|
791 // We also check that individual counters are positive first, overwise the sum can become positive. |
3a808be061ff
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
iveresov
parents:
2426
diff
changeset
|
792 if (taken < 0 || not_taken < 0 || taken + not_taken < 40) { |
0 | 793 if (C->log() != NULL) { |
794 C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken); | |
795 } | |
796 return PROB_UNKNOWN; | |
797 } | |
798 | |
799 // Compute frequency that we arrive here | |
2481
3a808be061ff
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
iveresov
parents:
2426
diff
changeset
|
800 float sum = taken + not_taken; |
0 | 801 // Adjust, if this block is a cloned private block but the |
802 // Jump counts are shared. Taken the private counts for | |
803 // just this path instead of the shared counts. | |
804 if( block()->count() > 0 ) | |
805 sum = block()->count(); | |
2481
3a808be061ff
6988308: assert((cnt > 0.0f) && (prob > 0.0f)) failed: Bad frequency assignment in if
iveresov
parents:
2426
diff
changeset
|
806 cnt = sum / FreqCountInvocations; |
0 | 807 |
808 // Pin probability to sane limits | |
809 float prob; | |
810 if( !taken ) | |
811 prob = (0+PROB_MIN) / 2; | |
812 else if( !not_taken ) | |
813 prob = (1+PROB_MAX) / 2; | |
814 else { // Compute probability of true path | |
815 prob = (float)taken / (float)(taken + not_taken); | |
816 if (prob > PROB_MAX) prob = PROB_MAX; | |
817 if (prob < PROB_MIN) prob = PROB_MIN; | |
818 } | |
819 | |
820 assert((cnt > 0.0f) && (prob > 0.0f), | |
821 "Bad frequency assignment in if"); | |
822 | |
823 if (C->log() != NULL) { | |
824 const char* prob_str = NULL; | |
825 if (prob >= PROB_MAX) prob_str = (prob == PROB_MAX) ? "max" : "always"; | |
826 if (prob <= PROB_MIN) prob_str = (prob == PROB_MIN) ? "min" : "never"; | |
827 char prob_str_buf[30]; | |
828 if (prob_str == NULL) { | |
829 sprintf(prob_str_buf, "%g", prob); | |
830 prob_str = prob_str_buf; | |
831 } | |
832 C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%g' prob='%s'", | |
833 iter().get_dest(), taken, not_taken, cnt, prob_str); | |
834 } | |
835 return prob; | |
836 } | |
837 | |
838 //-----------------------------branch_prediction------------------------------- | |
839 float Parse::branch_prediction(float& cnt, | |
840 BoolTest::mask btest, | |
841 int target_bci) { | |
842 float prob = dynamic_branch_prediction(cnt); | |
843 // If prob is unknown, switch to static prediction | |
844 if (prob != PROB_UNKNOWN) return prob; | |
845 | |
846 prob = PROB_FAIR; // Set default value | |
847 if (btest == BoolTest::eq) // Exactly equal test? | |
848 prob = PROB_STATIC_INFREQUENT; // Assume its relatively infrequent | |
849 else if (btest == BoolTest::ne) | |
850 prob = PROB_STATIC_FREQUENT; // Assume its relatively frequent | |
851 | |
852 // If this is a conditional test guarding a backwards branch, | |
853 // assume its a loop-back edge. Make it a likely taken branch. | |
854 if (target_bci < bci()) { | |
855 if (is_osr_parse()) { // Could be a hot OSR'd loop; force deopt | |
856 // Since it's an OSR, we probably have profile data, but since | |
857 // branch_prediction returned PROB_UNKNOWN, the counts are too small. | |
858 // Let's make a special check here for completely zero counts. | |
859 ciMethodData* methodData = method()->method_data(); | |
860 if (!methodData->is_empty()) { | |
861 ciProfileData* data = methodData->bci_to_data(bci()); | |
862 // Only stop for truly zero counts, which mean an unknown part | |
863 // of the OSR-ed method, and we want to deopt to gather more stats. | |
864 // If you have ANY counts, then this loop is simply 'cold' relative | |
865 // to the OSR loop. | |
866 if (data->as_BranchData()->taken() + | |
867 data->as_BranchData()->not_taken() == 0 ) { | |
868 // This is the only way to return PROB_UNKNOWN: | |
869 return PROB_UNKNOWN; | |
870 } | |
871 } | |
872 } | |
873 prob = PROB_STATIC_FREQUENT; // Likely to take backwards branch | |
874 } | |
875 | |
876 assert(prob != PROB_UNKNOWN, "must have some guess at this point"); | |
877 return prob; | |
878 } | |
879 | |
880 // The magic constants are chosen so as to match the output of | |
881 // branch_prediction() when the profile reports a zero taken count. | |
882 // It is important to distinguish zero counts unambiguously, because | |
883 // some branches (e.g., _213_javac.Assembler.eliminate) validly produce | |
884 // very small but nonzero probabilities, which if confused with zero | |
885 // counts would keep the program recompiling indefinitely. | |
886 bool Parse::seems_never_taken(float prob) { | |
887 return prob < PROB_MIN; | |
888 } | |
889 | |
1746
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
890 // True if the comparison seems to be the kind that will not change its |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
891 // statistics from true to false. See comments in adjust_map_after_if. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
892 // This question is only asked along paths which are already |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
893 // classifed as untaken (by seems_never_taken), so really, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
894 // if a path is never taken, its controlling comparison is |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
895 // already acting in a stable fashion. If the comparison |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
896 // seems stable, we will put an expensive uncommon trap |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
897 // on the untaken path. To be conservative, and to allow |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
898 // partially executed counted loops to be compiled fully, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
899 // we will plant uncommon traps only after pointer comparisons. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
900 bool Parse::seems_stable_comparison(BoolTest::mask btest, Node* cmp) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
901 for (int depth = 4; depth > 0; depth--) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
902 // The following switch can find CmpP here over half the time for |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
903 // dynamic language code rich with type tests. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
904 // Code using counted loops or array manipulations (typical |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
905 // of benchmarks) will have many (>80%) CmpI instructions. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
906 switch (cmp->Opcode()) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
907 case Op_CmpP: |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
908 // A never-taken null check looks like CmpP/BoolTest::eq. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
909 // These certainly should be closed off as uncommon traps. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
910 if (btest == BoolTest::eq) |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
911 return true; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
912 // A never-failed type check looks like CmpP/BoolTest::ne. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
913 // Let's put traps on those, too, so that we don't have to compile |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
914 // unused paths with indeterminate dynamic type information. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
915 if (ProfileDynamicTypes) |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
916 return true; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
917 return false; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
918 |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
919 case Op_CmpI: |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
920 // A small minority (< 10%) of CmpP are masked as CmpI, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
921 // as if by boolean conversion ((p == q? 1: 0) != 0). |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
922 // Detect that here, even if it hasn't optimized away yet. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
923 // Specifically, this covers the 'instanceof' operator. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
924 if (btest == BoolTest::ne || btest == BoolTest::eq) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
925 if (_gvn.type(cmp->in(2))->singleton() && |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
926 cmp->in(1)->is_Phi()) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
927 PhiNode* phi = cmp->in(1)->as_Phi(); |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
928 int true_path = phi->is_diamond_phi(); |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
929 if (true_path > 0 && |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
930 _gvn.type(phi->in(1))->singleton() && |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
931 _gvn.type(phi->in(2))->singleton()) { |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
932 // phi->region->if_proj->ifnode->bool->cmp |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
933 BoolNode* bol = phi->in(0)->in(1)->in(0)->in(1)->as_Bool(); |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
934 btest = bol->_test._test; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
935 cmp = bol->in(1); |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
936 continue; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
937 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
938 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
939 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
940 return false; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
941 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
942 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
943 return false; |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
944 } |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
945 |
246
9b66e6287f4a
6707044: uncommon_trap of ifnull bytecode leaves garbage on expression stack
rasbold
parents:
235
diff
changeset
|
946 //-------------------------------repush_if_args-------------------------------- |
9b66e6287f4a
6707044: uncommon_trap of ifnull bytecode leaves garbage on expression stack
rasbold
parents:
235
diff
changeset
|
947 // Push arguments of an "if" bytecode back onto the stack by adjusting _sp. |
1172 | 948 inline int Parse::repush_if_args() { |
0 | 949 #ifndef PRODUCT |
950 if (PrintOpto && WizardMode) { | |
951 tty->print("defending against excessive implicit null exceptions on %s @%d in ", | |
952 Bytecodes::name(iter().cur_bc()), iter().cur_bci()); | |
953 method()->print_name(); tty->cr(); | |
954 } | |
955 #endif | |
956 int bc_depth = - Bytecodes::depth(iter().cur_bc()); | |
957 assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches"); | |
958 DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms | |
959 assert(argument(0) != NULL, "must exist"); | |
960 assert(bc_depth == 1 || argument(1) != NULL, "two must exist"); | |
961 _sp += bc_depth; | |
1172 | 962 return bc_depth; |
0 | 963 } |
964 | |
965 //----------------------------------do_ifnull---------------------------------- | |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
966 void Parse::do_ifnull(BoolTest::mask btest, Node *c) { |
0 | 967 int target_bci = iter().get_dest(); |
968 | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
969 Block* branch_block = successor_for_bci(target_bci); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
970 Block* next_block = successor_for_bci(iter().next_bci()); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
971 |
0 | 972 float cnt; |
973 float prob = branch_prediction(cnt, btest, target_bci); | |
974 if (prob == PROB_UNKNOWN) { | |
975 // (An earlier version of do_ifnull omitted this trap for OSR methods.) | |
976 #ifndef PRODUCT | |
977 if (PrintOpto && Verbose) | |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
978 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); |
0 | 979 #endif |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
980 repush_if_args(); // to gather stats on loop |
0 | 981 // We need to mark this branch as taken so that if we recompile we will |
982 // see that it is possible. In the tiered system the interpreter doesn't | |
983 // do profiling and by the time we get to the lower tier from the interpreter | |
984 // the path may be cold again. Make sure it doesn't look untaken | |
985 profile_taken_branch(target_bci, !ProfileInterpreter); | |
986 uncommon_trap(Deoptimization::Reason_unreached, | |
987 Deoptimization::Action_reinterpret, | |
988 NULL, "cold"); | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
989 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
990 // Mark the successor blocks as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
991 branch_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
992 next_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
993 } |
0 | 994 return; |
995 } | |
996 | |
997 explicit_null_checks_inserted++; | |
998 | |
999 // Generate real control flow | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1000 Node *tst = _gvn.transform( new (C) BoolNode( c, btest ) ); |
0 | 1001 |
1002 // Sanity check the probability value | |
1003 assert(prob > 0.0f,"Bad probability in Parser"); | |
1004 // Need xform to put node in hash table | |
1005 IfNode *iff = create_and_xform_if( control(), tst, prob, cnt ); | |
1006 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); | |
1007 // True branch | |
1008 { PreserveJVMState pjvms(this); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1009 Node* iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); |
0 | 1010 set_control(iftrue); |
1011 | |
1012 if (stopped()) { // Path is dead? | |
1013 explicit_null_checks_elided++; | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1014 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1015 // Mark the successor block as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1016 branch_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1017 } |
0 | 1018 } else { // Path is live. |
1019 // Update method data | |
1020 profile_taken_branch(target_bci); | |
1021 adjust_map_after_if(btest, c, prob, branch_block, next_block); | |
1172 | 1022 if (!stopped()) { |
0 | 1023 merge(target_bci); |
1172 | 1024 } |
0 | 1025 } |
1026 } | |
1027 | |
1028 // False branch | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1029 Node* iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); |
0 | 1030 set_control(iffalse); |
1031 | |
1032 if (stopped()) { // Path is dead? | |
1033 explicit_null_checks_elided++; | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1034 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1035 // Mark the successor block as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1036 next_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1037 } |
0 | 1038 } else { // Path is live. |
1039 // Update method data | |
1040 profile_not_taken_branch(); | |
1041 adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, | |
1042 next_block, branch_block); | |
1043 } | |
1044 } | |
1045 | |
1046 //------------------------------------do_if------------------------------------ | |
1047 void Parse::do_if(BoolTest::mask btest, Node* c) { | |
1048 int target_bci = iter().get_dest(); | |
1049 | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1050 Block* branch_block = successor_for_bci(target_bci); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1051 Block* next_block = successor_for_bci(iter().next_bci()); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1052 |
0 | 1053 float cnt; |
1054 float prob = branch_prediction(cnt, btest, target_bci); | |
1055 float untaken_prob = 1.0 - prob; | |
1056 | |
1057 if (prob == PROB_UNKNOWN) { | |
1058 #ifndef PRODUCT | |
1059 if (PrintOpto && Verbose) | |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
1060 tty->print_cr("Never-taken edge stops compilation at bci %d",bci()); |
0 | 1061 #endif |
1062 repush_if_args(); // to gather stats on loop | |
1063 // We need to mark this branch as taken so that if we recompile we will | |
1064 // see that it is possible. In the tiered system the interpreter doesn't | |
1065 // do profiling and by the time we get to the lower tier from the interpreter | |
1066 // the path may be cold again. Make sure it doesn't look untaken | |
1067 profile_taken_branch(target_bci, !ProfileInterpreter); | |
1068 uncommon_trap(Deoptimization::Reason_unreached, | |
1069 Deoptimization::Action_reinterpret, | |
1070 NULL, "cold"); | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1071 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1072 // Mark the successor blocks as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1073 branch_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1074 next_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1075 } |
0 | 1076 return; |
1077 } | |
1078 | |
1079 // Sanity check the probability value | |
1080 assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); | |
1081 | |
1082 bool taken_if_true = true; | |
1083 // Convert BoolTest to canonical form: | |
1084 if (!BoolTest(btest).is_canonical()) { | |
1085 btest = BoolTest(btest).negate(); | |
1086 taken_if_true = false; | |
1087 // prob is NOT updated here; it remains the probability of the taken | |
1088 // path (as opposed to the prob of the path guarded by an 'IfTrueNode'). | |
1089 } | |
1090 assert(btest != BoolTest::eq, "!= is the only canonical exact test"); | |
1091 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1092 Node* tst0 = new (C) BoolNode(c, btest); |
0 | 1093 Node* tst = _gvn.transform(tst0); |
1094 BoolTest::mask taken_btest = BoolTest::illegal; | |
1095 BoolTest::mask untaken_btest = BoolTest::illegal; | |
37
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1096 |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1097 if (tst->is_Bool()) { |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1098 // Refresh c from the transformed bool node, since it may be |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1099 // simpler than the original c. Also re-canonicalize btest. |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1100 // This wins when (Bool ne (Conv2B p) 0) => (Bool ne (CmpP p NULL)). |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1101 // That can arise from statements like: if (x instanceof C) ... |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1102 if (tst != tst0) { |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1103 // Canonicalize one more time since transform can change it. |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1104 btest = tst->as_Bool()->_test._test; |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1105 if (!BoolTest(btest).is_canonical()) { |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1106 // Reverse edges one more time... |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1107 tst = _gvn.transform( tst->as_Bool()->negate(&_gvn) ); |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1108 btest = tst->as_Bool()->_test._test; |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1109 assert(BoolTest(btest).is_canonical(), "sanity"); |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1110 taken_if_true = !taken_if_true; |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1111 } |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1112 c = tst->in(1); |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1113 } |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1114 BoolTest::mask neg_btest = BoolTest(btest).negate(); |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1115 taken_btest = taken_if_true ? btest : neg_btest; |
73970d8c0b27
6671250: In Parse::do_if() old Cmp node 'c' should be replaced with new one after BoolNode transformation
kvn
parents:
17
diff
changeset
|
1116 untaken_btest = taken_if_true ? neg_btest : btest; |
0 | 1117 } |
1118 | |
1119 // Generate real control flow | |
1120 float true_prob = (taken_if_true ? prob : untaken_prob); | |
1121 IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt); | |
1122 assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1123 Node* taken_branch = new (C) IfTrueNode(iff); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1124 Node* untaken_branch = new (C) IfFalseNode(iff); |
0 | 1125 if (!taken_if_true) { // Finish conversion to canonical form |
1126 Node* tmp = taken_branch; | |
1127 taken_branch = untaken_branch; | |
1128 untaken_branch = tmp; | |
1129 } | |
1130 | |
1131 // Branch is taken: | |
1132 { PreserveJVMState pjvms(this); | |
1133 taken_branch = _gvn.transform(taken_branch); | |
1134 set_control(taken_branch); | |
1135 | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1136 if (stopped()) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1137 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1138 // Mark the successor block as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1139 branch_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1140 } |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1141 } else { |
0 | 1142 // Update method data |
1143 profile_taken_branch(target_bci); | |
1144 adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); | |
1172 | 1145 if (!stopped()) { |
0 | 1146 merge(target_bci); |
1172 | 1147 } |
0 | 1148 } |
1149 } | |
1150 | |
1151 untaken_branch = _gvn.transform(untaken_branch); | |
1152 set_control(untaken_branch); | |
1153 | |
1154 // Branch not taken. | |
17
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1155 if (stopped()) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1156 if (EliminateAutoBox) { |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1157 // Mark the successor block as parsed |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1158 next_block->next_path_num(); |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1159 } |
ff5961f4c095
6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents:
0
diff
changeset
|
1160 } else { |
0 | 1161 // Update method data |
1162 profile_not_taken_branch(); | |
1163 adjust_map_after_if(untaken_btest, c, untaken_prob, | |
1164 next_block, branch_block); | |
1165 } | |
1166 } | |
1167 | |
1168 //----------------------------adjust_map_after_if------------------------------ | |
1169 // Adjust the JVM state to reflect the result of taking this path. | |
1170 // Basically, it means inspecting the CmpNode controlling this | |
1171 // branch, seeing how it constrains a tested value, and then | |
1172 // deciding if it's worth our while to encode this constraint | |
1173 // as graph nodes in the current abstract interpretation map. | |
1174 void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, | |
1175 Block* path, Block* other_path) { | |
1176 if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal) | |
1177 return; // nothing to do | |
1178 | |
1179 bool is_fallthrough = (path == successor_for_bci(iter().next_bci())); | |
1180 | |
1746
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1181 if (seems_never_taken(prob) && seems_stable_comparison(btest, c)) { |
0 | 1182 // If this might possibly turn into an implicit null check, |
1183 // and the null has never yet been seen, we need to generate | |
1184 // an uncommon trap, so as to recompile instead of suffering | |
1185 // with very slow branches. (We'll get the slow branches if | |
1186 // the program ever changes phase and starts seeing nulls here.) | |
1187 // | |
1746
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1188 // We do not inspect for a null constant, since a node may |
0 | 1189 // optimize to 'null' later on. |
1746
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1190 // |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1191 // Null checks, and other tests which expect inequality, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1192 // show btest == BoolTest::eq along the non-taken branch. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1193 // On the other hand, type tests, must-be-null tests, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1194 // and other tests which expect pointer equality, |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1195 // show btest == BoolTest::ne along the non-taken branch. |
4b29a725c43c
6912064: type profiles need to be exploited more for dynamic language support
jrose
parents:
1602
diff
changeset
|
1196 // We prune both types of branches if they look unused. |
0 | 1197 repush_if_args(); |
1198 // We need to mark this branch as taken so that if we recompile we will | |
1199 // see that it is possible. In the tiered system the interpreter doesn't | |
1200 // do profiling and by the time we get to the lower tier from the interpreter | |
1201 // the path may be cold again. Make sure it doesn't look untaken | |
1202 if (is_fallthrough) { | |
1203 profile_not_taken_branch(!ProfileInterpreter); | |
1204 } else { | |
1205 profile_taken_branch(iter().get_dest(), !ProfileInterpreter); | |
1206 } | |
1207 uncommon_trap(Deoptimization::Reason_unreached, | |
1208 Deoptimization::Action_reinterpret, | |
1209 NULL, | |
1210 (is_fallthrough ? "taken always" : "taken never")); | |
1211 return; | |
1212 } | |
1213 | |
1214 Node* val = c->in(1); | |
1215 Node* con = c->in(2); | |
1216 const Type* tcon = _gvn.type(con); | |
1217 const Type* tval = _gvn.type(val); | |
1218 bool have_con = tcon->singleton(); | |
1219 if (tval->singleton()) { | |
1220 if (!have_con) { | |
1221 // Swap, so constant is in con. | |
1222 con = val; | |
1223 tcon = tval; | |
1224 val = c->in(2); | |
1225 tval = _gvn.type(val); | |
1226 btest = BoolTest(btest).commute(); | |
1227 have_con = true; | |
1228 } else { | |
1229 // Do we have two constants? Then leave well enough alone. | |
1230 have_con = false; | |
1231 } | |
1232 } | |
1233 if (!have_con) // remaining adjustments need a con | |
1234 return; | |
1235 | |
6131
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1236 sharpen_type_after_if(btest, con, tcon, val, tval); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1237 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1238 |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1239 |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1240 static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1241 Node* ldk; |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6804
diff
changeset
|
1242 if (n->is_DecodeNKlass()) { |
6131
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1243 if (n->in(1)->Opcode() != Op_LoadNKlass) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1244 return NULL; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1245 } else { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1246 ldk = n->in(1); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1247 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1248 } else if (n->Opcode() != Op_LoadKlass) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1249 return NULL; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1250 } else { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1251 ldk = n; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1252 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1253 assert(ldk != NULL && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node"); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1254 |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1255 Node* adr = ldk->in(MemNode::Address); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1256 intptr_t off = 0; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1257 Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1258 if (obj == NULL || off != oopDesc::klass_offset_in_bytes()) // loading oopDesc::_klass? |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1259 return NULL; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1260 const TypePtr* tp = gvn->type(obj)->is_ptr(); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1261 if (tp == NULL || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr? |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1262 return NULL; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1263 |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1264 return obj; |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1265 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1266 |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1267 void Parse::sharpen_type_after_if(BoolTest::mask btest, |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1268 Node* con, const Type* tcon, |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1269 Node* val, const Type* tval) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1270 // Look for opportunities to sharpen the type of a node |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1271 // whose klass is compared with a constant klass. |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1272 if (btest == BoolTest::eq && tcon->isa_klassptr()) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1273 Node* obj = extract_obj_from_klass_load(&_gvn, val); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1274 const TypeOopPtr* con_type = tcon->isa_klassptr()->as_instance_type(); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1275 if (obj != NULL && (con_type->isa_instptr() || con_type->isa_aryptr())) { |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1276 // Found: |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1277 // Bool(CmpP(LoadKlass(obj._klass), ConP(Foo.klass)), [eq]) |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1278 // or the narrowOop equivalent. |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1279 const Type* obj_type = _gvn.type(obj); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1280 const TypeOopPtr* tboth = obj_type->join(con_type)->isa_oopptr(); |
6206
70862d781d01
7180769: assert(tboth->klass_is_exact()) failed: klass should be exact
kvn
parents:
6131
diff
changeset
|
1281 if (tboth != NULL && tboth->klass_is_exact() && tboth != obj_type && |
70862d781d01
7180769: assert(tboth->klass_is_exact()) failed: klass should be exact
kvn
parents:
6131
diff
changeset
|
1282 tboth->higher_equal(obj_type)) { |
6131
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1283 // obj has to be of the exact type Foo if the CmpP succeeds. |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1284 int obj_in_map = map()->find_edge(obj); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1285 JVMState* jvms = this->jvms(); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1286 if (obj_in_map >= 0 && |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1287 (jvms->is_loc(obj_in_map) || jvms->is_stk(obj_in_map))) { |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1288 TypeNode* ccast = new (C) CheckCastPPNode(control(), obj, tboth); |
6131
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1289 const Type* tcc = ccast->as_Type()->type(); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1290 assert(tcc != obj_type && tcc->higher_equal(obj_type), "must improve"); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1291 // Delay transform() call to allow recovery of pre-cast value |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1292 // at the control merge. |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1293 _gvn.set_type_bottom(ccast); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1294 record_for_igvn(ccast); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1295 // Here's the payoff. |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1296 replace_in_map(obj, ccast); |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1297 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1298 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1299 } |
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1300 } |
0 | 1301 |
1302 int val_in_map = map()->find_edge(val); | |
1303 if (val_in_map < 0) return; // replace_in_map would be useless | |
1304 { | |
1305 JVMState* jvms = this->jvms(); | |
1306 if (!(jvms->is_loc(val_in_map) || | |
1307 jvms->is_stk(val_in_map))) | |
1308 return; // again, it would be useless | |
1309 } | |
1310 | |
1311 // Check for a comparison to a constant, and "know" that the compared | |
1312 // value is constrained on this path. | |
1313 assert(tcon->singleton(), ""); | |
1314 ConstraintCastNode* ccast = NULL; | |
1315 Node* cast = NULL; | |
1316 | |
1317 switch (btest) { | |
1318 case BoolTest::eq: // Constant test? | |
1319 { | |
1320 const Type* tboth = tcon->join(tval); | |
1321 if (tboth == tval) break; // Nothing to gain. | |
1322 if (tcon->isa_int()) { | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1323 ccast = new (C) CastIINode(val, tboth); |
0 | 1324 } else if (tcon == TypePtr::NULL_PTR) { |
1325 // Cast to null, but keep the pointer identity temporarily live. | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1326 ccast = new (C) CastPPNode(val, tboth); |
0 | 1327 } else { |
1328 const TypeF* tf = tcon->isa_float_constant(); | |
1329 const TypeD* td = tcon->isa_double_constant(); | |
1330 // Exclude tests vs float/double 0 as these could be | |
1331 // either +0 or -0. Just because you are equal to +0 | |
1332 // doesn't mean you ARE +0! | |
6131
8f6ce6f1049b
7170463: C2 should recognize "obj.getClass() == A.class" code pattern
kvn
parents:
3899
diff
changeset
|
1333 // Note, following code also replaces Long and Oop values. |
0 | 1334 if ((!tf || tf->_f != 0.0) && |
1335 (!td || td->_d != 0.0)) | |
1336 cast = con; // Replace non-constant val by con. | |
1337 } | |
1338 } | |
1339 break; | |
1340 | |
1341 case BoolTest::ne: | |
1342 if (tcon == TypePtr::NULL_PTR) { | |
1343 cast = cast_not_null(val, false); | |
1344 } | |
1345 break; | |
1346 | |
1347 default: | |
1348 // (At this point we could record int range types with CastII.) | |
1349 break; | |
1350 } | |
1351 | |
1352 if (ccast != NULL) { | |
1353 const Type* tcc = ccast->as_Type()->type(); | |
1354 assert(tcc != tval && tcc->higher_equal(tval), "must improve"); | |
1355 // Delay transform() call to allow recovery of pre-cast value | |
1356 // at the control merge. | |
1357 ccast->set_req(0, control()); | |
1358 _gvn.set_type_bottom(ccast); | |
1359 record_for_igvn(ccast); | |
1360 cast = ccast; | |
1361 } | |
1362 | |
1363 if (cast != NULL) { // Here's the payoff. | |
1364 replace_in_map(val, cast); | |
1365 } | |
1366 } | |
1367 | |
1368 | |
1369 //------------------------------do_one_bytecode-------------------------------- | |
1370 // Parse this bytecode, and alter the Parsers JVM->Node mapping | |
1371 void Parse::do_one_bytecode() { | |
1372 Node *a, *b, *c, *d; // Handy temps | |
1373 BoolTest::mask btest; | |
1374 int i; | |
1375 | |
1376 assert(!has_exceptions(), "bytecode entry state must be clear of throws"); | |
1377 | |
1378 if (C->check_node_count(NodeLimitFudgeFactor * 5, | |
1379 "out of nodes parsing method")) { | |
1380 return; | |
1381 } | |
1382 | |
1383 #ifdef ASSERT | |
1384 // for setting breakpoints | |
1385 if (TraceOptoParse) { | |
1386 tty->print(" @"); | |
1387 dump_bci(bci()); | |
1388 } | |
1389 #endif | |
1390 | |
1391 switch (bc()) { | |
1392 case Bytecodes::_nop: | |
1393 // do nothing | |
1394 break; | |
1395 case Bytecodes::_lconst_0: | |
1396 push_pair(longcon(0)); | |
1397 break; | |
1398 | |
1399 case Bytecodes::_lconst_1: | |
1400 push_pair(longcon(1)); | |
1401 break; | |
1402 | |
1403 case Bytecodes::_fconst_0: | |
1404 push(zerocon(T_FLOAT)); | |
1405 break; | |
1406 | |
1407 case Bytecodes::_fconst_1: | |
1408 push(makecon(TypeF::ONE)); | |
1409 break; | |
1410 | |
1411 case Bytecodes::_fconst_2: | |
1412 push(makecon(TypeF::make(2.0f))); | |
1413 break; | |
1414 | |
1415 case Bytecodes::_dconst_0: | |
1416 push_pair(zerocon(T_DOUBLE)); | |
1417 break; | |
1418 | |
1419 case Bytecodes::_dconst_1: | |
1420 push_pair(makecon(TypeD::ONE)); | |
1421 break; | |
1422 | |
1423 case Bytecodes::_iconst_m1:push(intcon(-1)); break; | |
1424 case Bytecodes::_iconst_0: push(intcon( 0)); break; | |
1425 case Bytecodes::_iconst_1: push(intcon( 1)); break; | |
1426 case Bytecodes::_iconst_2: push(intcon( 2)); break; | |
1427 case Bytecodes::_iconst_3: push(intcon( 3)); break; | |
1428 case Bytecodes::_iconst_4: push(intcon( 4)); break; | |
1429 case Bytecodes::_iconst_5: push(intcon( 5)); break; | |
1565 | 1430 case Bytecodes::_bipush: push(intcon(iter().get_constant_u1())); break; |
1431 case Bytecodes::_sipush: push(intcon(iter().get_constant_u2())); break; | |
0 | 1432 case Bytecodes::_aconst_null: push(null()); break; |
1433 case Bytecodes::_ldc: | |
1434 case Bytecodes::_ldc_w: | |
1435 case Bytecodes::_ldc2_w: | |
1436 // If the constant is unresolved, run this BC once in the interpreter. | |
1602 | 1437 { |
0 | 1438 ciConstant constant = iter().get_constant(); |
1602 | 1439 if (constant.basic_type() == T_OBJECT && |
1440 !constant.as_object()->is_loaded()) { | |
1441 int index = iter().get_constant_pool_index(); | |
1442 constantTag tag = iter().get_constant_pool_tag(index); | |
1443 uncommon_trap(Deoptimization::make_trap_request | |
1444 (Deoptimization::Reason_unloaded, | |
1445 Deoptimization::Action_reinterpret, | |
1446 index), | |
1447 NULL, tag.internal_name()); | |
1448 break; | |
0 | 1449 } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6206
diff
changeset
|
1450 assert(constant.basic_type() != T_OBJECT || constant.as_object()->is_instance(), |
1602 | 1451 "must be java_mirror of klass"); |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
844
diff
changeset
|
1452 bool pushed = push_constant(constant, true); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
844
diff
changeset
|
1453 guarantee(pushed, "must be possible to push this constant"); |
0 | 1454 } |
1455 | |
1456 break; | |
1457 | |
1458 case Bytecodes::_aload_0: | |
1459 push( local(0) ); | |
1460 break; | |
1461 case Bytecodes::_aload_1: | |
1462 push( local(1) ); | |
1463 break; | |
1464 case Bytecodes::_aload_2: | |
1465 push( local(2) ); | |
1466 break; | |
1467 case Bytecodes::_aload_3: | |
1468 push( local(3) ); | |
1469 break; | |
1470 case Bytecodes::_aload: | |
1471 push( local(iter().get_index()) ); | |
1472 break; | |
1473 | |
1474 case Bytecodes::_fload_0: | |
1475 case Bytecodes::_iload_0: | |
1476 push( local(0) ); | |
1477 break; | |
1478 case Bytecodes::_fload_1: | |
1479 case Bytecodes::_iload_1: | |
1480 push( local(1) ); | |
1481 break; | |
1482 case Bytecodes::_fload_2: | |
1483 case Bytecodes::_iload_2: | |
1484 push( local(2) ); | |
1485 break; | |
1486 case Bytecodes::_fload_3: | |
1487 case Bytecodes::_iload_3: | |
1488 push( local(3) ); | |
1489 break; | |
1490 case Bytecodes::_fload: | |
1491 case Bytecodes::_iload: | |
1492 push( local(iter().get_index()) ); | |
1493 break; | |
1494 case Bytecodes::_lload_0: | |
1495 push_pair_local( 0 ); | |
1496 break; | |
1497 case Bytecodes::_lload_1: | |
1498 push_pair_local( 1 ); | |
1499 break; | |
1500 case Bytecodes::_lload_2: | |
1501 push_pair_local( 2 ); | |
1502 break; | |
1503 case Bytecodes::_lload_3: | |
1504 push_pair_local( 3 ); | |
1505 break; | |
1506 case Bytecodes::_lload: | |
1507 push_pair_local( iter().get_index() ); | |
1508 break; | |
1509 | |
1510 case Bytecodes::_dload_0: | |
1511 push_pair_local(0); | |
1512 break; | |
1513 case Bytecodes::_dload_1: | |
1514 push_pair_local(1); | |
1515 break; | |
1516 case Bytecodes::_dload_2: | |
1517 push_pair_local(2); | |
1518 break; | |
1519 case Bytecodes::_dload_3: | |
1520 push_pair_local(3); | |
1521 break; | |
1522 case Bytecodes::_dload: | |
1523 push_pair_local(iter().get_index()); | |
1524 break; | |
1525 case Bytecodes::_fstore_0: | |
1526 case Bytecodes::_istore_0: | |
1527 case Bytecodes::_astore_0: | |
1528 set_local( 0, pop() ); | |
1529 break; | |
1530 case Bytecodes::_fstore_1: | |
1531 case Bytecodes::_istore_1: | |
1532 case Bytecodes::_astore_1: | |
1533 set_local( 1, pop() ); | |
1534 break; | |
1535 case Bytecodes::_fstore_2: | |
1536 case Bytecodes::_istore_2: | |
1537 case Bytecodes::_astore_2: | |
1538 set_local( 2, pop() ); | |
1539 break; | |
1540 case Bytecodes::_fstore_3: | |
1541 case Bytecodes::_istore_3: | |
1542 case Bytecodes::_astore_3: | |
1543 set_local( 3, pop() ); | |
1544 break; | |
1545 case Bytecodes::_fstore: | |
1546 case Bytecodes::_istore: | |
1547 case Bytecodes::_astore: | |
1548 set_local( iter().get_index(), pop() ); | |
1549 break; | |
1550 // long stores | |
1551 case Bytecodes::_lstore_0: | |
1552 set_pair_local( 0, pop_pair() ); | |
1553 break; | |
1554 case Bytecodes::_lstore_1: | |
1555 set_pair_local( 1, pop_pair() ); | |
1556 break; | |
1557 case Bytecodes::_lstore_2: | |
1558 set_pair_local( 2, pop_pair() ); | |
1559 break; | |
1560 case Bytecodes::_lstore_3: | |
1561 set_pair_local( 3, pop_pair() ); | |
1562 break; | |
1563 case Bytecodes::_lstore: | |
1564 set_pair_local( iter().get_index(), pop_pair() ); | |
1565 break; | |
1566 | |
1567 // double stores | |
1568 case Bytecodes::_dstore_0: | |
1569 set_pair_local( 0, dstore_rounding(pop_pair()) ); | |
1570 break; | |
1571 case Bytecodes::_dstore_1: | |
1572 set_pair_local( 1, dstore_rounding(pop_pair()) ); | |
1573 break; | |
1574 case Bytecodes::_dstore_2: | |
1575 set_pair_local( 2, dstore_rounding(pop_pair()) ); | |
1576 break; | |
1577 case Bytecodes::_dstore_3: | |
1578 set_pair_local( 3, dstore_rounding(pop_pair()) ); | |
1579 break; | |
1580 case Bytecodes::_dstore: | |
1581 set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) ); | |
1582 break; | |
1583 | |
1584 case Bytecodes::_pop: _sp -= 1; break; | |
1585 case Bytecodes::_pop2: _sp -= 2; break; | |
1586 case Bytecodes::_swap: | |
1587 a = pop(); | |
1588 b = pop(); | |
1589 push(a); | |
1590 push(b); | |
1591 break; | |
1592 case Bytecodes::_dup: | |
1593 a = pop(); | |
1594 push(a); | |
1595 push(a); | |
1596 break; | |
1597 case Bytecodes::_dup_x1: | |
1598 a = pop(); | |
1599 b = pop(); | |
1600 push( a ); | |
1601 push( b ); | |
1602 push( a ); | |
1603 break; | |
1604 case Bytecodes::_dup_x2: | |
1605 a = pop(); | |
1606 b = pop(); | |
1607 c = pop(); | |
1608 push( a ); | |
1609 push( c ); | |
1610 push( b ); | |
1611 push( a ); | |
1612 break; | |
1613 case Bytecodes::_dup2: | |
1614 a = pop(); | |
1615 b = pop(); | |
1616 push( b ); | |
1617 push( a ); | |
1618 push( b ); | |
1619 push( a ); | |
1620 break; | |
1621 | |
1622 case Bytecodes::_dup2_x1: | |
1623 // before: .. c, b, a | |
1624 // after: .. b, a, c, b, a | |
1625 // not tested | |
1626 a = pop(); | |
1627 b = pop(); | |
1628 c = pop(); | |
1629 push( b ); | |
1630 push( a ); | |
1631 push( c ); | |
1632 push( b ); | |
1633 push( a ); | |
1634 break; | |
1635 case Bytecodes::_dup2_x2: | |
1636 // before: .. d, c, b, a | |
1637 // after: .. b, a, d, c, b, a | |
1638 // not tested | |
1639 a = pop(); | |
1640 b = pop(); | |
1641 c = pop(); | |
1642 d = pop(); | |
1643 push( b ); | |
1644 push( a ); | |
1645 push( d ); | |
1646 push( c ); | |
1647 push( b ); | |
1648 push( a ); | |
1649 break; | |
1650 | |
1651 case Bytecodes::_arraylength: { | |
1652 // Must do null-check with value on expression stack | |
1653 Node *ary = do_null_check(peek(), T_ARRAY); | |
1654 // Compile-time detect of null-exception? | |
1655 if (stopped()) return; | |
1656 a = pop(); | |
1657 push(load_array_length(a)); | |
1658 break; | |
1659 } | |
1660 | |
1661 case Bytecodes::_baload: array_load(T_BYTE); break; | |
1662 case Bytecodes::_caload: array_load(T_CHAR); break; | |
1663 case Bytecodes::_iaload: array_load(T_INT); break; | |
1664 case Bytecodes::_saload: array_load(T_SHORT); break; | |
1665 case Bytecodes::_faload: array_load(T_FLOAT); break; | |
1666 case Bytecodes::_aaload: array_load(T_OBJECT); break; | |
1667 case Bytecodes::_laload: { | |
1668 a = array_addressing(T_LONG, 0); | |
605 | 1669 if (stopped()) return; // guaranteed null or range check |
0 | 1670 _sp -= 2; // Pop array and index |
1671 push_pair( make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS)); | |
1672 break; | |
1673 } | |
1674 case Bytecodes::_daload: { | |
1675 a = array_addressing(T_DOUBLE, 0); | |
605 | 1676 if (stopped()) return; // guaranteed null or range check |
0 | 1677 _sp -= 2; // Pop array and index |
1678 push_pair( make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES)); | |
1679 break; | |
1680 } | |
1681 case Bytecodes::_bastore: array_store(T_BYTE); break; | |
1682 case Bytecodes::_castore: array_store(T_CHAR); break; | |
1683 case Bytecodes::_iastore: array_store(T_INT); break; | |
1684 case Bytecodes::_sastore: array_store(T_SHORT); break; | |
1685 case Bytecodes::_fastore: array_store(T_FLOAT); break; | |
1686 case Bytecodes::_aastore: { | |
1687 d = array_addressing(T_OBJECT, 1); | |
605 | 1688 if (stopped()) return; // guaranteed null or range check |
0 | 1689 array_store_check(); |
1690 c = pop(); // Oop to store | |
1691 b = pop(); // index (already used) | |
1692 a = pop(); // the array itself | |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
825
diff
changeset
|
1693 const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr(); |
0 | 1694 const TypeAryPtr* adr_type = TypeAryPtr::OOPS; |
1695 Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT); | |
1696 break; | |
1697 } | |
1698 case Bytecodes::_lastore: { | |
1699 a = array_addressing(T_LONG, 2); | |
605 | 1700 if (stopped()) return; // guaranteed null or range check |
0 | 1701 c = pop_pair(); |
1702 _sp -= 2; // Pop array and index | |
1703 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS); | |
1704 break; | |
1705 } | |
1706 case Bytecodes::_dastore: { | |
1707 a = array_addressing(T_DOUBLE, 2); | |
605 | 1708 if (stopped()) return; // guaranteed null or range check |
0 | 1709 c = pop_pair(); |
1710 _sp -= 2; // Pop array and index | |
1711 c = dstore_rounding(c); | |
1712 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES); | |
1713 break; | |
1714 } | |
1715 case Bytecodes::_getfield: | |
1716 do_getfield(); | |
1717 break; | |
1718 | |
1719 case Bytecodes::_getstatic: | |
1720 do_getstatic(); | |
1721 break; | |
1722 | |
1723 case Bytecodes::_putfield: | |
1724 do_putfield(); | |
1725 break; | |
1726 | |
1727 case Bytecodes::_putstatic: | |
1728 do_putstatic(); | |
1729 break; | |
1730 | |
1731 case Bytecodes::_irem: | |
1732 do_irem(); | |
1733 break; | |
1734 case Bytecodes::_idiv: | |
1735 // Must keep both values on the expression-stack during null-check | |
1736 do_null_check(peek(), T_INT); | |
1737 // Compile-time detect of null-exception? | |
1738 if (stopped()) return; | |
1739 b = pop(); | |
1740 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1741 push( _gvn.transform( new (C) DivINode(control(),a,b) ) ); |
0 | 1742 break; |
1743 case Bytecodes::_imul: | |
1744 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1745 push( _gvn.transform( new (C) MulINode(a,b) ) ); |
0 | 1746 break; |
1747 case Bytecodes::_iadd: | |
1748 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1749 push( _gvn.transform( new (C) AddINode(a,b) ) ); |
0 | 1750 break; |
1751 case Bytecodes::_ineg: | |
1752 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1753 push( _gvn.transform( new (C) SubINode(_gvn.intcon(0),a)) ); |
0 | 1754 break; |
1755 case Bytecodes::_isub: | |
1756 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1757 push( _gvn.transform( new (C) SubINode(a,b) ) ); |
0 | 1758 break; |
1759 case Bytecodes::_iand: | |
1760 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1761 push( _gvn.transform( new (C) AndINode(a,b) ) ); |
0 | 1762 break; |
1763 case Bytecodes::_ior: | |
1764 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1765 push( _gvn.transform( new (C) OrINode(a,b) ) ); |
0 | 1766 break; |
1767 case Bytecodes::_ixor: | |
1768 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1769 push( _gvn.transform( new (C) XorINode(a,b) ) ); |
0 | 1770 break; |
1771 case Bytecodes::_ishl: | |
1772 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1773 push( _gvn.transform( new (C) LShiftINode(a,b) ) ); |
0 | 1774 break; |
1775 case Bytecodes::_ishr: | |
1776 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1777 push( _gvn.transform( new (C) RShiftINode(a,b) ) ); |
0 | 1778 break; |
1779 case Bytecodes::_iushr: | |
1780 b = pop(); a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1781 push( _gvn.transform( new (C) URShiftINode(a,b) ) ); |
0 | 1782 break; |
1783 | |
1784 case Bytecodes::_fneg: | |
1785 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1786 b = _gvn.transform(new (C) NegFNode (a)); |
0 | 1787 push(b); |
1788 break; | |
1789 | |
1790 case Bytecodes::_fsub: | |
1791 b = pop(); | |
1792 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1793 c = _gvn.transform( new (C) SubFNode(a,b) ); |
0 | 1794 d = precision_rounding(c); |
1795 push( d ); | |
1796 break; | |
1797 | |
1798 case Bytecodes::_fadd: | |
1799 b = pop(); | |
1800 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1801 c = _gvn.transform( new (C) AddFNode(a,b) ); |
0 | 1802 d = precision_rounding(c); |
1803 push( d ); | |
1804 break; | |
1805 | |
1806 case Bytecodes::_fmul: | |
1807 b = pop(); | |
1808 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1809 c = _gvn.transform( new (C) MulFNode(a,b) ); |
0 | 1810 d = precision_rounding(c); |
1811 push( d ); | |
1812 break; | |
1813 | |
1814 case Bytecodes::_fdiv: | |
1815 b = pop(); | |
1816 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1817 c = _gvn.transform( new (C) DivFNode(0,a,b) ); |
0 | 1818 d = precision_rounding(c); |
1819 push( d ); | |
1820 break; | |
1821 | |
1822 case Bytecodes::_frem: | |
1823 if (Matcher::has_match_rule(Op_ModF)) { | |
1824 // Generate a ModF node. | |
1825 b = pop(); | |
1826 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1827 c = _gvn.transform( new (C) ModFNode(0,a,b) ); |
0 | 1828 d = precision_rounding(c); |
1829 push( d ); | |
1830 } | |
1831 else { | |
1832 // Generate a call. | |
1833 modf(); | |
1834 } | |
1835 break; | |
1836 | |
1837 case Bytecodes::_fcmpl: | |
1838 b = pop(); | |
1839 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1840 c = _gvn.transform( new (C) CmpF3Node( a, b)); |
0 | 1841 push(c); |
1842 break; | |
1843 case Bytecodes::_fcmpg: | |
1844 b = pop(); | |
1845 a = pop(); | |
1846 | |
1847 // Same as fcmpl but need to flip the unordered case. Swap the inputs, | |
1848 // which negates the result sign except for unordered. Flip the unordered | |
1849 // as well by using CmpF3 which implements unordered-lesser instead of | |
1850 // unordered-greater semantics. Finally, commute the result bits. Result | |
1851 // is same as using a CmpF3Greater except we did it with CmpF3 alone. | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1852 c = _gvn.transform( new (C) CmpF3Node( b, a)); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1853 c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) ); |
0 | 1854 push(c); |
1855 break; | |
1856 | |
1857 case Bytecodes::_f2i: | |
1858 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1859 push(_gvn.transform(new (C) ConvF2INode(a))); |
0 | 1860 break; |
1861 | |
1862 case Bytecodes::_d2i: | |
1863 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1864 b = _gvn.transform(new (C) ConvD2INode(a)); |
0 | 1865 push( b ); |
1866 break; | |
1867 | |
1868 case Bytecodes::_f2d: | |
1869 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1870 b = _gvn.transform( new (C) ConvF2DNode(a)); |
0 | 1871 push_pair( b ); |
1872 break; | |
1873 | |
1874 case Bytecodes::_d2f: | |
1875 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1876 b = _gvn.transform( new (C) ConvD2FNode(a)); |
0 | 1877 // This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed) |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1878 //b = _gvn.transform(new (C) RoundFloatNode(0, b) ); |
0 | 1879 push( b ); |
1880 break; | |
1881 | |
1882 case Bytecodes::_l2f: | |
1883 if (Matcher::convL2FSupported()) { | |
1884 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1885 b = _gvn.transform( new (C) ConvL2FNode(a)); |
0 | 1886 // For i486.ad, FILD doesn't restrict precision to 24 or 53 bits. |
1887 // Rather than storing the result into an FP register then pushing | |
1888 // out to memory to round, the machine instruction that implements | |
1889 // ConvL2D is responsible for rounding. | |
1890 // c = precision_rounding(b); | |
1891 c = _gvn.transform(b); | |
1892 push(c); | |
1893 } else { | |
1894 l2f(); | |
1895 } | |
1896 break; | |
1897 | |
1898 case Bytecodes::_l2d: | |
1899 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1900 b = _gvn.transform( new (C) ConvL2DNode(a)); |
0 | 1901 // For i486.ad, rounding is always necessary (see _l2f above). |
1902 // c = dprecision_rounding(b); | |
1903 c = _gvn.transform(b); | |
1904 push_pair(c); | |
1905 break; | |
1906 | |
1907 case Bytecodes::_f2l: | |
1908 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1909 b = _gvn.transform( new (C) ConvF2LNode(a)); |
0 | 1910 push_pair(b); |
1911 break; | |
1912 | |
1913 case Bytecodes::_d2l: | |
1914 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1915 b = _gvn.transform( new (C) ConvD2LNode(a)); |
0 | 1916 push_pair(b); |
1917 break; | |
1918 | |
1919 case Bytecodes::_dsub: | |
1920 b = pop_pair(); | |
1921 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1922 c = _gvn.transform( new (C) SubDNode(a,b) ); |
0 | 1923 d = dprecision_rounding(c); |
1924 push_pair( d ); | |
1925 break; | |
1926 | |
1927 case Bytecodes::_dadd: | |
1928 b = pop_pair(); | |
1929 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1930 c = _gvn.transform( new (C) AddDNode(a,b) ); |
0 | 1931 d = dprecision_rounding(c); |
1932 push_pair( d ); | |
1933 break; | |
1934 | |
1935 case Bytecodes::_dmul: | |
1936 b = pop_pair(); | |
1937 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1938 c = _gvn.transform( new (C) MulDNode(a,b) ); |
0 | 1939 d = dprecision_rounding(c); |
1940 push_pair( d ); | |
1941 break; | |
1942 | |
1943 case Bytecodes::_ddiv: | |
1944 b = pop_pair(); | |
1945 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1946 c = _gvn.transform( new (C) DivDNode(0,a,b) ); |
0 | 1947 d = dprecision_rounding(c); |
1948 push_pair( d ); | |
1949 break; | |
1950 | |
1951 case Bytecodes::_dneg: | |
1952 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1953 b = _gvn.transform(new (C) NegDNode (a)); |
0 | 1954 push_pair(b); |
1955 break; | |
1956 | |
1957 case Bytecodes::_drem: | |
1958 if (Matcher::has_match_rule(Op_ModD)) { | |
1959 // Generate a ModD node. | |
1960 b = pop_pair(); | |
1961 a = pop_pair(); | |
1962 // a % b | |
1963 | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1964 c = _gvn.transform( new (C) ModDNode(0,a,b) ); |
0 | 1965 d = dprecision_rounding(c); |
1966 push_pair( d ); | |
1967 } | |
1968 else { | |
1969 // Generate a call. | |
1970 modd(); | |
1971 } | |
1972 break; | |
1973 | |
1974 case Bytecodes::_dcmpl: | |
1975 b = pop_pair(); | |
1976 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1977 c = _gvn.transform( new (C) CmpD3Node( a, b)); |
0 | 1978 push(c); |
1979 break; | |
1980 | |
1981 case Bytecodes::_dcmpg: | |
1982 b = pop_pair(); | |
1983 a = pop_pair(); | |
1984 // Same as dcmpl but need to flip the unordered case. | |
1985 // Commute the inputs, which negates the result sign except for unordered. | |
1986 // Flip the unordered as well by using CmpD3 which implements | |
1987 // unordered-lesser instead of unordered-greater semantics. | |
1988 // Finally, negate the result bits. Result is same as using a | |
1989 // CmpD3Greater except we did it with CmpD3 alone. | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1990 c = _gvn.transform( new (C) CmpD3Node( b, a)); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
1991 c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) ); |
0 | 1992 push(c); |
1993 break; | |
1994 | |
1995 | |
1996 // Note for longs -> lo word is on TOS, hi word is on TOS - 1 | |
1997 case Bytecodes::_land: | |
1998 b = pop_pair(); | |
1999 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2000 c = _gvn.transform( new (C) AndLNode(a,b) ); |
0 | 2001 push_pair(c); |
2002 break; | |
2003 case Bytecodes::_lor: | |
2004 b = pop_pair(); | |
2005 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2006 c = _gvn.transform( new (C) OrLNode(a,b) ); |
0 | 2007 push_pair(c); |
2008 break; | |
2009 case Bytecodes::_lxor: | |
2010 b = pop_pair(); | |
2011 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2012 c = _gvn.transform( new (C) XorLNode(a,b) ); |
0 | 2013 push_pair(c); |
2014 break; | |
2015 | |
2016 case Bytecodes::_lshl: | |
2017 b = pop(); // the shift count | |
2018 a = pop_pair(); // value to be shifted | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2019 c = _gvn.transform( new (C) LShiftLNode(a,b) ); |
0 | 2020 push_pair(c); |
2021 break; | |
2022 case Bytecodes::_lshr: | |
2023 b = pop(); // the shift count | |
2024 a = pop_pair(); // value to be shifted | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2025 c = _gvn.transform( new (C) RShiftLNode(a,b) ); |
0 | 2026 push_pair(c); |
2027 break; | |
2028 case Bytecodes::_lushr: | |
2029 b = pop(); // the shift count | |
2030 a = pop_pair(); // value to be shifted | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2031 c = _gvn.transform( new (C) URShiftLNode(a,b) ); |
0 | 2032 push_pair(c); |
2033 break; | |
2034 case Bytecodes::_lmul: | |
2035 b = pop_pair(); | |
2036 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2037 c = _gvn.transform( new (C) MulLNode(a,b) ); |
0 | 2038 push_pair(c); |
2039 break; | |
2040 | |
2041 case Bytecodes::_lrem: | |
2042 // Must keep both values on the expression-stack during null-check | |
2043 assert(peek(0) == top(), "long word order"); | |
2044 do_null_check(peek(1), T_LONG); | |
2045 // Compile-time detect of null-exception? | |
2046 if (stopped()) return; | |
2047 b = pop_pair(); | |
2048 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2049 c = _gvn.transform( new (C) ModLNode(control(),a,b) ); |
0 | 2050 push_pair(c); |
2051 break; | |
2052 | |
2053 case Bytecodes::_ldiv: | |
2054 // Must keep both values on the expression-stack during null-check | |
2055 assert(peek(0) == top(), "long word order"); | |
2056 do_null_check(peek(1), T_LONG); | |
2057 // Compile-time detect of null-exception? | |
2058 if (stopped()) return; | |
2059 b = pop_pair(); | |
2060 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2061 c = _gvn.transform( new (C) DivLNode(control(),a,b) ); |
0 | 2062 push_pair(c); |
2063 break; | |
2064 | |
2065 case Bytecodes::_ladd: | |
2066 b = pop_pair(); | |
2067 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2068 c = _gvn.transform( new (C) AddLNode(a,b) ); |
0 | 2069 push_pair(c); |
2070 break; | |
2071 case Bytecodes::_lsub: | |
2072 b = pop_pair(); | |
2073 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2074 c = _gvn.transform( new (C) SubLNode(a,b) ); |
0 | 2075 push_pair(c); |
2076 break; | |
2077 case Bytecodes::_lcmp: | |
2078 // Safepoints are now inserted _before_ branches. The long-compare | |
2079 // bytecode painfully produces a 3-way value (-1,0,+1) which requires a | |
2080 // slew of control flow. These are usually followed by a CmpI vs zero and | |
2081 // a branch; this pattern then optimizes to the obvious long-compare and | |
2082 // branch. However, if the branch is backwards there's a Safepoint | |
2083 // inserted. The inserted Safepoint captures the JVM state at the | |
2084 // pre-branch point, i.e. it captures the 3-way value. Thus if a | |
2085 // long-compare is used to control a loop the debug info will force | |
2086 // computation of the 3-way value, even though the generated code uses a | |
2087 // long-compare and branch. We try to rectify the situation by inserting | |
2088 // a SafePoint here and have it dominate and kill the safepoint added at a | |
2089 // following backwards branch. At this point the JVM state merely holds 2 | |
2090 // longs but not the 3-way value. | |
2091 if( UseLoopSafepoints ) { | |
2092 switch( iter().next_bc() ) { | |
2093 case Bytecodes::_ifgt: | |
2094 case Bytecodes::_iflt: | |
2095 case Bytecodes::_ifge: | |
2096 case Bytecodes::_ifle: | |
2097 case Bytecodes::_ifne: | |
2098 case Bytecodes::_ifeq: | |
2099 // If this is a backwards branch in the bytecodes, add Safepoint | |
2100 maybe_add_safepoint(iter().next_get_dest()); | |
2101 } | |
2102 } | |
2103 b = pop_pair(); | |
2104 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2105 c = _gvn.transform( new (C) CmpL3Node( a, b )); |
0 | 2106 push(c); |
2107 break; | |
2108 | |
2109 case Bytecodes::_lneg: | |
2110 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2111 b = _gvn.transform( new (C) SubLNode(longcon(0),a)); |
0 | 2112 push_pair(b); |
2113 break; | |
2114 case Bytecodes::_l2i: | |
2115 a = pop_pair(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2116 push( _gvn.transform( new (C) ConvL2INode(a))); |
0 | 2117 break; |
2118 case Bytecodes::_i2l: | |
2119 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2120 b = _gvn.transform( new (C) ConvI2LNode(a)); |
0 | 2121 push_pair(b); |
2122 break; | |
2123 case Bytecodes::_i2b: | |
2124 // Sign extend | |
2125 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2126 a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(24)) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2127 a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(24)) ); |
0 | 2128 push( a ); |
2129 break; | |
2130 case Bytecodes::_i2s: | |
2131 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2132 a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(16)) ); |
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2133 a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(16)) ); |
0 | 2134 push( a ); |
2135 break; | |
2136 case Bytecodes::_i2c: | |
2137 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2138 push( _gvn.transform( new (C) AndINode(a,_gvn.intcon(0xFFFF)) ) ); |
0 | 2139 break; |
2140 | |
2141 case Bytecodes::_i2f: | |
2142 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2143 b = _gvn.transform( new (C) ConvI2FNode(a) ) ; |
0 | 2144 c = precision_rounding(b); |
2145 push (b); | |
2146 break; | |
2147 | |
2148 case Bytecodes::_i2d: | |
2149 a = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2150 b = _gvn.transform( new (C) ConvI2DNode(a)); |
0 | 2151 push_pair(b); |
2152 break; | |
2153 | |
2154 case Bytecodes::_iinc: // Increment local | |
2155 i = iter().get_index(); // Get local index | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2156 set_local( i, _gvn.transform( new (C) AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) ); |
0 | 2157 break; |
2158 | |
2159 // Exit points of synchronized methods must have an unlock node | |
2160 case Bytecodes::_return: | |
2161 return_current(NULL); | |
2162 break; | |
2163 | |
2164 case Bytecodes::_ireturn: | |
2165 case Bytecodes::_areturn: | |
2166 case Bytecodes::_freturn: | |
2167 return_current(pop()); | |
2168 break; | |
2169 case Bytecodes::_lreturn: | |
2170 return_current(pop_pair()); | |
2171 break; | |
2172 case Bytecodes::_dreturn: | |
2173 return_current(pop_pair()); | |
2174 break; | |
2175 | |
2176 case Bytecodes::_athrow: | |
2177 // null exception oop throws NULL pointer exception | |
2178 do_null_check(peek(), T_OBJECT); | |
2179 if (stopped()) return; | |
2180 // Hook the thrown exception directly to subsequent handlers. | |
2181 if (BailoutToInterpreterForThrows) { | |
2182 // Keep method interpreted from now on. | |
2183 uncommon_trap(Deoptimization::Reason_unhandled, | |
2184 Deoptimization::Action_make_not_compilable); | |
2185 return; | |
2186 } | |
1213
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1172
diff
changeset
|
2187 if (env()->jvmti_can_post_on_exceptions()) { |
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1172
diff
changeset
|
2188 // check if we must post exception events, take uncommon trap if so (with must_throw = false) |
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1172
diff
changeset
|
2189 uncommon_trap_if_should_post_on_exceptions(Deoptimization::Reason_unhandled, false); |
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1172
diff
changeset
|
2190 } |
6deeaebad47a
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
1172
diff
changeset
|
2191 // Here if either can_post_on_exceptions or should_post_on_exceptions is false |
0 | 2192 add_exception_state(make_exception_state(peek())); |
2193 break; | |
2194 | |
2195 case Bytecodes::_goto: // fall through | |
2196 case Bytecodes::_goto_w: { | |
2197 int target_bci = (bc() == Bytecodes::_goto) ? iter().get_dest() : iter().get_far_dest(); | |
2198 | |
2199 // If this is a backwards branch in the bytecodes, add Safepoint | |
2200 maybe_add_safepoint(target_bci); | |
2201 | |
2202 // Update method data | |
2203 profile_taken_branch(target_bci); | |
2204 | |
2205 // Merge the current control into the target basic block | |
2206 merge(target_bci); | |
2207 | |
2208 // See if we can get some profile data and hand it off to the next block | |
2209 Block *target_block = block()->successor_for_bci(target_bci); | |
2210 if (target_block->pred_count() != 1) break; | |
2211 ciMethodData* methodData = method()->method_data(); | |
2212 if (!methodData->is_mature()) break; | |
2213 ciProfileData* data = methodData->bci_to_data(bci()); | |
2214 assert( data->is_JumpData(), "" ); | |
2215 int taken = ((ciJumpData*)data)->taken(); | |
2216 taken = method()->scale_count(taken); | |
2217 target_block->set_count(taken); | |
2218 break; | |
2219 } | |
2220 | |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2221 case Bytecodes::_ifnull: btest = BoolTest::eq; goto handle_if_null; |
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2222 case Bytecodes::_ifnonnull: btest = BoolTest::ne; goto handle_if_null; |
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2223 handle_if_null: |
254
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2224 // If this is a backwards branch in the bytecodes, add Safepoint |
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2225 maybe_add_safepoint(iter().get_dest()); |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2226 a = null(); |
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2227 b = pop(); |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2228 c = _gvn.transform( new (C) CmpPNode(b, a) ); |
248
18aab3cdd513
6726504: handle do_ifxxx calls in parser more uniformly
rasbold
parents:
246
diff
changeset
|
2229 do_ifnull(btest, c); |
0 | 2230 break; |
2231 | |
2232 case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp; | |
2233 case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp; | |
2234 handle_if_acmp: | |
254
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2235 // If this is a backwards branch in the bytecodes, add Safepoint |
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2236 maybe_add_safepoint(iter().get_dest()); |
0 | 2237 a = pop(); |
2238 b = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2239 c = _gvn.transform( new (C) CmpPNode(b, a) ); |
0 | 2240 do_if(btest, c); |
2241 break; | |
2242 | |
2243 case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx; | |
2244 case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx; | |
2245 case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx; | |
2246 case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx; | |
2247 case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx; | |
2248 case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx; | |
2249 handle_ifxx: | |
254
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2250 // If this is a backwards branch in the bytecodes, add Safepoint |
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2251 maybe_add_safepoint(iter().get_dest()); |
0 | 2252 a = _gvn.intcon(0); |
2253 b = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2254 c = _gvn.transform( new (C) CmpINode(b, a) ); |
0 | 2255 do_if(btest, c); |
2256 break; | |
2257 | |
2258 case Bytecodes::_if_icmpeq: btest = BoolTest::eq; goto handle_if_icmp; | |
2259 case Bytecodes::_if_icmpne: btest = BoolTest::ne; goto handle_if_icmp; | |
2260 case Bytecodes::_if_icmplt: btest = BoolTest::lt; goto handle_if_icmp; | |
2261 case Bytecodes::_if_icmple: btest = BoolTest::le; goto handle_if_icmp; | |
2262 case Bytecodes::_if_icmpgt: btest = BoolTest::gt; goto handle_if_icmp; | |
2263 case Bytecodes::_if_icmpge: btest = BoolTest::ge; goto handle_if_icmp; | |
2264 handle_if_icmp: | |
254
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2265 // If this is a backwards branch in the bytecodes, add Safepoint |
3e333d6f35dd
6730192: expression stack wrong at deoptimization point
rasbold
parents:
248
diff
changeset
|
2266 maybe_add_safepoint(iter().get_dest()); |
0 | 2267 a = pop(); |
2268 b = pop(); | |
6804
e626685e9f6c
7193318: C2: remove number of inputs requirement from Node's new operator
kvn
parents:
6725
diff
changeset
|
2269 c = _gvn.transform( new (C) CmpINode( b, a ) ); |
0 | 2270 do_if(btest, c); |
2271 break; | |
2272 | |
2273 case Bytecodes::_tableswitch: | |
2274 do_tableswitch(); | |
2275 break; | |
2276 | |
2277 case Bytecodes::_lookupswitch: | |
2278 do_lookupswitch(); | |
2279 break; | |
2280 | |
2281 case Bytecodes::_invokestatic: | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
605
diff
changeset
|
2282 case Bytecodes::_invokedynamic: |
0 | 2283 case Bytecodes::_invokespecial: |
2284 case Bytecodes::_invokevirtual: | |
2285 case Bytecodes::_invokeinterface: | |
2286 do_call(); | |
2287 break; | |
2288 case Bytecodes::_checkcast: | |
2289 do_checkcast(); | |
2290 break; | |
2291 case Bytecodes::_instanceof: | |
2292 do_instanceof(); | |
2293 break; | |
2294 case Bytecodes::_anewarray: | |
2295 do_anewarray(); | |
2296 break; | |
2297 case Bytecodes::_newarray: | |
2298 do_newarray((BasicType)iter().get_index()); | |
2299 break; | |
2300 case Bytecodes::_multianewarray: | |
2301 do_multianewarray(); | |
2302 break; | |
2303 case Bytecodes::_new: | |
2304 do_new(); | |
2305 break; | |
2306 | |
2307 case Bytecodes::_jsr: | |
2308 case Bytecodes::_jsr_w: | |
2309 do_jsr(); | |
2310 break; | |
2311 | |
2312 case Bytecodes::_ret: | |
2313 do_ret(); | |
2314 break; | |
2315 | |
2316 | |
2317 case Bytecodes::_monitorenter: | |
2318 do_monitor_enter(); | |
2319 break; | |
2320 | |
2321 case Bytecodes::_monitorexit: | |
2322 do_monitor_exit(); | |
2323 break; | |
2324 | |
2325 case Bytecodes::_breakpoint: | |
2326 // Breakpoint set concurrently to compile | |
2327 // %%% use an uncommon trap? | |
2328 C->record_failure("breakpoint in method"); | |
2329 return; | |
2330 | |
2331 default: | |
2332 #ifndef PRODUCT | |
2333 map()->dump(99); | |
2334 #endif | |
2335 tty->print("\nUnhandled bytecode %s\n", Bytecodes::name(bc()) ); | |
2336 ShouldNotReachHere(); | |
2337 } | |
2338 | |
2339 #ifndef PRODUCT | |
2340 IdealGraphPrinter *printer = IdealGraphPrinter::printer(); | |
2341 if(printer) { | |
2342 char buffer[256]; | |
2343 sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc())); | |
2344 bool old = printer->traverse_outs(); | |
2345 printer->set_traverse_outs(true); | |
222 | 2346 printer->print_method(C, buffer, 4); |
0 | 2347 printer->set_traverse_outs(old); |
2348 } | |
2349 #endif | |
2350 } |