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

src/share/vm/opto/parse3.cpp

Print this page




 400     for (jint i = 0; i < length_con; i++) {
 401       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
 402       intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
 403       Node*    eaddr  = basic_plus_adr(array, offset);
 404       store_oop_to_array(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT);
 405     }
 406   }
 407   return array;
 408 }
 409 
 410 void Parse::do_multianewarray() {
 411   int ndimensions = iter().get_dimensions();
 412 
 413   // the m-dimensional array
 414   bool will_link;
 415   ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
 416   assert(will_link, "multianewarray: typeflow responsibility");
 417 
 418   // Note:  Array classes are always initialized; no is_initialized check.
 419 
 420   enum { MAX_DIMENSION = 5 };
 421   if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {
 422     uncommon_trap(Deoptimization::Reason_unhandled,
 423                   Deoptimization::Action_none);
 424     return;
 425   }
 426 
 427   kill_dead_locals();
 428 
 429   // get the lengths from the stack (first dimension is on top)
 430   Node* length[MAX_DIMENSION+1];
 431   length[ndimensions] = NULL;  // terminating null for make_runtime_call
 432   int j;
 433   for (j = ndimensions-1; j >= 0 ; j--) length[j] = pop();
 434 
 435   // The original expression was of this form: new T[length0][length1]...
 436   // It is often the case that the lengths are small (except the last).
 437   // If that happens, use the fast 1-d creator a constant number of times.
 438   const jint expand_limit = MIN2((juint)MultiArrayExpandLimit, (juint)100);
 439   jint expand_count = 1;        // count of allocations in the expansion
 440   jint expand_fanout = 1;       // running total fanout
 441   for (j = 0; j < ndimensions-1; j++) {
 442     jint dim_con = find_int_con(length[j], -1);
 443     expand_fanout *= dim_con;
 444     expand_count  += expand_fanout; // count the level-J sub-arrays
 445     if (dim_con <= 0
 446         || dim_con > expand_limit
 447         || expand_count > expand_limit) {
 448       expand_count = 0;
 449       break;
 450     }


 458     // to reexecute the multianewarray bytecode if deoptimization happens.
 459     // Do it unconditionally even for one dimension multianewarray.
 460     // Note: the reexecute bit will be set in GraphKit::add_safepoint_edges()
 461     // when AllocateArray node for newarray is created.
 462     { PreserveReexecuteState preexecs(this);
 463       _sp += ndimensions;
 464       // Pass 0 as nargs since uncommon trap code does not need to restore stack.
 465       obj = expand_multianewarray(array_klass, &length[0], ndimensions, 0);
 466     } //original reexecute and sp are set back here
 467     push(obj);
 468     return;
 469   }
 470 
 471   address fun = NULL;
 472   switch (ndimensions) {
 473   //case 1: Actually, there is no case 1.  It's handled by new_array.
 474   case 2: fun = OptoRuntime::multianewarray2_Java(); break;
 475   case 3: fun = OptoRuntime::multianewarray3_Java(); break;
 476   case 4: fun = OptoRuntime::multianewarray4_Java(); break;
 477   case 5: fun = OptoRuntime::multianewarray5_Java(); break;
 478   default: ShouldNotReachHere();
 479   };

 480 
 481   Node* c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,

 482                               OptoRuntime::multianewarray_Type(ndimensions),
 483                               fun, NULL, TypeRawPtr::BOTTOM,
 484                               makecon(TypeKlassPtr::make(array_klass)),
 485                               length[0], length[1], length[2],
 486                               length[3], length[4]);


















 487   Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms));
 488 
 489   const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
 490 
 491   // Improve the type:  We know it's not null, exact, and of a given length.
 492   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 493   type = type->is_aryptr()->cast_to_exactness(true);
 494 
 495   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 496   if (ltype != NULL)
 497     type = type->is_aryptr()->cast_to_size(ltype);
 498 
 499   // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 500 
 501   Node* cast = _gvn.transform( new (C, 2) CheckCastPPNode(control(), res, type) );
 502   push(cast);
 503 
 504   // Possible improvements:
 505   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 506   // - Issue CastII against length[*] values, to TypeInt::POS.


 400     for (jint i = 0; i < length_con; i++) {
 401       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
 402       intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
 403       Node*    eaddr  = basic_plus_adr(array, offset);
 404       store_oop_to_array(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT);
 405     }
 406   }
 407   return array;
 408 }
 409 
 410 void Parse::do_multianewarray() {
 411   int ndimensions = iter().get_dimensions();
 412 
 413   // the m-dimensional array
 414   bool will_link;
 415   ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
 416   assert(will_link, "multianewarray: typeflow responsibility");
 417 
 418   // Note:  Array classes are always initialized; no is_initialized check.
 419 







 420   kill_dead_locals();
 421 
 422   // get the lengths from the stack (first dimension is on top)
 423   Node** length = NEW_RESOURCE_ARRAY(Node*, ndimensions + 1);
 424   length[ndimensions] = NULL;  // terminating null for make_runtime_call
 425   int j;
 426   for (j = ndimensions-1; j >= 0 ; j--) length[j] = pop();
 427 
 428   // The original expression was of this form: new T[length0][length1]...
 429   // It is often the case that the lengths are small (except the last).
 430   // If that happens, use the fast 1-d creator a constant number of times.
 431   const jint expand_limit = MIN2((juint)MultiArrayExpandLimit, (juint)100);
 432   jint expand_count = 1;        // count of allocations in the expansion
 433   jint expand_fanout = 1;       // running total fanout
 434   for (j = 0; j < ndimensions-1; j++) {
 435     jint dim_con = find_int_con(length[j], -1);
 436     expand_fanout *= dim_con;
 437     expand_count  += expand_fanout; // count the level-J sub-arrays
 438     if (dim_con <= 0
 439         || dim_con > expand_limit
 440         || expand_count > expand_limit) {
 441       expand_count = 0;
 442       break;
 443     }


 451     // to reexecute the multianewarray bytecode if deoptimization happens.
 452     // Do it unconditionally even for one dimension multianewarray.
 453     // Note: the reexecute bit will be set in GraphKit::add_safepoint_edges()
 454     // when AllocateArray node for newarray is created.
 455     { PreserveReexecuteState preexecs(this);
 456       _sp += ndimensions;
 457       // Pass 0 as nargs since uncommon trap code does not need to restore stack.
 458       obj = expand_multianewarray(array_klass, &length[0], ndimensions, 0);
 459     } //original reexecute and sp are set back here
 460     push(obj);
 461     return;
 462   }
 463 
 464   address fun = NULL;
 465   switch (ndimensions) {
 466   //case 1: Actually, there is no case 1.  It's handled by new_array.
 467   case 2: fun = OptoRuntime::multianewarray2_Java(); break;
 468   case 3: fun = OptoRuntime::multianewarray3_Java(); break;
 469   case 4: fun = OptoRuntime::multianewarray4_Java(); break;
 470   case 5: fun = OptoRuntime::multianewarray5_Java(); break;

 471   };
 472   Node* c = NULL;
 473 
 474   if (fun != NULL) {
 475     c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
 476                           OptoRuntime::multianewarray_Type(ndimensions),
 477                           fun, NULL, TypeRawPtr::BOTTOM,
 478                           makecon(TypeKlassPtr::make(array_klass)),
 479                           length[0], length[1], length[2],
 480                           length[3], length[4]);
 481   } else {
 482     // Create a java array for dimention sizes
 483     Node* dims_array_klass = makecon(TypeKlassPtr::make(ciArrayKlass::make(ciType::make(T_INT))));
 484     Node* dims = new_array(dims_array_klass, intcon(ndimensions), 0);
 485 
 486     // Fill-in it with values
 487     for (j = 0; j < ndimensions; j++) {
 488       Node *dims_elem = array_element_address(dims, intcon(j), T_INT);
 489       store_to_memory(control(), dims_elem, length[j], T_INT, TypeAryPtr::INTS);
 490     }
 491 
 492     c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
 493                           OptoRuntime::multianewarrayN_Type(),
 494                           OptoRuntime::multianewarrayN_Java(), NULL, TypeRawPtr::BOTTOM,
 495                           makecon(TypeKlassPtr::make(array_klass)),
 496                           dims);
 497   }
 498 
 499   Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms));
 500 
 501   const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
 502 
 503   // Improve the type:  We know it's not null, exact, and of a given length.
 504   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 505   type = type->is_aryptr()->cast_to_exactness(true);
 506 
 507   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 508   if (ltype != NULL)
 509     type = type->is_aryptr()->cast_to_size(ltype);
 510 
 511     // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 512 
 513   Node* cast = _gvn.transform( new (C, 2) CheckCastPPNode(control(), res, type) );
 514   push(cast);
 515 
 516   // Possible improvements:
 517   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 518   // - Issue CastII against length[*] values, to TypeInt::POS.
src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File