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

src/share/vm/opto/parse3.cpp

Print this page



 516 
 517   // Improve the type:  We know it's not null, exact, and of a given length.
 518   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 519   type = type->is_aryptr()->cast_to_exactness(true);
 520 
 521   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 522   if (ltype != NULL)
 523     type = type->is_aryptr()->cast_to_size(ltype);
 524 
 525     // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 526 
 527   Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
 528   push(cast);
 529 
 530   // Possible improvements:
 531   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 532   // - Issue CastII against length[*] values, to TypeInt::POS.
 533 }
 534 
 535 void Parse::do_vbox() {
 536   // Obtain a value type from the top of the stack
 537   ValueTypeNode* vt = pop()->as_ValueType();
 538 
 539   // Obtain types
 540   bool will_link;
 541   ciValueKlass* dvt_klass = gvn().type(vt)->is_valuetype()->value_klass();
 542   ciInstanceKlass* vcc_klass = iter().get_klass(will_link)->as_instance_klass();
 543   guarantee(will_link, "value-capable class must be loaded");










 544 
 545   kill_dead_locals();
 546 
 547   // TODO: Generate all (or some) of the following checks
 548   // (1) if target is not an value-capable instance, throw ClassCastException
 549   // (2) if source is not a value type instance, throw ClassCastException
 550   // (3) if target type is not a value type derived from source






 551 
 552   // create new object
 553   Node* kls = makecon(TypeKlassPtr::make(vcc_klass));
 554   Node* obj = new_instance(kls);
 555 
 556   // Store all field values to the newly created object.
 557   // The code below relies on the assumption that the VCC has the
 558   // same memory layout as the derived value type.
 559   // TODO: Once the layout of the two is not the same, update code below.
 560   vt->store_values(this, obj, obj, vcc_klass);
 561 
 562   // Push the new object onto the stack
 563   push(obj);
 564 }
 565 
 566 void Parse::do_vunbox() {
 567   // Obtain object from the top of the stack
 568   Node* obj = pop();







 569 
 570   // Obtain types
 571   bool will_link;
 572   ciInstanceKlass* vcc_klass = gvn().type(obj)->is_oopptr()->klass()->as_instance_klass();
 573   ciValueKlass* dvt_klass = iter().get_klass(will_link)->as_value_klass();
 574   guarantee(will_link, "derived value type must be loaded");
































 575 
 576   // TOOD: Generate all the checks. Similar to vbox

 577 
 578   // Create a value type node with the corresponding type
 579   Node* vt = ValueTypeNode::make(gvn(), dvt_klass, map()->memory(), obj, obj, vcc_klass, dvt_klass->first_field_offset());
 580 
 581   // Push the value type onto the stack
 582   push(vt);
 583 }

 516 
 517   // Improve the type:  We know it's not null, exact, and of a given length.
 518   type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
 519   type = type->is_aryptr()->cast_to_exactness(true);
 520 
 521   const TypeInt* ltype = _gvn.find_int_type(length[0]);
 522   if (ltype != NULL)
 523     type = type->is_aryptr()->cast_to_size(ltype);
 524 
 525     // We cannot sharpen the nested sub-arrays, since the top level is mutable.
 526 
 527   Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
 528   push(cast);
 529 
 530   // Possible improvements:
 531   // - Make a fast path for small multi-arrays.  (W/ implicit init. loops.)
 532   // - Issue CastII against length[*] values, to TypeInt::POS.
 533 }
 534 
 535 void Parse::do_vbox() {
 536   // Obtain target type (from bytecodes)



 537   bool will_link;
 538   ciKlass* target_klass = iter().get_klass(will_link);
 539   guarantee(will_link, "vbox: Value-capable class must be loaded");
 540   guarantee(target_klass->is_instance_klass(), "vbox: Target class must be an instance type");
 541 
 542   // Obtain source type
 543   ValueTypeNode* vt = peek()->as_ValueType();
 544   const TypeValueType* source_type = gvn().type(vt)->isa_valuetype();
 545   guarantee(source_type != NULL && source_type->value_klass() != NULL && source_type->value_klass()->is_loaded(),
 546             "vbox: Source class must be a value type and must be loaded");
 547 
 548   ciInstanceKlass* target_vcc_klass = target_klass->as_instance_klass();
 549   guarantee(target_vcc_klass->has_derive_value_type(), "vbox: Target class must have a derived value type class linked");
 550   ciValueKlass* target_dvt_klass = target_vcc_klass->derive_value_type()->as_value_klass();
 551 
 552   kill_dead_locals();
 553 
 554   // TODO: Extend type check below if (and once) value type class hierarchies become available.
 555   // (incl. extension to support dynamic type checks).
 556   guarantee(source_type->value_klass()->exact_klass(), "Value type classes are exact");
 557   if (!source_type->value_klass()->equals(target_dvt_klass)) {
 558     builtin_throw(Deoptimization::Reason_class_check);
 559     guarantee(stopped(), "A ClassCastException must be always thrown on this path");
 560     return;
 561   }
 562 
 563   pop();
 564 
 565   // Create new object
 566   Node* kls = makecon(TypeKlassPtr::make(target_vcc_klass));
 567   Node* obj = new_instance(kls);
 568 
 569   // Store all field values to the newly created object.
 570   // The code below relies on the assumption that the VCC has the
 571   // same memory layout as the derived value type.
 572   // TODO: Once the layout of the two is not the same, update code below.
 573   vt->as_ValueType()->store_values(this, obj, obj, target_vcc_klass);
 574 
 575   // Push the new object onto the stack
 576   push(obj);
 577 }
 578 
 579 void Parse::do_vunbox() {
 580   kill_dead_locals();
 581 
 582   // Check if the VCC instance is null.
 583   Node* not_null_obj = null_check(peek());
 584 
 585   // Value determined to be null at compile time
 586   if (stopped()) {
 587     return;
 588   }
 589 
 590   // Obtain target type (from bytecodes)
 591   bool will_link;
 592   ciKlass* target_klass = iter().get_klass(will_link);
 593   guarantee(will_link, "vunbox: Derived value type must be loaded");
 594   guarantee(target_klass->is_valuetype(), "vunbox: Target class must be a value type");
 595 
 596   // Obtain source type
 597   const TypeOopPtr* source_type = gvn().type(not_null_obj)->isa_oopptr();
 598   guarantee(source_type != NULL && source_type->klass() != NULL &&
 599             source_type->klass()->is_instance_klass() && source_type->klass()->is_loaded(),
 600             "vunbox: Source class must be an instance type and must be loaded");
 601 
 602   ciValueKlass* target_dvt_klass = target_klass->as_value_klass();
 603   guarantee(target_dvt_klass->has_derive_value_type(), "vunbox: Target class must have a value-capable class linked");
 604   ciInstanceKlass* target_vcc_klass = target_dvt_klass->derive_value_type()->as_instance_klass();
 605 
 606   // Check if the class of the source is a subclass of the value-capable class
 607   // corresponding to the target.
 608   // TOOD: Implement profiling of vunbox bytecodes to enable type speculation.
 609   if (!target_vcc_klass->is_subclass_of(source_type->klass())) {
 610     // It is obvious at compile-time that source and target are unrelated.
 611     builtin_throw(Deoptimization::Reason_class_check);
 612     guarantee(stopped(), "A ClassCastException must be always thrown on this path");
 613     return;
 614   }
 615 
 616   if (!target_vcc_klass->equals(source_type->klass()) || !source_type->klass_is_exact()) {
 617     Node* exact_obj = not_null_obj;
 618     Node* slow_ctl  = type_check_receiver(exact_obj, target_vcc_klass, 1.0, &exact_obj);
 619     {
 620       PreserveJVMState pjvms(this);
 621       set_control(slow_ctl);
 622       builtin_throw(Deoptimization::Reason_class_check);
 623     }
 624     replace_in_map(not_null_obj, exact_obj);
 625     not_null_obj = exact_obj;
 626   }
 627 
 628   // Remove object from the top of the stack
 629   pop();
 630 
 631   // Create a value type node with the corresponding type
 632   Node* vt = ValueTypeNode::make(gvn(), target_dvt_klass, map()->memory(), not_null_obj, not_null_obj, target_vcc_klass, target_dvt_klass->first_field_offset());
 633 
 634   // Push the value type onto the stack
 635   push(vt);
 636 }
src/share/vm/opto/parse3.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File