56 void Parse::array_load(BasicType bt) {
57 const Type* elemtype = Type::TOP;
58 Node* adr = array_addressing(bt, 0, &elemtype);
59 if (stopped()) return; // guaranteed null or range check
60
61 Node* idx = pop();
62 Node* ary = pop();
63
64 // Handle value type arrays
65 const TypeOopPtr* elemptr = elemtype->make_oopptr();
66 const TypeAryPtr* ary_t = _gvn.type(ary)->is_aryptr();
67 if (elemtype->isa_valuetype() != NULL) {
68 // Load from flattened value type array
69 Node* vt = ValueTypeNode::make_from_flattened(this, elemtype->value_klass(), ary, adr);
70 push(vt);
71 return;
72 } else if (elemptr != NULL && elemptr->is_valuetypeptr() && !elemptr->maybe_null()) {
73 // Load from non-flattened but flattenable value type array (elements can never be null)
74 bt = T_VALUETYPE;
75 } else if (ValueArrayFlatten && elemptr != NULL && elemptr->can_be_value_type() &&
76 (!ary_t->klass_is_exact() || (elemptr->is_valuetypeptr() && elemptr->value_klass()->flatten_array()))) {
77 // Cannot statically determine if array is flattened, emit runtime check
78 IdealKit ideal(this);
79 IdealVariable res(ideal);
80 ideal.declarations_done();
81 Node* kls = load_object_klass(ary);
82 Node* tag = load_lh_array_tag(kls);
83 ideal.if_then(tag, BoolTest::ne, intcon(Klass::_lh_array_tag_vt_value)); {
84 // non-flattened
85 sync_kit(ideal);
86 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
87 Node* ld = access_load_at(ary, adr, adr_type, elemptr, bt,
88 IN_HEAP | IS_ARRAY | C2_CONTROL_DEPENDENT_LOAD);
89 ideal.sync_kit(this);
90 ideal.set(res, ld);
91 } ideal.else_(); {
92 // flattened
93 sync_kit(ideal);
94 if (elemptr->is_valuetypeptr()) {
95 // Element type is known, cast and load from flattened representation
96 assert(elemptr->maybe_null(), "must be nullable");
|
56 void Parse::array_load(BasicType bt) {
57 const Type* elemtype = Type::TOP;
58 Node* adr = array_addressing(bt, 0, &elemtype);
59 if (stopped()) return; // guaranteed null or range check
60
61 Node* idx = pop();
62 Node* ary = pop();
63
64 // Handle value type arrays
65 const TypeOopPtr* elemptr = elemtype->make_oopptr();
66 const TypeAryPtr* ary_t = _gvn.type(ary)->is_aryptr();
67 if (elemtype->isa_valuetype() != NULL) {
68 // Load from flattened value type array
69 Node* vt = ValueTypeNode::make_from_flattened(this, elemtype->value_klass(), ary, adr);
70 push(vt);
71 return;
72 } else if (elemptr != NULL && elemptr->is_valuetypeptr() && !elemptr->maybe_null()) {
73 // Load from non-flattened but flattenable value type array (elements can never be null)
74 bt = T_VALUETYPE;
75 } else if (ValueArrayFlatten && elemptr != NULL && elemptr->can_be_value_type() &&
76 !ary_t->klass_is_exact() && (!elemptr->is_valuetypeptr() || elemptr->value_klass()->flatten_array())) {
77 // Cannot statically determine if array is flattened, emit runtime check
78 IdealKit ideal(this);
79 IdealVariable res(ideal);
80 ideal.declarations_done();
81 Node* kls = load_object_klass(ary);
82 Node* tag = load_lh_array_tag(kls);
83 ideal.if_then(tag, BoolTest::ne, intcon(Klass::_lh_array_tag_vt_value)); {
84 // non-flattened
85 sync_kit(ideal);
86 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(bt);
87 Node* ld = access_load_at(ary, adr, adr_type, elemptr, bt,
88 IN_HEAP | IS_ARRAY | C2_CONTROL_DEPENDENT_LOAD);
89 ideal.sync_kit(this);
90 ideal.set(res, ld);
91 } ideal.else_(); {
92 // flattened
93 sync_kit(ideal);
94 if (elemptr->is_valuetypeptr()) {
95 // Element type is known, cast and load from flattened representation
96 assert(elemptr->maybe_null(), "must be nullable");
|