annotate src/share/vm/opto/parse2.cpp @ 23614:32b682649973 jdk8u75-b04

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