Index: runtime/vm/intermediate_language_arm64.cc |
diff --git a/runtime/vm/intermediate_language_arm64.cc b/runtime/vm/intermediate_language_arm64.cc |
index 3952992d3662834f3948baeb5beb4be9e1fa061f..e0c0e81e413e4dc6d4860695e2d15d05fb2174aa 100644 |
--- a/runtime/vm/intermediate_language_arm64.cc |
+++ b/runtime/vm/intermediate_language_arm64.cc |
@@ -333,12 +333,13 @@ void UnboxedConstantInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
LocationSummary* AssertAssignableInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
- const intptr_t kNumInputs = 2; |
+ const intptr_t kNumInputs = 3; |
const intptr_t kNumTemps = 0; |
LocationSummary* summary = new (zone) |
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); |
summary->set_in(0, Location::RegisterLocation(R0)); // Value. |
- summary->set_in(1, Location::RegisterLocation(R1)); // Type arguments. |
+ summary->set_in(1, Location::RegisterLocation(R1)); // Instant. type args. |
+ summary->set_in(2, Location::RegisterLocation(R2)); // Function type args. |
summary->set_out(0, Location::RegisterLocation(R0)); |
return summary; |
} |
@@ -2091,12 +2092,13 @@ void StoreStaticFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
LocationSummary* InstanceOfInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
- const intptr_t kNumInputs = 2; |
+ const intptr_t kNumInputs = 3; |
const intptr_t kNumTemps = 0; |
LocationSummary* summary = new (zone) |
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); |
- summary->set_in(0, Location::RegisterLocation(R0)); |
- summary->set_in(1, Location::RegisterLocation(R1)); |
+ summary->set_in(0, Location::RegisterLocation(R0)); // Instance. |
+ summary->set_in(1, Location::RegisterLocation(R1)); // Instant. type args. |
+ summary->set_in(2, Location::RegisterLocation(R2)); // Function type args. |
summary->set_out(0, Location::RegisterLocation(R0)); |
return summary; |
} |
@@ -2105,6 +2107,7 @@ LocationSummary* InstanceOfInstr::MakeLocationSummary(Zone* zone, |
void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
ASSERT(locs()->in(0).reg() == R0); // Value. |
ASSERT(locs()->in(1).reg() == R1); // Instantiator type arguments. |
+ ASSERT(locs()->in(2).reg() == R2); // Function type arguments. |
compiler->GenerateInstanceOf(token_pos(), deopt_id(), type(), locs()); |
ASSERT(locs()->out(0).reg() == R0); |
@@ -2344,41 +2347,45 @@ void LoadFieldInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
LocationSummary* InstantiateTypeInstr::MakeLocationSummary(Zone* zone, |
bool opt) const { |
- const intptr_t kNumInputs = 1; |
+ const intptr_t kNumInputs = 2; |
const intptr_t kNumTemps = 0; |
LocationSummary* locs = new (zone) |
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); |
- locs->set_in(0, Location::RegisterLocation(R0)); |
+ locs->set_in(0, Location::RegisterLocation(R0)); // Instant. type args. |
+ locs->set_in(1, Location::RegisterLocation(R1)); // Function type args. |
locs->set_out(0, Location::RegisterLocation(R0)); |
return locs; |
} |
void InstantiateTypeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- const Register instantiator_reg = locs()->in(0).reg(); |
+ const Register instantiator_type_args_reg = locs()->in(0).reg(); |
+ const Register function_type_args_reg = locs()->in(1).reg(); |
const Register result_reg = locs()->out(0).reg(); |
- // 'instantiator_reg' is the instantiator TypeArguments object (or null). |
+ // 'instantiator_type_args_reg' is a TypeArguments object (or null). |
+ // 'function_type_args_reg' is a TypeArguments object (or null). |
// A runtime call to instantiate the type is required. |
__ PushObject(Object::null_object()); // Make room for the result. |
__ PushObject(type()); |
- __ Push(instantiator_reg); // Push instantiator type arguments. |
+ __ PushPair(function_type_args_reg, instantiator_type_args_reg); |
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), |
- kInstantiateTypeRuntimeEntry, 2, locs()); |
- __ Drop(2); // Drop instantiator and uninstantiated type. |
+ kInstantiateTypeRuntimeEntry, 3, locs()); |
+ __ Drop(3); // Drop 2 type argument vectors and uninstantiated type. |
__ Pop(result_reg); // Pop instantiated type. |
- ASSERT(instantiator_reg == result_reg); |
+ ASSERT(instantiator_type_args_reg == result_reg); |
} |
LocationSummary* InstantiateTypeArgumentsInstr::MakeLocationSummary( |
Zone* zone, |
bool opt) const { |
- const intptr_t kNumInputs = 1; |
+ const intptr_t kNumInputs = 2; |
const intptr_t kNumTemps = 0; |
LocationSummary* locs = new (zone) |
LocationSummary(zone, kNumInputs, kNumTemps, LocationSummary::kCall); |
- locs->set_in(0, Location::RegisterLocation(R0)); |
+ locs->set_in(0, Location::RegisterLocation(R0)); // Instant. type args. |
+ locs->set_in(1, Location::RegisterLocation(R1)); // Function type args. |
locs->set_out(0, Location::RegisterLocation(R0)); |
return locs; |
} |
@@ -2386,41 +2393,54 @@ LocationSummary* InstantiateTypeArgumentsInstr::MakeLocationSummary( |
void InstantiateTypeArgumentsInstr::EmitNativeCode( |
FlowGraphCompiler* compiler) { |
- const Register instantiator_reg = locs()->in(0).reg(); |
+ const Register instantiator_type_args_reg = locs()->in(0).reg(); |
+ const Register function_type_args_reg = locs()->in(1).reg(); |
const Register result_reg = locs()->out(0).reg(); |
- ASSERT(instantiator_reg == R0); |
- ASSERT(instantiator_reg == result_reg); |
+ ASSERT(instantiator_type_args_reg == R0); |
+ ASSERT(instantiator_type_args_reg == result_reg); |
- // 'instantiator_reg' is the instantiator TypeArguments object (or null). |
+ // 'instantiator_type_args_reg' is a TypeArguments object (or null). |
+ // 'function_type_args_reg' is a TypeArguments object (or null). |
ASSERT(!type_arguments().IsUninstantiatedIdentity() && |
!type_arguments().CanShareInstantiatorTypeArguments( |
instantiator_class())); |
- // If the instantiator is null and if the type argument vector |
- // instantiated from null becomes a vector of dynamic, then use null as |
- // the type arguments. |
+ // If both the instantiator and function type arguments are null and if the |
+ // type argument vector instantiated from null becomes a vector of dynamic, |
+ // then use null as the type arguments. |
Label type_arguments_instantiated; |
const intptr_t len = type_arguments().Length(); |
- if (type_arguments().IsRawInstantiatedRaw(len)) { |
- __ CompareObject(instantiator_reg, Object::null_object()); |
+ if (type_arguments().IsRawWhenInstantiatedFromRaw(len)) { |
+ Label non_null_type_args; |
+ __ CompareObject(instantiator_type_args_reg, Object::null_object()); |
+ __ b(&non_null_type_args, NE); |
+ __ CompareObject(function_type_args_reg, Object::null_object()); |
__ b(&type_arguments_instantiated, EQ); |
+ __ Bind(&non_null_type_args); |
} |
- __ LoadObject(R2, type_arguments()); |
- __ LoadFieldFromOffset(R2, R2, TypeArguments::instantiations_offset()); |
- __ AddImmediate(R2, R2, Array::data_offset() - kHeapObjectTag); |
+ // Lookup cache before calling runtime. |
+ // TODO(regis): Consider moving this into a shared stub to reduce |
+ // generated code size. |
+ __ LoadObject(R3, type_arguments()); |
+ __ LoadFieldFromOffset(R3, R3, TypeArguments::instantiations_offset()); |
+ __ AddImmediate(R3, R3, Array::data_offset() - kHeapObjectTag); |
// The instantiations cache is initialized with Object::zero_array() and is |
// therefore guaranteed to contain kNoInstantiator. No length check needed. |
- Label loop, found, slow_case; |
+ Label loop, next, found, slow_case; |
__ Bind(&loop); |
- __ LoadFromOffset(R1, R2, 0 * kWordSize); // Cached instantiator. |
- __ CompareRegisters(R1, R0); |
+ __ LoadFromOffset(R2, R3, 0 * kWordSize); // Cached instantiator type args. |
+ __ CompareRegisters(R2, instantiator_type_args_reg); |
+ __ b(&next, NE); |
+ __ LoadFromOffset(TMP, R3, 1 * kWordSize); // Cached function type args. |
+ __ CompareRegisters(TMP, function_type_args_reg); |
__ b(&found, EQ); |
- __ AddImmediate(R2, R2, 2 * kWordSize); |
- __ CompareImmediate(R1, Smi::RawValue(StubCode::kNoInstantiator)); |
+ __ Bind(&next); |
+ __ AddImmediate(R3, R3, StubCode::kInstantiationSizeInWords * kWordSize); |
+ __ CompareImmediate(R2, Smi::RawValue(StubCode::kNoInstantiator)); |
__ b(&loop, NE); |
__ b(&slow_case); |
__ Bind(&found); |
- __ LoadFromOffset(R0, R2, 1 * kWordSize); // Cached instantiated args. |
+ __ LoadFromOffset(result_reg, R3, 2 * kWordSize); // Cached instantiated ta. |
__ b(&type_arguments_instantiated); |
__ Bind(&slow_case); |
@@ -2428,11 +2448,11 @@ void InstantiateTypeArgumentsInstr::EmitNativeCode( |
// A runtime call to instantiate the type arguments is required. |
__ PushObject(Object::null_object()); // Make room for the result. |
__ PushObject(type_arguments()); |
- __ Push(instantiator_reg); // Push instantiator type arguments. |
+ __ PushPair(function_type_args_reg, instantiator_type_args_reg); |
compiler->GenerateRuntimeCall(token_pos(), deopt_id(), |
- kInstantiateTypeArgumentsRuntimeEntry, 2, |
+ kInstantiateTypeArgumentsRuntimeEntry, 3, |
locs()); |
- __ Drop(2); // Drop instantiator and uninstantiated type arguments. |
+ __ Drop(3); // Drop 2 type argument vectors and uninstantiated args. |
__ Pop(result_reg); // Pop instantiated type arguments. |
__ Bind(&type_arguments_instantiated); |
} |