Revision: 22014
Author:   [email protected]
Date:     Wed Jun 25 12:52:58 2014 UTC
Log:      Cleanup CallInterfaceDescriptor

Make CallInterfaceDescriptor work like CodeStubInterfaceDescriptor, owning it's register and representation arrays. This also eliminates a host of TSAN warnings
for static arrays.

This CL depends on https://codereview.chromium.org/352583002 landing first
(a conceptual dependency at least).

[email protected]

Review URL: https://codereview.chromium.org/350293003
http://code.google.com/p/v8/source/detail?r=22014

Modified:
 /branches/bleeding_edge/src/arm/code-stubs-arm.cc
 /branches/bleeding_edge/src/arm/code-stubs-arm.h
 /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc
 /branches/bleeding_edge/src/arm64/code-stubs-arm64.h
 /branches/bleeding_edge/src/code-stubs.cc
 /branches/bleeding_edge/src/code-stubs.h
 /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/x64/code-stubs-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Jun 25 12:32:12 2014 UTC +++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Wed Jun 25 12:52:58 2014 UTC
@@ -311,87 +311,77 @@
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
-    static Register registers[] = { r1,  // JSFunction
-                                    cp,  // context
-                                    r0,  // actual number of arguments
-                                    r2,  // expected number of arguments
+    Register registers[] = { r1,  // JSFunction
+                             cp,  // context
+                             r0,  // actual number of arguments
+                             r2,  // expected number of arguments
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // JSFunction
         Representation::Tagged(),     // context
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->register_param_count_ = 4;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::KeyedCall);
-    static Register registers[] = { cp,  // context
-                                    r2,  // key
+    Register registers[] = { cp,  // context
+                             r2,  // key
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &noInlineDescriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::NamedCall);
-    static Register registers[] = { cp,  // context
-                                    r2,  // name
+    Register registers[] = { cp,  // context
+                             r2,  // name
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &noInlineDescriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::CallHandler);
-    static Register registers[] = { cp,  // context
-                                    r0,  // receiver
+    Register registers[] = { cp,  // context
+                             r0,  // receiver
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ApiFunctionCall);
-    static Register registers[] = { r0,  // callee
-                                    r4,  // call_data
-                                    r2,  // holder
-                                    r1,  // api_function_address
-                                    cp,  // context
+    Register registers[] = { r0,  // callee
+                             r4,  // call_data
+                             r2,  // holder
+                             r1,  // api_function_address
+                             cp,  // context
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),    // callee
         Representation::Tagged(),    // call_data
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
         Representation::Tagged(),    // context
     };
-    descriptor->register_param_count_ = 5;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
 }

=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.h Wed Jun 11 06:59:25 2014 UTC +++ /branches/bleeding_edge/src/arm/code-stubs-arm.h Wed Jun 25 12:52:58 2014 UTC
@@ -404,7 +404,8 @@
 };


-struct PlatformCallInterfaceDescriptor {
+class PlatformCallInterfaceDescriptor {
+ public:
   explicit PlatformCallInterfaceDescriptor(
       TargetAddressStorageMode storage_mode)
       : storage_mode_(storage_mode) { }
=======================================
--- /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc Wed Jun 25 12:32:12 2014 UTC +++ /branches/bleeding_edge/src/arm64/code-stubs-arm64.cc Wed Jun 25 12:52:58 2014 UTC
@@ -347,87 +347,77 @@
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
-    static Register registers[] = { x1,  // JSFunction
-                                    cp,  // context
-                                    x0,  // actual number of arguments
-                                    x2,  // expected number of arguments
+    Register registers[] = { x1,  // JSFunction
+                             cp,  // context
+                             x0,  // actual number of arguments
+                             x2,  // expected number of arguments
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // JSFunction
         Representation::Tagged(),     // context
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->register_param_count_ = 4;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::KeyedCall);
-    static Register registers[] = { cp,  // context
-                                    x2,  // key
+    Register registers[] = { cp,  // context
+                             x2,  // key
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &noInlineDescriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::NamedCall);
-    static Register registers[] = { cp,  // context
-                                    x2,  // name
+    Register registers[] = { cp,  // context
+                             x2,  // name
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &noInlineDescriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &noInlineDescriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::CallHandler);
-    static Register registers[] = { cp,  // context
-                                    x0,  // receiver
+    Register registers[] = { cp,  // context
+                             x0,  // receiver
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ApiFunctionCall);
-    static Register registers[] = { x0,  // callee
-                                    x4,  // call_data
-                                    x2,  // holder
-                                    x1,  // api_function_address
-                                    cp,  // context
+    Register registers[] = { x0,  // callee
+                             x4,  // call_data
+                             x2,  // holder
+                             x1,  // api_function_address
+                             cp,  // context
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),    // callee
         Representation::Tagged(),    // call_data
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
         Representation::Tagged(),    // context
     };
-    descriptor->register_param_count_ = 5;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
-    descriptor->platform_specific_descriptor_ = &default_descriptor;
+    descriptor->Initialize(ARRAY_SIZE(registers), registers,
+                           representations, &default_descriptor);
   }
 }

=======================================
--- /branches/bleeding_edge/src/arm64/code-stubs-arm64.h Tue Jun 3 08:12:43 2014 UTC +++ /branches/bleeding_edge/src/arm64/code-stubs-arm64.h Wed Jun 25 12:52:58 2014 UTC
@@ -461,7 +461,8 @@
 };


-struct PlatformCallInterfaceDescriptor {
+class PlatformCallInterfaceDescriptor {
+ public:
   explicit PlatformCallInterfaceDescriptor(
       TargetAddressStorageMode storage_mode)
       : storage_mode_(storage_mode) { }
=======================================
--- /branches/bleeding_edge/src/code-stubs.cc   Wed Jun 25 12:32:12 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.cc   Wed Jun 25 12:52:58 2014 UTC
@@ -75,6 +75,29 @@
   stack_parameter_count_ = stack_parameter_count;
   handler_arguments_mode_ = handler_mode;
 }
+
+
+void CallInterfaceDescriptor::Initialize(
+    int register_parameter_count,
+    Register* registers,
+    Representation* param_representations,
+    PlatformCallInterfaceDescriptor* platform_descriptor) {
+  // CallInterfaceDescriptor owns a copy of the registers array.
+  register_param_count_ = register_parameter_count;
+  register_params_.Reset(NewArray<Register>(register_parameter_count));
+  for (int i = 0; i < register_parameter_count; i++) {
+    register_params_[i] = registers[i];
+  }
+
+  // Also the register parameter representations.
+  param_representations_.Reset(
+      NewArray<Representation>(register_parameter_count));
+  for (int i = 0; i < register_parameter_count; i++) {
+    param_representations_[i] = param_representations[i];
+  }
+
+  platform_specific_descriptor_ = platform_descriptor;
+}


 bool CodeStub::FindCodeInCache(Code** code_out) {
=======================================
--- /branches/bleeding_edge/src/code-stubs.h    Wed Jun 25 12:32:12 2014 UTC
+++ /branches/bleeding_edge/src/code-stubs.h    Wed Jun 25 12:52:58 2014 UTC
@@ -367,15 +367,27 @@
 };


-struct PlatformCallInterfaceDescriptor;
+class PlatformCallInterfaceDescriptor;


-struct CallInterfaceDescriptor {
+class CallInterfaceDescriptor {
+ public:
   CallInterfaceDescriptor()
       : register_param_count_(-1),
         register_params_(NULL),
         param_representations_(NULL),
         platform_specific_descriptor_(NULL) { }
+
+  // A copy of the passed in registers and param_representations is made
+  // and owned by the CallInterfaceDescriptor.
+
+  // TODO(mvstanton): Instead of taking parallel arrays register and
+  // param_representations, how about a struct that puts the representation
+  // and register side by side (eg, RegRep(r1, Representation::Tagged()).
+  // The same should go for the CodeStubInterfaceDescriptor class.
+  void Initialize(int register_parameter_count, Register* registers,
+                  Representation* param_representations,
+ PlatformCallInterfaceDescriptor* platform_descriptor = NULL);

   bool initialized() const { return register_param_count_ >= 0; }

@@ -395,9 +407,10 @@
     return platform_specific_descriptor_;
   }

+ private:
   int register_param_count_;
-  Register* register_params_;
-  Representation* param_representations_;
+  SmartArrayPointer<Register> register_params_;
+  SmartArrayPointer<Representation> param_representations_;
   PlatformCallInterfaceDescriptor* platform_specific_descriptor_;
 };

=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Jun 25 12:32:12 2014 UTC +++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Wed Jun 25 12:52:58 2014 UTC
@@ -310,82 +310,72 @@
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
-    static Register registers[] = { edi,  // JSFunction
-                                    esi,  // context
-                                    eax,  // actual number of arguments
-                                    ebx,  // expected number of arguments
+    Register registers[] = { edi,  // JSFunction
+                             esi,  // context
+                             eax,  // actual number of arguments
+                             ebx,  // expected number of arguments
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // JSFunction
         Representation::Tagged(),     // context
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->register_param_count_ = 4;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::KeyedCall);
-    static Register registers[] = { esi,  // context
-                                    ecx,  // key
+    Register registers[] = { esi,  // context
+                             ecx,  // key
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::NamedCall);
-    static Register registers[] = { esi,  // context
-                                    ecx,  // name
+    Register registers[] = { esi,  // context
+                             ecx,  // name
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::CallHandler);
-    static Register registers[] = { esi,  // context
-                                    edx,  // receiver
+    Register registers[] = { esi,  // context
+                             edx,  // receiver
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ApiFunctionCall);
-    static Register registers[] = { eax,  // callee
-                                    ebx,  // call_data
-                                    ecx,  // holder
-                                    edx,  // api_function_address
-                                    esi,  // context
+    Register registers[] = { eax,  // callee
+                             ebx,  // call_data
+                             ecx,  // holder
+                             edx,  // api_function_address
+                             esi,  // context
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),    // callee
         Representation::Tagged(),    // call_data
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
         Representation::Tagged(),    // context
     };
-    descriptor->register_param_count_ = 5;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
 }

=======================================
--- /branches/bleeding_edge/src/isolate.h       Wed Jun 25 12:32:12 2014 UTC
+++ /branches/bleeding_edge/src/isolate.h       Wed Jun 25 12:52:58 2014 UTC
@@ -28,7 +28,7 @@
 namespace internal {

 class Bootstrapper;
-struct CallInterfaceDescriptor;
+class CallInterfaceDescriptor;
 class CodeGenerator;
 class CodeRange;
 class CodeStubInterfaceDescriptor;
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Jun 25 12:32:12 2014 UTC +++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Wed Jun 25 12:52:58 2014 UTC
@@ -306,82 +306,72 @@
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ArgumentAdaptorCall);
-    static Register registers[] = { rdi,  // JSFunction
-                                    rsi,  // context
-                                    rax,  // actual number of arguments
-                                    rbx,  // expected number of arguments
+    Register registers[] = { rdi,  // JSFunction
+                             rsi,  // context
+                             rax,  // actual number of arguments
+                             rbx,  // expected number of arguments
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // JSFunction
         Representation::Tagged(),     // context
         Representation::Integer32(),  // actual number of arguments
         Representation::Integer32(),  // expected number of arguments
     };
-    descriptor->register_param_count_ = 4;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::KeyedCall);
-    static Register registers[] = { rsi,  // context
-                                    rcx,  // key
+    Register registers[] = { rsi,  // context
+                             rcx,  // key
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // key
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::NamedCall);
-    static Register registers[] = { rsi,  // context
-                                    rcx,  // name
+    Register registers[] = { rsi,  // context
+                             rcx,  // name
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),     // context
         Representation::Tagged(),     // name
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::CallHandler);
-    static Register registers[] = { rsi,  // context
-                                    rdx,  // receiver
+    Register registers[] = { rsi,  // context
+                             rdx,  // receiver
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),  // context
         Representation::Tagged(),  // receiver
     };
-    descriptor->register_param_count_ = 2;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
   {
     CallInterfaceDescriptor* descriptor =
         isolate->call_descriptor(Isolate::ApiFunctionCall);
-    static Register registers[] = { rax,  // callee
-                                    rbx,  // call_data
-                                    rcx,  // holder
-                                    rdx,  // api_function_address
-                                    rsi,  // context
+    Register registers[] = { rax,  // callee
+                             rbx,  // call_data
+                             rcx,  // holder
+                             rdx,  // api_function_address
+                             rsi,  // context
     };
-    static Representation representations[] = {
+    Representation representations[] = {
         Representation::Tagged(),    // callee
         Representation::Tagged(),    // call_data
         Representation::Tagged(),    // holder
         Representation::External(),  // api_function_address
         Representation::Tagged(),    // context
     };
-    descriptor->register_param_count_ = 5;
-    descriptor->register_params_ = registers;
-    descriptor->param_representations_ = representations;
+ descriptor->Initialize(ARRAY_SIZE(registers), registers, representations);
   }
 }

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