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