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

src/share/vm/opto/parse2.cpp

Print this page




 388   jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
 389 }
 390 
 391 //----------------------------create_jump_tables-------------------------------
 392 bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) {
 393   // Are jumptables enabled
 394   if (!UseJumpTables)  return false;
 395 
 396   // Are jumptables supported
 397   if (!Matcher::has_match_rule(Op_Jump))  return false;
 398 
 399   // Don't make jump table if profiling
 400   if (method_data_update())  return false;
 401 
 402   // Decide if a guard is needed to lop off big ranges at either (or
 403   // both) end(s) of the input set. We'll call this the default target
 404   // even though we can't be sure that it is the true "default".
 405 
 406   bool needs_guard = false;
 407   int default_dest;
 408   int64 total_outlier_size = 0;
 409   int64 hi_size = ((int64)hi->hi()) - ((int64)hi->lo()) + 1;
 410   int64 lo_size = ((int64)lo->hi()) - ((int64)lo->lo()) + 1;
 411 
 412   if (lo->dest() == hi->dest()) {
 413     total_outlier_size = hi_size + lo_size;
 414     default_dest = lo->dest();
 415   } else if (lo_size > hi_size) {
 416     total_outlier_size = lo_size;
 417     default_dest = lo->dest();
 418   } else {
 419     total_outlier_size = hi_size;
 420     default_dest = hi->dest();
 421   }
 422 
 423   // If a guard test will eliminate very sparse end ranges, then
 424   // it is worth the cost of an extra jump.
 425   if (total_outlier_size > (MaxJumpTableSparseness * 4)) {
 426     needs_guard = true;
 427     if (default_dest == lo->dest()) lo++;
 428     if (default_dest == hi->dest()) hi--;
 429   }
 430 
 431   // Find the total number of cases and ranges
 432   int64 num_cases = ((int64)hi->hi()) - ((int64)lo->lo()) + 1;
 433   int num_range = hi - lo + 1;
 434 
 435   // Don't create table if: too large, too small, or too sparse.
 436   if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize)
 437     return false;
 438   if (num_cases > (MaxJumpTableSparseness * num_range))
 439     return false;
 440 
 441   // Normalize table lookups to zero
 442   int lowval = lo->lo();
 443   key_val = _gvn.transform( new (C) SubINode(key_val, _gvn.intcon(lowval)) );
 444 
 445   // Generate a guard to protect against input keyvals that aren't
 446   // in the switch domain.
 447   if (needs_guard) {
 448     Node*   size = _gvn.intcon(num_cases);
 449     Node*   cmp = _gvn.transform( new (C) CmpUNode(key_val, size) );
 450     Node*   tst = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ge) );
 451     IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN);
 452     jump_if_true_fork(iff, default_dest, NullTableIndex);


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




 388   jump_switch_ranges(lookup, &ranges[0], &ranges[rp]);
 389 }
 390 
 391 //----------------------------create_jump_tables-------------------------------
 392 bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) {
 393   // Are jumptables enabled
 394   if (!UseJumpTables)  return false;
 395 
 396   // Are jumptables supported
 397   if (!Matcher::has_match_rule(Op_Jump))  return false;
 398 
 399   // Don't make jump table if profiling
 400   if (method_data_update())  return false;
 401 
 402   // Decide if a guard is needed to lop off big ranges at either (or
 403   // both) end(s) of the input set. We'll call this the default target
 404   // even though we can't be sure that it is the true "default".
 405 
 406   bool needs_guard = false;
 407   int default_dest;
 408   int64_t total_outlier_size = 0;
 409   int64_t hi_size = ((int64_t)hi->hi()) - ((int64_t)hi->lo()) + 1;
 410   int64_t lo_size = ((int64_t)lo->hi()) - ((int64_t)lo->lo()) + 1;
 411 
 412   if (lo->dest() == hi->dest()) {
 413     total_outlier_size = hi_size + lo_size;
 414     default_dest = lo->dest();
 415   } else if (lo_size > hi_size) {
 416     total_outlier_size = lo_size;
 417     default_dest = lo->dest();
 418   } else {
 419     total_outlier_size = hi_size;
 420     default_dest = hi->dest();
 421   }
 422 
 423   // If a guard test will eliminate very sparse end ranges, then
 424   // it is worth the cost of an extra jump.
 425   if (total_outlier_size > (MaxJumpTableSparseness * 4)) {
 426     needs_guard = true;
 427     if (default_dest == lo->dest()) lo++;
 428     if (default_dest == hi->dest()) hi--;
 429   }
 430 
 431   // Find the total number of cases and ranges
 432   int64_t num_cases = ((int64_t)hi->hi()) - ((int64_t)lo->lo()) + 1;
 433   int num_range = hi - lo + 1;
 434 
 435   // Don't create table if: too large, too small, or too sparse.
 436   if (num_cases < MinJumpTableSize || num_cases > MaxJumpTableSize)
 437     return false;
 438   if (num_cases > (MaxJumpTableSparseness * num_range))
 439     return false;
 440 
 441   // Normalize table lookups to zero
 442   int lowval = lo->lo();
 443   key_val = _gvn.transform( new (C) SubINode(key_val, _gvn.intcon(lowval)) );
 444 
 445   // Generate a guard to protect against input keyvals that aren't
 446   // in the switch domain.
 447   if (needs_guard) {
 448     Node*   size = _gvn.intcon(num_cases);
 449     Node*   cmp = _gvn.transform( new (C) CmpUNode(key_val, size) );
 450     Node*   tst = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ge) );
 451     IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN);
 452     jump_if_true_fork(iff, default_dest, NullTableIndex);


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


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