Index: runtime/vm/intermediate_language_x64.cc |
diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc |
index 55f64e92449612c9454afe60c10f167fd61098dc..03a3741b984141d01e465d7beaad632ef1e7a8ab 100644 |
--- a/runtime/vm/intermediate_language_x64.cc |
+++ b/runtime/vm/intermediate_language_x64.cc |
@@ -310,12 +310,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(RAX)); // Value. |
- summary->set_in(1, Location::RegisterLocation(RDX)); // Type arguments. |
+ summary->set_in(1, Location::RegisterLocation(RDX)); // Instant. type args. |
+ summary->set_in(2, Location::RegisterLocation(RCX)); // Function type args. |
summary->set_out(0, Location::RegisterLocation(RAX)); |
return summary; |
} |
@@ -2034,12 +2035,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(RAX)); |
- summary->set_in(1, Location::RegisterLocation(RDX)); |
+ summary->set_in(0, Location::RegisterLocation(RAX)); // Instance. |
+ summary->set_in(1, Location::RegisterLocation(RDX)); // Instant. type args. |
+ summary->set_in(2, Location::RegisterLocation(RCX)); // Function type args. |
summary->set_out(0, Location::RegisterLocation(RAX)); |
return summary; |
} |
@@ -2048,6 +2050,7 @@ LocationSummary* InstanceOfInstr::MakeLocationSummary(Zone* zone, |
void InstanceOfInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
ASSERT(locs()->in(0).reg() == RAX); // Value. |
ASSERT(locs()->in(1).reg() == RDX); // Instantiator type arguments. |
+ ASSERT(locs()->in(2).reg() == RCX); // Function type arguments. |
compiler->GenerateInstanceOf(token_pos(), deopt_id(), type(), locs()); |
ASSERT(locs()->out(0).reg() == RAX); |
@@ -2288,41 +2291,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(RAX)); |
+ locs->set_in(0, Location::RegisterLocation(RAX)); // Instant. type args. |
+ locs->set_in(1, Location::RegisterLocation(RDX)); // Function type args. |
locs->set_out(0, Location::RegisterLocation(RAX)); |
return locs; |
} |
void InstantiateTypeInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
- Register instantiator_reg = locs()->in(0).reg(); |
+ Register instantiator_type_args_reg = locs()->in(0).reg(); |
+ Register function_type_args_reg = locs()->in(1).reg(); |
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()); |
- __ pushq(instantiator_reg); // Push instantiator type arguments. |
+ __ pushq(instantiator_type_args_reg); // Push instantiator type arguments. |
+ __ pushq(function_type_args_reg); // Push function type arguments. |
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. |
__ popq(result_reg); // Pop instantiated type. |
- ASSERT(instantiator_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(RAX)); |
+ locs->set_in(0, Location::RegisterLocation(RAX)); // Instant. type args. |
+ locs->set_in(1, Location::RegisterLocation(RCX)); // Function type args. |
locs->set_out(0, Location::RegisterLocation(RAX)); |
return locs; |
} |
@@ -2330,44 +2337,54 @@ LocationSummary* InstantiateTypeArgumentsInstr::MakeLocationSummary( |
void InstantiateTypeArgumentsInstr::EmitNativeCode( |
FlowGraphCompiler* compiler) { |
- Register instantiator_reg = locs()->in(0).reg(); |
+ Register instantiator_type_args_reg = locs()->in(0).reg(); |
+ Register function_type_args_reg = locs()->in(1).reg(); |
Register result_reg = locs()->out(0).reg(); |
- ASSERT(instantiator_reg == RAX); |
- ASSERT(instantiator_reg == result_reg); |
+ ASSERT(instantiator_type_args_reg == RAX); |
+ 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()); |
+ __ j(NOT_EQUAL, &non_null_type_args, Assembler::kNearJump); |
+ __ CompareObject(function_type_args_reg, Object::null_object()); |
__ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); |
+ __ Bind(&non_null_type_args); |
} |
// Lookup cache before calling runtime. |
- // TODO(fschneider): Consider moving this into a shared stub to reduce |
+ // TODO(regis): Consider moving this into a shared stub to reduce |
// generated code size. |
__ LoadObject(RDI, type_arguments()); |
__ movq(RDI, FieldAddress(RDI, TypeArguments::instantiations_offset())); |
__ leaq(RDI, FieldAddress(RDI, Array::data_offset())); |
// 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); |
- __ movq(RDX, Address(RDI, 0 * kWordSize)); // Cached instantiator. |
- __ cmpq(RDX, RAX); |
+ __ movq(RDX, Address(RDI, 0 * kWordSize)); // Cached instantiator type args. |
+ __ cmpq(RDX, instantiator_type_args_reg); |
+ __ j(NOT_EQUAL, &next, Assembler::kNearJump); |
+ __ movq(R10, Address(RDI, 1 * kWordSize)); // Cached function type args. |
+ __ cmpq(R10, function_type_args_reg); |
__ j(EQUAL, &found, Assembler::kNearJump); |
- __ addq(RDI, Immediate(2 * kWordSize)); |
+ __ Bind(&next); |
+ __ addq(RDI, Immediate(StubCode::kInstantiationSizeInWords * kWordSize)); |
__ cmpq(RDX, Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
__ j(NOT_EQUAL, &loop, Assembler::kNearJump); |
__ jmp(&slow_case, Assembler::kNearJump); |
__ Bind(&found); |
- __ movq(RAX, Address(RDI, 1 * kWordSize)); // Cached instantiated args. |
+ __ movq(result_reg, Address(RDI, 2 * kWordSize)); // Cached instantiated ta. |
__ jmp(&type_arguments_instantiated, Assembler::kNearJump); |
__ Bind(&slow_case); |
@@ -2375,14 +2392,14 @@ 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()); |
- __ pushq(instantiator_reg); // Push instantiator type arguments. |
+ __ pushq(instantiator_type_args_reg); // Push instantiator type arguments. |
+ __ pushq(function_type_args_reg); // Push function type arguments. |
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. |
__ popq(result_reg); // Pop instantiated type arguments. |
__ Bind(&type_arguments_instantiated); |
- ASSERT(instantiator_reg == result_reg); |
} |