RFR(L): 8185556: [MVT] C2 compiler support for non-flattened value type fields
Roland Westrelin
rwestrel at redhat.com
Thu Sep 28 14:47:51 UTC 2017
Hi Tobias,
>> callGenerator.cpp:
>>
>> 442 Node* ctl = map->control();
>> 443 arg = ValueTypeNode::make(gvn, ctl, map->memory(), arg);
>> 444 map->set_control(ctl);
>>
>> Why the set_control()?
>
> That's necessary because ValueTypeNode::make may update ctl when adding a null check for a non-flattened value type
> field load. We need to use the new control when continuing with parsing.
I still don't get that one.
Is this the code we're talking about:
Node* ValueTypeNode::make(PhaseGVN& gvn, Node*& ctl, Node* mem, Node* oop, bool null_check) {
// Create and initialize a ValueTypeNode by loading all field
// values from a heap-allocated version and also save the oop.
const TypeValueType* type = gvn.type(oop)->is_valuetypeptr()->value_type();
ValueTypeNode* vt = new ValueTypeNode(type, oop);
if (null_check && !vt->is_allocated(&gvn)) {
// Add oop null check
Node* chk = gvn.transform(new CmpPNode(oop, gvn.zerocon(T_VALUETYPE)));
Node* tst = gvn.transform(new BoolNode(chk, BoolTest::ne));
IfNode* iff = gvn.transform(new IfNode(ctl, tst, PROB_MAX, COUNT_UNKNOWN))->as_If();
Node* not_null = gvn.transform(new IfTrueNode(iff));
Node* null = gvn.transform(new IfFalseNode(iff));
Node* region = new RegionNode(3);
// Load value type from memory if oop is non-null
oop = new CastPPNode(oop, TypePtr::NOTNULL);
oop->set_req(0, not_null);
oop = gvn.transform(oop);
vt->load(gvn, not_null, mem, oop, oop, type->value_klass());
region->init_req(1, not_null);
// Use default value type if oop is null
Node* def = make_default(gvn, type->value_klass());
region->init_req(2, null);
// Merge the two value types and update control
vt = vt->clone_with_phis(&gvn, region)->as_ValueType();
vt->merge_with(&gvn, def->as_ValueType(), 2, true);
ctl = gvn.transform(region);
What is the use of the region then? How is it connected to the rest of
the graph?
Roland.
More information about the valhalla-dev
mailing list