0N/A/*
2273N/A * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "ci/ciMethodData.hpp"
1879N/A#include "classfile/systemDictionary.hpp"
1879N/A#include "classfile/vmSymbols.hpp"
1879N/A#include "compiler/compileLog.hpp"
1879N/A#include "interpreter/linkResolver.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "opto/addnode.hpp"
1879N/A#include "opto/divnode.hpp"
1879N/A#include "opto/idealGraphPrinter.hpp"
1879N/A#include "opto/matcher.hpp"
1879N/A#include "opto/memnode.hpp"
1879N/A#include "opto/mulnode.hpp"
1879N/A#include "opto/parse.hpp"
1879N/A#include "opto/runtime.hpp"
1879N/A#include "runtime/deoptimization.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
0N/A
0N/Aextern int explicit_null_checks_inserted,
0N/A explicit_null_checks_elided;
0N/A
0N/A//---------------------------------array_load----------------------------------
0N/Avoid Parse::array_load(BasicType elem_type) {
0N/A const Type* elem = Type::TOP;
0N/A Node* adr = array_addressing(elem_type, 0, &elem);
605N/A if (stopped()) return; // guaranteed null or range check
4122N/A dec_sp(2); // Pop array and index
0N/A const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
0N/A Node* ld = make_load(control(), adr, elem, elem_type, adr_type);
0N/A push(ld);
0N/A}
0N/A
0N/A
0N/A//--------------------------------array_store----------------------------------
0N/Avoid Parse::array_store(BasicType elem_type) {
0N/A Node* adr = array_addressing(elem_type, 1);
605N/A if (stopped()) return; // guaranteed null or range check
0N/A Node* val = pop();
4122N/A dec_sp(2); // Pop array and index
0N/A const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
0N/A store_to_memory(control(), adr, val, elem_type, adr_type);
0N/A}
0N/A
0N/A
0N/A//------------------------------array_addressing-------------------------------
0N/A// Pull array and index from the stack. Compute pointer-to-element.
0N/ANode* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
0N/A Node *idx = peek(0+vals); // Get from stack without popping
0N/A Node *ary = peek(1+vals); // in case of exception
0N/A
0N/A // Null check the array base, with correct stack contents
4122N/A ary = null_check(ary, T_ARRAY);
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return top();
0N/A
0N/A const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
0N/A const TypeInt* sizetype = arytype->size();
0N/A const Type* elemtype = arytype->elem();
0N/A
0N/A if (UseUniqueSubclasses && result2 != NULL) {
221N/A const Type* el = elemtype->make_ptr();
221N/A if (el && el->isa_instptr()) {
221N/A const TypeInstPtr* toop = el->is_instptr();
0N/A if (toop->klass()->as_instance_klass()->unique_concrete_subklass()) {
0N/A // If we load from "AbstractClass[]" we must see "ConcreteSubClass".
0N/A const Type* subklass = Type::get_const_type(toop->klass());
113N/A elemtype = subklass->join(el);
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Check for big class initializers with all constant offsets
0N/A // feeding into a known-size array.
0N/A const TypeInt* idxtype = _gvn.type(idx)->is_int();
0N/A // See if the highest idx value is less than the lowest array bound,
0N/A // and if the idx value cannot be negative:
0N/A bool need_range_check = true;
0N/A if (idxtype->_hi < sizetype->_lo && idxtype->_lo >= 0) {
0N/A need_range_check = false;
0N/A if (C->log() != NULL) C->log()->elem("observe that='!need_range_check'");
0N/A }
0N/A
4333N/A ciKlass * arytype_klass = arytype->klass();
4333N/A if ((arytype_klass != NULL) && (!arytype_klass->is_loaded())) {
0N/A // Only fails for some -Xcomp runs
0N/A // The class is unloaded. We have to run this bytecode in the interpreter.
0N/A uncommon_trap(Deoptimization::Reason_unloaded,
0N/A Deoptimization::Action_reinterpret,
0N/A arytype->klass(), "!loaded array");
0N/A return top();
0N/A }
0N/A
0N/A // Do the range check
0N/A if (GenerateRangeChecks && need_range_check) {
129N/A Node* tst;
129N/A if (sizetype->_hi <= 0) {
366N/A // The greatest array bound is negative, so we can conclude that we're
129N/A // compiling unreachable code, but the unsigned compare trick used below
129N/A // only works with non-negative lengths. Instead, hack "tst" to be zero so
129N/A // the uncommon_trap path will always be taken.
129N/A tst = _gvn.intcon(0);
129N/A } else {
366N/A // Range is constant in array-oop, so we can use the original state of mem
366N/A Node* len = load_array_length(ary);
366N/A
129N/A // Test length vs index (standard trick using unsigned compare)
4022N/A Node* chk = _gvn.transform( new (C) CmpUNode(idx, len) );
129N/A BoolTest::mask btest = BoolTest::lt;
4022N/A tst = _gvn.transform( new (C) BoolNode(chk, btest) );
129N/A }
0N/A // Branch to failure if out of bounds
0N/A { BuildCutout unless(this, tst, PROB_MAX);
0N/A if (C->allow_range_check_smearing()) {
0N/A // Do not use builtin_throw, since range checks are sometimes
0N/A // made more stringent by an optimistic transformation.
0N/A // This creates "tentative" range checks at this point,
0N/A // which are not guaranteed to throw exceptions.
0N/A // See IfNode::Ideal, is_range_check, adjust_check.
0N/A uncommon_trap(Deoptimization::Reason_range_check,
0N/A Deoptimization::Action_make_not_entrant,
0N/A NULL, "range_check");
0N/A } else {
0N/A // If we have already recompiled with the range-check-widening
0N/A // heroic optimization turned off, then we must really be throwing
0N/A // range check exceptions.
0N/A builtin_throw(Deoptimization::Reason_range_check, idx);
0N/A }
0N/A }
0N/A }
0N/A // Check for always knowing you are throwing a range-check exception
0N/A if (stopped()) return top();
0N/A
366N/A Node* ptr = array_element_address(ary, idx, type, sizetype);
0N/A
0N/A if (result2 != NULL) *result2 = elemtype;
366N/A
366N/A assert(ptr != top(), "top should go hand-in-hand with stopped");
366N/A
0N/A return ptr;
0N/A}
0N/A
0N/A
0N/A// returns IfNode
0N/AIfNode* Parse::jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask) {
4022N/A Node *cmp = _gvn.transform( new (C) CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32
4022N/A Node *tst = _gvn.transform( new (C) BoolNode( cmp, mask));
0N/A IfNode *iff = create_and_map_if( control(), tst, ((mask == BoolTest::eq) ? PROB_STATIC_INFREQUENT : PROB_FAIR), COUNT_UNKNOWN );
0N/A return iff;
0N/A}
0N/A
0N/A// return Region node
0N/ANode* Parse::jump_if_join(Node* iffalse, Node* iftrue) {
4022N/A Node *region = new (C) RegionNode(3); // 2 results
0N/A record_for_igvn(region);
0N/A region->init_req(1, iffalse);
0N/A region->init_req(2, iftrue );
0N/A _gvn.set_type(region, Type::CONTROL);
0N/A region = _gvn.transform(region);
0N/A set_control (region);
0N/A return region;
0N/A}
0N/A
0N/A
0N/A//------------------------------helper for tableswitch-------------------------
0N/Avoid Parse::jump_if_true_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) {
0N/A // True branch, use existing map info
0N/A { PreserveJVMState pjvms(this);
4022N/A Node *iftrue = _gvn.transform( new (C) IfTrueNode (iff) );
0N/A set_control( iftrue );
0N/A profile_switch_case(prof_table_index);
0N/A merge_new_path(dest_bci_if_true);
0N/A }
0N/A
0N/A // False branch
4022N/A Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff) );
0N/A set_control( iffalse );
0N/A}
0N/A
0N/Avoid Parse::jump_if_false_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) {
0N/A // True branch, use existing map info
0N/A { PreserveJVMState pjvms(this);
4022N/A Node *iffalse = _gvn.transform( new (C) IfFalseNode (iff) );
0N/A set_control( iffalse );
0N/A profile_switch_case(prof_table_index);
0N/A merge_new_path(dest_bci_if_true);
0N/A }
0N/A
0N/A // False branch
4022N/A Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff) );
0N/A set_control( iftrue );
0N/A}
0N/A
0N/Avoid Parse::jump_if_always_fork(int dest_bci, int prof_table_index) {
0N/A // False branch, use existing map and control()
0N/A profile_switch_case(prof_table_index);
0N/A merge_new_path(dest_bci);
0N/A}
0N/A
0N/A
0N/Aextern "C" {
0N/A static int jint_cmp(const void *i, const void *j) {
0N/A int a = *(jint *)i;
0N/A int b = *(jint *)j;
0N/A return a > b ? 1 : a < b ? -1 : 0;
0N/A }
0N/A}
0N/A
0N/A
0N/A// Default value for methodData switch indexing. Must be a negative value to avoid
0N/A// conflict with any legal switch index.
0N/A#define NullTableIndex -1
0N/A
0N/Aclass SwitchRange : public StackObj {
0N/A // a range of integers coupled with a bci destination
0N/A jint _lo; // inclusive lower limit
0N/A jint _hi; // inclusive upper limit
0N/A int _dest;
0N/A int _table_index; // index into method data table
0N/A
0N/Apublic:
0N/A jint lo() const { return _lo; }
0N/A jint hi() const { return _hi; }
0N/A int dest() const { return _dest; }
0N/A int table_index() const { return _table_index; }
0N/A bool is_singleton() const { return _lo == _hi; }
0N/A
0N/A void setRange(jint lo, jint hi, int dest, int table_index) {
0N/A assert(lo <= hi, "must be a non-empty range");
0N/A _lo = lo, _hi = hi; _dest = dest; _table_index = table_index;
0N/A }
0N/A bool adjoinRange(jint lo, jint hi, int dest, int table_index) {
0N/A assert(lo <= hi, "must be a non-empty range");
0N/A if (lo == _hi+1 && dest == _dest && table_index == _table_index) {
0N/A _hi = hi;
0N/A return true;
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A void set (jint value, int dest, int table_index) {
0N/A setRange(value, value, dest, table_index);
0N/A }
0N/A bool adjoin(jint value, int dest, int table_index) {
0N/A return adjoinRange(value, value, dest, table_index);
0N/A }
0N/A
0N/A void print(ciEnv* env) {
0N/A if (is_singleton())
0N/A tty->print(" {%d}=>%d", lo(), dest());
0N/A else if (lo() == min_jint)
0N/A tty->print(" {..%d}=>%d", hi(), dest());
0N/A else if (hi() == max_jint)
0N/A tty->print(" {%d..}=>%d", lo(), dest());
0N/A else
0N/A tty->print(" {%d..%d}=>%d", lo(), hi(), dest());
0N/A }
0N/A};
0N/A
0N/A
0N/A//-------------------------------do_tableswitch--------------------------------
0N/Avoid Parse::do_tableswitch() {
0N/A Node* lookup = pop();
0N/A
0N/A // Get information about tableswitch
0N/A int default_dest = iter().get_dest_table(0);
0N/A int lo_index = iter().get_int_table(1);
0N/A int hi_index = iter().get_int_table(2);
0N/A int len = hi_index - lo_index + 1;
0N/A
0N/A if (len < 1) {
0N/A // If this is a backward branch, add safepoint
0N/A maybe_add_safepoint(default_dest);
0N/A merge(default_dest);
0N/A return;
0N/A }
0N/A
0N/A // generate decision tree, using trichotomy when possible
0N/A int rnum = len+2;
0N/A bool makes_backward_branch = false;
0N/A SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum);
0N/A int rp = -1;
0N/A if (lo_index != min_jint) {
0N/A ranges[++rp].setRange(min_jint, lo_index-1, default_dest, NullTableIndex);
0N/A }
0N/A for (int j = 0; j < len; j++) {
0N/A jint match_int = lo_index+j;
0N/A int dest = iter().get_dest_table(j+3);
0N/A makes_backward_branch |= (dest <= bci());
0N/A int table_index = method_data_update() ? j : NullTableIndex;
0N/A if (rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index)) {
0N/A ranges[++rp].set(match_int, dest, table_index);
0N/A }
0N/A }
0N/A jint highest = lo_index+(len-1);
0N/A assert(ranges[rp].hi() == highest, "");
0N/A if (highest != max_jint
0N/A && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex)) {
0N/A ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex);
0N/A }
0N/A assert(rp < len+2, "not too many ranges");
0N/A
0N/A // Safepoint in case if backward branch observed
0N/A if( makes_backward_branch && UseLoopSafepoints )
0N/A add_safepoint();
0N/A
0N/A jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
0N/A}
0N/A
0N/A
0N/A//------------------------------do_lookupswitch--------------------------------
0N/Avoid Parse::do_lookupswitch() {
0N/A Node *lookup = pop(); // lookup value
0N/A // Get information about lookupswitch
0N/A int default_dest = iter().get_dest_table(0);
0N/A int len = iter().get_int_table(1);
0N/A
0N/A if (len < 1) { // If this is a backward branch, add safepoint
0N/A maybe_add_safepoint(default_dest);
0N/A merge(default_dest);
0N/A return;
0N/A }
0N/A
0N/A // generate decision tree, using trichotomy when possible
0N/A jint* table = NEW_RESOURCE_ARRAY(jint, len*2);
0N/A {
0N/A for( int j = 0; j < len; j++ ) {
0N/A table[j+j+0] = iter().get_int_table(2+j+j);
0N/A table[j+j+1] = iter().get_dest_table(2+j+j+1);
0N/A }
0N/A qsort( table, len, 2*sizeof(table[0]), jint_cmp );
0N/A }
0N/A
0N/A int rnum = len*2+1;
0N/A bool makes_backward_branch = false;
0N/A SwitchRange* ranges = NEW_RESOURCE_ARRAY(SwitchRange, rnum);
0N/A int rp = -1;
0N/A for( int j = 0; j < len; j++ ) {
0N/A jint match_int = table[j+j+0];
0N/A int dest = table[j+j+1];
0N/A int next_lo = rp < 0 ? min_jint : ranges[rp].hi()+1;
0N/A int table_index = method_data_update() ? j : NullTableIndex;
0N/A makes_backward_branch |= (dest <= bci());
0N/A if( match_int != next_lo ) {
0N/A ranges[++rp].setRange(next_lo, match_int-1, default_dest, NullTableIndex);
0N/A }
0N/A if( rp < 0 || !ranges[rp].adjoin(match_int, dest, table_index) ) {
0N/A ranges[++rp].set(match_int, dest, table_index);
0N/A }
0N/A }
0N/A jint highest = table[2*(len-1)];
0N/A assert(ranges[rp].hi() == highest, "");
0N/A if( highest != max_jint
0N/A && !ranges[rp].adjoinRange(highest+1, max_jint, default_dest, NullTableIndex) ) {
0N/A ranges[++rp].setRange(highest+1, max_jint, default_dest, NullTableIndex);
0N/A }
0N/A assert(rp < rnum, "not too many ranges");
0N/A
0N/A // Safepoint in case backward branch observed
0N/A if( makes_backward_branch && UseLoopSafepoints )
0N/A add_safepoint();
0N/A
0N/A jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
0N/A}
0N/A
0N/A//----------------------------create_jump_tables-------------------------------
0N/Abool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) {
0N/A // Are jumptables enabled
0N/A if (!UseJumpTables) return false;
0N/A
0N/A // Are jumptables supported
0N/A if (!Matcher::has_match_rule(Op_Jump)) return false;
0N/A
0N/A // Don't make jump table if profiling
0N/A if (method_data_update()) return false;
0N/A
0N/A // Decide if a guard is needed to lop off big ranges at either (or
0N/A // both) end(s) of the input set. We'll call this the default target
0N/A // even though we can't be sure that it is the true "default".
0N/A
0N/A bool needs_guard = false;
0N/A int default_dest;
0N/A int64 total_outlier_size = 0;
0N/A int64 hi_size = ((int64)hi->hi()) - ((int64)hi->lo()) + 1;
0N/A int64 lo_size = ((int64)lo->hi()) - ((int64)lo->lo()) + 1;
0N/A
0N/A if (lo->dest() == hi->dest()) {
0N/A total_outlier_size = hi_size + lo_size;
0N/A default_dest = lo->dest();
0N/A } else if (lo_size > hi_size) {
0N/A total_outlier_size = lo_size;
0N/A default_dest = lo->dest();
0N/A } else {
0N/A total_outlier_size = hi_size;
0N/A default_dest = hi->dest();
0N/A }
0N/A
0N/A // If a guard test will eliminate very sparse end ranges, then
0N/A // it is worth the cost of an extra jump.
0N/A if (total_outlier_size > (MaxJumpTableSparseness * 4)) {
0N/A needs_guard = true;
0N/A if (default_dest == lo->dest()) lo++;
0N/A if (default_dest == hi->dest()) hi--;
0N/A }
0N/A
0N/A // Find the total number of cases and ranges
0N/A int64 num_cases = ((int64)hi->hi()) - ((int64)lo->lo()) + 1;
0N/A int num_range = hi - lo + 1;
0N/A
0N/A // Don't create table if: too large, too small, or too sparse.
0N/A if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize)
0N/A return false;
0N/A if (num_cases > (MaxJumpTableSparseness * num_range))
0N/A return false;
0N/A
0N/A // Normalize table lookups to zero
0N/A int lowval = lo->lo();
4022N/A key_val = _gvn.transform( new (C) SubINode(key_val, _gvn.intcon(lowval)) );
0N/A
0N/A // Generate a guard to protect against input keyvals that aren't
0N/A // in the switch domain.
0N/A if (needs_guard) {
0N/A Node* size = _gvn.intcon(num_cases);
4022N/A Node* cmp = _gvn.transform( new (C) CmpUNode(key_val, size) );
4022N/A Node* tst = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ge) );
0N/A IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN);
0N/A jump_if_true_fork(iff, default_dest, NullTableIndex);
0N/A }
0N/A
0N/A // Create an ideal node JumpTable that has projections
0N/A // of all possible ranges for a switch statement
0N/A // The key_val input must be converted to a pointer offset and scaled.
0N/A // Compare Parse::array_addressing above.
0N/A#ifdef _LP64
0N/A // Clean the 32-bit int into a real 64-bit offset.
0N/A // Otherwise, the jint value 0 might turn into an offset of 0x0800000000.
0N/A const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin);
4022N/A key_val = _gvn.transform( new (C) ConvI2LNode(key_val, lkeytype) );
0N/A#endif
0N/A // Shift the value by wordsize so we have an index into the table, rather
0N/A // than a switch value
0N/A Node *shiftWord = _gvn.MakeConX(wordSize);
4022N/A key_val = _gvn.transform( new (C) MulXNode( key_val, shiftWord));
0N/A
0N/A // Create the JumpNode
4022N/A Node* jtn = _gvn.transform( new (C) JumpNode(control(), key_val, num_cases) );
0N/A
0N/A // These are the switch destinations hanging off the jumpnode
0N/A int i = 0;
0N/A for (SwitchRange* r = lo; r <= hi; r++) {
0N/A for (int j = r->lo(); j <= r->hi(); j++, i++) {
4022N/A Node* input = _gvn.transform(new (C) JumpProjNode(jtn, i, r->dest(), j - lowval));
0N/A {
0N/A PreserveJVMState pjvms(this);
0N/A set_control(input);
0N/A jump_if_always_fork(r->dest(), r->table_index());
0N/A }
0N/A }
0N/A }
0N/A assert(i == num_cases, "miscount of cases");
0N/A stop_and_kill_map(); // no more uses for this JVMS
0N/A return true;
0N/A}
0N/A
0N/A//----------------------------jump_switch_ranges-------------------------------
0N/Avoid Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) {
0N/A Block* switch_block = block();
0N/A
0N/A if (switch_depth == 0) {
0N/A // Do special processing for the top-level call.
0N/A assert(lo->lo() == min_jint, "initial range must exhaust Type::INT");
0N/A assert(hi->hi() == max_jint, "initial range must exhaust Type::INT");
0N/A
0N/A // Decrement pred-numbers for the unique set of nodes.
0N/A#ifdef ASSERT
0N/A // Ensure that the block's successors are a (duplicate-free) set.
0N/A int successors_counted = 0; // block occurrences in [hi..lo]
0N/A int unique_successors = switch_block->num_successors();
0N/A for (int i = 0; i < unique_successors; i++) {
0N/A Block* target = switch_block->successor_at(i);
0N/A
0N/A // Check that the set of successors is the same in both places.
0N/A int successors_found = 0;
0N/A for (SwitchRange* p = lo; p <= hi; p++) {
0N/A if (p->dest() == target->start()) successors_found++;
0N/A }
0N/A assert(successors_found > 0, "successor must be known");
0N/A successors_counted += successors_found;
0N/A }
0N/A assert(successors_counted == (hi-lo)+1, "no unexpected successors");
0N/A#endif
0N/A
0N/A // Maybe prune the inputs, based on the type of key_val.
0N/A jint min_val = min_jint;
0N/A jint max_val = max_jint;
0N/A const TypeInt* ti = key_val->bottom_type()->isa_int();
0N/A if (ti != NULL) {
0N/A min_val = ti->_lo;
0N/A max_val = ti->_hi;
0N/A assert(min_val <= max_val, "invalid int type");
0N/A }
0N/A while (lo->hi() < min_val) lo++;
0N/A if (lo->lo() < min_val) lo->setRange(min_val, lo->hi(), lo->dest(), lo->table_index());
0N/A while (hi->lo() > max_val) hi--;
0N/A if (hi->hi() > max_val) hi->setRange(hi->lo(), max_val, hi->dest(), hi->table_index());
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A if (switch_depth == 0) {
0N/A _max_switch_depth = 0;
0N/A _est_switch_depth = log2_intptr((hi-lo+1)-1)+1;
0N/A }
0N/A#endif
0N/A
0N/A assert(lo <= hi, "must be a non-empty set of ranges");
0N/A if (lo == hi) {
0N/A jump_if_always_fork(lo->dest(), lo->table_index());
0N/A } else {
0N/A assert(lo->hi() == (lo+1)->lo()-1, "contiguous ranges");
0N/A assert(hi->lo() == (hi-1)->hi()+1, "contiguous ranges");
0N/A
0N/A if (create_jump_tables(key_val, lo, hi)) return;
0N/A
0N/A int nr = hi - lo + 1;
0N/A
0N/A SwitchRange* mid = lo + nr/2;
0N/A // if there is an easy choice, pivot at a singleton:
0N/A if (nr > 3 && !mid->is_singleton() && (mid-1)->is_singleton()) mid--;
0N/A
0N/A assert(lo < mid && mid <= hi, "good pivot choice");
0N/A assert(nr != 2 || mid == hi, "should pick higher of 2");
0N/A assert(nr != 3 || mid == hi-1, "should pick middle of 3");
0N/A
0N/A Node *test_val = _gvn.intcon(mid->lo());
0N/A
0N/A if (mid->is_singleton()) {
0N/A IfNode *iff_ne = jump_if_fork_int(key_val, test_val, BoolTest::ne);
0N/A jump_if_false_fork(iff_ne, mid->dest(), mid->table_index());
0N/A
0N/A // Special Case: If there are exactly three ranges, and the high
0N/A // and low range each go to the same place, omit the "gt" test,
0N/A // since it will not discriminate anything.
0N/A bool eq_test_only = (hi == lo+2 && hi->dest() == lo->dest());
0N/A if (eq_test_only) {
0N/A assert(mid == hi-1, "");
0N/A }
0N/A
0N/A // if there is a higher range, test for it and process it:
0N/A if (mid < hi && !eq_test_only) {
0N/A // two comparisons of same values--should enable 1 test for 2 branches
0N/A // Use BoolTest::le instead of BoolTest::gt
0N/A IfNode *iff_le = jump_if_fork_int(key_val, test_val, BoolTest::le);
4022N/A Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_le) );
4022N/A Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_le) );
0N/A { PreserveJVMState pjvms(this);
0N/A set_control(iffalse);
0N/A jump_switch_ranges(key_val, mid+1, hi, switch_depth+1);
0N/A }
0N/A set_control(iftrue);
0N/A }
0N/A
0N/A } else {
0N/A // mid is a range, not a singleton, so treat mid..hi as a unit
0N/A IfNode *iff_ge = jump_if_fork_int(key_val, test_val, BoolTest::ge);
0N/A
0N/A // if there is a higher range, test for it and process it:
0N/A if (mid == hi) {
0N/A jump_if_true_fork(iff_ge, mid->dest(), mid->table_index());
0N/A } else {
4022N/A Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_ge) );
4022N/A Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_ge) );
0N/A { PreserveJVMState pjvms(this);
0N/A set_control(iftrue);
0N/A jump_switch_ranges(key_val, mid, hi, switch_depth+1);
0N/A }
0N/A set_control(iffalse);
0N/A }
0N/A }
0N/A
0N/A // in any case, process the lower range
0N/A jump_switch_ranges(key_val, lo, mid-1, switch_depth+1);
0N/A }
0N/A
0N/A // Decrease pred_count for each successor after all is done.
0N/A if (switch_depth == 0) {
0N/A int unique_successors = switch_block->num_successors();
0N/A for (int i = 0; i < unique_successors; i++) {
0N/A Block* target = switch_block->successor_at(i);
0N/A // Throw away the pre-allocated path for each unique successor.
0N/A target->next_path_num();
0N/A }
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A _max_switch_depth = MAX2(switch_depth, _max_switch_depth);
0N/A if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) {
0N/A SwitchRange* r;
0N/A int nsing = 0;
0N/A for( r = lo; r <= hi; r++ ) {
0N/A if( r->is_singleton() ) nsing++;
0N/A }
0N/A tty->print(">>> ");
0N/A _method->print_short_name();
0N/A tty->print_cr(" switch decision tree");
0N/A tty->print_cr(" %d ranges (%d singletons), max_depth=%d, est_depth=%d",
0N/A hi-lo+1, nsing, _max_switch_depth, _est_switch_depth);
0N/A if (_max_switch_depth > _est_switch_depth) {
0N/A tty->print_cr("******** BAD SWITCH DEPTH ********");
0N/A }
0N/A tty->print(" ");
0N/A for( r = lo; r <= hi; r++ ) {
0N/A r->print(env());
0N/A }
0N/A tty->print_cr("");
0N/A }
0N/A#endif
0N/A}
0N/A
0N/Avoid Parse::modf() {
0N/A Node *f2 = pop();
0N/A Node *f1 = pop();
0N/A Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(),
0N/A CAST_FROM_FN_PTR(address, SharedRuntime::frem),
0N/A "frem", NULL, //no memory effects
0N/A f1, f2);
4022N/A Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0));
0N/A
0N/A push(res);
0N/A}
0N/A
0N/Avoid Parse::modd() {
0N/A Node *d2 = pop_pair();
0N/A Node *d1 = pop_pair();
0N/A Node* c = make_runtime_call(RC_LEAF, OptoRuntime::Math_DD_D_Type(),
0N/A CAST_FROM_FN_PTR(address, SharedRuntime::drem),
0N/A "drem", NULL, //no memory effects
0N/A d1, top(), d2, top());
4022N/A Node* res_d = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0));
0N/A
0N/A#ifdef ASSERT
4022N/A Node* res_top = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 1));
0N/A assert(res_top == top(), "second value must be top");
0N/A#endif
0N/A
0N/A push_pair(res_d);
0N/A}
0N/A
0N/Avoid Parse::l2f() {
0N/A Node* f2 = pop();
0N/A Node* f1 = pop();
0N/A Node* c = make_runtime_call(RC_LEAF, OptoRuntime::l2f_Type(),
0N/A CAST_FROM_FN_PTR(address, SharedRuntime::l2f),
0N/A "l2f", NULL, //no memory effects
0N/A f1, f2);
4022N/A Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0));
0N/A
0N/A push(res);
0N/A}
0N/A
0N/Avoid Parse::do_irem() {
0N/A // Must keep both values on the expression-stack during null-check
4122N/A zero_check_int(peek());
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return;
0N/A
0N/A Node* b = pop();
0N/A Node* a = pop();
0N/A
0N/A const Type *t = _gvn.type(b);
0N/A if (t != Type::TOP) {
0N/A const TypeInt *ti = t->is_int();
0N/A if (ti->is_con()) {
0N/A int divisor = ti->get_con();
0N/A // check for positive power of 2
0N/A if (divisor > 0 &&
0N/A (divisor & ~(divisor-1)) == divisor) {
0N/A // yes !
0N/A Node *mask = _gvn.intcon((divisor - 1));
0N/A // Sigh, must handle negative dividends
0N/A Node *zero = _gvn.intcon(0);
0N/A IfNode *ifff = jump_if_fork_int(a, zero, BoolTest::lt);
4022N/A Node *iff = _gvn.transform( new (C) IfFalseNode(ifff) );
4022N/A Node *ift = _gvn.transform( new (C) IfTrueNode (ifff) );
0N/A Node *reg = jump_if_join(ift, iff);
0N/A Node *phi = PhiNode::make(reg, NULL, TypeInt::INT);
0N/A // Negative path; negate/and/negate
4022N/A Node *neg = _gvn.transform( new (C) SubINode(zero, a) );
4022N/A Node *andn= _gvn.transform( new (C) AndINode(neg, mask) );
4022N/A Node *negn= _gvn.transform( new (C) SubINode(zero, andn) );
0N/A phi->init_req(1, negn);
0N/A // Fast positive case
4022N/A Node *andx = _gvn.transform( new (C) AndINode(a, mask) );
0N/A phi->init_req(2, andx);
0N/A // Push the merge
0N/A push( _gvn.transform(phi) );
0N/A return;
0N/A }
0N/A }
0N/A }
0N/A // Default case
4022N/A push( _gvn.transform( new (C) ModINode(control(),a,b) ) );
0N/A}
0N/A
0N/A// Handle jsr and jsr_w bytecode
0N/Avoid Parse::do_jsr() {
0N/A assert(bc() == Bytecodes::_jsr || bc() == Bytecodes::_jsr_w, "wrong bytecode");
0N/A
0N/A // Store information about current state, tagged with new _jsr_bci
0N/A int return_bci = iter().next_bci();
0N/A int jsr_bci = (bc() == Bytecodes::_jsr) ? iter().get_dest() : iter().get_far_dest();
0N/A
0N/A // Update method data
0N/A profile_taken_branch(jsr_bci);
0N/A
0N/A // The way we do things now, there is only one successor block
0N/A // for the jsr, because the target code is cloned by ciTypeFlow.
0N/A Block* target = successor_for_bci(jsr_bci);
0N/A
0N/A // What got pushed?
0N/A const Type* ret_addr = target->peek();
0N/A assert(ret_addr->singleton(), "must be a constant (cloned jsr body)");
0N/A
0N/A // Effect on jsr on stack
0N/A push(_gvn.makecon(ret_addr));
0N/A
0N/A // Flow to the jsr.
0N/A merge(jsr_bci);
0N/A}
0N/A
0N/A// Handle ret bytecode
0N/Avoid Parse::do_ret() {
0N/A // Find to whom we return.
0N/A assert(block()->num_successors() == 1, "a ret can only go one place now");
0N/A Block* target = block()->successor_at(0);
0N/A assert(!target->is_ready(), "our arrival must be expected");
0N/A profile_ret(target->flow()->start());
0N/A int pnum = target->next_path_num();
0N/A merge_common(target, pnum);
0N/A}
0N/A
0N/A//--------------------------dynamic_branch_prediction--------------------------
0N/A// Try to gather dynamic branch prediction behavior. Return a probability
0N/A// of the branch being taken and set the "cnt" field. Returns a -1.0
0N/A// if we need to use static prediction for some reason.
0N/Afloat Parse::dynamic_branch_prediction(float &cnt) {
0N/A ResourceMark rm;
0N/A
0N/A cnt = COUNT_UNKNOWN;
0N/A
0N/A // Use MethodData information if it is available
0N/A // FIXME: free the ProfileData structure
0N/A ciMethodData* methodData = method()->method_data();
0N/A if (!methodData->is_mature()) return PROB_UNKNOWN;
0N/A ciProfileData* data = methodData->bci_to_data(bci());
0N/A if (!data->is_JumpData()) return PROB_UNKNOWN;
0N/A
0N/A // get taken and not taken values
0N/A int taken = data->as_JumpData()->taken();
0N/A int not_taken = 0;
0N/A if (data->is_BranchData()) {
0N/A not_taken = data->as_BranchData()->not_taken();
0N/A }
0N/A
0N/A // scale the counts to be commensurate with invocation counts:
0N/A taken = method()->scale_count(taken);
0N/A not_taken = method()->scale_count(not_taken);
0N/A
2328N/A // Give up if too few (or too many, in which case the sum will overflow) counts to be meaningful.
2328N/A // We also check that individual counters are positive first, overwise the sum can become positive.
2328N/A if (taken < 0 || not_taken < 0 || taken + not_taken < 40) {
0N/A if (C->log() != NULL) {
0N/A C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken);
0N/A }
0N/A return PROB_UNKNOWN;
0N/A }
0N/A
0N/A // Compute frequency that we arrive here
2328N/A float sum = taken + not_taken;
0N/A // Adjust, if this block is a cloned private block but the
0N/A // Jump counts are shared. Taken the private counts for
0N/A // just this path instead of the shared counts.
0N/A if( block()->count() > 0 )
0N/A sum = block()->count();
2328N/A cnt = sum / FreqCountInvocations;
0N/A
0N/A // Pin probability to sane limits
0N/A float prob;
0N/A if( !taken )
0N/A prob = (0+PROB_MIN) / 2;
0N/A else if( !not_taken )
0N/A prob = (1+PROB_MAX) / 2;
0N/A else { // Compute probability of true path
0N/A prob = (float)taken / (float)(taken + not_taken);
0N/A if (prob > PROB_MAX) prob = PROB_MAX;
0N/A if (prob < PROB_MIN) prob = PROB_MIN;
0N/A }
0N/A
0N/A assert((cnt > 0.0f) && (prob > 0.0f),
0N/A "Bad frequency assignment in if");
0N/A
0N/A if (C->log() != NULL) {
0N/A const char* prob_str = NULL;
0N/A if (prob >= PROB_MAX) prob_str = (prob == PROB_MAX) ? "max" : "always";
0N/A if (prob <= PROB_MIN) prob_str = (prob == PROB_MIN) ? "min" : "never";
0N/A char prob_str_buf[30];
0N/A if (prob_str == NULL) {
0N/A sprintf(prob_str_buf, "%g", prob);
0N/A prob_str = prob_str_buf;
0N/A }
0N/A C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d' cnt='%g' prob='%s'",
0N/A iter().get_dest(), taken, not_taken, cnt, prob_str);
0N/A }
0N/A return prob;
0N/A}
0N/A
0N/A//-----------------------------branch_prediction-------------------------------
0N/Afloat Parse::branch_prediction(float& cnt,
0N/A BoolTest::mask btest,
0N/A int target_bci) {
0N/A float prob = dynamic_branch_prediction(cnt);
0N/A // If prob is unknown, switch to static prediction
0N/A if (prob != PROB_UNKNOWN) return prob;
0N/A
0N/A prob = PROB_FAIR; // Set default value
0N/A if (btest == BoolTest::eq) // Exactly equal test?
0N/A prob = PROB_STATIC_INFREQUENT; // Assume its relatively infrequent
0N/A else if (btest == BoolTest::ne)
0N/A prob = PROB_STATIC_FREQUENT; // Assume its relatively frequent
0N/A
0N/A // If this is a conditional test guarding a backwards branch,
0N/A // assume its a loop-back edge. Make it a likely taken branch.
0N/A if (target_bci < bci()) {
0N/A if (is_osr_parse()) { // Could be a hot OSR'd loop; force deopt
0N/A // Since it's an OSR, we probably have profile data, but since
0N/A // branch_prediction returned PROB_UNKNOWN, the counts are too small.
0N/A // Let's make a special check here for completely zero counts.
0N/A ciMethodData* methodData = method()->method_data();
0N/A if (!methodData->is_empty()) {
0N/A ciProfileData* data = methodData->bci_to_data(bci());
0N/A // Only stop for truly zero counts, which mean an unknown part
0N/A // of the OSR-ed method, and we want to deopt to gather more stats.
0N/A // If you have ANY counts, then this loop is simply 'cold' relative
0N/A // to the OSR loop.
0N/A if (data->as_BranchData()->taken() +
0N/A data->as_BranchData()->not_taken() == 0 ) {
0N/A // This is the only way to return PROB_UNKNOWN:
0N/A return PROB_UNKNOWN;
0N/A }
0N/A }
0N/A }
0N/A prob = PROB_STATIC_FREQUENT; // Likely to take backwards branch
0N/A }
0N/A
0N/A assert(prob != PROB_UNKNOWN, "must have some guess at this point");
0N/A return prob;
0N/A}
0N/A
0N/A// The magic constants are chosen so as to match the output of
0N/A// branch_prediction() when the profile reports a zero taken count.
0N/A// It is important to distinguish zero counts unambiguously, because
0N/A// some branches (e.g., _213_javac.Assembler.eliminate) validly produce
0N/A// very small but nonzero probabilities, which if confused with zero
0N/A// counts would keep the program recompiling indefinitely.
0N/Abool Parse::seems_never_taken(float prob) {
0N/A return prob < PROB_MIN;
0N/A}
0N/A
1666N/A// True if the comparison seems to be the kind that will not change its
1666N/A// statistics from true to false. See comments in adjust_map_after_if.
1666N/A// This question is only asked along paths which are already
1666N/A// classifed as untaken (by seems_never_taken), so really,
1666N/A// if a path is never taken, its controlling comparison is
1666N/A// already acting in a stable fashion. If the comparison
1666N/A// seems stable, we will put an expensive uncommon trap
1666N/A// on the untaken path. To be conservative, and to allow
1666N/A// partially executed counted loops to be compiled fully,
1666N/A// we will plant uncommon traps only after pointer comparisons.
1666N/Abool Parse::seems_stable_comparison(BoolTest::mask btest, Node* cmp) {
1666N/A for (int depth = 4; depth > 0; depth--) {
1666N/A // The following switch can find CmpP here over half the time for
1666N/A // dynamic language code rich with type tests.
1666N/A // Code using counted loops or array manipulations (typical
1666N/A // of benchmarks) will have many (>80%) CmpI instructions.
1666N/A switch (cmp->Opcode()) {
1666N/A case Op_CmpP:
1666N/A // A never-taken null check looks like CmpP/BoolTest::eq.
1666N/A // These certainly should be closed off as uncommon traps.
1666N/A if (btest == BoolTest::eq)
1666N/A return true;
1666N/A // A never-failed type check looks like CmpP/BoolTest::ne.
1666N/A // Let's put traps on those, too, so that we don't have to compile
1666N/A // unused paths with indeterminate dynamic type information.
1666N/A if (ProfileDynamicTypes)
1666N/A return true;
1666N/A return false;
1666N/A
1666N/A case Op_CmpI:
1666N/A // A small minority (< 10%) of CmpP are masked as CmpI,
1666N/A // as if by boolean conversion ((p == q? 1: 0) != 0).
1666N/A // Detect that here, even if it hasn't optimized away yet.
1666N/A // Specifically, this covers the 'instanceof' operator.
1666N/A if (btest == BoolTest::ne || btest == BoolTest::eq) {
1666N/A if (_gvn.type(cmp->in(2))->singleton() &&
1666N/A cmp->in(1)->is_Phi()) {
1666N/A PhiNode* phi = cmp->in(1)->as_Phi();
1666N/A int true_path = phi->is_diamond_phi();
1666N/A if (true_path > 0 &&
1666N/A _gvn.type(phi->in(1))->singleton() &&
1666N/A _gvn.type(phi->in(2))->singleton()) {
1666N/A // phi->region->if_proj->ifnode->bool->cmp
1666N/A BoolNode* bol = phi->in(0)->in(1)->in(0)->in(1)->as_Bool();
1666N/A btest = bol->_test._test;
1666N/A cmp = bol->in(1);
1666N/A continue;
1666N/A }
1666N/A }
1666N/A }
1666N/A return false;
1666N/A }
1666N/A }
1666N/A return false;
1666N/A}
1666N/A
246N/A//-------------------------------repush_if_args--------------------------------
246N/A// Push arguments of an "if" bytecode back onto the stack by adjusting _sp.
1172N/Ainline int Parse::repush_if_args() {
0N/A#ifndef PRODUCT
0N/A if (PrintOpto && WizardMode) {
0N/A tty->print("defending against excessive implicit null exceptions on %s @%d in ",
0N/A Bytecodes::name(iter().cur_bc()), iter().cur_bci());
0N/A method()->print_name(); tty->cr();
0N/A }
0N/A#endif
0N/A int bc_depth = - Bytecodes::depth(iter().cur_bc());
0N/A assert(bc_depth == 1 || bc_depth == 2, "only two kinds of branches");
0N/A DEBUG_ONLY(sync_jvms()); // argument(n) requires a synced jvms
0N/A assert(argument(0) != NULL, "must exist");
0N/A assert(bc_depth == 1 || argument(1) != NULL, "two must exist");
4122N/A inc_sp(bc_depth);
1172N/A return bc_depth;
0N/A}
0N/A
0N/A//----------------------------------do_ifnull----------------------------------
248N/Avoid Parse::do_ifnull(BoolTest::mask btest, Node *c) {
0N/A int target_bci = iter().get_dest();
0N/A
17N/A Block* branch_block = successor_for_bci(target_bci);
17N/A Block* next_block = successor_for_bci(iter().next_bci());
17N/A
0N/A float cnt;
0N/A float prob = branch_prediction(cnt, btest, target_bci);
0N/A if (prob == PROB_UNKNOWN) {
0N/A // (An earlier version of do_ifnull omitted this trap for OSR methods.)
0N/A#ifndef PRODUCT
0N/A if (PrintOpto && Verbose)
248N/A tty->print_cr("Never-taken edge stops compilation at bci %d",bci());
0N/A#endif
248N/A repush_if_args(); // to gather stats on loop
0N/A // We need to mark this branch as taken so that if we recompile we will
0N/A // see that it is possible. In the tiered system the interpreter doesn't
0N/A // do profiling and by the time we get to the lower tier from the interpreter
0N/A // the path may be cold again. Make sure it doesn't look untaken
0N/A profile_taken_branch(target_bci, !ProfileInterpreter);
0N/A uncommon_trap(Deoptimization::Reason_unreached,
0N/A Deoptimization::Action_reinterpret,
0N/A NULL, "cold");
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor blocks as parsed
17N/A branch_block->next_path_num();
17N/A next_block->next_path_num();
17N/A }
0N/A return;
0N/A }
0N/A
0N/A explicit_null_checks_inserted++;
0N/A
0N/A // Generate real control flow
4022N/A Node *tst = _gvn.transform( new (C) BoolNode( c, btest ) );
0N/A
0N/A // Sanity check the probability value
0N/A assert(prob > 0.0f,"Bad probability in Parser");
0N/A // Need xform to put node in hash table
0N/A IfNode *iff = create_and_xform_if( control(), tst, prob, cnt );
0N/A assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
0N/A // True branch
0N/A { PreserveJVMState pjvms(this);
4022N/A Node* iftrue = _gvn.transform( new (C) IfTrueNode (iff) );
0N/A set_control(iftrue);
0N/A
0N/A if (stopped()) { // Path is dead?
0N/A explicit_null_checks_elided++;
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor block as parsed
17N/A branch_block->next_path_num();
17N/A }
0N/A } else { // Path is live.
0N/A // Update method data
0N/A profile_taken_branch(target_bci);
0N/A adjust_map_after_if(btest, c, prob, branch_block, next_block);
1172N/A if (!stopped()) {
0N/A merge(target_bci);
1172N/A }
0N/A }
0N/A }
0N/A
0N/A // False branch
4022N/A Node* iffalse = _gvn.transform( new (C) IfFalseNode(iff) );
0N/A set_control(iffalse);
0N/A
0N/A if (stopped()) { // Path is dead?
0N/A explicit_null_checks_elided++;
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor block as parsed
17N/A next_block->next_path_num();
17N/A }
0N/A } else { // Path is live.
0N/A // Update method data
0N/A profile_not_taken_branch();
0N/A adjust_map_after_if(BoolTest(btest).negate(), c, 1.0-prob,
0N/A next_block, branch_block);
0N/A }
0N/A}
0N/A
0N/A//------------------------------------do_if------------------------------------
0N/Avoid Parse::do_if(BoolTest::mask btest, Node* c) {
0N/A int target_bci = iter().get_dest();
0N/A
17N/A Block* branch_block = successor_for_bci(target_bci);
17N/A Block* next_block = successor_for_bci(iter().next_bci());
17N/A
0N/A float cnt;
0N/A float prob = branch_prediction(cnt, btest, target_bci);
0N/A float untaken_prob = 1.0 - prob;
0N/A
0N/A if (prob == PROB_UNKNOWN) {
0N/A#ifndef PRODUCT
0N/A if (PrintOpto && Verbose)
248N/A tty->print_cr("Never-taken edge stops compilation at bci %d",bci());
0N/A#endif
0N/A repush_if_args(); // to gather stats on loop
0N/A // We need to mark this branch as taken so that if we recompile we will
0N/A // see that it is possible. In the tiered system the interpreter doesn't
0N/A // do profiling and by the time we get to the lower tier from the interpreter
0N/A // the path may be cold again. Make sure it doesn't look untaken
0N/A profile_taken_branch(target_bci, !ProfileInterpreter);
0N/A uncommon_trap(Deoptimization::Reason_unreached,
0N/A Deoptimization::Action_reinterpret,
0N/A NULL, "cold");
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor blocks as parsed
17N/A branch_block->next_path_num();
17N/A next_block->next_path_num();
17N/A }
0N/A return;
0N/A }
0N/A
0N/A // Sanity check the probability value
0N/A assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser");
0N/A
0N/A bool taken_if_true = true;
0N/A // Convert BoolTest to canonical form:
0N/A if (!BoolTest(btest).is_canonical()) {
0N/A btest = BoolTest(btest).negate();
0N/A taken_if_true = false;
0N/A // prob is NOT updated here; it remains the probability of the taken
0N/A // path (as opposed to the prob of the path guarded by an 'IfTrueNode').
0N/A }
0N/A assert(btest != BoolTest::eq, "!= is the only canonical exact test");
0N/A
4022N/A Node* tst0 = new (C) BoolNode(c, btest);
0N/A Node* tst = _gvn.transform(tst0);
0N/A BoolTest::mask taken_btest = BoolTest::illegal;
0N/A BoolTest::mask untaken_btest = BoolTest::illegal;
37N/A
37N/A if (tst->is_Bool()) {
37N/A // Refresh c from the transformed bool node, since it may be
37N/A // simpler than the original c. Also re-canonicalize btest.
37N/A // This wins when (Bool ne (Conv2B p) 0) => (Bool ne (CmpP p NULL)).
37N/A // That can arise from statements like: if (x instanceof C) ...
37N/A if (tst != tst0) {
37N/A // Canonicalize one more time since transform can change it.
37N/A btest = tst->as_Bool()->_test._test;
37N/A if (!BoolTest(btest).is_canonical()) {
37N/A // Reverse edges one more time...
37N/A tst = _gvn.transform( tst->as_Bool()->negate(&_gvn) );
37N/A btest = tst->as_Bool()->_test._test;
37N/A assert(BoolTest(btest).is_canonical(), "sanity");
37N/A taken_if_true = !taken_if_true;
37N/A }
37N/A c = tst->in(1);
37N/A }
37N/A BoolTest::mask neg_btest = BoolTest(btest).negate();
37N/A taken_btest = taken_if_true ? btest : neg_btest;
37N/A untaken_btest = taken_if_true ? neg_btest : btest;
0N/A }
0N/A
0N/A // Generate real control flow
0N/A float true_prob = (taken_if_true ? prob : untaken_prob);
0N/A IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt);
0N/A assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
4022N/A Node* taken_branch = new (C) IfTrueNode(iff);
4022N/A Node* untaken_branch = new (C) IfFalseNode(iff);
0N/A if (!taken_if_true) { // Finish conversion to canonical form
0N/A Node* tmp = taken_branch;
0N/A taken_branch = untaken_branch;
0N/A untaken_branch = tmp;
0N/A }
0N/A
0N/A // Branch is taken:
0N/A { PreserveJVMState pjvms(this);
0N/A taken_branch = _gvn.transform(taken_branch);
0N/A set_control(taken_branch);
0N/A
17N/A if (stopped()) {
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor block as parsed
17N/A branch_block->next_path_num();
17N/A }
17N/A } else {
0N/A // Update method data
0N/A profile_taken_branch(target_bci);
0N/A adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
1172N/A if (!stopped()) {
0N/A merge(target_bci);
1172N/A }
0N/A }
0N/A }
0N/A
0N/A untaken_branch = _gvn.transform(untaken_branch);
0N/A set_control(untaken_branch);
0N/A
0N/A // Branch not taken.
17N/A if (stopped()) {
17N/A if (EliminateAutoBox) {
17N/A // Mark the successor block as parsed
17N/A next_block->next_path_num();
17N/A }
17N/A } else {
0N/A // Update method data
0N/A profile_not_taken_branch();
0N/A adjust_map_after_if(untaken_btest, c, untaken_prob,
0N/A next_block, branch_block);
0N/A }
0N/A}
0N/A
0N/A//----------------------------adjust_map_after_if------------------------------
0N/A// Adjust the JVM state to reflect the result of taking this path.
0N/A// Basically, it means inspecting the CmpNode controlling this
0N/A// branch, seeing how it constrains a tested value, and then
0N/A// deciding if it's worth our while to encode this constraint
0N/A// as graph nodes in the current abstract interpretation map.
0N/Avoid Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
0N/A Block* path, Block* other_path) {
0N/A if (stopped() || !c->is_Cmp() || btest == BoolTest::illegal)
0N/A return; // nothing to do
0N/A
0N/A bool is_fallthrough = (path == successor_for_bci(iter().next_bci()));
0N/A
1666N/A if (seems_never_taken(prob) && seems_stable_comparison(btest, c)) {
0N/A // If this might possibly turn into an implicit null check,
0N/A // and the null has never yet been seen, we need to generate
0N/A // an uncommon trap, so as to recompile instead of suffering
0N/A // with very slow branches. (We'll get the slow branches if
0N/A // the program ever changes phase and starts seeing nulls here.)
0N/A //
1666N/A // We do not inspect for a null constant, since a node may
0N/A // optimize to 'null' later on.
1666N/A //
1666N/A // Null checks, and other tests which expect inequality,
1666N/A // show btest == BoolTest::eq along the non-taken branch.
1666N/A // On the other hand, type tests, must-be-null tests,
1666N/A // and other tests which expect pointer equality,
1666N/A // show btest == BoolTest::ne along the non-taken branch.
1666N/A // We prune both types of branches if they look unused.
0N/A repush_if_args();
0N/A // We need to mark this branch as taken so that if we recompile we will
0N/A // see that it is possible. In the tiered system the interpreter doesn't
0N/A // do profiling and by the time we get to the lower tier from the interpreter
0N/A // the path may be cold again. Make sure it doesn't look untaken
0N/A if (is_fallthrough) {
0N/A profile_not_taken_branch(!ProfileInterpreter);
0N/A } else {
0N/A profile_taken_branch(iter().get_dest(), !ProfileInterpreter);
0N/A }
0N/A uncommon_trap(Deoptimization::Reason_unreached,
0N/A Deoptimization::Action_reinterpret,
0N/A NULL,
0N/A (is_fallthrough ? "taken always" : "taken never"));
0N/A return;
0N/A }
0N/A
0N/A Node* val = c->in(1);
0N/A Node* con = c->in(2);
0N/A const Type* tcon = _gvn.type(con);
0N/A const Type* tval = _gvn.type(val);
0N/A bool have_con = tcon->singleton();
0N/A if (tval->singleton()) {
0N/A if (!have_con) {
0N/A // Swap, so constant is in con.
0N/A con = val;
0N/A tcon = tval;
0N/A val = c->in(2);
0N/A tval = _gvn.type(val);
0N/A btest = BoolTest(btest).commute();
0N/A have_con = true;
0N/A } else {
0N/A // Do we have two constants? Then leave well enough alone.
0N/A have_con = false;
0N/A }
0N/A }
0N/A if (!have_con) // remaining adjustments need a con
0N/A return;
0N/A
3798N/A sharpen_type_after_if(btest, con, tcon, val, tval);
3798N/A}
3798N/A
3798N/A
3798N/Astatic Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) {
3798N/A Node* ldk;
3798N/A if (n->is_DecodeN()) {
3798N/A if (n->in(1)->Opcode() != Op_LoadNKlass) {
3798N/A return NULL;
3798N/A } else {
3798N/A ldk = n->in(1);
3798N/A }
3798N/A } else if (n->Opcode() != Op_LoadKlass) {
3798N/A return NULL;
3798N/A } else {
3798N/A ldk = n;
3798N/A }
3798N/A assert(ldk != NULL && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node");
3798N/A
3798N/A Node* adr = ldk->in(MemNode::Address);
3798N/A intptr_t off = 0;
3798N/A Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off);
3798N/A if (obj == NULL || off != oopDesc::klass_offset_in_bytes()) // loading oopDesc::_klass?
3798N/A return NULL;
3798N/A const TypePtr* tp = gvn->type(obj)->is_ptr();
3798N/A if (tp == NULL || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr?
3798N/A return NULL;
3798N/A
3798N/A return obj;
3798N/A}
3798N/A
3798N/Avoid Parse::sharpen_type_after_if(BoolTest::mask btest,
3798N/A Node* con, const Type* tcon,
3798N/A Node* val, const Type* tval) {
3798N/A // Look for opportunities to sharpen the type of a node
3798N/A // whose klass is compared with a constant klass.
3798N/A if (btest == BoolTest::eq && tcon->isa_klassptr()) {
3798N/A Node* obj = extract_obj_from_klass_load(&_gvn, val);
3798N/A const TypeOopPtr* con_type = tcon->isa_klassptr()->as_instance_type();
3798N/A if (obj != NULL && (con_type->isa_instptr() || con_type->isa_aryptr())) {
3798N/A // Found:
3798N/A // Bool(CmpP(LoadKlass(obj._klass), ConP(Foo.klass)), [eq])
3798N/A // or the narrowOop equivalent.
3798N/A const Type* obj_type = _gvn.type(obj);
3798N/A const TypeOopPtr* tboth = obj_type->join(con_type)->isa_oopptr();
3872N/A if (tboth != NULL && tboth->klass_is_exact() && tboth != obj_type &&
3872N/A tboth->higher_equal(obj_type)) {
3798N/A // obj has to be of the exact type Foo if the CmpP succeeds.
3798N/A int obj_in_map = map()->find_edge(obj);
3798N/A JVMState* jvms = this->jvms();
3798N/A if (obj_in_map >= 0 &&
3798N/A (jvms->is_loc(obj_in_map) || jvms->is_stk(obj_in_map))) {
4022N/A TypeNode* ccast = new (C) CheckCastPPNode(control(), obj, tboth);
3798N/A const Type* tcc = ccast->as_Type()->type();
3798N/A assert(tcc != obj_type && tcc->higher_equal(obj_type), "must improve");
3798N/A // Delay transform() call to allow recovery of pre-cast value
3798N/A // at the control merge.
3798N/A _gvn.set_type_bottom(ccast);
3798N/A record_for_igvn(ccast);
3798N/A // Here's the payoff.
3798N/A replace_in_map(obj, ccast);
3798N/A }
3798N/A }
3798N/A }
3798N/A }
0N/A
0N/A int val_in_map = map()->find_edge(val);
0N/A if (val_in_map < 0) return; // replace_in_map would be useless
0N/A {
0N/A JVMState* jvms = this->jvms();
0N/A if (!(jvms->is_loc(val_in_map) ||
0N/A jvms->is_stk(val_in_map)))
0N/A return; // again, it would be useless
0N/A }
0N/A
0N/A // Check for a comparison to a constant, and "know" that the compared
0N/A // value is constrained on this path.
0N/A assert(tcon->singleton(), "");
0N/A ConstraintCastNode* ccast = NULL;
0N/A Node* cast = NULL;
0N/A
0N/A switch (btest) {
0N/A case BoolTest::eq: // Constant test?
0N/A {
0N/A const Type* tboth = tcon->join(tval);
0N/A if (tboth == tval) break; // Nothing to gain.
0N/A if (tcon->isa_int()) {
4022N/A ccast = new (C) CastIINode(val, tboth);
0N/A } else if (tcon == TypePtr::NULL_PTR) {
0N/A // Cast to null, but keep the pointer identity temporarily live.
4022N/A ccast = new (C) CastPPNode(val, tboth);
0N/A } else {
0N/A const TypeF* tf = tcon->isa_float_constant();
0N/A const TypeD* td = tcon->isa_double_constant();
0N/A // Exclude tests vs float/double 0 as these could be
0N/A // either +0 or -0. Just because you are equal to +0
0N/A // doesn't mean you ARE +0!
3798N/A // Note, following code also replaces Long and Oop values.
0N/A if ((!tf || tf->_f != 0.0) &&
0N/A (!td || td->_d != 0.0))
0N/A cast = con; // Replace non-constant val by con.
0N/A }
0N/A }
0N/A break;
0N/A
0N/A case BoolTest::ne:
0N/A if (tcon == TypePtr::NULL_PTR) {
0N/A cast = cast_not_null(val, false);
0N/A }
0N/A break;
0N/A
0N/A default:
0N/A // (At this point we could record int range types with CastII.)
0N/A break;
0N/A }
0N/A
0N/A if (ccast != NULL) {
0N/A const Type* tcc = ccast->as_Type()->type();
0N/A assert(tcc != tval && tcc->higher_equal(tval), "must improve");
0N/A // Delay transform() call to allow recovery of pre-cast value
0N/A // at the control merge.
0N/A ccast->set_req(0, control());
0N/A _gvn.set_type_bottom(ccast);
0N/A record_for_igvn(ccast);
0N/A cast = ccast;
0N/A }
0N/A
0N/A if (cast != NULL) { // Here's the payoff.
0N/A replace_in_map(val, cast);
0N/A }
0N/A}
0N/A
0N/A
0N/A//------------------------------do_one_bytecode--------------------------------
0N/A// Parse this bytecode, and alter the Parsers JVM->Node mapping
0N/Avoid Parse::do_one_bytecode() {
0N/A Node *a, *b, *c, *d; // Handy temps
0N/A BoolTest::mask btest;
0N/A int i;
0N/A
0N/A assert(!has_exceptions(), "bytecode entry state must be clear of throws");
0N/A
0N/A if (C->check_node_count(NodeLimitFudgeFactor * 5,
0N/A "out of nodes parsing method")) {
0N/A return;
0N/A }
0N/A
0N/A#ifdef ASSERT
0N/A // for setting breakpoints
0N/A if (TraceOptoParse) {
0N/A tty->print(" @");
0N/A dump_bci(bci());
4333N/A tty->cr();
0N/A }
0N/A#endif
0N/A
0N/A switch (bc()) {
0N/A case Bytecodes::_nop:
0N/A // do nothing
0N/A break;
0N/A case Bytecodes::_lconst_0:
0N/A push_pair(longcon(0));
0N/A break;
0N/A
0N/A case Bytecodes::_lconst_1:
0N/A push_pair(longcon(1));
0N/A break;
0N/A
0N/A case Bytecodes::_fconst_0:
0N/A push(zerocon(T_FLOAT));
0N/A break;
0N/A
0N/A case Bytecodes::_fconst_1:
0N/A push(makecon(TypeF::ONE));
0N/A break;
0N/A
0N/A case Bytecodes::_fconst_2:
0N/A push(makecon(TypeF::make(2.0f)));
0N/A break;
0N/A
0N/A case Bytecodes::_dconst_0:
0N/A push_pair(zerocon(T_DOUBLE));
0N/A break;
0N/A
0N/A case Bytecodes::_dconst_1:
0N/A push_pair(makecon(TypeD::ONE));
0N/A break;
0N/A
0N/A case Bytecodes::_iconst_m1:push(intcon(-1)); break;
0N/A case Bytecodes::_iconst_0: push(intcon( 0)); break;
0N/A case Bytecodes::_iconst_1: push(intcon( 1)); break;
0N/A case Bytecodes::_iconst_2: push(intcon( 2)); break;
0N/A case Bytecodes::_iconst_3: push(intcon( 3)); break;
0N/A case Bytecodes::_iconst_4: push(intcon( 4)); break;
0N/A case Bytecodes::_iconst_5: push(intcon( 5)); break;
1485N/A case Bytecodes::_bipush: push(intcon(iter().get_constant_u1())); break;
1485N/A case Bytecodes::_sipush: push(intcon(iter().get_constant_u2())); break;
0N/A case Bytecodes::_aconst_null: push(null()); break;
0N/A case Bytecodes::_ldc:
0N/A case Bytecodes::_ldc_w:
0N/A case Bytecodes::_ldc2_w:
0N/A // If the constant is unresolved, run this BC once in the interpreter.
1522N/A {
0N/A ciConstant constant = iter().get_constant();
1522N/A if (constant.basic_type() == T_OBJECT &&
1522N/A !constant.as_object()->is_loaded()) {
1522N/A int index = iter().get_constant_pool_index();
1522N/A constantTag tag = iter().get_constant_pool_tag(index);
1522N/A uncommon_trap(Deoptimization::make_trap_request
1522N/A (Deoptimization::Reason_unloaded,
1522N/A Deoptimization::Action_reinterpret,
1522N/A index),
1522N/A NULL, tag.internal_name());
1522N/A break;
0N/A }
1522N/A assert(constant.basic_type() != T_OBJECT || !constant.as_object()->is_klass(),
1522N/A "must be java_mirror of klass");
989N/A bool pushed = push_constant(constant, true);
989N/A guarantee(pushed, "must be possible to push this constant");
0N/A }
0N/A
0N/A break;
0N/A
0N/A case Bytecodes::_aload_0:
0N/A push( local(0) );
0N/A break;
0N/A case Bytecodes::_aload_1:
0N/A push( local(1) );
0N/A break;
0N/A case Bytecodes::_aload_2:
0N/A push( local(2) );
0N/A break;
0N/A case Bytecodes::_aload_3:
0N/A push( local(3) );
0N/A break;
0N/A case Bytecodes::_aload:
0N/A push( local(iter().get_index()) );
0N/A break;
0N/A
0N/A case Bytecodes::_fload_0:
0N/A case Bytecodes::_iload_0:
0N/A push( local(0) );
0N/A break;
0N/A case Bytecodes::_fload_1:
0N/A case Bytecodes::_iload_1:
0N/A push( local(1) );
0N/A break;
0N/A case Bytecodes::_fload_2:
0N/A case Bytecodes::_iload_2:
0N/A push( local(2) );
0N/A break;
0N/A case Bytecodes::_fload_3:
0N/A case Bytecodes::_iload_3:
0N/A push( local(3) );
0N/A break;
0N/A case Bytecodes::_fload:
0N/A case Bytecodes::_iload:
0N/A push( local(iter().get_index()) );
0N/A break;
0N/A case Bytecodes::_lload_0:
0N/A push_pair_local( 0 );
0N/A break;
0N/A case Bytecodes::_lload_1:
0N/A push_pair_local( 1 );
0N/A break;
0N/A case Bytecodes::_lload_2:
0N/A push_pair_local( 2 );
0N/A break;
0N/A case Bytecodes::_lload_3:
0N/A push_pair_local( 3 );
0N/A break;
0N/A case Bytecodes::_lload:
0N/A push_pair_local( iter().get_index() );
0N/A break;
0N/A
0N/A case Bytecodes::_dload_0:
0N/A push_pair_local(0);
0N/A break;
0N/A case Bytecodes::_dload_1:
0N/A push_pair_local(1);
0N/A break;
0N/A case Bytecodes::_dload_2:
0N/A push_pair_local(2);
0N/A break;
0N/A case Bytecodes::_dload_3:
0N/A push_pair_local(3);
0N/A break;
0N/A case Bytecodes::_dload:
0N/A push_pair_local(iter().get_index());
0N/A break;
0N/A case Bytecodes::_fstore_0:
0N/A case Bytecodes::_istore_0:
0N/A case Bytecodes::_astore_0:
0N/A set_local( 0, pop() );
0N/A break;
0N/A case Bytecodes::_fstore_1:
0N/A case Bytecodes::_istore_1:
0N/A case Bytecodes::_astore_1:
0N/A set_local( 1, pop() );
0N/A break;
0N/A case Bytecodes::_fstore_2:
0N/A case Bytecodes::_istore_2:
0N/A case Bytecodes::_astore_2:
0N/A set_local( 2, pop() );
0N/A break;
0N/A case Bytecodes::_fstore_3:
0N/A case Bytecodes::_istore_3:
0N/A case Bytecodes::_astore_3:
0N/A set_local( 3, pop() );
0N/A break;
0N/A case Bytecodes::_fstore:
0N/A case Bytecodes::_istore:
0N/A case Bytecodes::_astore:
0N/A set_local( iter().get_index(), pop() );
0N/A break;
0N/A // long stores
0N/A case Bytecodes::_lstore_0:
0N/A set_pair_local( 0, pop_pair() );
0N/A break;
0N/A case Bytecodes::_lstore_1:
0N/A set_pair_local( 1, pop_pair() );
0N/A break;
0N/A case Bytecodes::_lstore_2:
0N/A set_pair_local( 2, pop_pair() );
0N/A break;
0N/A case Bytecodes::_lstore_3:
0N/A set_pair_local( 3, pop_pair() );
0N/A break;
0N/A case Bytecodes::_lstore:
0N/A set_pair_local( iter().get_index(), pop_pair() );
0N/A break;
0N/A
0N/A // double stores
0N/A case Bytecodes::_dstore_0:
0N/A set_pair_local( 0, dstore_rounding(pop_pair()) );
0N/A break;
0N/A case Bytecodes::_dstore_1:
0N/A set_pair_local( 1, dstore_rounding(pop_pair()) );
0N/A break;
0N/A case Bytecodes::_dstore_2:
0N/A set_pair_local( 2, dstore_rounding(pop_pair()) );
0N/A break;
0N/A case Bytecodes::_dstore_3:
0N/A set_pair_local( 3, dstore_rounding(pop_pair()) );
0N/A break;
0N/A case Bytecodes::_dstore:
0N/A set_pair_local( iter().get_index(), dstore_rounding(pop_pair()) );
0N/A break;
0N/A
4122N/A case Bytecodes::_pop: dec_sp(1); break;
4122N/A case Bytecodes::_pop2: dec_sp(2); break;
0N/A case Bytecodes::_swap:
0N/A a = pop();
0N/A b = pop();
0N/A push(a);
0N/A push(b);
0N/A break;
0N/A case Bytecodes::_dup:
0N/A a = pop();
0N/A push(a);
0N/A push(a);
0N/A break;
0N/A case Bytecodes::_dup_x1:
0N/A a = pop();
0N/A b = pop();
0N/A push( a );
0N/A push( b );
0N/A push( a );
0N/A break;
0N/A case Bytecodes::_dup_x2:
0N/A a = pop();
0N/A b = pop();
0N/A c = pop();
0N/A push( a );
0N/A push( c );
0N/A push( b );
0N/A push( a );
0N/A break;
0N/A case Bytecodes::_dup2:
0N/A a = pop();
0N/A b = pop();
0N/A push( b );
0N/A push( a );
0N/A push( b );
0N/A push( a );
0N/A break;
0N/A
0N/A case Bytecodes::_dup2_x1:
0N/A // before: .. c, b, a
0N/A // after: .. b, a, c, b, a
0N/A // not tested
0N/A a = pop();
0N/A b = pop();
0N/A c = pop();
0N/A push( b );
0N/A push( a );
0N/A push( c );
0N/A push( b );
0N/A push( a );
0N/A break;
0N/A case Bytecodes::_dup2_x2:
0N/A // before: .. d, c, b, a
0N/A // after: .. b, a, d, c, b, a
0N/A // not tested
0N/A a = pop();
0N/A b = pop();
0N/A c = pop();
0N/A d = pop();
0N/A push( b );
0N/A push( a );
0N/A push( d );
0N/A push( c );
0N/A push( b );
0N/A push( a );
0N/A break;
0N/A
0N/A case Bytecodes::_arraylength: {
0N/A // Must do null-check with value on expression stack
4122N/A Node *ary = null_check(peek(), T_ARRAY);
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return;
0N/A a = pop();
0N/A push(load_array_length(a));
0N/A break;
0N/A }
0N/A
0N/A case Bytecodes::_baload: array_load(T_BYTE); break;
0N/A case Bytecodes::_caload: array_load(T_CHAR); break;
0N/A case Bytecodes::_iaload: array_load(T_INT); break;
0N/A case Bytecodes::_saload: array_load(T_SHORT); break;
0N/A case Bytecodes::_faload: array_load(T_FLOAT); break;
0N/A case Bytecodes::_aaload: array_load(T_OBJECT); break;
0N/A case Bytecodes::_laload: {
0N/A a = array_addressing(T_LONG, 0);
605N/A if (stopped()) return; // guaranteed null or range check
4122N/A dec_sp(2); // Pop array and index
4122N/A push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS));
0N/A break;
0N/A }
0N/A case Bytecodes::_daload: {
0N/A a = array_addressing(T_DOUBLE, 0);
605N/A if (stopped()) return; // guaranteed null or range check
4122N/A dec_sp(2); // Pop array and index
4122N/A push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES));
0N/A break;
0N/A }
0N/A case Bytecodes::_bastore: array_store(T_BYTE); break;
0N/A case Bytecodes::_castore: array_store(T_CHAR); break;
0N/A case Bytecodes::_iastore: array_store(T_INT); break;
0N/A case Bytecodes::_sastore: array_store(T_SHORT); break;
0N/A case Bytecodes::_fastore: array_store(T_FLOAT); break;
0N/A case Bytecodes::_aastore: {
0N/A d = array_addressing(T_OBJECT, 1);
605N/A if (stopped()) return; // guaranteed null or range check
0N/A array_store_check();
0N/A c = pop(); // Oop to store
0N/A b = pop(); // index (already used)
0N/A a = pop(); // the array itself
827N/A const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
0N/A const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
0N/A Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT);
0N/A break;
0N/A }
0N/A case Bytecodes::_lastore: {
0N/A a = array_addressing(T_LONG, 2);
605N/A if (stopped()) return; // guaranteed null or range check
0N/A c = pop_pair();
4122N/A dec_sp(2); // Pop array and index
0N/A store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS);
0N/A break;
0N/A }
0N/A case Bytecodes::_dastore: {
0N/A a = array_addressing(T_DOUBLE, 2);
605N/A if (stopped()) return; // guaranteed null or range check
0N/A c = pop_pair();
4122N/A dec_sp(2); // Pop array and index
0N/A c = dstore_rounding(c);
0N/A store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES);
0N/A break;
0N/A }
0N/A case Bytecodes::_getfield:
0N/A do_getfield();
0N/A break;
0N/A
0N/A case Bytecodes::_getstatic:
0N/A do_getstatic();
0N/A break;
0N/A
0N/A case Bytecodes::_putfield:
0N/A do_putfield();
0N/A break;
0N/A
0N/A case Bytecodes::_putstatic:
0N/A do_putstatic();
0N/A break;
0N/A
0N/A case Bytecodes::_irem:
0N/A do_irem();
0N/A break;
0N/A case Bytecodes::_idiv:
0N/A // Must keep both values on the expression-stack during null-check
4122N/A zero_check_int(peek());
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return;
0N/A b = pop();
0N/A a = pop();
4022N/A push( _gvn.transform( new (C) DivINode(control(),a,b) ) );
0N/A break;
0N/A case Bytecodes::_imul:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) MulINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_iadd:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) AddINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_ineg:
0N/A a = pop();
4022N/A push( _gvn.transform( new (C) SubINode(_gvn.intcon(0),a)) );
0N/A break;
0N/A case Bytecodes::_isub:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) SubINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_iand:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) AndINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_ior:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) OrINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_ixor:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) XorINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_ishl:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) LShiftINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_ishr:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) RShiftINode(a,b) ) );
0N/A break;
0N/A case Bytecodes::_iushr:
0N/A b = pop(); a = pop();
4022N/A push( _gvn.transform( new (C) URShiftINode(a,b) ) );
0N/A break;
0N/A
0N/A case Bytecodes::_fneg:
0N/A a = pop();
4022N/A b = _gvn.transform(new (C) NegFNode (a));
0N/A push(b);
0N/A break;
0N/A
0N/A case Bytecodes::_fsub:
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) SubFNode(a,b) );
0N/A d = precision_rounding(c);
0N/A push( d );
0N/A break;
0N/A
0N/A case Bytecodes::_fadd:
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) AddFNode(a,b) );
0N/A d = precision_rounding(c);
0N/A push( d );
0N/A break;
0N/A
0N/A case Bytecodes::_fmul:
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) MulFNode(a,b) );
0N/A d = precision_rounding(c);
0N/A push( d );
0N/A break;
0N/A
0N/A case Bytecodes::_fdiv:
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) DivFNode(0,a,b) );
0N/A d = precision_rounding(c);
0N/A push( d );
0N/A break;
0N/A
0N/A case Bytecodes::_frem:
0N/A if (Matcher::has_match_rule(Op_ModF)) {
0N/A // Generate a ModF node.
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) ModFNode(0,a,b) );
0N/A d = precision_rounding(c);
0N/A push( d );
0N/A }
0N/A else {
0N/A // Generate a call.
0N/A modf();
0N/A }
0N/A break;
0N/A
0N/A case Bytecodes::_fcmpl:
0N/A b = pop();
0N/A a = pop();
4022N/A c = _gvn.transform( new (C) CmpF3Node( a, b));
0N/A push(c);
0N/A break;
0N/A case Bytecodes::_fcmpg:
0N/A b = pop();
0N/A a = pop();
0N/A
0N/A // Same as fcmpl but need to flip the unordered case. Swap the inputs,
0N/A // which negates the result sign except for unordered. Flip the unordered
0N/A // as well by using CmpF3 which implements unordered-lesser instead of
0N/A // unordered-greater semantics. Finally, commute the result bits. Result
0N/A // is same as using a CmpF3Greater except we did it with CmpF3 alone.
4022N/A c = _gvn.transform( new (C) CmpF3Node( b, a));
4022N/A c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) );
0N/A push(c);
0N/A break;
0N/A
0N/A case Bytecodes::_f2i:
0N/A a = pop();
4022N/A push(_gvn.transform(new (C) ConvF2INode(a)));
0N/A break;
0N/A
0N/A case Bytecodes::_d2i:
0N/A a = pop_pair();
4022N/A b = _gvn.transform(new (C) ConvD2INode(a));
0N/A push( b );
0N/A break;
0N/A
0N/A case Bytecodes::_f2d:
0N/A a = pop();
4022N/A b = _gvn.transform( new (C) ConvF2DNode(a));
0N/A push_pair( b );
0N/A break;
0N/A
0N/A case Bytecodes::_d2f:
0N/A a = pop_pair();
4022N/A b = _gvn.transform( new (C) ConvD2FNode(a));
0N/A // This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed)
4022N/A //b = _gvn.transform(new (C) RoundFloatNode(0, b) );
0N/A push( b );
0N/A break;
0N/A
0N/A case Bytecodes::_l2f:
0N/A if (Matcher::convL2FSupported()) {
0N/A a = pop_pair();
4022N/A b = _gvn.transform( new (C) ConvL2FNode(a));
0N/A // For i486.ad, FILD doesn't restrict precision to 24 or 53 bits.
0N/A // Rather than storing the result into an FP register then pushing
0N/A // out to memory to round, the machine instruction that implements
0N/A // ConvL2D is responsible for rounding.
0N/A // c = precision_rounding(b);
0N/A c = _gvn.transform(b);
0N/A push(c);
0N/A } else {
0N/A l2f();
0N/A }
0N/A break;
0N/A
0N/A case Bytecodes::_l2d:
0N/A a = pop_pair();
4022N/A b = _gvn.transform( new (C) ConvL2DNode(a));
0N/A // For i486.ad, rounding is always necessary (see _l2f above).
0N/A // c = dprecision_rounding(b);
0N/A c = _gvn.transform(b);
0N/A push_pair(c);
0N/A break;
0N/A
0N/A case Bytecodes::_f2l:
0N/A a = pop();
4022N/A b = _gvn.transform( new (C) ConvF2LNode(a));
0N/A push_pair(b);
0N/A break;
0N/A
0N/A case Bytecodes::_d2l:
0N/A a = pop_pair();
4022N/A b = _gvn.transform( new (C) ConvD2LNode(a));
0N/A push_pair(b);
0N/A break;
0N/A
0N/A case Bytecodes::_dsub:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) SubDNode(a,b) );
0N/A d = dprecision_rounding(c);
0N/A push_pair( d );
0N/A break;
0N/A
0N/A case Bytecodes::_dadd:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) AddDNode(a,b) );
0N/A d = dprecision_rounding(c);
0N/A push_pair( d );
0N/A break;
0N/A
0N/A case Bytecodes::_dmul:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) MulDNode(a,b) );
0N/A d = dprecision_rounding(c);
0N/A push_pair( d );
0N/A break;
0N/A
0N/A case Bytecodes::_ddiv:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) DivDNode(0,a,b) );
0N/A d = dprecision_rounding(c);
0N/A push_pair( d );
0N/A break;
0N/A
0N/A case Bytecodes::_dneg:
0N/A a = pop_pair();
4022N/A b = _gvn.transform(new (C) NegDNode (a));
0N/A push_pair(b);
0N/A break;
0N/A
0N/A case Bytecodes::_drem:
0N/A if (Matcher::has_match_rule(Op_ModD)) {
0N/A // Generate a ModD node.
0N/A b = pop_pair();
0N/A a = pop_pair();
0N/A // a % b
0N/A
4022N/A c = _gvn.transform( new (C) ModDNode(0,a,b) );
0N/A d = dprecision_rounding(c);
0N/A push_pair( d );
0N/A }
0N/A else {
0N/A // Generate a call.
0N/A modd();
0N/A }
0N/A break;
0N/A
0N/A case Bytecodes::_dcmpl:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) CmpD3Node( a, b));
0N/A push(c);
0N/A break;
0N/A
0N/A case Bytecodes::_dcmpg:
0N/A b = pop_pair();
0N/A a = pop_pair();
0N/A // Same as dcmpl but need to flip the unordered case.
0N/A // Commute the inputs, which negates the result sign except for unordered.
0N/A // Flip the unordered as well by using CmpD3 which implements
0N/A // unordered-lesser instead of unordered-greater semantics.
0N/A // Finally, negate the result bits. Result is same as using a
0N/A // CmpD3Greater except we did it with CmpD3 alone.
4022N/A c = _gvn.transform( new (C) CmpD3Node( b, a));
4022N/A c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) );
0N/A push(c);
0N/A break;
0N/A
0N/A
0N/A // Note for longs -> lo word is on TOS, hi word is on TOS - 1
0N/A case Bytecodes::_land:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) AndLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lor:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) OrLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lxor:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) XorLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A
0N/A case Bytecodes::_lshl:
0N/A b = pop(); // the shift count
0N/A a = pop_pair(); // value to be shifted
4022N/A c = _gvn.transform( new (C) LShiftLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lshr:
0N/A b = pop(); // the shift count
0N/A a = pop_pair(); // value to be shifted
4022N/A c = _gvn.transform( new (C) RShiftLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lushr:
0N/A b = pop(); // the shift count
0N/A a = pop_pair(); // value to be shifted
4022N/A c = _gvn.transform( new (C) URShiftLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lmul:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) MulLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A
0N/A case Bytecodes::_lrem:
0N/A // Must keep both values on the expression-stack during null-check
0N/A assert(peek(0) == top(), "long word order");
4122N/A zero_check_long(peek(1));
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return;
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) ModLNode(control(),a,b) );
0N/A push_pair(c);
0N/A break;
0N/A
0N/A case Bytecodes::_ldiv:
0N/A // Must keep both values on the expression-stack during null-check
0N/A assert(peek(0) == top(), "long word order");
4122N/A zero_check_long(peek(1));
0N/A // Compile-time detect of null-exception?
0N/A if (stopped()) return;
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) DivLNode(control(),a,b) );
0N/A push_pair(c);
0N/A break;
0N/A
0N/A case Bytecodes::_ladd:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) AddLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lsub:
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) SubLNode(a,b) );
0N/A push_pair(c);
0N/A break;
0N/A case Bytecodes::_lcmp:
0N/A // Safepoints are now inserted _before_ branches. The long-compare
0N/A // bytecode painfully produces a 3-way value (-1,0,+1) which requires a
0N/A // slew of control flow. These are usually followed by a CmpI vs zero and
0N/A // a branch; this pattern then optimizes to the obvious long-compare and
0N/A // branch. However, if the branch is backwards there's a Safepoint
0N/A // inserted. The inserted Safepoint captures the JVM state at the
0N/A // pre-branch point, i.e. it captures the 3-way value. Thus if a
0N/A // long-compare is used to control a loop the debug info will force
0N/A // computation of the 3-way value, even though the generated code uses a
0N/A // long-compare and branch. We try to rectify the situation by inserting
0N/A // a SafePoint here and have it dominate and kill the safepoint added at a
0N/A // following backwards branch. At this point the JVM state merely holds 2
0N/A // longs but not the 3-way value.
0N/A if( UseLoopSafepoints ) {
0N/A switch( iter().next_bc() ) {
0N/A case Bytecodes::_ifgt:
0N/A case Bytecodes::_iflt:
0N/A case Bytecodes::_ifge:
0N/A case Bytecodes::_ifle:
0N/A case Bytecodes::_ifne:
0N/A case Bytecodes::_ifeq:
0N/A // If this is a backwards branch in the bytecodes, add Safepoint
0N/A maybe_add_safepoint(iter().next_get_dest());
0N/A }
0N/A }
0N/A b = pop_pair();
0N/A a = pop_pair();
4022N/A c = _gvn.transform( new (C) CmpL3Node( a, b ));
0N/A push(c);
0N/A break;
0N/A
0N/A case Bytecodes::_lneg:
0N/A a = pop_pair();
4022N/A b = _gvn.transform( new (C) SubLNode(longcon(0),a));
0N/A push_pair(b);
0N/A break;
0N/A case Bytecodes::_l2i:
0N/A a = pop_pair();
4022N/A push( _gvn.transform( new (C) ConvL2INode(a)));
0N/A break;
0N/A case Bytecodes::_i2l:
0N/A a = pop();
4022N/A b = _gvn.transform( new (C) ConvI2LNode(a));
0N/A push_pair(b);
0N/A break;
0N/A case Bytecodes::_i2b:
0N/A // Sign extend
0N/A a = pop();
4022N/A a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(24)) );
4022N/A a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(24)) );
0N/A push( a );
0N/A break;
0N/A case Bytecodes::_i2s:
0N/A a = pop();
4022N/A a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(16)) );
4022N/A a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(16)) );
0N/A push( a );
0N/A break;
0N/A case Bytecodes::_i2c:
0N/A a = pop();
4022N/A push( _gvn.transform( new (C) AndINode(a,_gvn.intcon(0xFFFF)) ) );
0N/A break;
0N/A
0N/A case Bytecodes::_i2f:
0N/A a = pop();
4022N/A b = _gvn.transform( new (C) ConvI2FNode(a) ) ;
0N/A c = precision_rounding(b);
0N/A push (b);
0N/A break;
0N/A
0N/A case Bytecodes::_i2d:
0N/A a = pop();
4022N/A b = _gvn.transform( new (C) ConvI2DNode(a));
0N/A push_pair(b);
0N/A break;
0N/A
0N/A case Bytecodes::_iinc: // Increment local
0N/A i = iter().get_index(); // Get local index
4022N/A set_local( i, _gvn.transform( new (C) AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) );
0N/A break;
0N/A
0N/A // Exit points of synchronized methods must have an unlock node
0N/A case Bytecodes::_return:
0N/A return_current(NULL);
0N/A break;
0N/A
0N/A case Bytecodes::_ireturn:
0N/A case Bytecodes::_areturn:
0N/A case Bytecodes::_freturn:
0N/A return_current(pop());
0N/A break;
0N/A case Bytecodes::_lreturn:
0N/A return_current(pop_pair());
0N/A break;
0N/A case Bytecodes::_dreturn:
0N/A return_current(pop_pair());
0N/A break;
0N/A
0N/A case Bytecodes::_athrow:
0N/A // null exception oop throws NULL pointer exception
4122N/A null_check(peek());
0N/A if (stopped()) return;
0N/A // Hook the thrown exception directly to subsequent handlers.
0N/A if (BailoutToInterpreterForThrows) {
0N/A // Keep method interpreted from now on.
0N/A uncommon_trap(Deoptimization::Reason_unhandled,
0N/A Deoptimization::Action_make_not_compilable);
0N/A return;
0N/A }
1213N/A if (env()->jvmti_can_post_on_exceptions()) {
1213N/A // check if we must post exception events, take uncommon trap if so (with must_throw = false)
1213N/A uncommon_trap_if_should_post_on_exceptions(Deoptimization::Reason_unhandled, false);
1213N/A }
1213N/A // Here if either can_post_on_exceptions or should_post_on_exceptions is false
0N/A add_exception_state(make_exception_state(peek()));
0N/A break;
0N/A
0N/A case Bytecodes::_goto: // fall through
0N/A case Bytecodes::_goto_w: {
0N/A int target_bci = (bc() == Bytecodes::_goto) ? iter().get_dest() : iter().get_far_dest();
0N/A
0N/A // If this is a backwards branch in the bytecodes, add Safepoint
0N/A maybe_add_safepoint(target_bci);
0N/A
0N/A // Update method data
0N/A profile_taken_branch(target_bci);
0N/A
0N/A // Merge the current control into the target basic block
0N/A merge(target_bci);
0N/A
0N/A // See if we can get some profile data and hand it off to the next block
0N/A Block *target_block = block()->successor_for_bci(target_bci);
0N/A if (target_block->pred_count() != 1) break;
0N/A ciMethodData* methodData = method()->method_data();
0N/A if (!methodData->is_mature()) break;
0N/A ciProfileData* data = methodData->bci_to_data(bci());
0N/A assert( data->is_JumpData(), "" );
0N/A int taken = ((ciJumpData*)data)->taken();
0N/A taken = method()->scale_count(taken);
0N/A target_block->set_count(taken);
0N/A break;
0N/A }
0N/A
248N/A case Bytecodes::_ifnull: btest = BoolTest::eq; goto handle_if_null;
248N/A case Bytecodes::_ifnonnull: btest = BoolTest::ne; goto handle_if_null;
248N/A handle_if_null:
254N/A // If this is a backwards branch in the bytecodes, add Safepoint
254N/A maybe_add_safepoint(iter().get_dest());
248N/A a = null();
248N/A b = pop();
4022N/A c = _gvn.transform( new (C) CmpPNode(b, a) );
248N/A do_ifnull(btest, c);
0N/A break;
0N/A
0N/A case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp;
0N/A case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp;
0N/A handle_if_acmp:
254N/A // If this is a backwards branch in the bytecodes, add Safepoint
254N/A maybe_add_safepoint(iter().get_dest());
0N/A a = pop();
0N/A b = pop();
4022N/A c = _gvn.transform( new (C) CmpPNode(b, a) );
0N/A do_if(btest, c);
0N/A break;
0N/A
0N/A case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx;
0N/A case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx;
0N/A case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx;
0N/A case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx;
0N/A case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx;
0N/A case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx;
0N/A handle_ifxx:
254N/A // If this is a backwards branch in the bytecodes, add Safepoint
254N/A maybe_add_safepoint(iter().get_dest());
0N/A a = _gvn.intcon(0);
0N/A b = pop();
4022N/A c = _gvn.transform( new (C) CmpINode(b, a) );
0N/A do_if(btest, c);
0N/A break;
0N/A
0N/A case Bytecodes::_if_icmpeq: btest = BoolTest::eq; goto handle_if_icmp;
0N/A case Bytecodes::_if_icmpne: btest = BoolTest::ne; goto handle_if_icmp;
0N/A case Bytecodes::_if_icmplt: btest = BoolTest::lt; goto handle_if_icmp;
0N/A case Bytecodes::_if_icmple: btest = BoolTest::le; goto handle_if_icmp;
0N/A case Bytecodes::_if_icmpgt: btest = BoolTest::gt; goto handle_if_icmp;
0N/A case Bytecodes::_if_icmpge: btest = BoolTest::ge; goto handle_if_icmp;
0N/A handle_if_icmp:
254N/A // If this is a backwards branch in the bytecodes, add Safepoint
254N/A maybe_add_safepoint(iter().get_dest());
0N/A a = pop();
0N/A b = pop();
4022N/A c = _gvn.transform( new (C) CmpINode( b, a ) );
0N/A do_if(btest, c);
0N/A break;
0N/A
0N/A case Bytecodes::_tableswitch:
0N/A do_tableswitch();
0N/A break;
0N/A
0N/A case Bytecodes::_lookupswitch:
0N/A do_lookupswitch();
0N/A break;
0N/A
0N/A case Bytecodes::_invokestatic:
726N/A case Bytecodes::_invokedynamic:
0N/A case Bytecodes::_invokespecial:
0N/A case Bytecodes::_invokevirtual:
0N/A case Bytecodes::_invokeinterface:
0N/A do_call();
0N/A break;
0N/A case Bytecodes::_checkcast:
0N/A do_checkcast();
0N/A break;
0N/A case Bytecodes::_instanceof:
0N/A do_instanceof();
0N/A break;
0N/A case Bytecodes::_anewarray:
0N/A do_anewarray();
0N/A break;
0N/A case Bytecodes::_newarray:
0N/A do_newarray((BasicType)iter().get_index());
0N/A break;
0N/A case Bytecodes::_multianewarray:
0N/A do_multianewarray();
0N/A break;
0N/A case Bytecodes::_new:
0N/A do_new();
0N/A break;
0N/A
0N/A case Bytecodes::_jsr:
0N/A case Bytecodes::_jsr_w:
0N/A do_jsr();
0N/A break;
0N/A
0N/A case Bytecodes::_ret:
0N/A do_ret();
0N/A break;
0N/A
0N/A
0N/A case Bytecodes::_monitorenter:
0N/A do_monitor_enter();
0N/A break;
0N/A
0N/A case Bytecodes::_monitorexit:
0N/A do_monitor_exit();
0N/A break;
0N/A
0N/A case Bytecodes::_breakpoint:
0N/A // Breakpoint set concurrently to compile
0N/A // %%% use an uncommon trap?
0N/A C->record_failure("breakpoint in method");
0N/A return;
0N/A
0N/A default:
0N/A#ifndef PRODUCT
0N/A map()->dump(99);
0N/A#endif
0N/A tty->print("\nUnhandled bytecode %s\n", Bytecodes::name(bc()) );
0N/A ShouldNotReachHere();
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A IdealGraphPrinter *printer = IdealGraphPrinter::printer();
0N/A if(printer) {
0N/A char buffer[256];
0N/A sprintf(buffer, "Bytecode %d: %s", bci(), Bytecodes::name(bc()));
0N/A bool old = printer->traverse_outs();
0N/A printer->set_traverse_outs(true);
222N/A printer->print_method(C, buffer, 4);
0N/A printer->set_traverse_outs(old);
0N/A }
0N/A#endif
0N/A}