Reviewers: Wei, mvstanton,

Message:
weiliang
please review this porting patch.
thanks.

Description:
X87: StubCallInterfaceDescriptor takes a context register.

port r22448

original commit message:
StubCallInterfaceDescriptor and CallInterfaceDescriptor are unified under a
base class InterfaceDescriptor.

Handling of the context register had to be massaged to effect the unification.
This will make it easier
  to call hydrogen code stubs directly from crankshaft.

BUG=

Please review this at https://codereview.chromium.org/399313005/

SVN Base: https://chromium.googlesource.com/external/v8.git@bleeding_edge

Affected files (+45, -38 lines):
  M src/x87/code-stubs-x87.cc
  M src/x87/lithium-x87.h
  M src/x87/lithium-x87.cc


Index: src/x87/code-stubs-x87.cc
diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc
index aa6583b190b969065e1e76db5e66c00e17dd748c..96e08df1cce9faba7fbe9c6e77050de86d6aeca5 100644
--- a/src/x87/code-stubs-x87.cc
+++ b/src/x87/code-stubs-x87.cc
@@ -21,7 +21,7 @@ namespace internal {

 void FastNewClosureStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { ebx };
+  Register registers[] = { esi, ebx };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry);
@@ -30,21 +30,22 @@ void FastNewClosureStub::InitializeInterfaceDescriptor(

 void FastNewContextStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { edi };
+  Register registers[] = { esi, edi };
   descriptor->Initialize(ARRAY_SIZE(registers), registers);
 }


 void ToNumberStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax };
+  // ToNumberStub invokes a function, and therefore needs a context.
+  Register registers[] = { esi, eax };
   descriptor->Initialize(ARRAY_SIZE(registers), registers);
 }


 void NumberToStringStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax };
+  Register registers[] = { esi, eax };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry);
@@ -53,9 +54,10 @@ void NumberToStringStub::InitializeInterfaceDescriptor(

 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax, ebx, ecx };
+  Register registers[] = { esi, eax, ebx, ecx };
   Representation representations[] = {
     Representation::Tagged(),
+    Representation::Tagged(),
     Representation::Smi(),
     Representation::Tagged() };

@@ -69,7 +71,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor(

 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax, ebx, ecx, edx };
+  Register registers[] = { esi, eax, ebx, ecx, edx };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry);
@@ -78,14 +80,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor(

 void CreateAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { ebx, edx };
+  Register registers[] = { esi, ebx, edx };
   descriptor->Initialize(ARRAY_SIZE(registers), registers);
 }


 void RegExpConstructResultStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { ecx, ebx, eax };
+  Register registers[] = { esi, ecx, ebx, eax };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry);
@@ -94,13 +96,16 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor(

 void TransitionElementsKindStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax, ebx };
+  Register registers[] = { esi, eax, ebx };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry);
 }


