annotate src/share/vm/opto/parse2.cpp @ 825:8f5825e0aeaa

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