From: balazs.kilvady@imgtec.com Date: Thu, 11 Sep 2014 12:13:09 +0000 (+0000) Subject: MIPS: Added CallInterfaceDescriptors to all code stubs. X-Git-Tag: upstream/4.7.83~6981 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a5001ddd19cb0f97c222708fd8ff54c50ee9a3e;p=platform%2Fupstream%2Fv8.git MIPS: Added CallInterfaceDescriptors to all code stubs. Port r23854 (3870059) Original commit message: Added CallInterfaceDescriptors to all code stubs. A handful of code stubs are too complex to be described this way, and they are encoded with the macro DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(). Along the way: * allowed inheritance of CallInterfaceDescriptors. * Defined static Register methods for some of the new CallInterfaceDescriptors. We could go a lot further here, but it doesn't have to be done immediately. * Added Representation arrays to some CallInterfaceDescriptors, especially where future hydrogen versions of the stubs could benefit from this knowledge. BUG= R=dusan.milosavljevic@imgtec.com Review URL: https://codereview.chromium.org/562153002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23872 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/ic/mips/handler-compiler-mips.cc b/src/ic/mips/handler-compiler-mips.cc index c27e35c..0cbaf13 100644 --- a/src/ic/mips/handler-compiler-mips.cc +++ b/src/ic/mips/handler-compiler-mips.cc @@ -679,7 +679,7 @@ void NamedLoadHandlerCompiler::GenerateLoadCallback( __ mov(a2, scratch2()); // Saved in case scratch2 == a1. // Abi for CallApiGetter. - Register getter_address_reg = a2; + Register getter_address_reg = ApiGetterDescriptor::function_address(); Address getter_address = v8::ToCData
(callback->getter()); ApiFunction fun(getter_address); diff --git a/src/ic/mips64/handler-compiler-mips64.cc b/src/ic/mips64/handler-compiler-mips64.cc index 6d76113..231e715 100644 --- a/src/ic/mips64/handler-compiler-mips64.cc +++ b/src/ic/mips64/handler-compiler-mips64.cc @@ -679,7 +679,7 @@ void NamedLoadHandlerCompiler::GenerateLoadCallback( __ mov(a2, scratch2()); // Saved in case scratch2 == a1. // Abi for CallApiGetter. - Register getter_address_reg = a2; + Register getter_address_reg = ApiGetterDescriptor::function_address(); Address getter_address = v8::ToCData
(callback->getter()); ApiFunction fun(getter_address); diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 96098fc..963a83e 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -836,7 +836,8 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { void MathPowStub::Generate(MacroAssembler* masm) { const Register base = a1; - const Register exponent = a2; + const Register exponent = MathPowTaggedDescriptor::exponent(); + DCHECK(exponent.is(a2)); const Register heapnumbermap = t1; const Register heapnumber = v0; const DoubleRegister double_base = f2; @@ -1598,6 +1599,8 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { // relative to the frame pointer. const int kDisplacement = StandardFrameConstants::kCallerSPOffset - kPointerSize; + DCHECK(a1.is(ArgumentsAccessReadDescriptor::index())); + DCHECK(a0.is(ArgumentsAccessReadDescriptor::parameter_count())); // Check that the key is a smiGenerateReadElement. Label slow; @@ -4827,7 +4830,8 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) { // -- a2 : api_function_address // ----------------------------------- - Register api_function_address = a2; + Register api_function_address = ApiGetterDescriptor::function_address(); + DCHECK(api_function_address.is(a2)); __ mov(a0, sp); // a0 = Handle __ Addu(a1, a0, Operand(1 * kPointerSize)); // a1 = PCA diff --git a/src/mips/code-stubs-mips.h b/src/mips/code-stubs-mips.h index 6f075bc..afad32b 100644 --- a/src/mips/code-stubs-mips.h +++ b/src/mips/code-stubs-mips.h @@ -55,6 +55,7 @@ class StoreRegistersStateStub: public PlatformCodeStub { static void GenerateAheadOfTime(Isolate* isolate); private: + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(StoreRegistersState, PlatformCodeStub); }; @@ -67,6 +68,7 @@ class RestoreRegistersStateStub: public PlatformCodeStub { static void GenerateAheadOfTime(Isolate* isolate); private: + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(RestoreRegistersState, PlatformCodeStub); }; @@ -115,6 +117,7 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub { class ScratchRegisterBits: public BitField {}; class SignRegisterBits: public BitField {}; + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(WriteInt32ToHeapNumber, PlatformCodeStub); }; @@ -208,6 +211,8 @@ class RecordWriteStub: public PlatformCodeStub { 4 * Assembler::kInstrSize); } + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); + private: // This is a helper class for freeing up 3 scratch registers. The input is // two registers that must be preserved and one scratch register provided by @@ -332,6 +337,7 @@ class DirectCEntryStub: public PlatformCodeStub { private: bool NeedsImmovableCode() { return true; } + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(DirectCEntry, PlatformCodeStub); }; @@ -379,6 +385,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub { class LookupModeBits: public BitField {}; + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(NameDictionaryLookup, PlatformCodeStub); }; diff --git a/src/mips/interface-descriptors-mips.cc b/src/mips/interface-descriptors-mips.cc index 8f97b4b..936ce20 100644 --- a/src/mips/interface-descriptors-mips.cc +++ b/src/mips/interface-descriptors-mips.cc @@ -18,17 +18,9 @@ const Register LoadDescriptor::ReceiverRegister() { return a1; } const Register LoadDescriptor::NameRegister() { return a2; } -const Register VectorLoadICDescriptor::ReceiverRegister() { - return LoadDescriptor::ReceiverRegister(); -} - - -const Register VectorLoadICDescriptor::NameRegister() { - return LoadDescriptor::NameRegister(); -} +const Register VectorLoadICTrampolineDescriptor::SlotRegister() { return a0; } -const Register VectorLoadICDescriptor::SlotRegister() { return a0; } const Register VectorLoadICDescriptor::VectorRegister() { return a3; } @@ -37,26 +29,26 @@ const Register StoreDescriptor::NameRegister() { return a2; } const Register StoreDescriptor::ValueRegister() { return a0; } -const Register ElementTransitionAndStoreDescriptor::ReceiverRegister() { - return StoreDescriptor::ReceiverRegister(); -} +const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; } -const Register ElementTransitionAndStoreDescriptor::NameRegister() { - return StoreDescriptor::NameRegister(); -} +const Register InstanceofDescriptor::left() { return a0; } +const Register InstanceofDescriptor::right() { return a1; } -const Register ElementTransitionAndStoreDescriptor::ValueRegister() { - return StoreDescriptor::ValueRegister(); -} +const Register ArgumentsAccessReadDescriptor::index() { return a1; } +const Register ArgumentsAccessReadDescriptor::parameter_count() { return a0; } -const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; } +const Register ApiGetterDescriptor::function_address() { return a2; } -const Register InstanceofDescriptor::left() { return a0; } -const Register InstanceofDescriptor::right() { return a1; } +const Register MathPowTaggedDescriptor::exponent() { return a2; } + + +const Register MathPowIntegerDescriptor::exponent() { + return MathPowTaggedDescriptor::exponent(); +} void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) { @@ -107,12 +99,29 @@ void CreateAllocationSiteDescriptor::Initialize( } +void StoreArrayLiteralElementDescriptor::Initialize( + CallInterfaceDescriptorData* data) { + Register registers[] = {cp, a3, a0}; + data->Initialize(arraysize(registers), registers, NULL); +} + + void CallFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) { Register registers[] = {cp, a1}; data->Initialize(arraysize(registers), registers, NULL); } +void CallFunctionWithFeedbackDescriptor::Initialize( + CallInterfaceDescriptorData* data) { + Register registers[] = {cp, a1, a3}; + Representation representations[] = {Representation::Tagged(), + Representation::Tagged(), + Representation::Smi()}; + data->Initialize(arraysize(registers), registers, representations); +} + + void CallConstructDescriptor::Initialize(CallInterfaceDescriptorData* data) { // a0 : number of arguments // a1 : the function to call diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index aca6bb3..0f6a6a1 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -3854,10 +3854,11 @@ void LCodeGen::DoPower(LPower* instr) { Representation exponent_type = instr->hydrogen()->right()->representation(); // Having marked this as a call, we can use any registers. // Just make sure that the input/output registers are the expected ones. + Register tagged_exponent = MathPowTaggedDescriptor::exponent(); DCHECK(!instr->right()->IsDoubleRegister() || ToDoubleRegister(instr->right()).is(f4)); DCHECK(!instr->right()->IsRegister() || - ToRegister(instr->right()).is(a2)); + ToRegister(instr->right()).is(tagged_exponent)); DCHECK(ToDoubleRegister(instr->left()).is(f2)); DCHECK(ToDoubleRegister(instr->result()).is(f0)); @@ -3866,8 +3867,9 @@ void LCodeGen::DoPower(LPower* instr) { __ CallStub(&stub); } else if (exponent_type.IsTagged()) { Label no_deopt; - __ JumpIfSmi(a2, &no_deopt); - __ lw(t3, FieldMemOperand(a2, HeapObject::kMapOffset)); + __ JumpIfSmi(tagged_exponent, &no_deopt); + DCHECK(!t3.is(tagged_exponent)); + __ lw(t3, FieldMemOperand(tagged_exponent, HeapObject::kMapOffset)); __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); DeoptimizeIf(ne, instr->environment(), t3, Operand(at)); __ bind(&no_deopt); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 3109e4a..6b91023 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1640,9 +1640,10 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { Representation exponent_type = instr->right()->representation(); DCHECK(instr->left()->representation().IsDouble()); LOperand* left = UseFixedDouble(instr->left(), f2); - LOperand* right = exponent_type.IsDouble() ? - UseFixedDouble(instr->right(), f4) : - UseFixed(instr->right(), a2); + LOperand* right = + exponent_type.IsDouble() + ? UseFixedDouble(instr->right(), f4) + : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent()); LPower* result = new(zone()) LPower(left, right); return MarkAsCall(DefineFixedDouble(result, f0), instr, diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index 29313a9..45c56ef 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -831,7 +831,8 @@ void StoreBufferOverflowStub::Generate(MacroAssembler* masm) { void MathPowStub::Generate(MacroAssembler* masm) { const Register base = a1; - const Register exponent = a2; + const Register exponent = MathPowTaggedDescriptor::exponent(); + DCHECK(exponent.is(a2)); const Register heapnumbermap = a5; const Register heapnumber = v0; const DoubleRegister double_base = f2; @@ -1597,6 +1598,8 @@ void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { // relative to the frame pointer. const int kDisplacement = StandardFrameConstants::kCallerSPOffset - kPointerSize; + DCHECK(a1.is(ArgumentsAccessReadDescriptor::index())); + DCHECK(a0.is(ArgumentsAccessReadDescriptor::parameter_count())); // Check that the key is a smiGenerateReadElement. Label slow; @@ -4865,7 +4868,8 @@ void CallApiGetterStub::Generate(MacroAssembler* masm) { // -- a2 : api_function_address // ----------------------------------- - Register api_function_address = a2; + Register api_function_address = ApiGetterDescriptor::function_address(); + DCHECK(api_function_address.is(a2)); __ mov(a0, sp); // a0 = Handle __ Daddu(a1, a0, Operand(1 * kPointerSize)); // a1 = PCA diff --git a/src/mips64/code-stubs-mips64.h b/src/mips64/code-stubs-mips64.h index 86f4ab6..6c324bb 100644 --- a/src/mips64/code-stubs-mips64.h +++ b/src/mips64/code-stubs-mips64.h @@ -56,6 +56,7 @@ class StoreRegistersStateStub: public PlatformCodeStub { static void GenerateAheadOfTime(Isolate* isolate); private: + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(StoreRegistersState, PlatformCodeStub); }; @@ -68,6 +69,7 @@ class RestoreRegistersStateStub: public PlatformCodeStub { static void GenerateAheadOfTime(Isolate* isolate); private: + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(RestoreRegistersState, PlatformCodeStub); }; @@ -117,6 +119,7 @@ class WriteInt32ToHeapNumberStub : public PlatformCodeStub { class ScratchRegisterBits: public BitField {}; class SignRegisterBits: public BitField {}; + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_CODE_STUB(WriteInt32ToHeapNumber, PlatformCodeStub); }; @@ -210,6 +213,8 @@ class RecordWriteStub: public PlatformCodeStub { 4 * Assembler::kInstrSize); } + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); + private: // This is a helper class for freeing up 3 scratch registers. The input is // two registers that must be preserved and one scratch register provided by @@ -334,6 +339,7 @@ class DirectCEntryStub: public PlatformCodeStub { private: bool NeedsImmovableCode() { return true; } + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(DirectCEntry, PlatformCodeStub); }; @@ -381,6 +387,7 @@ class NameDictionaryLookupStub: public PlatformCodeStub { class LookupModeBits: public BitField {}; + DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR(); DEFINE_PLATFORM_CODE_STUB(NameDictionaryLookup, PlatformCodeStub); }; diff --git a/src/mips64/interface-descriptors-mips64.cc b/src/mips64/interface-descriptors-mips64.cc index 236cf64..8759bdd 100644 --- a/src/mips64/interface-descriptors-mips64.cc +++ b/src/mips64/interface-descriptors-mips64.cc @@ -18,17 +18,9 @@ const Register LoadDescriptor::ReceiverRegister() { return a1; } const Register LoadDescriptor::NameRegister() { return a2; } -const Register VectorLoadICDescriptor::ReceiverRegister() { - return LoadDescriptor::ReceiverRegister(); -} - - -const Register VectorLoadICDescriptor::NameRegister() { - return LoadDescriptor::NameRegister(); -} +const Register VectorLoadICTrampolineDescriptor::SlotRegister() { return a0; } -const Register VectorLoadICDescriptor::SlotRegister() { return a0; } const Register VectorLoadICDescriptor::VectorRegister() { return a3; } @@ -37,26 +29,26 @@ const Register StoreDescriptor::NameRegister() { return a2; } const Register StoreDescriptor::ValueRegister() { return a0; } -const Register ElementTransitionAndStoreDescriptor::ReceiverRegister() { - return StoreDescriptor::ReceiverRegister(); -} +const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; } -const Register ElementTransitionAndStoreDescriptor::NameRegister() { - return StoreDescriptor::NameRegister(); -} +const Register InstanceofDescriptor::left() { return a0; } +const Register InstanceofDescriptor::right() { return a1; } -const Register ElementTransitionAndStoreDescriptor::ValueRegister() { - return StoreDescriptor::ValueRegister(); -} +const Register ArgumentsAccessReadDescriptor::index() { return a1; } +const Register ArgumentsAccessReadDescriptor::parameter_count() { return a0; } -const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; } +const Register ApiGetterDescriptor::function_address() { return a2; } -const Register InstanceofDescriptor::left() { return a0; } -const Register InstanceofDescriptor::right() { return a1; } +const Register MathPowTaggedDescriptor::exponent() { return a2; } + + +const Register MathPowIntegerDescriptor::exponent() { + return MathPowTaggedDescriptor::exponent(); +} void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) { @@ -107,6 +99,23 @@ void CreateAllocationSiteDescriptor::Initialize( } +void StoreArrayLiteralElementDescriptor::Initialize( + CallInterfaceDescriptorData* data) { + Register registers[] = {cp, a3, a0}; + data->Initialize(arraysize(registers), registers, NULL); +} + + +void CallFunctionWithFeedbackDescriptor::Initialize( + CallInterfaceDescriptorData* data) { + Register registers[] = {cp, a1, a3}; + Representation representations[] = {Representation::Tagged(), + Representation::Tagged(), + Representation::Smi()}; + data->Initialize(arraysize(registers), registers, representations); +} + + void CallFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) { Register registers[] = {cp, a1}; data->Initialize(arraysize(registers), registers, NULL); diff --git a/src/mips64/lithium-codegen-mips64.cc b/src/mips64/lithium-codegen-mips64.cc index 7da40ff..2e5589b 100644 --- a/src/mips64/lithium-codegen-mips64.cc +++ b/src/mips64/lithium-codegen-mips64.cc @@ -3893,10 +3893,11 @@ void LCodeGen::DoPower(LPower* instr) { Representation exponent_type = instr->hydrogen()->right()->representation(); // Having marked this as a call, we can use any registers. // Just make sure that the input/output registers are the expected ones. + Register tagged_exponent = MathPowTaggedDescriptor::exponent(); DCHECK(!instr->right()->IsDoubleRegister() || ToDoubleRegister(instr->right()).is(f4)); DCHECK(!instr->right()->IsRegister() || - ToRegister(instr->right()).is(a2)); + ToRegister(instr->right()).is(tagged_exponent)); DCHECK(ToDoubleRegister(instr->left()).is(f2)); DCHECK(ToDoubleRegister(instr->result()).is(f0)); @@ -3905,8 +3906,9 @@ void LCodeGen::DoPower(LPower* instr) { __ CallStub(&stub); } else if (exponent_type.IsTagged()) { Label no_deopt; - __ JumpIfSmi(a2, &no_deopt); - __ ld(a7, FieldMemOperand(a2, HeapObject::kMapOffset)); + __ JumpIfSmi(tagged_exponent, &no_deopt); + DCHECK(!a7.is(tagged_exponent)); + __ lw(a7, FieldMemOperand(tagged_exponent, HeapObject::kMapOffset)); __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); DeoptimizeIf(ne, instr->environment(), a7, Operand(at)); __ bind(&no_deopt); diff --git a/src/mips64/lithium-mips64.cc b/src/mips64/lithium-mips64.cc index baeae9f..a7af7e0 100644 --- a/src/mips64/lithium-mips64.cc +++ b/src/mips64/lithium-mips64.cc @@ -1641,9 +1641,10 @@ LInstruction* LChunkBuilder::DoPower(HPower* instr) { Representation exponent_type = instr->right()->representation(); DCHECK(instr->left()->representation().IsDouble()); LOperand* left = UseFixedDouble(instr->left(), f2); - LOperand* right = exponent_type.IsDouble() ? - UseFixedDouble(instr->right(), f4) : - UseFixed(instr->right(), a2); + LOperand* right = + exponent_type.IsDouble() + ? UseFixedDouble(instr->right(), f4) + : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent()); LPower* result = new(zone()) LPower(left, right); return MarkAsCall(DefineFixedDouble(result, f0), instr,