src/share/vm/opto/parse2.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot-comp Sdiff src/share/vm/opto

src/share/vm/opto/parse2.cpp

Print this page




 251   void setRange(jint lo, jint hi, int dest, int table_index) {
 252     assert(lo <= hi, "must be a non-empty range");
 253     _lo = lo, _hi = hi; _dest = dest; _table_index = table_index;
 254   }
 255   bool adjoinRange(jint lo, jint hi, int dest, int table_index) {
 256     assert(lo <= hi, "must be a non-empty range");
 257     if (lo == _hi+1 && dest == _dest && table_index == _table_index) {
 258       _hi = hi;
 259       return true;
 260     }
 261     return false;
 262   }
 263 
 264   void set (jint value, int dest, int table_index) {
 265     setRange(value, value, dest, table_index);
 266   }
 267   bool adjoin(jint value, int dest, int table_index) {
 268     return adjoinRange(value, value, dest, table_index);
 269   }
 270 
 271   void print(ciEnv* env) {
 272     if (is_singleton())
 273       tty->print(" {%d}=>%d", lo(), dest());
 274     else if (lo() == min_jint)
 275       tty->print(" {..%d}=>%d", hi(), dest());
 276     else if (hi() == max_jint)
 277       tty->print(" {%d..}=>%d", lo(), dest());
 278     else
 279       tty->print(" {%d..%d}=>%d", lo(), hi(), dest());
 280   }
 281 };
 282 
 283 
 284 //-------------------------------do_tableswitch--------------------------------
 285 void Parse::do_tableswitch() {
 286   Node* lookup = pop();
 287 
 288   // Get information about tableswitch
 289   int default_dest = iter().get_dest_table(0);
 290   int lo_index     = iter().get_int_table(1);
 291   int hi_index     = iter().get_int_table(2);


 454   // of all possible ranges for a switch statement
 455   // The key_val input must be converted to a pointer offset and scaled.
 456   // Compare Parse::array_addressing above.
 457 #ifdef _LP64
 458   // Clean the 32-bit int into a real 64-bit offset.
 459   // Otherwise, the jint value 0 might turn into an offset of 0x0800000000.
 460   const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin);
 461   key_val       = _gvn.transform( new (C) ConvI2LNode(key_val, lkeytype) );
 462 #endif
 463   // Shift the value by wordsize so we have an index into the table, rather
 464   // than a switch value
 465   Node *shiftWord = _gvn.MakeConX(wordSize);
 466   key_val = _gvn.transform( new (C) MulXNode( key_val, shiftWord));
 467 
 468   // Create the JumpNode
 469   Node* jtn = _gvn.transform( new (C) JumpNode(control(), key_val, num_cases) );
 470 
 471   // These are the switch destinations hanging off the jumpnode
 472   int i = 0;
 473   for (SwitchRange* r = lo; r <= hi; r++) {
 474     for (int j = r->lo(); j <= r->hi(); j++, i++) {
 475       Node* input = _gvn.transform(new (C) JumpProjNode(jtn, i, r->dest(), j - lowval));
 476       {
 477         PreserveJVMState pjvms(this);
 478         set_control(input);
 479         jump_if_always_fork(r->dest(), r->table_index());
 480       }




 481     }
 482   }
 483   assert(i == num_cases, "miscount of cases");
 484   stop_and_kill_map();  // no more uses for this JVMS
 485   return true;
 486 }
 487 
 488 //----------------------------jump_switch_ranges-------------------------------
 489 void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) {
 490   Block* switch_block = block();
 491 
 492   if (switch_depth == 0) {
 493     // Do special processing for the top-level call.
 494     assert(lo->lo() == min_jint, "initial range must exhaust Type::INT");
 495     assert(hi->hi() == max_jint, "initial range must exhaust Type::INT");
 496 
 497     // Decrement pred-numbers for the unique set of nodes.
 498 #ifdef ASSERT
 499     // Ensure that the block's successors are a (duplicate-free) set.
 500     int successors_counted = 0;  // block occurrences in [hi..lo]


 615   }
 616 
 617 #ifndef PRODUCT
 618   _max_switch_depth = MAX2(switch_depth, _max_switch_depth);
 619   if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) {
 620     SwitchRange* r;
 621     int nsing = 0;
 622     for( r = lo; r <= hi; r++ ) {
 623       if( r->is_singleton() )  nsing++;
 624     }
 625     tty->print(">>> ");
 626     _method->print_short_name();
 627     tty->print_cr(" switch decision tree");
 628     tty->print_cr("    %d ranges (%d singletons), max_depth=%d, est_depth=%d",
 629                   hi-lo+1, nsing, _max_switch_depth, _est_switch_depth);
 630     if (_max_switch_depth > _est_switch_depth) {
 631       tty->print_cr("******** BAD SWITCH DEPTH ********");
 632     }
 633     tty->print("   ");
 634     for( r = lo; r <= hi; r++ ) {
 635       r->print(env());
 636     }
 637     tty->print_cr("");
 638   }
 639 #endif
 640 }
 641 
 642 void Parse::modf() {
 643   Node *f2 = pop();
 644   Node *f1 = pop();
 645   Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(),
 646                               CAST_FROM_FN_PTR(address, SharedRuntime::frem),
 647                               "frem", NULL, //no memory effects
 648                               f1, f2);
 649   Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0));
 650 
 651   push(res);
 652 }
 653 
 654 void Parse::modd() {
 655   Node *d2 = pop_pair();




 251   void setRange(jint lo, jint hi, int dest, int table_index) {
 252     assert(lo <= hi, "must be a non-empty range");
 253     _lo = lo, _hi = hi; _dest = dest; _table_index = table_index;
 254   }
 255   bool adjoinRange(jint lo, jint hi, int dest, int table_index) {
 256     assert(lo <= hi, "must be a non-empty range");
 257     if (lo == _hi+1 && dest == _dest && table_index == _table_index) {
 258       _hi = hi;
 259       return true;
 260     }
 261     return false;
 262   }
 263 
 264   void set (jint value, int dest, int table_index) {
 265     setRange(value, value, dest, table_index);
 266   }
 267   bool adjoin(jint value, int dest, int table_index) {
 268     return adjoinRange(value, value, dest, table_index);
 269   }
 270 
 271   void print() {
 272     if (is_singleton())
 273       tty->print(" {%d}=>%d", lo(), dest());
 274     else if (lo() == min_jint)
 275       tty->print(" {..%d}=>%d", hi(), dest());
 276     else if (hi() == max_jint)
 277       tty->print(" {%d..}=>%d", lo(), dest());
 278     else
 279       tty->print(" {%d..%d}=>%d", lo(), hi(), dest());
 280   }
 281 };
 282 
 283 
 284 //-------------------------------do_tableswitch--------------------------------
 285 void Parse::do_tableswitch() {
 286   Node* lookup = pop();
 287 
 288   // Get information about tableswitch
 289   int default_dest = iter().get_dest_table(0);
 290   int lo_index     = iter().get_int_table(1);
 291   int hi_index     = iter().get_int_table(2);


 454   // of all possible ranges for a switch statement
 455   // The key_val input must be converted to a pointer offset and scaled.
 456   // Compare Parse::array_addressing above.
 457 #ifdef _LP64
 458   // Clean the 32-bit int into a real 64-bit offset.
 459   // Otherwise, the jint value 0 might turn into an offset of 0x0800000000.
 460   const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin);
 461   key_val       = _gvn.transform( new (C) ConvI2LNode(key_val, lkeytype) );
 462 #endif
 463   // Shift the value by wordsize so we have an index into the table, rather
 464   // than a switch value
 465   Node *shiftWord = _gvn.MakeConX(wordSize);
 466   key_val = _gvn.transform( new (C) MulXNode( key_val, shiftWord));
 467 
 468   // Create the JumpNode
 469   Node* jtn = _gvn.transform( new (C) JumpNode(control(), key_val, num_cases) );
 470 
 471   // These are the switch destinations hanging off the jumpnode
 472   int i = 0;
 473   for (SwitchRange* r = lo; r <= hi; r++) {
 474     for (jint j = r->lo(); /* true */ ; j++) {
 475       Node* input = _gvn.transform(new (C) JumpProjNode(jtn, i, r->dest(), j - lowval));
 476       {
 477         PreserveJVMState pjvms(this);
 478         set_control(input);
 479         jump_if_always_fork(r->dest(), r->table_index());
 480       }
 481       ++i;
 482       // Stop iterating when upper bound is reached.
 483       // Don't increment j, because r->hi() may be MAX_INT.
 484       if (j >= r->hi()) break;
 485     }
 486   }
 487   assert(i == num_cases, "miscount of cases");
 488   stop_and_kill_map();  // no more uses for this JVMS
 489   return true;
 490 }
 491 
 492 //----------------------------jump_switch_ranges-------------------------------
 493 void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, int switch_depth) {
 494   Block* switch_block = block();
 495 
 496   if (switch_depth == 0) {
 497     // Do special processing for the top-level call.
 498     assert(lo->lo() == min_jint, "initial range must exhaust Type::INT");
 499     assert(hi->hi() == max_jint, "initial range must exhaust Type::INT");
 500 
 501     // Decrement pred-numbers for the unique set of nodes.
 502 #ifdef ASSERT
 503     // Ensure that the block's successors are a (duplicate-free) set.
 504     int successors_counted = 0;  // block occurrences in [hi..lo]


 619   }
 620 
 621 #ifndef PRODUCT
 622   _max_switch_depth = MAX2(switch_depth, _max_switch_depth);
 623   if (TraceOptoParse && Verbose && WizardMode && switch_depth == 0) {
 624     SwitchRange* r;
 625     int nsing = 0;
 626     for( r = lo; r <= hi; r++ ) {
 627       if( r->is_singleton() )  nsing++;
 628     }
 629     tty->print(">>> ");
 630     _method->print_short_name();
 631     tty->print_cr(" switch decision tree");
 632     tty->print_cr("    %d ranges (%d singletons), max_depth=%d, est_depth=%d",
 633                   hi-lo+1, nsing, _max_switch_depth, _est_switch_depth);
 634     if (_max_switch_depth > _est_switch_depth) {
 635       tty->print_cr("******** BAD SWITCH DEPTH ********");
 636     }
 637     tty->print("   ");
 638     for( r = lo; r <= hi; r++ ) {
 639       r->print();
 640     }
 641     tty->print_cr("");
 642   }
 643 #endif
 644 }
 645 
 646 void Parse::modf() {
 647   Node *f2 = pop();
 648   Node *f1 = pop();
 649   Node* c = make_runtime_call(RC_LEAF, OptoRuntime::modf_Type(),
 650                               CAST_FROM_FN_PTR(address, SharedRuntime::frem),
 651                               "frem", NULL, //no memory effects
 652                               f1, f2);
 653   Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0));
 654 
 655   push(res);
 656 }
 657 
 658 void Parse::modd() {
 659   Node *d2 = pop_pair();


src/share/vm/opto/parse2.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File