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

src/share/vm/opto/parse3.cpp

Print this page




 318 
 319   // Uncommon Trap when class that array contains is not loaded
 320   // we need the loaded class for the rest of graph; do not
 321   // initialize the container class (see Java spec)!!!
 322   assert(will_link, "anewarray: typeflow responsibility");
 323 
 324   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 325   // Check that array_klass object is loaded
 326   if (!array_klass->is_loaded()) {
 327     // Generate uncommon_trap for unloaded array_class
 328     uncommon_trap(Deoptimization::Reason_unloaded,
 329                   Deoptimization::Action_reinterpret,
 330                   array_klass);
 331     return;
 332   }
 333 
 334   kill_dead_locals();
 335 
 336   const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
 337   Node* count_val = pop();
 338   Node* obj = new_array(makecon(array_klass_type), count_val);
 339   push(obj);
 340 }
 341 
 342 
 343 void Parse::do_newarray(BasicType elem_type) {
 344   kill_dead_locals();
 345 
 346   Node*   count_val = pop();
 347   const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
 348   Node*   obj = new_array(makecon(array_klass), count_val);
 349   // Push resultant oop onto stack
 350   push(obj);
 351 }
 352 
 353 // Expand simple expressions like new int[3][5] and new Object[2][nonConLen].
 354 // Also handle the degenerate 1-dimensional case of anewarray.
 355 Node* Parse::expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions) {
 356   Node* length = lengths[0];
 357   assert(length != NULL, "");
 358   Node* array = new_array(makecon(TypeKlassPtr::make(array_klass)), length);
 359   if (ndimensions > 1) {
 360     jint length_con = find_int_con(length, -1);
 361     guarantee(length_con >= 0, "non-constant multianewarray");
 362     ciArrayKlass* array_klass_1 = array_klass->as_obj_array_klass()->element_klass()->as_array_klass();
 363     const TypePtr* adr_type = TypeAryPtr::OOPS;
 364     const Type*    elemtype = _gvn.type(array)->is_aryptr()->elem();
 365     const intptr_t header   = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
 366     for (jint i = 0; i < length_con; i++) {
 367       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1);
 368       intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
 369       Node*    eaddr  = basic_plus_adr(array, offset);
 370       store_oop_to_array(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT);
 371     }
 372   }
 373   return array;
 374 }
 375 
 376 void Parse::do_multianewarray() {
 377   int ndimensions = iter().get_dimensions();
 378 
 379   // the m-dimensional array
 380   bool will_link;
 381   ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
 382   assert(will_link, "multianewarray: typeflow responsibility");
 383 
 384   // Note:  Array classes are always initialized; no is_initialized check.
 385 
 386   enum { MAX_DIMENSION = 5 };
 387   if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {


 402   // It is often the case that the lengths are small (except the last).
 403   // If that happens, use the fast 1-d creator a constant number of times.
 404   const jint expand_limit = MIN2((juint)MultiArrayExpandLimit, (juint)100);
 405   jint expand_count = 1;        // count of allocations in the expansion
 406   jint expand_fanout = 1;       // running total fanout
 407   for (j = 0; j < ndimensions-1; j++) {
 408     jint dim_con = find_int_con(length[j], -1);
 409     expand_fanout *= dim_con;
 410     expand_count  += expand_fanout; // count the level-J sub-arrays
 411     if (dim_con <= 0
 412         || dim_con > expand_limit
 413         || expand_count > expand_limit) {
 414       expand_count = 0;
 415       break;
 416     }
 417   }
 418 
 419   // Can use multianewarray instead of [a]newarray if only one dimension,
 420   // or if all non-final dimensions are small constants.
 421   if (expand_count == 1 || (1 <= expand_count && expand_count <= expand_limit)) {
 422     Node* obj = expand_multianewarray(array_klass, &length[0], ndimensions);
 423     push(obj);
 424     return;
 425   }
 426 
 427   address fun = NULL;
 428   switch (ndimensions) {
 429   //case 1: Actually, there is no case 1.  It's handled by new_array.
 430   case 2: fun = OptoRuntime::multianewarray2_Java(); break;
 431   case 3: fun = OptoRuntime::multianewarray3_Java(); break;
 432   case 4: fun = OptoRuntime::multianewarray4_Java(); break;
 433   case 5: fun = OptoRuntime::multianewarray5_Java(); break;
 434   default: ShouldNotReachHere();
 435   };
 436 
 437   Node* c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
 438                               OptoRuntime::multianewarray_Type(ndimensions),
 439                               fun, NULL, TypeRawPtr::BOTTOM,
 440                               makecon(TypeKlassPtr::make(array_klass)),
 441                               length[0], length[1], length[2],
 442                               length[3], length[4]);




 318 
 319   // Uncommon Trap when class that array contains is not loaded
 320   // we need the loaded class for the rest of graph; do not
 321   // initialize the container class (see Java spec)!!!
 322   assert(will_link, "anewarray: typeflow responsibility");
 323 
 324   ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
 325   // Check that array_klass object is loaded
 326   if (!array_klass->is_loaded()) {
 327     // Generate uncommon_trap for unloaded array_class
 328     uncommon_trap(Deoptimization::Reason_unloaded,
 329                   Deoptimization::Action_reinterpret,
 330                   array_klass);
 331     return;
 332   }
 333 
 334   kill_dead_locals();
 335 
 336   const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
 337   Node* count_val = pop();
 338   Node* obj = new_array(makecon(array_klass_type), count_val, 1);
 339   push(obj);
 340 }
 341 
 342 
 343 void Parse::do_newarray(BasicType elem_type) {
 344   kill_dead_locals();
 345 
 346   Node*   count_val = pop();
 347   const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
 348   Node*   obj = new_array(makecon(array_klass), count_val, 1);
 349   // Push resultant oop onto stack
 350   push(obj);
 351 }
 352 
 353 // Expand simple expressions like new int[3][5] and new Object[2][nonConLen].
 354 // Also handle the degenerate 1-dimensional case of anewarray.
 355 Node* Parse::expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs) {
 356   Node* length = lengths[0];
 357   assert(length != NULL, "");
 358   Node* array = new_array(makecon(TypeKlassPtr::make(array_klass)), length, nargs);
 359   if (ndimensions > 1) {
 360     jint length_con = find_int_con(length, -1);
 361     guarantee(length_con >= 0, "non-constant multianewarray");
 362     ciArrayKlass* array_klass_1 = array_klass->as_obj_array_klass()->element_klass()->as_array_klass();
 363     const TypePtr* adr_type = TypeAryPtr::OOPS;
 364     const Type*    elemtype = _gvn.type(array)->is_aryptr()->elem();
 365     const intptr_t header   = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
 366     for (jint i = 0; i < length_con; i++) {
 367       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
 368       intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
 369       Node*    eaddr  = basic_plus_adr(array, offset);
 370       store_oop_to_array(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT);
 371     }
 372   }
 373   return array;
 374 }
 375 
 376 void Parse::do_multianewarray() {
 377   int ndimensions = iter().get_dimensions();
 378 
 379   // the m-dimensional array
 380   bool will_link;
 381   ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
 382   assert(will_link, "multianewarray: typeflow responsibility");
 383 
 384   // Note:  Array classes are always initialized; no is_initialized check.
 385 
 386   enum { MAX_DIMENSION = 5 };
 387   if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {


 402   // It is often the case that the lengths are small (except the last).
 403   // If that happens, use the fast 1-d creator a constant number of times.
 404   const jint expand_limit = MIN2((juint)MultiArrayExpandLimit, (juint)100);
 405   jint expand_count = 1;        // count of allocations in the expansion
 406   jint expand_fanout = 1;       // running total fanout
 407   for (j = 0; j < ndimensions-1; j++) {
 408     jint dim_con = find_int_con(length[j], -1);
 409     expand_fanout *= dim_con;
 410     expand_count  += expand_fanout; // count the level-J sub-arrays
 411     if (dim_con <= 0
 412         || dim_con > expand_limit
 413         || expand_count > expand_limit) {
 414       expand_count = 0;
 415       break;
 416     }
 417   }
 418 
 419   // Can use multianewarray instead of [a]newarray if only one dimension,
 420   // or if all non-final dimensions are small constants.
 421   if (expand_count == 1 || (1 <= expand_count && expand_count <= expand_limit)) {
 422     Node* obj = expand_multianewarray(array_klass, &length[0], ndimensions, ndimensions);
 423     push(obj);
 424     return;
 425   }
 426 
 427   address fun = NULL;
 428   switch (ndimensions) {
 429   //case 1: Actually, there is no case 1.  It's handled by new_array.
 430   case 2: fun = OptoRuntime::multianewarray2_Java(); break;
 431   case 3: fun = OptoRuntime::multianewarray3_Java(); break;
 432   case 4: fun = OptoRuntime::multianewarray4_Java(); break;
 433   case 5: fun = OptoRuntime::multianewarray5_Java(); break;
 434   default: ShouldNotReachHere();
 435   };
 436 
 437   Node* c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
 438                               OptoRuntime::multianewarray_Type(ndimensions),
 439                               fun, NULL, TypeRawPtr::BOTTOM,
 440                               makecon(TypeKlassPtr::make(array_klass)),
 441                               length[0], length[1], length[2],
 442                               length[3], length[4]);


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