134 do_put_xxx(obj, field, is_field);
135 (void) pop(); // pop receiver after putting
136 }
137 } else {
138 const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
139 obj = _gvn.makecon(tip);
140 if (is_get) {
141 do_get_xxx(obj, field, is_field);
142 } else {
143 do_put_xxx(obj, field, is_field);
144 }
145 }
146 }
147
148 void Parse::do_vgetfield() {
149 // fixme null/top check?
150 bool will_link;
151 ciField* field = iter().get_field(will_link);
152 BasicType bt = field->layout_type();
153 ValueTypeNode* vt = pop()->as_ValueType();
154 Node* value = vt->get_field_value_by_offset(field->offset());
155 push_node(bt, value);
156 }
157
158 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
159 BasicType bt = field->layout_type();
160 // Does this field have a constant value? If so, just push the value.
161 if (field->is_constant()) {
162 // final or stable field
163 const Type* con_type = Type::make_constant(field, obj);
164 if (con_type != NULL) {
165 Node* con = makecon(con_type);
166 if (bt == T_VALUETYPE) {
167 // Load value type from constant oop
168 con = ValueTypeNode::make(gvn(), map()->memory(), con);
169 }
170 push_node(con_type->basic_type(), con);
171 return;
172 }
173 }
174
504 Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms));
505
506 const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
507
508 // Improve the type: We know it's not null, exact, and of a given length.
509 type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
510 type = type->is_aryptr()->cast_to_exactness(true);
511
512 const TypeInt* ltype = _gvn.find_int_type(length[0]);
513 if (ltype != NULL)
514 type = type->is_aryptr()->cast_to_size(ltype);
515
516 // We cannot sharpen the nested sub-arrays, since the top level is mutable.
517
518 Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
519 push(cast);
520
521 // Possible improvements:
522 // - Make a fast path for small multi-arrays. (W/ implicit init. loops.)
523 // - Issue CastII against length[*] values, to TypeInt::POS.
524 }
|
134 do_put_xxx(obj, field, is_field);
135 (void) pop(); // pop receiver after putting
136 }
137 } else {
138 const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
139 obj = _gvn.makecon(tip);
140 if (is_get) {
141 do_get_xxx(obj, field, is_field);
142 } else {
143 do_put_xxx(obj, field, is_field);
144 }
145 }
146 }
147
148 void Parse::do_vgetfield() {
149 // fixme null/top check?
150 bool will_link;
151 ciField* field = iter().get_field(will_link);
152 BasicType bt = field->layout_type();
153 ValueTypeNode* vt = pop()->as_ValueType();
154 Node* value = vt->field_value_by_offset(field->offset());
155 push_node(bt, value);
156 }
157
158 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
159 BasicType bt = field->layout_type();
160 // Does this field have a constant value? If so, just push the value.
161 if (field->is_constant()) {
162 // final or stable field
163 const Type* con_type = Type::make_constant(field, obj);
164 if (con_type != NULL) {
165 Node* con = makecon(con_type);
166 if (bt == T_VALUETYPE) {
167 // Load value type from constant oop
168 con = ValueTypeNode::make(gvn(), map()->memory(), con);
169 }
170 push_node(con_type->basic_type(), con);
171 return;
172 }
173 }
174
504 Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms));
505
506 const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
507
508 // Improve the type: We know it's not null, exact, and of a given length.
509 type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
510 type = type->is_aryptr()->cast_to_exactness(true);
511
512 const TypeInt* ltype = _gvn.find_int_type(length[0]);
513 if (ltype != NULL)
514 type = type->is_aryptr()->cast_to_size(ltype);
515
516 // We cannot sharpen the nested sub-arrays, since the top level is mutable.
517
518 Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
519 push(cast);
520
521 // Possible improvements:
522 // - Make a fast path for small multi-arrays. (W/ implicit init. loops.)
523 // - Issue CastII against length[*] values, to TypeInt::POS.
524 }
525
526 void Parse::do_vbox() {
527 // Obtain a value type from the top of the stack
528 ValueTypeNode* vt = pop()->as_ValueType();
529
530 // Obtain types
531 bool will_link;
532 ciValueKlass* dvt_klass = gvn().type(vt)->is_valuetype()->value_klass();
533 ciInstanceKlass* vcc_klass = iter().get_klass(will_link)->as_instance_klass();
534 guarantee(will_link, "value-capable class must be loaded");
535
536 kill_dead_locals();
537
538 // TODO: Generate all (or some) of the following checks
539 // (1) if target is not an value-capable instance, throw ClassCastException
540 // (2) if source is not a value type instance, throw ClassCastException
541 // (3) if target type is not a value type derived from source
542
543 // create new object
544 Node* kls = makecon(TypeKlassPtr::make(vcc_klass));
545 Node* obj = new_instance(kls);
546
547 // Store all field values to the newly created object.
548 // The code below relies on the assumption that the VCC has the
549 // same memory layout as the derived value type.
550 // TODO: Once the layout of the two is not the same, update code below.
551 vt->store_values(this, vcc_klass, obj);
552
553 // Push the new object onto the stack
554 push(obj);
555 }
556
557 void Parse::do_vunbox() {
558 // Obtain object from the top of the stack
559 Node* obj = pop();
560
561 // Obtain types
562 bool will_link;
563 ciInstanceKlass* vcc_klass = gvn().type(obj)->is_oopptr()->klass()->as_instance_klass();
564 ciValueKlass* dvt_klass = iter().get_klass(will_link)->as_value_klass();
565 guarantee(will_link, "derived value type must be loaded");
566
567 // TOOD: Generate all the checks. Similar to vbox
568
569 // Create a value type node with the corresponding type
570 Node* vt = ValueTypeNode::make(gvn(), dvt_klass, map()->memory(), vcc_klass, obj, dvt_klass->first_field_offset());
571
572 // Push the value type onto the stack
573 push(vt);
574 }
|