Use the same registers for StoreIC and KeyedStoreIC.

Based on https://codereview.chromium.org/389283002 ("Use register parameters in ElementsTransitionGenerator") which must land first.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/390013002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22387 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent acffe8c7
......@@ -221,14 +221,6 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
}
void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { r0, r3, r1, r2 };
descriptor->Initialize(ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
void BinaryOpICStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { r1, r0 };
......
......@@ -500,8 +500,8 @@ void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) {
Register receiver = ReceiverRegister();
Register key = NameRegister();
Register value = ValueRegister();
ASSERT(receiver.is(r2));
ASSERT(key.is(r1));
ASSERT(receiver.is(r1));
ASSERT(key.is(r2));
ASSERT(value.is(r0));
Label slow, notin;
......@@ -552,9 +552,24 @@ const Register StoreIC::NameRegister() { return r2; }
const Register StoreIC::ValueRegister() { return r0; }
const Register KeyedStoreIC::ReceiverRegister() { return r2; }
const Register KeyedStoreIC::NameRegister() { return r1; }
const Register KeyedStoreIC::ValueRegister() { return r0; }
const Register KeyedStoreIC::ReceiverRegister() {
return StoreIC::ReceiverRegister();
}
const Register KeyedStoreIC::NameRegister() {
return StoreIC::NameRegister();
}
const Register KeyedStoreIC::ValueRegister() {
return StoreIC::ValueRegister();
}
const Register KeyedStoreIC::MapRegister() {
return r3;
}
void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
......@@ -1027,8 +1042,8 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
Register value = ValueRegister();
Register key = NameRegister();
Register receiver = ReceiverRegister();
ASSERT(receiver.is(r2));
ASSERT(key.is(r1));
ASSERT(receiver.is(r1));
ASSERT(key.is(r2));
ASSERT(value.is(r0));
Register receiver_map = r3;
Register elements_map = r6;
......
......@@ -1294,10 +1294,11 @@ Register* StoreStubCompiler::registers() {
Register* KeyedStoreStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3.
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
static Register registers[] = { receiver, name, r3, r4, r5 };
Register map = KeyedStoreIC::MapRegister();
static Register registers[] = { receiver, name, map, r4, r5 };
return registers;
}
......@@ -1397,7 +1398,10 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
Label* smi_target = IncludesNumberType(types) ? &number_case : &miss;
__ JumpIfSmi(receiver(), smi_target);
// Polymorphic keyed stores may use the map register
Register map_reg = scratch1();
ASSERT(kind() != Code::KEYED_STORE_IC ||
map_reg.is(KeyedStoreIC::MapRegister()));
int receiver_count = types->length();
int number_of_handled_maps = 0;
......
......@@ -238,18 +238,6 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
}
void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
// x0: value
// x3: target map
// x1: key
// x2: receiver
Register registers[] = { x0, x3, x1, x2 };
descriptor->Initialize(ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
void BinaryOpICStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
// x1: left operand
......
......@@ -506,8 +506,8 @@ void KeyedStoreIC::GenerateSloppyArguments(MacroAssembler* masm) {
Register value = ValueRegister();
Register key = NameRegister();
Register receiver = ReceiverRegister();
ASSERT(receiver.is(x2));
ASSERT(key.is(x1));
ASSERT(receiver.is(x1));
ASSERT(key.is(x2));
ASSERT(value.is(x0));
Register map = x3;
......@@ -574,9 +574,24 @@ const Register StoreIC::NameRegister() { return x2; }
const Register StoreIC::ValueRegister() { return x0; }
const Register KeyedStoreIC::ReceiverRegister() { return x2; }
const Register KeyedStoreIC::NameRegister() { return x1; }
const Register KeyedStoreIC::ValueRegister() { return x0; }
const Register KeyedStoreIC::ReceiverRegister() {
return StoreIC::ReceiverRegister();
}
const Register KeyedStoreIC::NameRegister() {
return StoreIC::NameRegister();
}
const Register KeyedStoreIC::ValueRegister() {
return StoreIC::ValueRegister();
}
const Register KeyedStoreIC::MapRegister() {
return x3;
}
void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
......@@ -1068,8 +1083,8 @@ void KeyedStoreIC::GenerateGeneric(MacroAssembler* masm,
Register value = ValueRegister();
Register key = NameRegister();
Register receiver = ReceiverRegister();
ASSERT(receiver.is(x2));
ASSERT(key.is(x1));
ASSERT(receiver.is(x1));
ASSERT(key.is(x2));
ASSERT(value.is(x0));
Register receiver_map = x3;
......
......@@ -1276,10 +1276,11 @@ Register* StoreStubCompiler::registers() {
Register* KeyedStoreStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3.
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
static Register registers[] = { receiver, name, x3, x4, x5 };
Register map = KeyedStoreIC::MapRegister();
static Register registers[] = { receiver, name, map, x4, x5 };
return registers;
}
......@@ -1370,7 +1371,10 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
Label* smi_target = IncludesNumberType(types) ? &number_case : &miss;
__ JumpIfSmi(receiver(), smi_target);
// Polymorphic keyed stores may use the map register
Register map_reg = scratch1();
ASSERT(kind() != Code::KEYED_STORE_IC ||
map_reg.is(KeyedStoreIC::MapRegister()));
__ Ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
int receiver_count = types->length();
int number_of_handled_maps = 0;
......
......@@ -1077,10 +1077,10 @@ Handle<Code> StoreGlobalStub::GenerateCode() {
template<>
HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
HValue* value = GetParameter(0);
HValue* map = GetParameter(1);
HValue* key = GetParameter(2);
HValue* object = GetParameter(3);
HValue* value = GetParameter(ElementsTransitionAndStoreStub::kValueIndex);
HValue* map = GetParameter(ElementsTransitionAndStoreStub::kMapIndex);
HValue* key = GetParameter(ElementsTransitionAndStoreStub::kKeyIndex);
HValue* object = GetParameter(ElementsTransitionAndStoreStub::kObjectIndex);
if (FLAG_trace_elements_transitions) {
// Tracing elements transitions is the job of the runtime.
......
......@@ -644,6 +644,17 @@ void KeyedStoreFastElementStub::InitializeInterfaceDescriptor(
}
void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { ValueRegister(),
MapRegister(),
KeyRegister(),
ObjectRegister() };
descriptor->Initialize(ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
void StoreGlobalStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { StoreIC::ReceiverRegister(),
......
......@@ -2455,6 +2455,23 @@ class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
enum RegisterInfo {
kValueIndex,
kMapIndex,
kKeyIndex,
kObjectIndex,
kRegisterArgumentCount
};
static const Register ValueRegister() {
return KeyedStoreIC::ValueRegister();
}
static const Register MapRegister() { return KeyedStoreIC::MapRegister(); }
static const Register KeyRegister() { return KeyedStoreIC::NameRegister(); }
static const Register ObjectRegister() {
return KeyedStoreIC::ReceiverRegister();
}
private:
class FromBits: public BitField<ElementsKind, 0, 8> {};
class ToBits: public BitField<ElementsKind, 8, 8> {};
......
......@@ -225,14 +225,6 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
}
void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { eax, ebx, ecx, edx };
descriptor->Initialize(ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
void BinaryOpICStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { edx, eax };
......
......@@ -1041,6 +1041,11 @@ const Register KeyedStoreIC::ValueRegister() {
}
const Register KeyedStoreIC::MapRegister() {
return ebx;
}
void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
// Return address is on the stack.
LoadIC_PushArgs(masm);
......
......@@ -1314,10 +1314,11 @@ Register* StoreStubCompiler::registers() {
Register* KeyedStoreStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3.
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
static Register registers[] = { receiver, name, ebx, edi, no_reg };
Register map = KeyedStoreIC::MapRegister();
static Register registers[] = { receiver, name, map, edi, no_reg };
return registers;
}
......@@ -1418,7 +1419,10 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
Label* smi_target = IncludesNumberType(types) ? &number_case : &miss;
__ JumpIfSmi(receiver(), smi_target);
// Polymorphic keyed stores may use the map register
Register map_reg = scratch1();
ASSERT(kind() != Code::KEYED_STORE_IC ||
map_reg.is(KeyedStoreIC::MapRegister()));
__ mov(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset));
int receiver_count = types->length();
int number_of_handled_maps = 0;
......
......@@ -705,6 +705,11 @@ class KeyedStoreIC: public StoreIC {
static const Register NameRegister();
static const Register ValueRegister();
// The map register isn't part of the normal call specification, but
// ElementsTransitionAndStoreStub, used in polymorphic keyed store
// stub implementations requires it to be initialized.
static const Register MapRegister();
KeyedStoreIC(FrameDepth depth, Isolate* isolate)
: StoreIC(depth, isolate) {
ASSERT(target()->is_keyed_store_stub());
......
......@@ -222,14 +222,6 @@ void ToBooleanStub::InitializeInterfaceDescriptor(
}
void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rax, rbx, rcx, rdx };
descriptor->Initialize(ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(ElementsTransitionAndStoreIC_Miss));
}
void BinaryOpICStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { rdx, rax };
......
......@@ -1067,6 +1067,11 @@ const Register KeyedStoreIC::ValueRegister() {
}
const Register KeyedStoreIC::MapRegister() {
return rbx;
}
void KeyedLoadIC::GenerateRuntimeGetProperty(MacroAssembler* masm) {
// The return address is on the stack.
......
......@@ -1253,10 +1253,11 @@ Register* StoreStubCompiler::registers() {
Register* KeyedStoreStubCompiler::registers() {
// receiver, name, scratch1, scratch2, scratch3.
// receiver, name, scratch1/map, scratch2, scratch3.
Register receiver = KeyedStoreIC::ReceiverRegister();
Register name = KeyedStoreIC::NameRegister();
static Register registers[] = { receiver, name, rbx, rdi, r8 };
Register map = KeyedStoreIC::MapRegister();
static Register registers[] = { receiver, name, map, rdi, r8 };
return registers;
}
......@@ -1361,7 +1362,10 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
Label* smi_target = IncludesNumberType(types) ? &number_case : &miss;
__ JumpIfSmi(receiver(), smi_target);
// Polymorphic keyed stores may use the map register
Register map_reg = scratch1();
ASSERT(kind() != Code::KEYED_STORE_IC ||
map_reg.is(KeyedStoreIC::MapRegister()));
__ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset));
int receiver_count = types->length();
int number_of_handled_maps = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment