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
This commit is contained in:
balazs.kilvady@imgtec.com 2014-09-11 12:13:09 +00:00
parent 1c76394503
commit 4a5001ddd1
12 changed files with 112 additions and 66 deletions

View File

@ -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<Address>(callback->getter());
ApiFunction fun(getter_address);

View File

@ -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<Address>(callback->getter());
ApiFunction fun(getter_address);

View File

@ -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<Name>
__ Addu(a1, a0, Operand(1 * kPointerSize)); // a1 = PCA

View File

@ -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<int, 8, 4> {};
class SignRegisterBits: public BitField<int, 12, 4> {};
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<LookupMode, 0, 1> {};
DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR();
DEFINE_PLATFORM_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
};

View File

@ -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 VectorLoadICTrampolineDescriptor::SlotRegister() { return a0; }
const Register VectorLoadICDescriptor::NameRegister() {
return LoadDescriptor::NameRegister();
}
const Register VectorLoadICDescriptor::SlotRegister() { return a0; }
const Register VectorLoadICDescriptor::VectorRegister() { return a3; }
@ -37,21 +29,6 @@ const Register StoreDescriptor::NameRegister() { return a2; }
const Register StoreDescriptor::ValueRegister() { return a0; }
const Register ElementTransitionAndStoreDescriptor::ReceiverRegister() {
return StoreDescriptor::ReceiverRegister();
}
const Register ElementTransitionAndStoreDescriptor::NameRegister() {
return StoreDescriptor::NameRegister();
}
const Register ElementTransitionAndStoreDescriptor::ValueRegister() {
return StoreDescriptor::ValueRegister();
}
const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; }
@ -59,6 +36,21 @@ const Register InstanceofDescriptor::left() { return a0; }
const Register InstanceofDescriptor::right() { return a1; }
const Register ArgumentsAccessReadDescriptor::index() { return a1; }
const Register ArgumentsAccessReadDescriptor::parameter_count() { return a0; }
const Register ApiGetterDescriptor::function_address() { return a2; }
const Register MathPowTaggedDescriptor::exponent() { return a2; }
const Register MathPowIntegerDescriptor::exponent() {
return MathPowTaggedDescriptor::exponent();
}
void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2};
data->Initialize(arraysize(registers), registers, NULL);
@ -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

View File

@ -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);

View File

@ -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,

View File

@ -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<Name>
__ Daddu(a1, a0, Operand(1 * kPointerSize)); // a1 = PCA

View File

@ -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<int, 8, 4> {};
class SignRegisterBits: public BitField<int, 12, 4> {};
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<LookupMode, 0, 1> {};
DEFINE_NULL_CALL_INTERFACE_DESCRIPTOR();
DEFINE_PLATFORM_CODE_STUB(NameDictionaryLookup, PlatformCodeStub);
};

View File

@ -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 VectorLoadICTrampolineDescriptor::SlotRegister() { return a0; }
const Register VectorLoadICDescriptor::NameRegister() {
return LoadDescriptor::NameRegister();
}
const Register VectorLoadICDescriptor::SlotRegister() { return a0; }
const Register VectorLoadICDescriptor::VectorRegister() { return a3; }
@ -37,21 +29,6 @@ const Register StoreDescriptor::NameRegister() { return a2; }
const Register StoreDescriptor::ValueRegister() { return a0; }
const Register ElementTransitionAndStoreDescriptor::ReceiverRegister() {
return StoreDescriptor::ReceiverRegister();
}
const Register ElementTransitionAndStoreDescriptor::NameRegister() {
return StoreDescriptor::NameRegister();
}
const Register ElementTransitionAndStoreDescriptor::ValueRegister() {
return StoreDescriptor::ValueRegister();
}
const Register ElementTransitionAndStoreDescriptor::MapRegister() { return a3; }
@ -59,6 +36,21 @@ const Register InstanceofDescriptor::left() { return a0; }
const Register InstanceofDescriptor::right() { return a1; }
const Register ArgumentsAccessReadDescriptor::index() { return a1; }
const Register ArgumentsAccessReadDescriptor::parameter_count() { return a0; }
const Register ApiGetterDescriptor::function_address() { return a2; }
const Register MathPowTaggedDescriptor::exponent() { return a2; }
const Register MathPowIntegerDescriptor::exponent() {
return MathPowTaggedDescriptor::exponent();
}
void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2};
data->Initialize(arraysize(registers), registers, NULL);
@ -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);

View File

@ -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);

View File

@ -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,