Reviewers: dcarney,

Message:
dcarney, ptal

Description:
Refactoring PropertyCallbackInfo & FunctionCallbackInfo, step 2.

This step reorders the FunctionCallbackInfo fields.

BUG=

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+33, -22 lines):
  M include/v8.h
  M src/arguments.h
  M src/x64/stub-cache-x64.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 7ffddea18283791af2b6a922b3bd690137da858c..3a8ae722fe1fc1dd9d3caffe578a415d01bfcd7f 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2369,11 +2369,11 @@ class FunctionCallbackInfo {
  protected:
   friend class internal::FunctionCallbackArguments;
   friend class internal::CustomArguments<FunctionCallbackInfo>;
-  static const int kReturnValueIndex = 0;
-  static const int kReturnValueDefaultValueIndex = -1;
-  static const int kIsolateIndex = -2;
-  static const int kDataIndex = -3;
-  static const int kCalleeIndex = -4;
+  static const int kCalleeIndex = 0;
+  static const int kDataIndex = -1;
+  static const int kReturnValueIndex = -2;
+  static const int kReturnValueDefaultValueIndex = -3;
+  static const int kIsolateIndex = -4;
   static const int kHolderIndex = -5;

   V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
Index: src/arguments.h
diff --git a/src/arguments.h b/src/arguments.h
index 169528b9cff052939e820ee97af649fb3d9b988f..261a9c875667a003c98570ec2195ff65abd0d3d4 100644
--- a/src/arguments.h
+++ b/src/arguments.h
@@ -233,6 +233,12 @@ class FunctionCallbackArguments
   typedef FunctionCallbackInfo<Value> T;
   typedef CustomArguments<T> Super;
   static const int kArgsLength = T::kArgsLength;
+  static const int kHolderIndex = T::kHolderIndex;
+  static const int kDataIndex = T::kDataIndex;
+  static const int kReturnValueDefaultValueIndex =
+      T::kReturnValueDefaultValueIndex;
+  static const int kIsolateIndex = T::kIsolateIndex;
+  static const int kCalleeIndex = T::kCalleeIndex;

   FunctionCallbackArguments(internal::Isolate* isolate,
       internal::Object* data,
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 6c840ebaa42bdc435cb138b5bfdf72dc482e6ddf..972addbe2fabe89f0a5e6a1649ed751a6a22bbf0 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -449,12 +449,12 @@ static void GenerateFastApiCall(MacroAssembler* masm,
   //  -- rsp[8]              : object passing the type check
   //                           (last fast api call extra argument,
   //                            set by CheckPrototypes)
-  //  -- rsp[16]             : api function
+  //  -- rsp[16]             : isolate
+  //  -- rsp[24]             : ReturnValue default value
+  //  -- rsp[32]             : ReturnValue
+  //  -- rsp[40]             : api call data
+  //  -- rsp[48]             : api function
   //                           (first fast api call extra argument)
-  //  -- rsp[24]             : api call data
-  //  -- rsp[32]             : isolate
-  //  -- rsp[40]             : ReturnValue default value
-  //  -- rsp[48]             : ReturnValue
   //
   //  -- rsp[56]             : last argument
   //  -- ...
@@ -462,33 +462,38 @@ static void GenerateFastApiCall(MacroAssembler* masm,
   //  -- rsp[(argc + 7) * 8] : receiver
   // -----------------------------------
   // Get the function and setup the context.
+  typedef FunctionCallbackArguments FCA;
+  STATIC_ASSERT(FCA::kArgsLength == 6);
+  STATIC_ASSERT(FCA::kReturnValueOffset == -2);
   Handle<JSFunction> function = optimization.constant_function();
   __ LoadHeapObject(rdi, function);
   __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));

-  int api_call_argc = argc + kFastApiCallArguments;
-  StackArgumentsAccessor args(rsp, api_call_argc);
+  StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments);

-  // Pass the additional arguments.
-  __ movq(args.GetArgumentOperand(api_call_argc - 1), rdi);
+  // Construct the FunctionCallbackInfo on the stack.
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kCalleeIndex), rdi);
   Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
   Handle<Object> call_data(api_call_info->data(), masm->isolate());
   if (masm->isolate()->heap()->InNewSpace(*call_data)) {
     __ Move(rcx, api_call_info);
     __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
-    __ movq(args.GetArgumentOperand(api_call_argc - 2), rbx);
+    __ movq(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), rbx);
   } else {
-    __ Move(args.GetArgumentOperand(api_call_argc - 2), call_data);
+ __ Move(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), call_data);
   }
   __ movq(kScratchRegister,
           ExternalReference::isolate_address(masm->isolate()));
-  __ movq(args.GetArgumentOperand(api_call_argc - 3), kScratchRegister);
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kIsolateIndex),
+          kScratchRegister);
   __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
-  __ movq(args.GetArgumentOperand(api_call_argc - 4), kScratchRegister);
-  __ movq(args.GetArgumentOperand(api_call_argc - 5), kScratchRegister);
+  __ movq(
+ args.GetArgumentOperand(argc + 1 - FCA::kReturnValueDefaultValueIndex),
+      kScratchRegister);
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kReturnValueOffset),
+          kScratchRegister);

   // Prepare arguments.
-  STATIC_ASSERT(kFastApiCallArguments == 6);
   __ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize));

   // Function address is a foreign pointer outside V8's heap.
@@ -523,8 +528,8 @@ static void GenerateFastApiCall(MacroAssembler* masm,
   __ CallApiFunctionAndReturn(function_address,
                               thunk_address,
                               callback_arg,
-                              api_call_argc + 1,
-                              kFastApiCallArguments + 1);
+                              argc + kFastApiCallArguments + 1,
+                              5);
 }




--
--
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/groups/opt_out.

Reply via email to