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