+const Register InterfaceDescriptor::ContextRegister() { return esi; }
+
+
 static void InitializeArrayConstructorDescriptor(
     Isolate* isolate,
     CodeStubInterfaceDescriptor* descriptor,
@@ -113,7 +118,7 @@ static void InitializeArrayConstructorDescriptor(
       Runtime::kArrayConstructor)->entry;

   if (constant_stack_parameter_count == 0) {
-    Register registers[] = { edi, ebx };
+    Register registers[] = { esi, edi, ebx };
     descriptor->Initialize(ARRAY_SIZE(registers), registers,
                            deopt_handler,
                            NULL,
@@ -121,10 +126,11 @@ static void InitializeArrayConstructorDescriptor(
                            JS_FUNCTION_STUB_MODE);
   } else {
     // stack param count needs (constructor pointer, and single argument)
-    Register registers[] = { edi, ebx, eax };
+    Register registers[] = { esi, edi, ebx, eax };
     Representation representations[] = {
         Representation::Tagged(),
         Representation::Tagged(),
+        Representation::Tagged(),
         Representation::Integer32() };
     descriptor->Initialize(ARRAY_SIZE(registers), registers,
                            eax,
@@ -147,7 +153,7 @@ static void InitializeInternalArrayConstructorDescriptor(
       Runtime::kInternalArrayConstructor)->entry;

   if (constant_stack_parameter_count == 0) {
-    Register registers[] = { edi };
+    Register registers[] = { esi, edi };
     descriptor->Initialize(ARRAY_SIZE(registers), registers,
                            deopt_handler,
                            NULL,
@@ -155,9 +161,10 @@ static void InitializeInternalArrayConstructorDescriptor(
                            JS_FUNCTION_STUB_MODE);
   } else {
     // stack param count needs (constructor pointer, and single argument)
-    Register registers[] = { edi, eax };
+    Register registers[] = { esi, edi, eax };
     Representation representations[] = {
         Representation::Tagged(),
+        Representation::Tagged(),
         Representation::Integer32() };
     descriptor->Initialize(ARRAY_SIZE(registers), registers,
                            eax,
@@ -208,7 +215,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(

 void CompareNilICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax };
+  Register registers[] = { esi, eax };
   descriptor->Initialize(ARRAY_SIZE(registers), registers,
                          FUNCTION_ADDR(CompareNilIC_Miss));
   descriptor->SetMissHandler(
@@ -217,7 +224,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor(

 void ToBooleanStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { eax };
+  Register registers[] = { esi, eax };
   descriptor->Initialize(ARRAY_SIZE(registers), registers,
                          FUNCTION_ADDR(ToBooleanIC_Miss));
   descriptor->SetMissHandler(
@@ -227,7 +234,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor(

 void BinaryOpICStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { edx, eax };
+  Register registers[] = { esi, edx, eax };
   descriptor->Initialize(ARRAY_SIZE(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_Miss));
   descriptor->SetMissHandler(
@@ -237,7 +244,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor(

 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { ecx, edx, eax };
+  Register registers[] = { esi, ecx, edx, eax };
   descriptor->Initialize(ARRAY_SIZE(registers), registers,
                          FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite));
 }
@@ -245,7 +252,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor(

 void StringAddStub::InitializeInterfaceDescriptor(
     CodeStubInterfaceDescriptor* descriptor) {
-  Register registers[] = { edx, eax };
+  Register registers[] = { esi, edx, eax };
   descriptor->Initialize(
       ARRAY_SIZE(registers), registers,
       Runtime::FunctionForId(Runtime::kStringAdd)->entry);
@@ -256,14 +263,14 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
-    Register registers[] = { edi,  // JSFunction
-                             esi,  // context
+    Register registers[] = { esi,  // context
+                             edi,  // JSFunction
                              eax,  // actual number of arguments
                              ebx,  // expected number of arguments
     };
     Representation representations[] = {
-        Representation::Tagged(),     // JSFunction
         Representation::Tagged(),     // context
+        Representation::Tagged(),     // JSFunction
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
@@ -297,29 +304,29 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::CallHandler);
     Register registers[] = { esi,  // context
-                             edx,  // receiver
+                             edx,  // name
     };
     Representation representations[] = {
-        Representation::Tagged(),  // context
-        Representation::Tagged(),  // receiver
+        Representation::Tagged(),     // context
+        Representation::Tagged(),     // receiver
     };
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ApiFunctionCall);
-    Register registers[] = { eax,  // callee
+    Register registers[] = { esi,  // context
+                             eax,  // callee
                              ebx,  // call_data
                              ecx,  // holder
                              edx,  // api_function_address
-                             esi,  // context
     };
     Representation representations[] = {
+        Representation::Tagged(),    // context
         Representation::Tagged(),    // callee
         Representation::Tagged(),    // call_data
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
-        Representation::Tagged(),    // context
     };
descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
@@ -334,18 +341,19 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
   isolate()->counters()->code_stubs()->Increment();

   CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor();
-  int param_count = descriptor->register_param_count();
+  int param_count = descriptor->GetEnvironmentParameterCount();
   {
     // Call the runtime system in a fresh internal frame.
     FrameScope scope(masm, StackFrame::INTERNAL);
-    ASSERT(descriptor->register_param_count() == 0 ||
-           eax.is(descriptor->GetParameterRegister(param_count - 1)));
+    ASSERT(param_count == 0 ||
+           eax.is(descriptor->GetEnvironmentParameterRegister(
+               param_count - 1)));
     // Push arguments
     for (int i = 0; i < param_count; ++i) {
-      __ push(descriptor->GetParameterRegister(i));
+      __ push(descriptor->GetEnvironmentParameterRegister(i));
     }
     ExternalReference miss = descriptor->miss_handler();
-    __ CallExternalReference(miss, descriptor->register_param_count());
+    __ CallExternalReference(miss, param_count);
   }

   __ ret(0);
Index: src/x87/lithium-x87.cc
diff --git a/src/x87/lithium-x87.cc b/src/x87/lithium-x87.cc
index 748e48fcc3ceeadea4a8aa9c6f1c8d63b4cd587e..533d36b9696ecf60b7e6093fe2dea1b4c18084db 100644
--- a/src/x87/lithium-x87.cc
+++ b/src/x87/lithium-x87.cc
@@ -1120,8 +1120,7 @@ LInstruction* LChunkBuilder::DoCallJSFunction(

 LInstruction* LChunkBuilder::DoCallWithDescriptor(
     HCallWithDescriptor* instr) {
-  const CallInterfaceDescriptor* descriptor = instr->descriptor();
-
+  const InterfaceDescriptor* descriptor = instr->descriptor();
   LOperand* target = UseRegisterOrConstantAtStart(instr->target());
   ZoneList<LOperand*> ops(instr->OperandCount(), zone());
   ops.Add(target, zone());
@@ -2458,7 +2457,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
     CodeStubInterfaceDescriptor* descriptor =
         info()->code_stub()->GetInterfaceDescriptor();
     int index = static_cast<int>(instr->index());
-    Register reg = descriptor->GetParameterRegister(index);
+    Register reg = descriptor->GetEnvironmentParameterRegister(index);
     return DefineFixed(result, reg);
   }
 }
Index: src/x87/lithium-x87.h
diff --git a/src/x87/lithium-x87.h b/src/x87/lithium-x87.h
index ebf463f7e60efa35a3a71f77af905ca9a5ba0001..245af490d3bab14254b7a38d82df42fd4d80fa16 100644
--- a/src/x87/lithium-x87.h
+++ b/src/x87/lithium-x87.h
@@ -1878,11 +1878,11 @@ class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> {

 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
  public:
-  LCallWithDescriptor(const CallInterfaceDescriptor* descriptor,
+  LCallWithDescriptor(const InterfaceDescriptor* descriptor,
                       const ZoneList<LOperand*>& operands,
                       Zone* zone)
-    : inputs_(descriptor->environment_length() + 1, zone) {
-    ASSERT(descriptor->environment_length() + 1 == operands.length());
+    : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) {
+ ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length());
     inputs_.AddAll(operands, zone);
   }



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to