1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/opto/parse2.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,2171 @@ 1.4 +/* 1.5 + * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "incls/_precompiled.incl" 1.29 +#include "incls/_parse2.cpp.incl" 1.30 + 1.31 +extern int explicit_null_checks_inserted, 1.32 + explicit_null_checks_elided; 1.33 + 1.34 +//---------------------------------array_load---------------------------------- 1.35 +void Parse::array_load(BasicType elem_type) { 1.36 + const Type* elem = Type::TOP; 1.37 + Node* adr = array_addressing(elem_type, 0, &elem); 1.38 + if (stopped()) return; // guarenteed null or range check 1.39 + _sp -= 2; // Pop array and index 1.40 + const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); 1.41 + Node* ld = make_load(control(), adr, elem, elem_type, adr_type); 1.42 + push(ld); 1.43 +} 1.44 + 1.45 + 1.46 +//--------------------------------array_store---------------------------------- 1.47 +void Parse::array_store(BasicType elem_type) { 1.48 + Node* adr = array_addressing(elem_type, 1); 1.49 + if (stopped()) return; // guarenteed null or range check 1.50 + Node* val = pop(); 1.51 + _sp -= 2; // Pop array and index 1.52 + const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type); 1.53 + store_to_memory(control(), adr, val, elem_type, adr_type); 1.54 +} 1.55 + 1.56 + 1.57 +//------------------------------array_addressing------------------------------- 1.58 +// Pull array and index from the stack. Compute pointer-to-element. 1.59 +Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { 1.60 + Node *idx = peek(0+vals); // Get from stack without popping 1.61 + Node *ary = peek(1+vals); // in case of exception 1.62 + 1.63 + // Null check the array base, with correct stack contents 1.64 + ary = do_null_check(ary, T_ARRAY); 1.65 + // Compile-time detect of null-exception? 1.66 + if (stopped()) return top(); 1.67 + 1.68 + const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr(); 1.69 + const TypeInt* sizetype = arytype->size(); 1.70 + const Type* elemtype = arytype->elem(); 1.71 + 1.72 + if (UseUniqueSubclasses && result2 != NULL) { 1.73 + const TypeInstPtr* toop = elemtype->isa_instptr(); 1.74 + if (toop) { 1.75 + if (toop->klass()->as_instance_klass()->unique_concrete_subklass()) { 1.76 + // If we load from "AbstractClass[]" we must see "ConcreteSubClass". 1.77 + const Type* subklass = Type::get_const_type(toop->klass()); 1.78 + elemtype = subklass->join(elemtype); 1.79 + } 1.80 + } 1.81 + } 1.82 + 1.83 + // Check for big class initializers with all constant offsets 1.84 + // feeding into a known-size array. 1.85 + const TypeInt* idxtype = _gvn.type(idx)->is_int(); 1.86 + // See if the highest idx value is less than the lowest array bound, 1.87 + // and if the idx value cannot be negative: 1.88 + bool need_range_check = true; 1.89 + if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) { 1.90 + need_range_check = false; 1.91 + if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'"); 1.92 + } 1.93 + 1.94 + if (!arytype->klass()->is_loaded()) { 1.95 + // Only fails for some -Xcomp runs 1.96 + // The class is unloaded. We have to run this bytecode in the interpreter. 1.97 + uncommon_trap(Deoptimization::Reason_unloaded, 1.98 + Deoptimization::Action_reinterpret, 1.99 + arytype->klass(), "!loaded array"); 1.100 + return top(); 1.101 + } 1.102 + 1.103 + // Do the range check 1.104 + if (GenerateRangeChecks && need_range_check) { 1.105 + // Range is constant in array-oop, so we can use the original state of mem 1.106 + Node* len = load_array_length(ary); 1.107 + // Test length vs index (standard trick using unsigned compare) 1.108 + Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) ); 1.109 + BoolTest::mask btest = BoolTest::lt; 1.110 + Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) ); 1.111 + // Branch to failure if out of bounds 1.112 + { BuildCutout unless(this, tst, PROB_MAX); 1.113 + if (C->allow_range_check_smearing()) { 1.114 + // Do not use builtin_throw, since range checks are sometimes 1.115 + // made more stringent by an optimistic transformation. 1.116 + // This creates "tentative" range checks at this point, 1.117 + // which are not guaranteed to throw exceptions. 1.118 + // See IfNode::Ideal, is_range_check, adjust_check. 1.119 + uncommon_trap(Deoptimization::Reason_range_check, 1.120 + Deoptimization::Action_make_not_entrant, 1.121 + NULL, "range_check"); 1.122 + } else { 1.123 + // If we have already recompiled with the range-check-widening 1.124 + // heroic optimization turned off, then we must really be throwing 1.125 + // range check exceptions. 1.126 + builtin_throw(Deoptimization::Reason_range_check, idx); 1.127 + } 1.128 + } 1.129 + } 1.130 + // Check for always knowing you are throwing a range-check exception 1.131 + if (stopped()) return top(); 1.132 + 1.133 + Node* ptr = array_element_address( ary, idx, type, sizetype); 1.134 + 1.135 + if (result2 != NULL) *result2 = elemtype; 1.136 + return ptr; 1.137 +} 1.138 + 1.139 + 1.140 +// returns IfNode 1.141 +IfNode* Parse::jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask) { 1.142 + Node *cmp = _gvn.transform( new (C, 3) CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32 1.143 + Node *tst = _gvn.transform( new (C, 2) BoolNode( cmp, mask)); 1.144 + IfNode *iff = create_and_map_if( control(), tst, ((mask == BoolTest::eq) ? PROB_STATIC_INFREQUENT : PROB_FAIR), COUNT_UNKNOWN ); 1.145 + return iff; 1.146 +} 1.147 + 1.148 +// return Region node 1.149 +Node* Parse::jump_if_join(Node* iffalse, Node* iftrue) { 1.150 + Node *region = new (C, 3) RegionNode(3); // 2 results 1.151 + record_for_igvn(region); 1.152 + region->init_req(1, iffalse); 1.153 + region->init_req(2, iftrue ); 1.154 + _gvn.set_type(region, Type::CONTROL); 1.155 + region = _gvn.transform(region); 1.156 + set_control (region); 1.157 + return region; 1.158 +} 1.159 + 1.160 + 1.161 +//------------------------------helper for tableswitch------------------------- 1.162 +void Parse::jump_if_true_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { 1.163 + // True branch, use existing map info 1.164 + { PreserveJVMState pjvms(this); 1.165 + Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) ); 1.166 + set_control( iftrue ); 1.167 + profile_switch_case(prof_table_index); 1.168 + merge_new_path(dest_bci_if_true); 1.169 + } 1.170 + 1.171 + // False branch 1.172 + Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) ); 1.173 + set_control( iffalse ); 1.174 +} 1.175 + 1.176 +void Parse::jump_if_false_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { 1.177 + // True branch, use existing map info 1.178 + { PreserveJVMState pjvms(this); 1.179 + Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode (iff) ); 1.180 + set_control( iffalse ); 1.181 + profile_switch_case(prof_table_index); 1.182 + merge_new_path(dest_bci_if_true); 1.183 + } 1.184 + 1.185 + // False branch 1.186 + Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff) ); 1.187 + set_control( iftrue ); 1.188 +} 1.189 + 1.190 +void Parse::jump_if_always_fork(int dest_bci, int prof_table_index) { 1.191 + // False branch, use existing map and control() 1.192 + profile_switch_case(prof_table_index); 1.193 + merge_new_path(dest_bci); 1.194 +} 1.195 + 1.196 + 1.197 +extern "C" { 1.198 + static int jint_cmp(const void *i, const void *j) { 1.199 + int a = *(jint *)i; 1.200 + int b = *(jint *)j; 1.201 + return a > b ? 1 : a < b ? -1 : 0; 1.202 + } 1.203 +} 1.204 + 1.205 + 1.206 +// Default value for methodData switch indexing. Must be a negative value to avoid 1.207 +// conflict with any legal switch index. 1.208 +#define NullTableIndex -1 1.209 + 1.210 +class SwitchRange : public StackObj { 1.211 + // a range of integers coupled with a bci destination 1.212 + jint _lo; // inclusive lower limit 1.213 + jint _hi; // inclusive upper limit 1.214 + int _dest; 1.215 + int _table_index; // index into method data table 1.216 + 1.217 +public: 1.218 + jint lo() const { return _lo; } 1.219 + jint hi() const { return _hi; } 1.220 + int dest() const { return _dest; } 1.221 + int table_index() const { return _table_index; } 1.222 + bool is_singleton() const { return _lo == _hi; } 1.223 + 1.224 + void setRange(jint lo, jint hi, int dest, int table_index) { 1.225 + assert(lo <= hi, "must be a non-empty range"); 1.226 + _lo = lo, _hi = hi; _dest = dest; _table_index = table_index; 1.227 + } 1.228 + bool adjoinRange(jint lo, jint hi, int dest, int table_index) { 1.229 + assert(lo <= hi, "must be a non-empty range"); 1.230 + if (lo == _hi+1 && dest == _dest && table_index == _table_index) { 1.231 + _hi = hi; 1.232 + return true; 1.233 + } 1.234 + return false; 1.235 + } 1.236 + 1.237 + void set (jint value, int dest, int table_index) { 1.238 + setRange(value, value, dest, table_index); 1.239 + } 1.240 + bool adjoin(jint value, int dest, int table_index) { 1.241 + return adjoinRange(value, value, dest, table_index); 1.242 + } 1.243 + 1.244 + void print(ciEnv* env) { 1.245 + if (is_singleton()) 1.246 + tty->print(" {%d}=>%d", lo(), dest()); 1.247 + else if (lo() == min_jint) 1.248 + tty->print(" {..%d}=>%d", hi(), dest()); 1.249 + else if (hi() == max_jint) 1.250 + tty->print(" {%d..}=>%d", lo(), dest()); 1.251 + else 1.252 + tty->print(" {%d..%d}=>%d", lo(), hi(), dest()); 1.253 + } 1.254 +}; 1.255 + 1.256 + 1.257 +//-------------------------------do_tableswitch-------------------------------- 1.258 +void Parse::do_tableswitch() { 1.259 + Node* lookup = pop(); 1.260 + 1.261 + // Get information about tableswitch 1.262 + int default_dest = iter().get_dest_table(0); 1.263 + int lo_index = iter().get_int_table(1); 1.264 + int hi_index = iter().get_int_table(2); 1.265 + int len = hi_index - lo_index + 1; 1.266 + 1.267 + if (len < 1) { 1.268 + // If this is a backward branch, add safepoint 1.269 + maybe_add_safepoint(default_dest); 1.270 + merge(default_dest); 1.271 + return; 1.272 + } 1.273 + 1.274 + // generate decision tree, using trichotomy when possible 1.275 + int rnum = len+2; 1.276 + bool makes_backward_branch = false; 1.277 + SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum); 1.278 + int rp = -1; 1.279 + if (lo_index != min_jint) { 1.280 + ranges[++rp].setRange(min_jint, lo_index-1, default_dest, NullTableIndex); 1.281 + } 1.282 + for (int j = 0; j < len; j++) { 1.283 + jint match_int = lo_index+j; 1.284 + int dest = iter().get_dest_table(j+3); 1.285 + makes_backward_branch |= (dest <= bci()); 1.286 + int table_index = method_data_update() ? j : NullTableIndex; 1.287 + if (rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index)) { 1.288 + ranges[++rp].set(match_int, dest, table_index); 1.289 + } 1.290 + } 1.291 + jint highest = lo_index+(len-1); 1.292 + assert(ranges[rp].hi() == highest, ""); 1.293 + if (highest != max_jint 1.294 + && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex)) { 1.295 + ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex); 1.296 + } 1.297 + assert(rp < len+2, "not too many ranges"); 1.298 + 1.299 + // Safepoint in case if backward branch observed 1.300 + if( makes_backward_branch && UseLoopSafepoints ) 1.301 + add_safepoint(); 1.302 + 1.303 + jump_switch_ranges(lookup, &ranges[0], &ranges[rp]); 1.304 +} 1.305 + 1.306 + 1.307 +//------------------------------do_lookupswitch-------------------------------- 1.308 +void Parse::do_lookupswitch() { 1.309 + Node *lookup = pop(); // lookup value 1.310 + // Get information about lookupswitch 1.311 + int default_dest = iter().get_dest_table(0); 1.312 + int len = iter().get_int_table(1); 1.313 + 1.314 + if (len < 1) { // If this is a backward branch, add safepoint 1.315 + maybe_add_safepoint(default_dest); 1.316 + merge(default_dest); 1.317 + return; 1.318 + } 1.319 + 1.320 + // generate decision tree, using trichotomy when possible 1.321 + jint* table = NEW_RESOURCE_ARRAY(jint, len*2); 1.322 + { 1.323 + for( int j = 0; j < len; j++ ) { 1.324 + table[j+j+0] = iter().get_int_table(2+j+j); 1.325 + table[j+j+1] = iter().get_dest_table(2+j+j+1); 1.326 + } 1.327 + qsort( table, len, 2*sizeof(table[0]), jint_cmp ); 1.328 + } 1.329 + 1.330 + int rnum = len*2+1; 1.331 + bool makes_backward_branch = false; 1.332 + SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum); 1.333 + int rp = -1; 1.334 + for( int j = 0; j < len; j++ ) { 1.335 + jint match_int = table[j+j+0]; 1.336 + int dest = table[j+j+1]; 1.337 + int next_lo = rp < 0 ? min_jint : ranges[rp].hi()+1; 1.338 + int table_index = method_data_update() ? j : NullTableIndex; 1.339 + makes_backward_branch |= (dest <= bci()); 1.340 + if( match_int != next_lo ) { 1.341 + ranges[++rp].setRange(next_lo, match_int-1, default_dest, NullTableIndex); 1.342 + } 1.343 + if( rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index) ) { 1.344 + ranges[++rp].set(match_int, dest, table_index); 1.345 + } 1.346 + } 1.347 + jint highest = table[2*(len-1)]; 1.348 + assert(ranges[rp].hi() == highest, ""); 1.349 + if( highest != max_jint 1.350 + && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex) ) { 1.351 + ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex); 1.352 + } 1.353 + assert(rp < rnum, "not too many ranges"); 1.354 + 1.355 + // Safepoint in case backward branch observed 1.356 + if( makes_backward_branch && UseLoopSafepoints ) 1.357 + add_safepoint(); 1.358 + 1.359 + jump_switch_ranges(lookup, &ranges[0], &ranges[rp]); 1.360 +} 1.361 + 1.362 +//----------------------------create_jump_tables------------------------------- 1.363 +bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) { 1.364 + // Are jumptables enabled 1.365 + if (!UseJumpTables) return false; 1.366 + 1.367 + // Are jumptables supported 1.368 + if (!Matcher::has_match_rule(Op_Jump)) return false; 1.369 + 1.370 + // Don't make jump table if profiling 1.371 + if (method_data_update()) return false; 1.372 + 1.373 + // Decide if a guard is needed to lop off big ranges at either (or 1.374 + // both) end(s) of the input set. We'll call this the default target 1.375 + // even though we can't be sure that it is the true "default". 1.376 + 1.377 + bool needs_guard = false; 1.378 + int default_dest; 1.379 + int64 total_outlier_size = 0; 1.380 + int64 hi_size = ((int64)hi->hi()) - ((int64)hi->lo()) + 1; 1.381 + int64 lo_size = ((int64)lo->hi()) - ((int64)lo->lo()) + 1; 1.382 + 1.383 + if (lo->dest() == hi->dest()) { 1.384 + total_outlier_size = hi_size + lo_size; 1.385 + default_dest = lo->dest(); 1.386 + } else if (lo_size > hi_size) { 1.387 + total_outlier_size = lo_size; 1.388 + default_dest = lo->dest(); 1.389 + } else { 1.390 + total_outlier_size = hi_size; 1.391 + default_dest = hi->dest(); 1.392 + } 1.393 + 1.394 + // If a guard test will eliminate very sparse end ranges, then 1.395 + // it is worth the cost of an extra jump. 1.396 + if (total_outlier_size > (MaxJumpTableSparseness * 4)) { 1.397 + needs_guard = true; 1.398 + if (default_dest == lo->dest()) lo++; 1.399 + if (default_dest == hi->dest()) hi--; 1.400 + } 1.401 + 1.402 + // Find the total number of cases and ranges 1.403 + int64 num_cases = ((int64)hi->hi()) - ((int64)lo->lo()) + 1; 1.404 + int num_range = hi - lo + 1; 1.405 + 1.406 + // Don't create table if: too large, too small, or too sparse. 1.407 + if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize) 1.408 + return false; 1.409 + if (num_cases > (MaxJumpTableSparseness * num_range)) 1.410 + return false; 1.411 + 1.412 + // Normalize table lookups to zero 1.413 + int lowval = lo->lo(); 1.414 + key_val = _gvn.transform( new (C, 3) SubINode(key_val, _gvn.intcon(lowval)) ); 1.415 + 1.416 + // Generate a guard to protect against input keyvals that aren't 1.417 + // in the switch domain. 1.418 + if (needs_guard) { 1.419 + Node* size = _gvn.intcon(num_cases); 1.420 + Node* cmp = _gvn.transform( new (C, 3) CmpUNode(key_val, size) ); 1.421 + Node* tst = _gvn.transform( new (C, 2) BoolNode(cmp, BoolTest::ge) ); 1.422 + IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN); 1.423 + jump_if_true_fork(iff, default_dest, NullTableIndex); 1.424 + } 1.425 + 1.426 + // Create an ideal node JumpTable that has projections 1.427 + // of all possible ranges for a switch statement 1.428 + // The key_val input must be converted to a pointer offset and scaled. 1.429 + // Compare Parse::array_addressing above. 1.430 +#ifdef _LP64 1.431 + // Clean the 32-bit int into a real 64-bit offset. 1.432 + // Otherwise, the jint value 0 might turn into an offset of 0x0800000000. 1.433 + const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin); 1.434 + key_val = _gvn.transform( new (C, 2) ConvI2LNode(key_val, lkeytype) ); 1.435 +#endif 1.436 + // Shift the value by wordsize so we have an index into the table, rather 1.437 + // than a switch value 1.438 + Node *shiftWord = _gvn.MakeConX(wordSize); 1.439 + key_val = _gvn.transform( new (C, 3) MulXNode( key_val, shiftWord)); 1.440 + 1.441 + // Create the JumpNode 1.442 + Node* jtn = _gvn.transform( new (C, 2) JumpNode(control(), key_val, num_cases) ); 1.443 + 1.444 + // These are the switch destinations hanging off the jumpnode 1.445 + int i = 0; 1.446 + for (SwitchRange* r = lo; r <= hi; r++) { 1.447 + for (int j = r->lo(); j <= r->hi(); j++, i++) { 1.448 + Node* input = _gvn.transform(new (C, 1) JumpProjNode(jtn, i, r->dest(), j - lowval)); 1.449 + { 1.450 + PreserveJVMState pjvms(this); 1.451 + set_control(input); 1.452 + jump_if_always_fork(r->dest(), r->table_index()); 1.453 + } 1.454 + } 1.455 + } 1.456 + assert(i == num_cases, "miscount of cases"); 1.457 + stop_and_kill_map(); // no more uses for this JVMS 1.458 + return true; 1.459 +} 1.460 + 1.461 +//----------------------------jump_switch_ranges------------------------------- 1.462 +void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) { 1.463 + Block* switch_block = block(); 1.464 + 1.465 + if (switch_depth == 0) { 1.466 + // Do special processing for the top-level call. 1.467 + assert(lo->lo() == min_jint, "initial range must exhaust Type::INT"); 1.468 + assert(hi->hi() == max_jint, "initial range must exhaust Type::INT"); 1.469 + 1.470 + // Decrement pred-numbers for the unique set of nodes. 1.471 +#ifdef ASSERT 1.472 + // Ensure that the block's successors are a (duplicate-free) set. 1.473 + int successors_counted = 0; // block occurrences in [hi..lo] 1.474 + int unique_successors = switch_block->num_successors(); 1.475 + for (int i = 0; i < unique_successors; i++) { 1.476 + Block* target = switch_block->successor_at(i); 1.477 + 1.478 + // Check that the set of successors is the same in both places. 1.479 + int successors_found = 0; 1.480 + for (SwitchRange* p = lo; p <= hi; p++) { 1.481 + if (p->dest() == target->start()) successors_found++; 1.482 + } 1.483 + assert(successors_found > 0, "successor must be known"); 1.484 + successors_counted += successors_found; 1.485 + } 1.486 + assert(successors_counted == (hi-lo)+1, "no unexpected successors"); 1.487 +#endif 1.488 + 1.489 + // Maybe prune the inputs, based on the type of key_val. 1.490 + jint min_val = min_jint; 1.491 + jint max_val = max_jint; 1.492 + const TypeInt* ti = key_val->bottom_type()->isa_int(); 1.493 + if (ti != NULL) { 1.494 + min_val = ti->_lo; 1.495 + max_val = ti->_hi; 1.496 + assert(min_val <= max_val, "invalid int type"); 1.497 + } 1.498 + while (lo->hi() < min_val) lo++; 1.499 + if (lo->lo() < min_val) lo->setRange(min_val, lo->hi(), lo->dest(), lo->table_index()); 1.500 + while (hi->lo() > max_val) hi--; 1.501 + if (hi->hi() > max_val) hi->setRange(hi->lo(), max_val, hi->dest(), hi->table_index()); 1.502 + } 1.503 + 1.504 +#ifndef PRODUCT 1.505 + if (switch_depth == 0) { 1.506 + _max_switch_depth = 0; 1.507 + _est_switch_depth = log2_intptr((hi-lo+1)-1)+1; 1.508 + } 1.509 +#endif 1.510 + 1.511 + assert(lo <= hi, "must be a non-empty set of ranges"); 1.512 + if (lo == hi) { 1.513 + jump_if_always_fork(lo->dest(), lo->table_index()); 1.514 + } else { 1.515 + assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges"); 1.516 + assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges"); 1.517 + 1.518 + if (create_jump_tables(key_val, lo, hi)) return; 1.519 + 1.520 + int nr = hi - lo + 1; 1.521 + 1.522 + SwitchRange* mid = lo + nr/2; 1.523 + // if there is an easy choice, pivot at a singleton: 1.524 + if (nr > 3 && !mid->is_singleton() && (mid-1)->is_singleton()) mid--; 1.525 + 1.526 + assert(lo < mid && mid <= hi, "good pivot choice"); 1.527 + assert(nr != 2 || mid == hi, "should pick higher of 2"); 1.528 + assert(nr != 3 || mid == hi-1, "should pick middle of 3"); 1.529 + 1.530 + Node *test_val = _gvn.intcon(mid->lo()); 1.531 + 1.532 + if (mid->is_singleton()) { 1.533 + IfNode *iff_ne = jump_if_fork_int(key_val, test_val, BoolTest::ne); 1.534 + jump_if_false_fork(iff_ne, mid->dest(), mid->table_index()); 1.535 + 1.536 + // Special Case: If there are exactly three ranges, and the high 1.537 + // and low range each go to the same place, omit the "gt" test, 1.538 + // since it will not discriminate anything. 1.539 + bool eq_test_only = (hi == lo+2 && hi->dest() == lo->dest()); 1.540 + if (eq_test_only) { 1.541 + assert(mid == hi-1, ""); 1.542 + } 1.543 + 1.544 + // if there is a higher range, test for it and process it: 1.545 + if (mid < hi && !eq_test_only) { 1.546 + // two comparisons of same values--should enable 1 test for 2 branches 1.547 + // Use BoolTest::le instead of BoolTest::gt 1.548 + IfNode *iff_le = jump_if_fork_int(key_val, test_val, BoolTest::le); 1.549 + Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff_le) ); 1.550 + Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff_le) ); 1.551 + { PreserveJVMState pjvms(this); 1.552 + set_control(iffalse); 1.553 + jump_switch_ranges(key_val, mid+1, hi, switch_depth+1); 1.554 + } 1.555 + set_control(iftrue); 1.556 + } 1.557 + 1.558 + } else { 1.559 + // mid is a range, not a singleton, so treat mid..hi as a unit 1.560 + IfNode *iff_ge = jump_if_fork_int(key_val, test_val, BoolTest::ge); 1.561 + 1.562 + // if there is a higher range, test for it and process it: 1.563 + if (mid == hi) { 1.564 + jump_if_true_fork(iff_ge, mid->dest(), mid->table_index()); 1.565 + } else { 1.566 + Node *iftrue = _gvn.transform( new (C, 1) IfTrueNode(iff_ge) ); 1.567 + Node *iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff_ge) ); 1.568 + { PreserveJVMState pjvms(this); 1.569 + set_control(iftrue); 1.570 + jump_switch_ranges(key_val, mid, hi, switch_depth+1); 1.571 + } 1.572 + set_control(iffalse); 1.573 + } 1.574 + } 1.575 + 1.576 + // in any case, process the lower range 1.577 + jump_switch_ranges(key_val, lo, mid-1, switch_depth+1); 1.578 + } 1.579 + 1.580 + // Decrease pred_count for each successor after all is done. 1.581 + if (switch_depth == 0) { 1.582 + int unique_successors = switch_block->num_successors(); 1.583 + for (int i = 0; i < unique_successors; i++) { 1.584 + Block* target = switch_block->successor_at(i); 1.585 + // Throw away the pre-allocated path for each unique successor. 1.586 + target->next_path_num(); 1.587 + } 1.588 + } 1.589 + 1.590 +#ifndef PRODUCT 1.591 + _max_switch_depth = MAX2(switch_depth, _max_switch_depth); 1.592 + if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) { 1.593 + SwitchRange* r; 1.594 + int nsing = 0; 1.595 + for( r = lo; r <= hi; r++ ) { 1.596 + if( r->is_singleton() ) nsing++; 1.597 + } 1.598 + tty->print(">>> "); 1.599 + _method->print_short_name(); 1.600 + tty->print_cr(" switch decision tree"); 1.601 + tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d", 1.602 + hi-lo+1, nsing, _max_switch_depth, _est_switch_depth); 1.603 + if (_max_switch_depth > _est_switch_depth) { 1.604 + tty->print_cr("******** BAD SWITCH DEPTH ********"); 1.605 + } 1.606 + tty->print(" "); 1.607 + for( r = lo; r <= hi; r++ ) { 1.608 + r->print(env()); 1.609 + } 1.610 + tty->print_cr(""); 1.611 + } 1.612 +#endif 1.613 +} 1.614 + 1.615 +void Parse::modf() { 1.616 + Node *f2 = pop(); 1.617 + Node *f1 = pop(); 1.618 + Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(), 1.619 + CAST_FROM_FN_PTR(address, SharedRuntime::frem), 1.620 + "frem", NULL, //no memory effects 1.621 + f1, f2); 1.622 + Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0)); 1.623 + 1.624 + push(res); 1.625 +} 1.626 + 1.627 +void Parse::modd() { 1.628 + Node *d2 = pop_pair(); 1.629 + Node *d1 = pop_pair(); 1.630 + Node* c = make_runtime_call(RC_LEAF, OptoRuntime::Math_DD_D_Type(), 1.631 + CAST_FROM_FN_PTR(address, SharedRuntime::drem), 1.632 + "drem", NULL, //no memory effects 1.633 + d1, top(), d2, top()); 1.634 + Node* res_d = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0)); 1.635 + 1.636 +#ifdef ASSERT 1.637 + Node* res_top = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 1)); 1.638 + assert(res_top == top(), "second value must be top"); 1.639 +#endif 1.640 + 1.641 + push_pair(res_d); 1.642 +} 1.643 + 1.644 +void Parse::l2f() { 1.645 + Node* f2 = pop(); 1.646 + Node* f1 = pop(); 1.647 + Node* c = make_runtime_call(RC_LEAF, OptoRuntime::l2f_Type(), 1.648 + CAST_FROM_FN_PTR(address, SharedRuntime::l2f), 1.649 + "l2f", NULL, //no memory effects 1.650 + f1, f2); 1.651 + Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms + 0)); 1.652 + 1.653 + push(res); 1.654 +} 1.655 + 1.656 +void Parse::do_irem() { 1.657 + // Must keep both values on the expression-stack during null-check 1.658 + do_null_check(peek(), T_INT); 1.659 + // Compile-time detect of null-exception? 1.660 + if (stopped()) return; 1.661 + 1.662 + Node* b = pop(); 1.663 + Node* a = pop(); 1.664 + 1.665 + const Type *t = _gvn.type(b); 1.666 + if (t != Type::TOP) { 1.667 + const TypeInt *ti = t->is_int(); 1.668 + if (ti->is_con()) { 1.669 + int divisor = ti->get_con(); 1.670 + // check for positive power of 2 1.671 + if (divisor > 0 && 1.672 + (divisor & ~(divisor-1)) == divisor) { 1.673 + // yes ! 1.674 + Node *mask = _gvn.intcon((divisor - 1)); 1.675 + // Sigh, must handle negative dividends 1.676 + Node *zero = _gvn.intcon(0); 1.677 + IfNode *ifff = jump_if_fork_int(a, zero, BoolTest::lt); 1.678 + Node *iff = _gvn.transform( new (C, 1) IfFalseNode(ifff) ); 1.679 + Node *ift = _gvn.transform( new (C, 1) IfTrueNode (ifff) ); 1.680 + Node *reg = jump_if_join(ift, iff); 1.681 + Node *phi = PhiNode::make(reg, NULL, TypeInt::INT); 1.682 + // Negative path; negate/and/negate 1.683 + Node *neg = _gvn.transform( new (C, 3) SubINode(zero, a) ); 1.684 + Node *andn= _gvn.transform( new (C, 3) AndINode(neg, mask) ); 1.685 + Node *negn= _gvn.transform( new (C, 3) SubINode(zero, andn) ); 1.686 + phi->init_req(1, negn); 1.687 + // Fast positive case 1.688 + Node *andx = _gvn.transform( new (C, 3) AndINode(a, mask) ); 1.689 + phi->init_req(2, andx); 1.690 + // Push the merge 1.691 + push( _gvn.transform(phi) ); 1.692 + return; 1.693 + } 1.694 + } 1.695 + } 1.696 + // Default case 1.697 + push( _gvn.transform( new (C, 3) ModINode(control(),a,b) ) ); 1.698 +} 1.699 + 1.700 +// Handle jsr and jsr_w bytecode 1.701 +void Parse::do_jsr() { 1.702 + assert(bc() == Bytecodes::_jsr || bc() == Bytecodes::_jsr_w, "wrong bytecode"); 1.703 + 1.704 + // Store information about current state, tagged with new _jsr_bci 1.705 + int return_bci = iter().next_bci(); 1.706 + int jsr_bci = (bc() == Bytecodes::_jsr) ? iter().get_dest() : iter().get_far_dest(); 1.707 + 1.708 + // Update method data 1.709 + profile_taken_branch(jsr_bci); 1.710 + 1.711 + // The way we do things now, there is only one successor block 1.712 + // for the jsr, because the target code is cloned by ciTypeFlow. 1.713 + Block* target = successor_for_bci(jsr_bci); 1.714 + 1.715 + // What got pushed? 1.716 + const Type* ret_addr = target->peek(); 1.717 + assert(ret_addr->singleton(), "must be a constant (cloned jsr body)"); 1.718 + 1.719 + // Effect on jsr on stack 1.720 + push(_gvn.makecon(ret_addr)); 1.721 + 1.722 + // Flow to the jsr. 1.723 + merge(jsr_bci); 1.724 +} 1.725 + 1.726 +// Handle ret bytecode 1.727 +void Parse::do_ret() { 1.728 + // Find to whom we return. 1.729 +#if 0 // %%%% MAKE THIS WORK 1.730 + Node* con = local(); 1.731 + const TypePtr* tp = con->bottom_type()->isa_ptr(); 1.732 + assert(tp && tp->singleton(), ""); 1.733 + int return_bci = (int) tp->get_con(); 1.734 + merge(return_bci); 1.735 +#else 1.736 + assert(block()->num_successors() == 1, "a ret can only go one place now"); 1.737 + Block* target = block()->successor_at(0); 1.738 + assert(!target->is_ready(), "our arrival must be expected"); 1.739 + profile_ret(target->flow()->start()); 1.740 + int pnum = target->next_path_num(); 1.741 + merge_common(target, pnum); 1.742 +#endif 1.743 +} 1.744 + 1.745 +//--------------------------dynamic_branch_prediction-------------------------- 1.746 +// Try to gather dynamic branch prediction behavior. Return a probability 1.747 +// of the branch being taken and set the "cnt" field. Returns a -1.0 1.748 +// if we need to use static prediction for some reason. 1.749 +float Parse::dynamic_branch_prediction(float &cnt) { 1.750 + ResourceMark rm; 1.751 + 1.752 + cnt = COUNT_UNKNOWN; 1.753 + 1.754 + // Use MethodData information if it is available 1.755 + // FIXME: free the ProfileData structure 1.756 + ciMethodData* methodData = method()->method_data(); 1.757 + if (!methodData->is_mature()) return PROB_UNKNOWN; 1.758 + ciProfileData* data = methodData->bci_to_data(bci()); 1.759 + if (!data->is_JumpData()) return PROB_UNKNOWN; 1.760 + 1.761 + // get taken and not taken values 1.762 + int taken = data->as_JumpData()->taken(); 1.763 + int not_taken = 0; 1.764 + if (data->is_BranchData()) { 1.765 + not_taken = data->as_BranchData()->not_taken(); 1.766 + } 1.767 + 1.768 + // scale the counts to be commensurate with invocation counts: 1.769 + taken = method()->scale_count(taken); 1.770 + not_taken = method()->scale_count(not_taken); 1.771 + 1.772 + // Give up if too few counts to be meaningful 1.773 + if (taken + not_taken < 40) { 1.774 + if (C->log() != NULL) { 1.775 + C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken); 1.776 + } 1.777 + return PROB_UNKNOWN; 1.778 + } 1.779 + 1.780 + // Compute frequency that we arrive here 1.781 + int sum = taken + not_taken; 1.782 + // Adjust, if this block is a cloned private block but the 1.783 + // Jump counts are shared. Taken the private counts for 1.784 + // just this path instead of the shared counts. 1.785 + if( block()->count() > 0 ) 1.786 + sum = block()->count(); 1.787 + cnt = (float)sum / (float)FreqCountInvocations; 1.788 + 1.789 + // Pin probability to sane limits 1.790 + float prob; 1.791 + if( !taken ) 1.792 + prob = (0+PROB_MIN) / 2; 1.793 + else if( !not_taken ) 1.794 + prob = (1+PROB_MAX) / 2; 1.795 + else { // Compute probability of true path 1.796 + prob = (float)taken / (float)(taken + not_taken); 1.797 + if (prob > PROB_MAX) prob = PROB_MAX; 1.798 + if (prob < PROB_MIN) prob = PROB_MIN; 1.799 + } 1.800 + 1.801 + assert((cnt > 0.0f) && (prob > 0.0f), 1.802 + "Bad frequency assignment in if"); 1.803 + 1.804 + if (C->log() != NULL) { 1.805 + const char* prob_str = NULL; 1.806 + if (prob >= PROB_MAX) prob_str = (prob == PROB_MAX) ? "max" : "always"; 1.807 + if (prob <= PROB_MIN) prob_str = (prob == PROB_MIN) ? "min" : "never"; 1.808 + char prob_str_buf[30]; 1.809 + if (prob_str == NULL) { 1.810 + sprintf(prob_str_buf, "%g", prob); 1.811 + prob_str = prob_str_buf; 1.812 + } 1.813 + C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%g' prob='%s'", 1.814 + iter().get_dest(), taken, not_taken, cnt, prob_str); 1.815 + } 1.816 + return prob; 1.817 +} 1.818 + 1.819 +//-----------------------------branch_prediction------------------------------- 1.820 +float Parse::branch_prediction(float& cnt, 1.821 + BoolTest::mask btest, 1.822 + int target_bci) { 1.823 + float prob = dynamic_branch_prediction(cnt); 1.824 + // If prob is unknown, switch to static prediction 1.825 + if (prob != PROB_UNKNOWN) return prob; 1.826 + 1.827 + prob = PROB_FAIR; // Set default value 1.828 + if (btest == BoolTest::eq) // Exactly equal test? 1.829 + prob = PROB_STATIC_INFREQUENT; // Assume its relatively infrequent 1.830 + else if (btest == BoolTest::ne) 1.831 + prob = PROB_STATIC_FREQUENT; // Assume its relatively frequent 1.832 + 1.833 + // If this is a conditional test guarding a backwards branch, 1.834 + // assume its a loop-back edge. Make it a likely taken branch. 1.835 + if (target_bci < bci()) { 1.836 + if (is_osr_parse()) { // Could be a hot OSR'd loop; force deopt 1.837 + // Since it's an OSR, we probably have profile data, but since 1.838 + // branch_prediction returned PROB_UNKNOWN, the counts are too small. 1.839 + // Let's make a special check here for completely zero counts. 1.840 + ciMethodData* methodData = method()->method_data(); 1.841 + if (!methodData->is_empty()) { 1.842 + ciProfileData* data = methodData->bci_to_data(bci()); 1.843 + // Only stop for truly zero counts, which mean an unknown part 1.844 + // of the OSR-ed method, and we want to deopt to gather more stats. 1.845 + // If you have ANY counts, then this loop is simply 'cold' relative 1.846 + // to the OSR loop. 1.847 + if (data->as_BranchData()->taken() + 1.848 + data->as_BranchData()->not_taken() == 0 ) { 1.849 + // This is the only way to return PROB_UNKNOWN: 1.850 + return PROB_UNKNOWN; 1.851 + } 1.852 + } 1.853 + } 1.854 + prob = PROB_STATIC_FREQUENT; // Likely to take backwards branch 1.855 + } 1.856 + 1.857 + assert(prob != PROB_UNKNOWN, "must have some guess at this point"); 1.858 + return prob; 1.859 +} 1.860 + 1.861 +// The magic constants are chosen so as to match the output of 1.862 +// branch_prediction() when the profile reports a zero taken count. 1.863 +// It is important to distinguish zero counts unambiguously, because 1.864 +// some branches (e.g., _213_javac.Assembler.eliminate) validly produce 1.865 +// very small but nonzero probabilities, which if confused with zero 1.866 +// counts would keep the program recompiling indefinitely. 1.867 +bool Parse::seems_never_taken(float prob) { 1.868 + return prob < PROB_MIN; 1.869 +} 1.870 + 1.871 +inline void Parse::repush_if_args() { 1.872 +#ifndef PRODUCT 1.873 + if (PrintOpto && WizardMode) { 1.874 + tty->print("defending against excessive implicit null exceptions on %s @%d in ", 1.875 + Bytecodes::name(iter().cur_bc()), iter().cur_bci()); 1.876 + method()->print_name(); tty->cr(); 1.877 + } 1.878 +#endif 1.879 + int bc_depth = - Bytecodes::depth(iter().cur_bc()); 1.880 + assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches"); 1.881 + DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms 1.882 + assert(argument(0) != NULL, "must exist"); 1.883 + assert(bc_depth == 1 || argument(1) != NULL, "two must exist"); 1.884 + _sp += bc_depth; 1.885 +} 1.886 + 1.887 +//----------------------------------do_ifnull---------------------------------- 1.888 +void Parse::do_ifnull(BoolTest::mask btest) { 1.889 + int target_bci = iter().get_dest(); 1.890 + 1.891 + float cnt; 1.892 + float prob = branch_prediction(cnt, btest, target_bci); 1.893 + if (prob == PROB_UNKNOWN) { 1.894 + // (An earlier version of do_ifnull omitted this trap for OSR methods.) 1.895 +#ifndef PRODUCT 1.896 + if (PrintOpto && Verbose) 1.897 + tty->print_cr("Never-taken backedge stops compilation at bci %d",bci()); 1.898 +#endif 1.899 + repush_if_args(); // to gather stats on loop 1.900 + // We need to mark this branch as taken so that if we recompile we will 1.901 + // see that it is possible. In the tiered system the interpreter doesn't 1.902 + // do profiling and by the time we get to the lower tier from the interpreter 1.903 + // the path may be cold again. Make sure it doesn't look untaken 1.904 + profile_taken_branch(target_bci, !ProfileInterpreter); 1.905 + uncommon_trap(Deoptimization::Reason_unreached, 1.906 + Deoptimization::Action_reinterpret, 1.907 + NULL, "cold"); 1.908 + return; 1.909 + } 1.910 + 1.911 + // If this is a backwards branch in the bytecodes, add Safepoint 1.912 + maybe_add_safepoint(target_bci); 1.913 + Block* branch_block = successor_for_bci(target_bci); 1.914 + Block* next_block = successor_for_bci(iter().next_bci()); 1.915 + 1.916 + explicit_null_checks_inserted++; 1.917 + Node* a = null(); 1.918 + Node* b = pop(); 1.919 + Node* c = _gvn.transform( new (C, 3) CmpPNode(b, a) ); 1.920 + 1.921 + // Make a cast-away-nullness that is control dependent on the test 1.922 + const Type *t = _gvn.type(b); 1.923 + const Type *t_not_null = t->join(TypePtr::NOTNULL); 1.924 + Node *cast = new (C, 2) CastPPNode(b,t_not_null); 1.925 + 1.926 + // Generate real control flow 1.927 + Node *tst = _gvn.transform( new (C, 2) BoolNode( c, btest ) ); 1.928 + 1.929 + // Sanity check the probability value 1.930 + assert(prob > 0.0f,"Bad probability in Parser"); 1.931 + // Need xform to put node in hash table 1.932 + IfNode *iff = create_and_xform_if( control(), tst, prob, cnt ); 1.933 + assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1.934 + // True branch 1.935 + { PreserveJVMState pjvms(this); 1.936 + Node* iftrue = _gvn.transform( new (C, 1) IfTrueNode (iff) ); 1.937 + set_control(iftrue); 1.938 + 1.939 + if (stopped()) { // Path is dead? 1.940 + explicit_null_checks_elided++; 1.941 + } else { // Path is live. 1.942 + // Update method data 1.943 + profile_taken_branch(target_bci); 1.944 + adjust_map_after_if(btest, c, prob, branch_block, next_block); 1.945 + if (!stopped()) 1.946 + merge(target_bci); 1.947 + } 1.948 + } 1.949 + 1.950 + // False branch 1.951 + Node* iffalse = _gvn.transform( new (C, 1) IfFalseNode(iff) ); 1.952 + set_control(iffalse); 1.953 + 1.954 + if (stopped()) { // Path is dead? 1.955 + explicit_null_checks_elided++; 1.956 + } else { // Path is live. 1.957 + // Update method data 1.958 + profile_not_taken_branch(); 1.959 + adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob, 1.960 + next_block, branch_block); 1.961 + } 1.962 +} 1.963 + 1.964 +//------------------------------------do_if------------------------------------ 1.965 +void Parse::do_if(BoolTest::mask btest, Node* c) { 1.966 + int target_bci = iter().get_dest(); 1.967 + 1.968 + float cnt; 1.969 + float prob = branch_prediction(cnt, btest, target_bci); 1.970 + float untaken_prob = 1.0 - prob; 1.971 + 1.972 + if (prob == PROB_UNKNOWN) { 1.973 +#ifndef PRODUCT 1.974 + if (PrintOpto && Verbose) 1.975 + tty->print_cr("Never-taken backedge stops compilation at bci %d",bci()); 1.976 +#endif 1.977 + repush_if_args(); // to gather stats on loop 1.978 + // We need to mark this branch as taken so that if we recompile we will 1.979 + // see that it is possible. In the tiered system the interpreter doesn't 1.980 + // do profiling and by the time we get to the lower tier from the interpreter 1.981 + // the path may be cold again. Make sure it doesn't look untaken 1.982 + profile_taken_branch(target_bci, !ProfileInterpreter); 1.983 + uncommon_trap(Deoptimization::Reason_unreached, 1.984 + Deoptimization::Action_reinterpret, 1.985 + NULL, "cold"); 1.986 + return; 1.987 + } 1.988 + 1.989 + // Sanity check the probability value 1.990 + assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser"); 1.991 + 1.992 + bool taken_if_true = true; 1.993 + // Convert BoolTest to canonical form: 1.994 + if (!BoolTest(btest).is_canonical()) { 1.995 + btest = BoolTest(btest).negate(); 1.996 + taken_if_true = false; 1.997 + // prob is NOT updated here; it remains the probability of the taken 1.998 + // path (as opposed to the prob of the path guarded by an 'IfTrueNode'). 1.999 + } 1.1000 + assert(btest != BoolTest::eq, "!= is the only canonical exact test"); 1.1001 + 1.1002 + Node* tst0 = new (C, 2) BoolNode(c, btest); 1.1003 + Node* tst = _gvn.transform(tst0); 1.1004 + BoolTest::mask taken_btest = BoolTest::illegal; 1.1005 + BoolTest::mask untaken_btest = BoolTest::illegal; 1.1006 + if (btest == BoolTest::ne) { 1.1007 + // For now, these are the only cases of btest that matter. (More later.) 1.1008 + taken_btest = taken_if_true ? btest : BoolTest::eq; 1.1009 + untaken_btest = taken_if_true ? BoolTest::eq : btest; 1.1010 + } 1.1011 + 1.1012 + // Generate real control flow 1.1013 + float true_prob = (taken_if_true ? prob : untaken_prob); 1.1014 + IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt); 1.1015 + assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); 1.1016 + Node* taken_branch = new (C, 1) IfTrueNode(iff); 1.1017 + Node* untaken_branch = new (C, 1) IfFalseNode(iff); 1.1018 + if (!taken_if_true) { // Finish conversion to canonical form 1.1019 + Node* tmp = taken_branch; 1.1020 + taken_branch = untaken_branch; 1.1021 + untaken_branch = tmp; 1.1022 + } 1.1023 + 1.1024 + Block* branch_block = successor_for_bci(target_bci); 1.1025 + Block* next_block = successor_for_bci(iter().next_bci()); 1.1026 + 1.1027 + // Branch is taken: 1.1028 + { PreserveJVMState pjvms(this); 1.1029 + taken_branch = _gvn.transform(taken_branch); 1.1030 + set_control(taken_branch); 1.1031 + 1.1032 + if (!stopped()) { 1.1033 + // Update method data 1.1034 + profile_taken_branch(target_bci); 1.1035 + adjust_map_after_if(taken_btest, c, prob, branch_block, next_block); 1.1036 + if (!stopped()) 1.1037 + merge(target_bci); 1.1038 + } 1.1039 + } 1.1040 + 1.1041 + untaken_branch = _gvn.transform(untaken_branch); 1.1042 + set_control(untaken_branch); 1.1043 + 1.1044 + // Branch not taken. 1.1045 + if (!stopped()) { 1.1046 + // Update method data 1.1047 + profile_not_taken_branch(); 1.1048 + adjust_map_after_if(untaken_btest, c, untaken_prob, 1.1049 + next_block, branch_block); 1.1050 + } 1.1051 +} 1.1052 + 1.1053 +//----------------------------adjust_map_after_if------------------------------ 1.1054 +// Adjust the JVM state to reflect the result of taking this path. 1.1055 +// Basically, it means inspecting the CmpNode controlling this 1.1056 +// branch, seeing how it constrains a tested value, and then 1.1057 +// deciding if it's worth our while to encode this constraint 1.1058 +// as graph nodes in the current abstract interpretation map. 1.1059 +void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, 1.1060 + Block* path, Block* other_path) { 1.1061 + if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal) 1.1062 + return; // nothing to do 1.1063 + 1.1064 + bool is_fallthrough = (path == successor_for_bci(iter().next_bci())); 1.1065 + 1.1066 + int cop = c->Opcode(); 1.1067 + if (seems_never_taken(prob) && cop == Op_CmpP && btest == BoolTest::eq) { 1.1068 + // (An earlier version of do_if omitted '&& btest == BoolTest::eq'.) 1.1069 + // 1.1070 + // If this might possibly turn into an implicit null check, 1.1071 + // and the null has never yet been seen, we need to generate 1.1072 + // an uncommon trap, so as to recompile instead of suffering 1.1073 + // with very slow branches. (We'll get the slow branches if 1.1074 + // the program ever changes phase and starts seeing nulls here.) 1.1075 + // 1.1076 + // The tests we worry about are of the form (p == null). 1.1077 + // We do not simply inspect for a null constant, since a node may 1.1078 + // optimize to 'null' later on. 1.1079 + repush_if_args(); 1.1080 + // We need to mark this branch as taken so that if we recompile we will 1.1081 + // see that it is possible. In the tiered system the interpreter doesn't 1.1082 + // do profiling and by the time we get to the lower tier from the interpreter 1.1083 + // the path may be cold again. Make sure it doesn't look untaken 1.1084 + if (is_fallthrough) { 1.1085 + profile_not_taken_branch(!ProfileInterpreter); 1.1086 + } else { 1.1087 + profile_taken_branch(iter().get_dest(), !ProfileInterpreter); 1.1088 + } 1.1089 + uncommon_trap(Deoptimization::Reason_unreached, 1.1090 + Deoptimization::Action_reinterpret, 1.1091 + NULL, 1.1092 + (is_fallthrough ? "taken always" : "taken never")); 1.1093 + return; 1.1094 + } 1.1095 + 1.1096 + Node* val = c->in(1); 1.1097 + Node* con = c->in(2); 1.1098 + const Type* tcon = _gvn.type(con); 1.1099 + const Type* tval = _gvn.type(val); 1.1100 + bool have_con = tcon->singleton(); 1.1101 + if (tval->singleton()) { 1.1102 + if (!have_con) { 1.1103 + // Swap, so constant is in con. 1.1104 + con = val; 1.1105 + tcon = tval; 1.1106 + val = c->in(2); 1.1107 + tval = _gvn.type(val); 1.1108 + btest = BoolTest(btest).commute(); 1.1109 + have_con = true; 1.1110 + } else { 1.1111 + // Do we have two constants? Then leave well enough alone. 1.1112 + have_con = false; 1.1113 + } 1.1114 + } 1.1115 + if (!have_con) // remaining adjustments need a con 1.1116 + return; 1.1117 + 1.1118 + 1.1119 + int val_in_map = map()->find_edge(val); 1.1120 + if (val_in_map < 0) return; // replace_in_map would be useless 1.1121 + { 1.1122 + JVMState* jvms = this->jvms(); 1.1123 + if (!(jvms->is_loc(val_in_map) || 1.1124 + jvms->is_stk(val_in_map))) 1.1125 + return; // again, it would be useless 1.1126 + } 1.1127 + 1.1128 + // Check for a comparison to a constant, and "know" that the compared 1.1129 + // value is constrained on this path. 1.1130 + assert(tcon->singleton(), ""); 1.1131 + ConstraintCastNode* ccast = NULL; 1.1132 + Node* cast = NULL; 1.1133 + 1.1134 + switch (btest) { 1.1135 + case BoolTest::eq: // Constant test? 1.1136 + { 1.1137 + const Type* tboth = tcon->join(tval); 1.1138 + if (tboth == tval) break; // Nothing to gain. 1.1139 + if (tcon->isa_int()) { 1.1140 + ccast = new (C, 2) CastIINode(val, tboth); 1.1141 + } else if (tcon == TypePtr::NULL_PTR) { 1.1142 + // Cast to null, but keep the pointer identity temporarily live. 1.1143 + ccast = new (C, 2) CastPPNode(val, tboth); 1.1144 + } else { 1.1145 + const TypeF* tf = tcon->isa_float_constant(); 1.1146 + const TypeD* td = tcon->isa_double_constant(); 1.1147 + // Exclude tests vs float/double 0 as these could be 1.1148 + // either +0 or -0. Just because you are equal to +0 1.1149 + // doesn't mean you ARE +0! 1.1150 + if ((!tf || tf->_f != 0.0) && 1.1151 + (!td || td->_d != 0.0)) 1.1152 + cast = con; // Replace non-constant val by con. 1.1153 + } 1.1154 + } 1.1155 + break; 1.1156 + 1.1157 + case BoolTest::ne: 1.1158 + if (tcon == TypePtr::NULL_PTR) { 1.1159 + cast = cast_not_null(val, false); 1.1160 + } 1.1161 + break; 1.1162 + 1.1163 + default: 1.1164 + // (At this point we could record int range types with CastII.) 1.1165 + break; 1.1166 + } 1.1167 + 1.1168 + if (ccast != NULL) { 1.1169 + const Type* tcc = ccast->as_Type()->type(); 1.1170 + assert(tcc != tval && tcc->higher_equal(tval), "must improve"); 1.1171 + // Delay transform() call to allow recovery of pre-cast value 1.1172 + // at the control merge. 1.1173 + ccast->set_req(0, control()); 1.1174 + _gvn.set_type_bottom(ccast); 1.1175 + record_for_igvn(ccast); 1.1176 + cast = ccast; 1.1177 + } 1.1178 + 1.1179 + if (cast != NULL) { // Here's the payoff. 1.1180 + replace_in_map(val, cast); 1.1181 + } 1.1182 +} 1.1183 + 1.1184 + 1.1185 +//------------------------------do_one_bytecode-------------------------------- 1.1186 +// Parse this bytecode, and alter the Parsers JVM->Node mapping 1.1187 +void Parse::do_one_bytecode() { 1.1188 + Node *a, *b, *c, *d; // Handy temps 1.1189 + BoolTest::mask btest; 1.1190 + int i; 1.1191 + 1.1192 + assert(!has_exceptions(), "bytecode entry state must be clear of throws"); 1.1193 + 1.1194 + if (C->check_node_count(NodeLimitFudgeFactor * 5, 1.1195 + "out of nodes parsing method")) { 1.1196 + return; 1.1197 + } 1.1198 + 1.1199 +#ifdef ASSERT 1.1200 + // for setting breakpoints 1.1201 + if (TraceOptoParse) { 1.1202 + tty->print(" @"); 1.1203 + dump_bci(bci()); 1.1204 + } 1.1205 +#endif 1.1206 + 1.1207 + switch (bc()) { 1.1208 + case Bytecodes::_nop: 1.1209 + // do nothing 1.1210 + break; 1.1211 + case Bytecodes::_lconst_0: 1.1212 + push_pair(longcon(0)); 1.1213 + break; 1.1214 + 1.1215 + case Bytecodes::_lconst_1: 1.1216 + push_pair(longcon(1)); 1.1217 + break; 1.1218 + 1.1219 + case Bytecodes::_fconst_0: 1.1220 + push(zerocon(T_FLOAT)); 1.1221 + break; 1.1222 + 1.1223 + case Bytecodes::_fconst_1: 1.1224 + push(makecon(TypeF::ONE)); 1.1225 + break; 1.1226 + 1.1227 + case Bytecodes::_fconst_2: 1.1228 + push(makecon(TypeF::make(2.0f))); 1.1229 + break; 1.1230 + 1.1231 + case Bytecodes::_dconst_0: 1.1232 + push_pair(zerocon(T_DOUBLE)); 1.1233 + break; 1.1234 + 1.1235 + case Bytecodes::_dconst_1: 1.1236 + push_pair(makecon(TypeD::ONE)); 1.1237 + break; 1.1238 + 1.1239 + case Bytecodes::_iconst_m1:push(intcon(-1)); break; 1.1240 + case Bytecodes::_iconst_0: push(intcon( 0)); break; 1.1241 + case Bytecodes::_iconst_1: push(intcon( 1)); break; 1.1242 + case Bytecodes::_iconst_2: push(intcon( 2)); break; 1.1243 + case Bytecodes::_iconst_3: push(intcon( 3)); break; 1.1244 + case Bytecodes::_iconst_4: push(intcon( 4)); break; 1.1245 + case Bytecodes::_iconst_5: push(intcon( 5)); break; 1.1246 + case Bytecodes::_bipush: push(intcon( iter().get_byte())); break; 1.1247 + case Bytecodes::_sipush: push(intcon( iter().get_short())); break; 1.1248 + case Bytecodes::_aconst_null: push(null()); break; 1.1249 + case Bytecodes::_ldc: 1.1250 + case Bytecodes::_ldc_w: 1.1251 + case Bytecodes::_ldc2_w: 1.1252 + // If the constant is unresolved, run this BC once in the interpreter. 1.1253 + if (iter().is_unresolved_string()) { 1.1254 + uncommon_trap(Deoptimization::make_trap_request 1.1255 + (Deoptimization::Reason_unloaded, 1.1256 + Deoptimization::Action_reinterpret, 1.1257 + iter().get_constant_index()), 1.1258 + NULL, "unresolved_string"); 1.1259 + break; 1.1260 + } else { 1.1261 + ciConstant constant = iter().get_constant(); 1.1262 + if (constant.basic_type() == T_OBJECT) { 1.1263 + ciObject* c = constant.as_object(); 1.1264 + if (c->is_klass()) { 1.1265 + // The constant returned for a klass is the ciKlass for the 1.1266 + // entry. We want the java_mirror so get it. 1.1267 + ciKlass* klass = c->as_klass(); 1.1268 + if (klass->is_loaded()) { 1.1269 + constant = ciConstant(T_OBJECT, klass->java_mirror()); 1.1270 + } else { 1.1271 + uncommon_trap(Deoptimization::make_trap_request 1.1272 + (Deoptimization::Reason_unloaded, 1.1273 + Deoptimization::Action_reinterpret, 1.1274 + iter().get_constant_index()), 1.1275 + NULL, "unresolved_klass"); 1.1276 + break; 1.1277 + } 1.1278 + } 1.1279 + } 1.1280 + push_constant(constant); 1.1281 + } 1.1282 + 1.1283 + break; 1.1284 + 1.1285 + case Bytecodes::_aload_0: 1.1286 + push( local(0) ); 1.1287 + break; 1.1288 + case Bytecodes::_aload_1: 1.1289 + push( local(1) ); 1.1290 + break; 1.1291 + case Bytecodes::_aload_2: 1.1292 + push( local(2) ); 1.1293 + break; 1.1294 + case Bytecodes::_aload_3: 1.1295 + push( local(3) ); 1.1296 + break; 1.1297 + case Bytecodes::_aload: 1.1298 + push( local(iter().get_index()) ); 1.1299 + break; 1.1300 + 1.1301 + case Bytecodes::_fload_0: 1.1302 + case Bytecodes::_iload_0: 1.1303 + push( local(0) ); 1.1304 + break; 1.1305 + case Bytecodes::_fload_1: 1.1306 + case Bytecodes::_iload_1: 1.1307 + push( local(1) ); 1.1308 + break; 1.1309 + case Bytecodes::_fload_2: 1.1310 + case Bytecodes::_iload_2: 1.1311 + push( local(2) ); 1.1312 + break; 1.1313 + case Bytecodes::_fload_3: 1.1314 + case Bytecodes::_iload_3: 1.1315 + push( local(3) ); 1.1316 + break; 1.1317 + case Bytecodes::_fload: 1.1318 + case Bytecodes::_iload: 1.1319 + push( local(iter().get_index()) ); 1.1320 + break; 1.1321 + case Bytecodes::_lload_0: 1.1322 + push_pair_local( 0 ); 1.1323 + break; 1.1324 + case Bytecodes::_lload_1: 1.1325 + push_pair_local( 1 ); 1.1326 + break; 1.1327 + case Bytecodes::_lload_2: 1.1328 + push_pair_local( 2 ); 1.1329 + break; 1.1330 + case Bytecodes::_lload_3: 1.1331 + push_pair_local( 3 ); 1.1332 + break; 1.1333 + case Bytecodes::_lload: 1.1334 + push_pair_local( iter().get_index() ); 1.1335 + break; 1.1336 + 1.1337 + case Bytecodes::_dload_0: 1.1338 + push_pair_local(0); 1.1339 + break; 1.1340 + case Bytecodes::_dload_1: 1.1341 + push_pair_local(1); 1.1342 + break; 1.1343 + case Bytecodes::_dload_2: 1.1344 + push_pair_local(2); 1.1345 + break; 1.1346 + case Bytecodes::_dload_3: 1.1347 + push_pair_local(3); 1.1348 + break; 1.1349 + case Bytecodes::_dload: 1.1350 + push_pair_local(iter().get_index()); 1.1351 + break; 1.1352 + case Bytecodes::_fstore_0: 1.1353 + case Bytecodes::_istore_0: 1.1354 + case Bytecodes::_astore_0: 1.1355 + set_local( 0, pop() ); 1.1356 + break; 1.1357 + case Bytecodes::_fstore_1: 1.1358 + case Bytecodes::_istore_1: 1.1359 + case Bytecodes::_astore_1: 1.1360 + set_local( 1, pop() ); 1.1361 + break; 1.1362 + case Bytecodes::_fstore_2: 1.1363 + case Bytecodes::_istore_2: 1.1364 + case Bytecodes::_astore_2: 1.1365 + set_local( 2, pop() ); 1.1366 + break; 1.1367 + case Bytecodes::_fstore_3: 1.1368 + case Bytecodes::_istore_3: 1.1369 + case Bytecodes::_astore_3: 1.1370 + set_local( 3, pop() ); 1.1371 + break; 1.1372 + case Bytecodes::_fstore: 1.1373 + case Bytecodes::_istore: 1.1374 + case Bytecodes::_astore: 1.1375 + set_local( iter().get_index(), pop() ); 1.1376 + break; 1.1377 + // long stores 1.1378 + case Bytecodes::_lstore_0: 1.1379 + set_pair_local( 0, pop_pair() ); 1.1380 + break; 1.1381 + case Bytecodes::_lstore_1: 1.1382 + set_pair_local( 1, pop_pair() ); 1.1383 + break; 1.1384 + case Bytecodes::_lstore_2: 1.1385 + set_pair_local( 2, pop_pair() ); 1.1386 + break; 1.1387 + case Bytecodes::_lstore_3: 1.1388 + set_pair_local( 3, pop_pair() ); 1.1389 + break; 1.1390 + case Bytecodes::_lstore: 1.1391 + set_pair_local( iter().get_index(), pop_pair() ); 1.1392 + break; 1.1393 + 1.1394 + // double stores 1.1395 + case Bytecodes::_dstore_0: 1.1396 + set_pair_local( 0, dstore_rounding(pop_pair()) ); 1.1397 + break; 1.1398 + case Bytecodes::_dstore_1: 1.1399 + set_pair_local( 1, dstore_rounding(pop_pair()) ); 1.1400 + break; 1.1401 + case Bytecodes::_dstore_2: 1.1402 + set_pair_local( 2, dstore_rounding(pop_pair()) ); 1.1403 + break; 1.1404 + case Bytecodes::_dstore_3: 1.1405 + set_pair_local( 3, dstore_rounding(pop_pair()) ); 1.1406 + break; 1.1407 + case Bytecodes::_dstore: 1.1408 + set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) ); 1.1409 + break; 1.1410 + 1.1411 + case Bytecodes::_pop: _sp -= 1; break; 1.1412 + case Bytecodes::_pop2: _sp -= 2; break; 1.1413 + case Bytecodes::_swap: 1.1414 + a = pop(); 1.1415 + b = pop(); 1.1416 + push(a); 1.1417 + push(b); 1.1418 + break; 1.1419 + case Bytecodes::_dup: 1.1420 + a = pop(); 1.1421 + push(a); 1.1422 + push(a); 1.1423 + break; 1.1424 + case Bytecodes::_dup_x1: 1.1425 + a = pop(); 1.1426 + b = pop(); 1.1427 + push( a ); 1.1428 + push( b ); 1.1429 + push( a ); 1.1430 + break; 1.1431 + case Bytecodes::_dup_x2: 1.1432 + a = pop(); 1.1433 + b = pop(); 1.1434 + c = pop(); 1.1435 + push( a ); 1.1436 + push( c ); 1.1437 + push( b ); 1.1438 + push( a ); 1.1439 + break; 1.1440 + case Bytecodes::_dup2: 1.1441 + a = pop(); 1.1442 + b = pop(); 1.1443 + push( b ); 1.1444 + push( a ); 1.1445 + push( b ); 1.1446 + push( a ); 1.1447 + break; 1.1448 + 1.1449 + case Bytecodes::_dup2_x1: 1.1450 + // before: .. c, b, a 1.1451 + // after: .. b, a, c, b, a 1.1452 + // not tested 1.1453 + a = pop(); 1.1454 + b = pop(); 1.1455 + c = pop(); 1.1456 + push( b ); 1.1457 + push( a ); 1.1458 + push( c ); 1.1459 + push( b ); 1.1460 + push( a ); 1.1461 + break; 1.1462 + case Bytecodes::_dup2_x2: 1.1463 + // before: .. d, c, b, a 1.1464 + // after: .. b, a, d, c, b, a 1.1465 + // not tested 1.1466 + a = pop(); 1.1467 + b = pop(); 1.1468 + c = pop(); 1.1469 + d = pop(); 1.1470 + push( b ); 1.1471 + push( a ); 1.1472 + push( d ); 1.1473 + push( c ); 1.1474 + push( b ); 1.1475 + push( a ); 1.1476 + break; 1.1477 + 1.1478 + case Bytecodes::_arraylength: { 1.1479 + // Must do null-check with value on expression stack 1.1480 + Node *ary = do_null_check(peek(), T_ARRAY); 1.1481 + // Compile-time detect of null-exception? 1.1482 + if (stopped()) return; 1.1483 + a = pop(); 1.1484 + push(load_array_length(a)); 1.1485 + break; 1.1486 + } 1.1487 + 1.1488 + case Bytecodes::_baload: array_load(T_BYTE); break; 1.1489 + case Bytecodes::_caload: array_load(T_CHAR); break; 1.1490 + case Bytecodes::_iaload: array_load(T_INT); break; 1.1491 + case Bytecodes::_saload: array_load(T_SHORT); break; 1.1492 + case Bytecodes::_faload: array_load(T_FLOAT); break; 1.1493 + case Bytecodes::_aaload: array_load(T_OBJECT); break; 1.1494 + case Bytecodes::_laload: { 1.1495 + a = array_addressing(T_LONG, 0); 1.1496 + if (stopped()) return; // guarenteed null or range check 1.1497 + _sp -= 2; // Pop array and index 1.1498 + push_pair( make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS)); 1.1499 + break; 1.1500 + } 1.1501 + case Bytecodes::_daload: { 1.1502 + a = array_addressing(T_DOUBLE, 0); 1.1503 + if (stopped()) return; // guarenteed null or range check 1.1504 + _sp -= 2; // Pop array and index 1.1505 + push_pair( make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES)); 1.1506 + break; 1.1507 + } 1.1508 + case Bytecodes::_bastore: array_store(T_BYTE); break; 1.1509 + case Bytecodes::_castore: array_store(T_CHAR); break; 1.1510 + case Bytecodes::_iastore: array_store(T_INT); break; 1.1511 + case Bytecodes::_sastore: array_store(T_SHORT); break; 1.1512 + case Bytecodes::_fastore: array_store(T_FLOAT); break; 1.1513 + case Bytecodes::_aastore: { 1.1514 + d = array_addressing(T_OBJECT, 1); 1.1515 + if (stopped()) return; // guarenteed null or range check 1.1516 + array_store_check(); 1.1517 + c = pop(); // Oop to store 1.1518 + b = pop(); // index (already used) 1.1519 + a = pop(); // the array itself 1.1520 + const Type* elemtype = _gvn.type(a)->is_aryptr()->elem(); 1.1521 + const TypeAryPtr* adr_type = TypeAryPtr::OOPS; 1.1522 + Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT); 1.1523 + break; 1.1524 + } 1.1525 + case Bytecodes::_lastore: { 1.1526 + a = array_addressing(T_LONG, 2); 1.1527 + if (stopped()) return; // guarenteed null or range check 1.1528 + c = pop_pair(); 1.1529 + _sp -= 2; // Pop array and index 1.1530 + store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS); 1.1531 + break; 1.1532 + } 1.1533 + case Bytecodes::_dastore: { 1.1534 + a = array_addressing(T_DOUBLE, 2); 1.1535 + if (stopped()) return; // guarenteed null or range check 1.1536 + c = pop_pair(); 1.1537 + _sp -= 2; // Pop array and index 1.1538 + c = dstore_rounding(c); 1.1539 + store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES); 1.1540 + break; 1.1541 + } 1.1542 + case Bytecodes::_getfield: 1.1543 + do_getfield(); 1.1544 + break; 1.1545 + 1.1546 + case Bytecodes::_getstatic: 1.1547 + do_getstatic(); 1.1548 + break; 1.1549 + 1.1550 + case Bytecodes::_putfield: 1.1551 + do_putfield(); 1.1552 + break; 1.1553 + 1.1554 + case Bytecodes::_putstatic: 1.1555 + do_putstatic(); 1.1556 + break; 1.1557 + 1.1558 + case Bytecodes::_irem: 1.1559 + do_irem(); 1.1560 + break; 1.1561 + case Bytecodes::_idiv: 1.1562 + // Must keep both values on the expression-stack during null-check 1.1563 + do_null_check(peek(), T_INT); 1.1564 + // Compile-time detect of null-exception? 1.1565 + if (stopped()) return; 1.1566 + b = pop(); 1.1567 + a = pop(); 1.1568 + push( _gvn.transform( new (C, 3) DivINode(control(),a,b) ) ); 1.1569 + break; 1.1570 + case Bytecodes::_imul: 1.1571 + b = pop(); a = pop(); 1.1572 + push( _gvn.transform( new (C, 3) MulINode(a,b) ) ); 1.1573 + break; 1.1574 + case Bytecodes::_iadd: 1.1575 + b = pop(); a = pop(); 1.1576 + push( _gvn.transform( new (C, 3) AddINode(a,b) ) ); 1.1577 + break; 1.1578 + case Bytecodes::_ineg: 1.1579 + a = pop(); 1.1580 + push( _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),a)) ); 1.1581 + break; 1.1582 + case Bytecodes::_isub: 1.1583 + b = pop(); a = pop(); 1.1584 + push( _gvn.transform( new (C, 3) SubINode(a,b) ) ); 1.1585 + break; 1.1586 + case Bytecodes::_iand: 1.1587 + b = pop(); a = pop(); 1.1588 + push( _gvn.transform( new (C, 3) AndINode(a,b) ) ); 1.1589 + break; 1.1590 + case Bytecodes::_ior: 1.1591 + b = pop(); a = pop(); 1.1592 + push( _gvn.transform( new (C, 3) OrINode(a,b) ) ); 1.1593 + break; 1.1594 + case Bytecodes::_ixor: 1.1595 + b = pop(); a = pop(); 1.1596 + push( _gvn.transform( new (C, 3) XorINode(a,b) ) ); 1.1597 + break; 1.1598 + case Bytecodes::_ishl: 1.1599 + b = pop(); a = pop(); 1.1600 + push( _gvn.transform( new (C, 3) LShiftINode(a,b) ) ); 1.1601 + break; 1.1602 + case Bytecodes::_ishr: 1.1603 + b = pop(); a = pop(); 1.1604 + push( _gvn.transform( new (C, 3) RShiftINode(a,b) ) ); 1.1605 + break; 1.1606 + case Bytecodes::_iushr: 1.1607 + b = pop(); a = pop(); 1.1608 + push( _gvn.transform( new (C, 3) URShiftINode(a,b) ) ); 1.1609 + break; 1.1610 + 1.1611 + case Bytecodes::_fneg: 1.1612 + a = pop(); 1.1613 + b = _gvn.transform(new (C, 2) NegFNode (a)); 1.1614 + push(b); 1.1615 + break; 1.1616 + 1.1617 + case Bytecodes::_fsub: 1.1618 + b = pop(); 1.1619 + a = pop(); 1.1620 + c = _gvn.transform( new (C, 3) SubFNode(a,b) ); 1.1621 + d = precision_rounding(c); 1.1622 + push( d ); 1.1623 + break; 1.1624 + 1.1625 + case Bytecodes::_fadd: 1.1626 + b = pop(); 1.1627 + a = pop(); 1.1628 + c = _gvn.transform( new (C, 3) AddFNode(a,b) ); 1.1629 + d = precision_rounding(c); 1.1630 + push( d ); 1.1631 + break; 1.1632 + 1.1633 + case Bytecodes::_fmul: 1.1634 + b = pop(); 1.1635 + a = pop(); 1.1636 + c = _gvn.transform( new (C, 3) MulFNode(a,b) ); 1.1637 + d = precision_rounding(c); 1.1638 + push( d ); 1.1639 + break; 1.1640 + 1.1641 + case Bytecodes::_fdiv: 1.1642 + b = pop(); 1.1643 + a = pop(); 1.1644 + c = _gvn.transform( new (C, 3) DivFNode(0,a,b) ); 1.1645 + d = precision_rounding(c); 1.1646 + push( d ); 1.1647 + break; 1.1648 + 1.1649 + case Bytecodes::_frem: 1.1650 + if (Matcher::has_match_rule(Op_ModF)) { 1.1651 + // Generate a ModF node. 1.1652 + b = pop(); 1.1653 + a = pop(); 1.1654 + c = _gvn.transform( new (C, 3) ModFNode(0,a,b) ); 1.1655 + d = precision_rounding(c); 1.1656 + push( d ); 1.1657 + } 1.1658 + else { 1.1659 + // Generate a call. 1.1660 + modf(); 1.1661 + } 1.1662 + break; 1.1663 + 1.1664 + case Bytecodes::_fcmpl: 1.1665 + b = pop(); 1.1666 + a = pop(); 1.1667 + c = _gvn.transform( new (C, 3) CmpF3Node( a, b)); 1.1668 + push(c); 1.1669 + break; 1.1670 + case Bytecodes::_fcmpg: 1.1671 + b = pop(); 1.1672 + a = pop(); 1.1673 + 1.1674 + // Same as fcmpl but need to flip the unordered case. Swap the inputs, 1.1675 + // which negates the result sign except for unordered. Flip the unordered 1.1676 + // as well by using CmpF3 which implements unordered-lesser instead of 1.1677 + // unordered-greater semantics. Finally, commute the result bits. Result 1.1678 + // is same as using a CmpF3Greater except we did it with CmpF3 alone. 1.1679 + c = _gvn.transform( new (C, 3) CmpF3Node( b, a)); 1.1680 + c = _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),c) ); 1.1681 + push(c); 1.1682 + break; 1.1683 + 1.1684 + case Bytecodes::_f2i: 1.1685 + a = pop(); 1.1686 + push(_gvn.transform(new (C, 2) ConvF2INode(a))); 1.1687 + break; 1.1688 + 1.1689 + case Bytecodes::_d2i: 1.1690 + a = pop_pair(); 1.1691 + b = _gvn.transform(new (C, 2) ConvD2INode(a)); 1.1692 + push( b ); 1.1693 + break; 1.1694 + 1.1695 + case Bytecodes::_f2d: 1.1696 + a = pop(); 1.1697 + b = _gvn.transform( new (C, 2) ConvF2DNode(a)); 1.1698 + push_pair( b ); 1.1699 + break; 1.1700 + 1.1701 + case Bytecodes::_d2f: 1.1702 + a = pop_pair(); 1.1703 + b = _gvn.transform( new (C, 2) ConvD2FNode(a)); 1.1704 + // This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed) 1.1705 + //b = _gvn.transform(new (C, 2) RoundFloatNode(0, b) ); 1.1706 + push( b ); 1.1707 + break; 1.1708 + 1.1709 + case Bytecodes::_l2f: 1.1710 + if (Matcher::convL2FSupported()) { 1.1711 + a = pop_pair(); 1.1712 + b = _gvn.transform( new (C, 2) ConvL2FNode(a)); 1.1713 + // For i486.ad, FILD doesn't restrict precision to 24 or 53 bits. 1.1714 + // Rather than storing the result into an FP register then pushing 1.1715 + // out to memory to round, the machine instruction that implements 1.1716 + // ConvL2D is responsible for rounding. 1.1717 + // c = precision_rounding(b); 1.1718 + c = _gvn.transform(b); 1.1719 + push(c); 1.1720 + } else { 1.1721 + l2f(); 1.1722 + } 1.1723 + break; 1.1724 + 1.1725 + case Bytecodes::_l2d: 1.1726 + a = pop_pair(); 1.1727 + b = _gvn.transform( new (C, 2) ConvL2DNode(a)); 1.1728 + // For i486.ad, rounding is always necessary (see _l2f above). 1.1729 + // c = dprecision_rounding(b); 1.1730 + c = _gvn.transform(b); 1.1731 + push_pair(c); 1.1732 + break; 1.1733 + 1.1734 + case Bytecodes::_f2l: 1.1735 + a = pop(); 1.1736 + b = _gvn.transform( new (C, 2) ConvF2LNode(a)); 1.1737 + push_pair(b); 1.1738 + break; 1.1739 + 1.1740 + case Bytecodes::_d2l: 1.1741 + a = pop_pair(); 1.1742 + b = _gvn.transform( new (C, 2) ConvD2LNode(a)); 1.1743 + push_pair(b); 1.1744 + break; 1.1745 + 1.1746 + case Bytecodes::_dsub: 1.1747 + b = pop_pair(); 1.1748 + a = pop_pair(); 1.1749 + c = _gvn.transform( new (C, 3) SubDNode(a,b) ); 1.1750 + d = dprecision_rounding(c); 1.1751 + push_pair( d ); 1.1752 + break; 1.1753 + 1.1754 + case Bytecodes::_dadd: 1.1755 + b = pop_pair(); 1.1756 + a = pop_pair(); 1.1757 + c = _gvn.transform( new (C, 3) AddDNode(a,b) ); 1.1758 + d = dprecision_rounding(c); 1.1759 + push_pair( d ); 1.1760 + break; 1.1761 + 1.1762 + case Bytecodes::_dmul: 1.1763 + b = pop_pair(); 1.1764 + a = pop_pair(); 1.1765 + c = _gvn.transform( new (C, 3) MulDNode(a,b) ); 1.1766 + d = dprecision_rounding(c); 1.1767 + push_pair( d ); 1.1768 + break; 1.1769 + 1.1770 + case Bytecodes::_ddiv: 1.1771 + b = pop_pair(); 1.1772 + a = pop_pair(); 1.1773 + c = _gvn.transform( new (C, 3) DivDNode(0,a,b) ); 1.1774 + d = dprecision_rounding(c); 1.1775 + push_pair( d ); 1.1776 + break; 1.1777 + 1.1778 + case Bytecodes::_dneg: 1.1779 + a = pop_pair(); 1.1780 + b = _gvn.transform(new (C, 2) NegDNode (a)); 1.1781 + push_pair(b); 1.1782 + break; 1.1783 + 1.1784 + case Bytecodes::_drem: 1.1785 + if (Matcher::has_match_rule(Op_ModD)) { 1.1786 + // Generate a ModD node. 1.1787 + b = pop_pair(); 1.1788 + a = pop_pair(); 1.1789 + // a % b 1.1790 + 1.1791 + c = _gvn.transform( new (C, 3) ModDNode(0,a,b) ); 1.1792 + d = dprecision_rounding(c); 1.1793 + push_pair( d ); 1.1794 + } 1.1795 + else { 1.1796 + // Generate a call. 1.1797 + modd(); 1.1798 + } 1.1799 + break; 1.1800 + 1.1801 + case Bytecodes::_dcmpl: 1.1802 + b = pop_pair(); 1.1803 + a = pop_pair(); 1.1804 + c = _gvn.transform( new (C, 3) CmpD3Node( a, b)); 1.1805 + push(c); 1.1806 + break; 1.1807 + 1.1808 + case Bytecodes::_dcmpg: 1.1809 + b = pop_pair(); 1.1810 + a = pop_pair(); 1.1811 + // Same as dcmpl but need to flip the unordered case. 1.1812 + // Commute the inputs, which negates the result sign except for unordered. 1.1813 + // Flip the unordered as well by using CmpD3 which implements 1.1814 + // unordered-lesser instead of unordered-greater semantics. 1.1815 + // Finally, negate the result bits. Result is same as using a 1.1816 + // CmpD3Greater except we did it with CmpD3 alone. 1.1817 + c = _gvn.transform( new (C, 3) CmpD3Node( b, a)); 1.1818 + c = _gvn.transform( new (C, 3) SubINode(_gvn.intcon(0),c) ); 1.1819 + push(c); 1.1820 + break; 1.1821 + 1.1822 + 1.1823 + // Note for longs -> lo word is on TOS, hi word is on TOS - 1 1.1824 + case Bytecodes::_land: 1.1825 + b = pop_pair(); 1.1826 + a = pop_pair(); 1.1827 + c = _gvn.transform( new (C, 3) AndLNode(a,b) ); 1.1828 + push_pair(c); 1.1829 + break; 1.1830 + case Bytecodes::_lor: 1.1831 + b = pop_pair(); 1.1832 + a = pop_pair(); 1.1833 + c = _gvn.transform( new (C, 3) OrLNode(a,b) ); 1.1834 + push_pair(c); 1.1835 + break; 1.1836 + case Bytecodes::_lxor: 1.1837 + b = pop_pair(); 1.1838 + a = pop_pair(); 1.1839 + c = _gvn.transform( new (C, 3) XorLNode(a,b) ); 1.1840 + push_pair(c); 1.1841 + break; 1.1842 + 1.1843 + case Bytecodes::_lshl: 1.1844 + b = pop(); // the shift count 1.1845 + a = pop_pair(); // value to be shifted 1.1846 + c = _gvn.transform( new (C, 3) LShiftLNode(a,b) ); 1.1847 + push_pair(c); 1.1848 + break; 1.1849 + case Bytecodes::_lshr: 1.1850 + b = pop(); // the shift count 1.1851 + a = pop_pair(); // value to be shifted 1.1852 + c = _gvn.transform( new (C, 3) RShiftLNode(a,b) ); 1.1853 + push_pair(c); 1.1854 + break; 1.1855 + case Bytecodes::_lushr: 1.1856 + b = pop(); // the shift count 1.1857 + a = pop_pair(); // value to be shifted 1.1858 + c = _gvn.transform( new (C, 3) URShiftLNode(a,b) ); 1.1859 + push_pair(c); 1.1860 + break; 1.1861 + case Bytecodes::_lmul: 1.1862 + b = pop_pair(); 1.1863 + a = pop_pair(); 1.1864 + c = _gvn.transform( new (C, 3) MulLNode(a,b) ); 1.1865 + push_pair(c); 1.1866 + break; 1.1867 + 1.1868 + case Bytecodes::_lrem: 1.1869 + // Must keep both values on the expression-stack during null-check 1.1870 + assert(peek(0) == top(), "long word order"); 1.1871 + do_null_check(peek(1), T_LONG); 1.1872 + // Compile-time detect of null-exception? 1.1873 + if (stopped()) return; 1.1874 + b = pop_pair(); 1.1875 + a = pop_pair(); 1.1876 + c = _gvn.transform( new (C, 3) ModLNode(control(),a,b) ); 1.1877 + push_pair(c); 1.1878 + break; 1.1879 + 1.1880 + case Bytecodes::_ldiv: 1.1881 + // Must keep both values on the expression-stack during null-check 1.1882 + assert(peek(0) == top(), "long word order"); 1.1883 + do_null_check(peek(1), T_LONG); 1.1884 + // Compile-time detect of null-exception? 1.1885 + if (stopped()) return; 1.1886 + b = pop_pair(); 1.1887 + a = pop_pair(); 1.1888 + c = _gvn.transform( new (C, 3) DivLNode(control(),a,b) ); 1.1889 + push_pair(c); 1.1890 + break; 1.1891 + 1.1892 + case Bytecodes::_ladd: 1.1893 + b = pop_pair(); 1.1894 + a = pop_pair(); 1.1895 + c = _gvn.transform( new (C, 3) AddLNode(a,b) ); 1.1896 + push_pair(c); 1.1897 + break; 1.1898 + case Bytecodes::_lsub: 1.1899 + b = pop_pair(); 1.1900 + a = pop_pair(); 1.1901 + c = _gvn.transform( new (C, 3) SubLNode(a,b) ); 1.1902 + push_pair(c); 1.1903 + break; 1.1904 + case Bytecodes::_lcmp: 1.1905 + // Safepoints are now inserted _before_ branches. The long-compare 1.1906 + // bytecode painfully produces a 3-way value (-1,0,+1) which requires a 1.1907 + // slew of control flow. These are usually followed by a CmpI vs zero and 1.1908 + // a branch; this pattern then optimizes to the obvious long-compare and 1.1909 + // branch. However, if the branch is backwards there's a Safepoint 1.1910 + // inserted. The inserted Safepoint captures the JVM state at the 1.1911 + // pre-branch point, i.e. it captures the 3-way value. Thus if a 1.1912 + // long-compare is used to control a loop the debug info will force 1.1913 + // computation of the 3-way value, even though the generated code uses a 1.1914 + // long-compare and branch. We try to rectify the situation by inserting 1.1915 + // a SafePoint here and have it dominate and kill the safepoint added at a 1.1916 + // following backwards branch. At this point the JVM state merely holds 2 1.1917 + // longs but not the 3-way value. 1.1918 + if( UseLoopSafepoints ) { 1.1919 + switch( iter().next_bc() ) { 1.1920 + case Bytecodes::_ifgt: 1.1921 + case Bytecodes::_iflt: 1.1922 + case Bytecodes::_ifge: 1.1923 + case Bytecodes::_ifle: 1.1924 + case Bytecodes::_ifne: 1.1925 + case Bytecodes::_ifeq: 1.1926 + // If this is a backwards branch in the bytecodes, add Safepoint 1.1927 + maybe_add_safepoint(iter().next_get_dest()); 1.1928 + } 1.1929 + } 1.1930 + b = pop_pair(); 1.1931 + a = pop_pair(); 1.1932 + c = _gvn.transform( new (C, 3) CmpL3Node( a, b )); 1.1933 + push(c); 1.1934 + break; 1.1935 + 1.1936 + case Bytecodes::_lneg: 1.1937 + a = pop_pair(); 1.1938 + b = _gvn.transform( new (C, 3) SubLNode(longcon(0),a)); 1.1939 + push_pair(b); 1.1940 + break; 1.1941 + case Bytecodes::_l2i: 1.1942 + a = pop_pair(); 1.1943 + push( _gvn.transform( new (C, 2) ConvL2INode(a))); 1.1944 + break; 1.1945 + case Bytecodes::_i2l: 1.1946 + a = pop(); 1.1947 + b = _gvn.transform( new (C, 2) ConvI2LNode(a)); 1.1948 + push_pair(b); 1.1949 + break; 1.1950 + case Bytecodes::_i2b: 1.1951 + // Sign extend 1.1952 + a = pop(); 1.1953 + a = _gvn.transform( new (C, 3) LShiftINode(a,_gvn.intcon(24)) ); 1.1954 + a = _gvn.transform( new (C, 3) RShiftINode(a,_gvn.intcon(24)) ); 1.1955 + push( a ); 1.1956 + break; 1.1957 + case Bytecodes::_i2s: 1.1958 + a = pop(); 1.1959 + a = _gvn.transform( new (C, 3) LShiftINode(a,_gvn.intcon(16)) ); 1.1960 + a = _gvn.transform( new (C, 3) RShiftINode(a,_gvn.intcon(16)) ); 1.1961 + push( a ); 1.1962 + break; 1.1963 + case Bytecodes::_i2c: 1.1964 + a = pop(); 1.1965 + push( _gvn.transform( new (C, 3) AndINode(a,_gvn.intcon(0xFFFF)) ) ); 1.1966 + break; 1.1967 + 1.1968 + case Bytecodes::_i2f: 1.1969 + a = pop(); 1.1970 + b = _gvn.transform( new (C, 2) ConvI2FNode(a) ) ; 1.1971 + c = precision_rounding(b); 1.1972 + push (b); 1.1973 + break; 1.1974 + 1.1975 + case Bytecodes::_i2d: 1.1976 + a = pop(); 1.1977 + b = _gvn.transform( new (C, 2) ConvI2DNode(a)); 1.1978 + push_pair(b); 1.1979 + break; 1.1980 + 1.1981 + case Bytecodes::_iinc: // Increment local 1.1982 + i = iter().get_index(); // Get local index 1.1983 + set_local( i, _gvn.transform( new (C, 3) AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) ); 1.1984 + break; 1.1985 + 1.1986 + // Exit points of synchronized methods must have an unlock node 1.1987 + case Bytecodes::_return: 1.1988 + return_current(NULL); 1.1989 + break; 1.1990 + 1.1991 + case Bytecodes::_ireturn: 1.1992 + case Bytecodes::_areturn: 1.1993 + case Bytecodes::_freturn: 1.1994 + return_current(pop()); 1.1995 + break; 1.1996 + case Bytecodes::_lreturn: 1.1997 + return_current(pop_pair()); 1.1998 + break; 1.1999 + case Bytecodes::_dreturn: 1.2000 + return_current(pop_pair()); 1.2001 + break; 1.2002 + 1.2003 + case Bytecodes::_athrow: 1.2004 + // null exception oop throws NULL pointer exception 1.2005 + do_null_check(peek(), T_OBJECT); 1.2006 + if (stopped()) return; 1.2007 + if (JvmtiExport::can_post_exceptions()) { 1.2008 + // "Full-speed throwing" is not necessary here, 1.2009 + // since we're notifying the VM on every throw. 1.2010 + uncommon_trap(Deoptimization::Reason_unhandled, 1.2011 + Deoptimization::Action_none); 1.2012 + return; 1.2013 + } 1.2014 + // Hook the thrown exception directly to subsequent handlers. 1.2015 + if (BailoutToInterpreterForThrows) { 1.2016 + // Keep method interpreted from now on. 1.2017 + uncommon_trap(Deoptimization::Reason_unhandled, 1.2018 + Deoptimization::Action_make_not_compilable); 1.2019 + return; 1.2020 + } 1.2021 + add_exception_state(make_exception_state(peek())); 1.2022 + break; 1.2023 + 1.2024 + case Bytecodes::_goto: // fall through 1.2025 + case Bytecodes::_goto_w: { 1.2026 + int target_bci = (bc() == Bytecodes::_goto) ? iter().get_dest() : iter().get_far_dest(); 1.2027 + 1.2028 + // If this is a backwards branch in the bytecodes, add Safepoint 1.2029 + maybe_add_safepoint(target_bci); 1.2030 + 1.2031 + // Update method data 1.2032 + profile_taken_branch(target_bci); 1.2033 + 1.2034 + // Merge the current control into the target basic block 1.2035 + merge(target_bci); 1.2036 + 1.2037 + // See if we can get some profile data and hand it off to the next block 1.2038 + Block *target_block = block()->successor_for_bci(target_bci); 1.2039 + if (target_block->pred_count() != 1) break; 1.2040 + ciMethodData* methodData = method()->method_data(); 1.2041 + if (!methodData->is_mature()) break; 1.2042 + ciProfileData* data = methodData->bci_to_data(bci()); 1.2043 + assert( data->is_JumpData(), "" ); 1.2044 + int taken = ((ciJumpData*)data)->taken(); 1.2045 + taken = method()->scale_count(taken); 1.2046 + target_block->set_count(taken); 1.2047 + break; 1.2048 + } 1.2049 + 1.2050 + case Bytecodes::_ifnull: 1.2051 + do_ifnull(BoolTest::eq); 1.2052 + break; 1.2053 + case Bytecodes::_ifnonnull: 1.2054 + do_ifnull(BoolTest::ne); 1.2055 + break; 1.2056 + 1.2057 + case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp; 1.2058 + case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp; 1.2059 + handle_if_acmp: 1.2060 + // If this is a backwards branch in the bytecodes, add Safepoint 1.2061 + maybe_add_safepoint(iter().get_dest()); 1.2062 + a = pop(); 1.2063 + b = pop(); 1.2064 + c = _gvn.transform( new (C, 3) CmpPNode(b, a) ); 1.2065 + do_if(btest, c); 1.2066 + break; 1.2067 + 1.2068 + case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx; 1.2069 + case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx; 1.2070 + case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx; 1.2071 + case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx; 1.2072 + case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx; 1.2073 + case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx; 1.2074 + handle_ifxx: 1.2075 + // If this is a backwards branch in the bytecodes, add Safepoint 1.2076 + maybe_add_safepoint(iter().get_dest()); 1.2077 + a = _gvn.intcon(0); 1.2078 + b = pop(); 1.2079 + c = _gvn.transform( new (C, 3) CmpINode(b, a) ); 1.2080 + do_if(btest, c); 1.2081 + break; 1.2082 + 1.2083 + case Bytecodes::_if_icmpeq: btest = BoolTest::eq; goto handle_if_icmp; 1.2084 + case Bytecodes::_if_icmpne: btest = BoolTest::ne; goto handle_if_icmp; 1.2085 + case Bytecodes::_if_icmplt: btest = BoolTest::lt; goto handle_if_icmp; 1.2086 + case Bytecodes::_if_icmple: btest = BoolTest::le; goto handle_if_icmp; 1.2087 + case Bytecodes::_if_icmpgt: btest = BoolTest::gt; goto handle_if_icmp; 1.2088 + case Bytecodes::_if_icmpge: btest = BoolTest::ge; goto handle_if_icmp; 1.2089 + handle_if_icmp: 1.2090 + // If this is a backwards branch in the bytecodes, add Safepoint 1.2091 + maybe_add_safepoint(iter().get_dest()); 1.2092 + a = pop(); 1.2093 + b = pop(); 1.2094 + c = _gvn.transform( new (C, 3) CmpINode( b, a ) ); 1.2095 + do_if(btest, c); 1.2096 + break; 1.2097 + 1.2098 + case Bytecodes::_tableswitch: 1.2099 + do_tableswitch(); 1.2100 + break; 1.2101 + 1.2102 + case Bytecodes::_lookupswitch: 1.2103 + do_lookupswitch(); 1.2104 + break; 1.2105 + 1.2106 + case Bytecodes::_invokestatic: 1.2107 + case Bytecodes::_invokespecial: 1.2108 + case Bytecodes::_invokevirtual: 1.2109 + case Bytecodes::_invokeinterface: 1.2110 + do_call(); 1.2111 + break; 1.2112 + case Bytecodes::_checkcast: 1.2113 + do_checkcast(); 1.2114 + break; 1.2115 + case Bytecodes::_instanceof: 1.2116 + do_instanceof(); 1.2117 + break; 1.2118 + case Bytecodes::_anewarray: 1.2119 + do_anewarray(); 1.2120 + break; 1.2121 + case Bytecodes::_newarray: 1.2122 + do_newarray((BasicType)iter().get_index()); 1.2123 + break; 1.2124 + case Bytecodes::_multianewarray: 1.2125 + do_multianewarray(); 1.2126 + break; 1.2127 + case Bytecodes::_new: 1.2128 + do_new(); 1.2129 + break; 1.2130 + 1.2131 + case Bytecodes::_jsr: 1.2132 + case Bytecodes::_jsr_w: 1.2133 + do_jsr(); 1.2134 + break; 1.2135 + 1.2136 + case Bytecodes::_ret: 1.2137 + do_ret(); 1.2138 + break; 1.2139 + 1.2140 + 1.2141 + case Bytecodes::_monitorenter: 1.2142 + do_monitor_enter(); 1.2143 + break; 1.2144 + 1.2145 + case Bytecodes::_monitorexit: 1.2146 + do_monitor_exit(); 1.2147 + break; 1.2148 + 1.2149 + case Bytecodes::_breakpoint: 1.2150 + // Breakpoint set concurrently to compile 1.2151 + // %%% use an uncommon trap? 1.2152 + C->record_failure("breakpoint in method"); 1.2153 + return; 1.2154 + 1.2155 + default: 1.2156 +#ifndef PRODUCT 1.2157 + map()->dump(99); 1.2158 +#endif 1.2159 + tty->print("\nUnhandled bytecode %s\n", Bytecodes::name(bc()) ); 1.2160 + ShouldNotReachHere(); 1.2161 + } 1.2162 + 1.2163 +#ifndef PRODUCT 1.2164 + IdealGraphPrinter *printer = IdealGraphPrinter::printer(); 1.2165 + if(printer) { 1.2166 + char buffer[256]; 1.2167 + sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc())); 1.2168 + bool old = printer->traverse_outs(); 1.2169 + printer->set_traverse_outs(true); 1.2170 + printer->print_method(C, buffer, 3); 1.2171 + printer->set_traverse_outs(old); 1.2172 + } 1.2173 +#endif 1.2174 +}