< prev index next >

src/hotspot/share/opto/parse3.cpp

Print this page




 530 
 531   const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
 532 
 533   // Improve the type:  We know it's not null, exact, and of a given length.
 534   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 535   type = type->is_aryptr()->cast_to_exactness(true);
 536 
 537   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 538   if (ltype != NULL)
 539     type = type->is_aryptr()->cast_to_size(ltype);
 540 
 541     // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 542 
 543   Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
 544   push(cast);
 545 
 546   // Possible improvements:
 547   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 548   // - Issue CastII against length[*] values, to TypeInt::POS.
 549 }
 550 
 551 void Parse::do_vbox() {
 552   // Obtain target value-capable class
 553   bool will_link;
 554   ciInstanceKlass* dst_vcc = iter().get_klass(will_link)->as_instance_klass();
 555   assert(will_link, "vbox: Target value-capable class must be loaded");
 556 
 557   // Obtain source value type instance and type
 558   const ValueTypeNode* vt = peek()->as_ValueType();
 559   ciValueKlass* src_vk = vt->type()->is_valuetype()->value_klass();
 560   assert(src_vk != NULL && src_vk->is_loaded() && src_vk->exact_klass(),
 561          "vbox: Source class must be a value type and must be loaded and exact");
 562 
 563   // Verify that the vcc derived from the source value klass is equal to the target vcc
 564   const ciInstanceKlass* src_vcc = src_vk->vcc_klass();
 565   assert(src_vcc, "vbox: Source value-capable class must not be null");
 566   if (!src_vcc->equals(dst_vcc)) {
 567     builtin_throw(Deoptimization::Reason_class_check);
 568     assert(stopped(), "A ClassCastException must be always thrown on this path");
 569     return;
 570   }
 571 
 572   // Create new object
 573   pop();
 574   kill_dead_locals();
 575   Node* kls = makecon(TypeKlassPtr::make(dst_vcc));
 576   Node* obj = new_instance(kls);
 577 
 578   // Store all field values to the newly created object.
 579   // The code below relies on the assumption that the VCC has the
 580   // same memory layout as the derived value type.
 581   vt->store(this, obj, obj, dst_vcc);
 582 
 583   // Push the new object onto the stack
 584   push(obj);
 585 }
 586 
 587 void Parse::do_vunbox() {
 588   // Obtain target value klass
 589   bool will_link;
 590   ciValueKlass* dst_vk = iter().get_klass(will_link)->as_value_klass();
 591   assert(will_link, "vunbox: Derived value type must be loaded");
 592 
 593   // Obtain source value-capable class instance and type
 594   Node* vcc = null_check(peek());
 595   if (stopped()) {
 596     return; // Always null
 597   }
 598   ciKlass* src_vcc = gvn().type(vcc)->isa_oopptr()->klass();
 599   assert(src_vcc != NULL && src_vcc->is_instance_klass() && src_vcc->is_loaded(),
 600          "vunbox: Source class must be an instance type and must be loaded");
 601 
 602   // Verify that the source vcc is equal to the vcc derived from the target value klass
 603   ciInstanceKlass* dst_vcc = dst_vk->vcc_klass();
 604   assert(dst_vcc != NULL && dst_vcc->exact_klass(), "vunbox: Target value-capable class must not be null and exact");
 605   if (!src_vcc->equals(dst_vcc)) {
 606     if (src_vcc->exact_klass()) {
 607       // Source vcc is exact and therefore always incompatible with dst_vcc
 608       builtin_throw(Deoptimization::Reason_class_check);
 609       assert(stopped(), "A ClassCastException must be always thrown on this path");
 610       return;
 611     } else {
 612       // Emit a runtime check to verify that the dynamic type of vcc is equal to dst_vcc
 613       Node* exact_vcc = vcc;
 614       Node* slow_ctl  = type_check_receiver(vcc, dst_vcc, 1.0, &exact_vcc);
 615       {
 616         PreserveJVMState pjvms(this);
 617         set_control(slow_ctl);
 618         builtin_throw(Deoptimization::Reason_class_check);
 619       }
 620       replace_in_map(vcc, exact_vcc);
 621       vcc = exact_vcc;
 622     }
 623   }
 624 
 625   // Create a value type node with the corresponding type and push it onto the stack
 626   pop();
 627   kill_dead_locals();
 628   ValueTypeNode* vt = ValueTypeNode::make_from_flattened(this, dst_vk, vcc, vcc, dst_vcc, dst_vk->first_field_offset());
 629   push(vt);
 630 }


 530 
 531   const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
 532 
 533   // Improve the type:  We know it's not null, exact, and of a given length.
 534   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 535   type = type->is_aryptr()->cast_to_exactness(true);
 536 
 537   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 538   if (ltype != NULL)
 539     type = type->is_aryptr()->cast_to_size(ltype);
 540 
 541     // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 542 
 543   Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
 544   push(cast);
 545 
 546   // Possible improvements:
 547   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 548   // - Issue CastII against length[*] values, to TypeInt::POS.
 549 }

















































































< prev index next >