Use the same registers for StoreIC and KeyedStoreIC.
authormvstanton@chromium.org <mvstanton@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 14 Jul 2014 20:43:41 +0000 (20:43 +0000)
committermvstanton@chromium.org <mvstanton@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 14 Jul 2014 20:43:41 +0000 (20:43 +0000)
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

16 files changed:
src/arm/code-stubs-arm.cc
src/arm/ic-arm.cc
src/arm/stub-cache-arm.cc
src/arm64/code-stubs-arm64.cc
src/arm64/ic-arm64.cc
src/arm64/stub-cache-arm64.cc
src/code-stubs-hydrogen.cc
src/code-stubs.cc
src/code-stubs.h
src/ia32/code-stubs-ia32.cc
src/ia32/ic-ia32.cc
src/ia32/stub-cache-ia32.cc
src/ic.h
src/x64/code-stubs-x64.cc
src/x64/ic-x64.cc
src/x64/stub-cache-x64.cc

index 5e0e69e..77eaf22 100644 (file)
@@ -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 };
index e5ea82a..0a16ba5 100644 (file)
@@ -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;
index 98002dc..1898dbc 100644 (file)
@@ -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;
index 5b76f1a..7126628 100644 (file)
@@ -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
index 51fa354..1607e5f 100644 (file)
@@ -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;
index d52493e..c3b48a5 100644 (file)
@@ -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;
index bdd168b..547820c 100644 (file)
@@ -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.
index 5a3f4e4..c36568c 100644 (file)
@@ -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(),
index c0ab7e9..f6ae893 100644 (file)
@@ -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> {};
index 1dfd62f..0f01934 100644 (file)
@@ -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 };
index 47ecc92..24419f3 100644 (file)
@@ -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);
index 7350319..a35be80 100644 (file)
@@ -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;
index 47ffd6e..262893f 100644 (file)
--- a/src/ic.h
+++ b/src/ic.h
@@ -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());
index 486917f..48668d3 100644 (file)
@@ -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 };
index eb625a0..ead1d99 100644 (file)
@@ -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.
 
index 886d9ad..508b1b3 100644 (file)
@@ -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;