src/share/vm/opto/parse2.cpp

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

mercurial