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