src/share/vm/opto/parse2.cpp

Tue, 01 Mar 2016 12:50:37 +0530

author
csahu
date
Tue, 01 Mar 2016 12:50:37 +0530
changeset 8316
626f594dffa6
parent 8285
535618ab1c04
child 8415
d109bda16490
permissions
-rw-r--r--

8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
Reviewed-by: stuefe, coleenp, roland

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

mercurial