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