Revision: 16961
Author:   [email protected]
Date:     Thu Sep 26 10:28:00 2013 UTC
Log:      Refactoring PropertyCallbackInfo & FunctionCallbackInfo, step 2.

This step reorders the FunctionCallbackInfo fields.

BUG=
[email protected], [email protected]

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

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/arguments.h
 /branches/bleeding_edge/src/arm/stub-cache-arm.cc
 /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc
 /branches/bleeding_edge/src/x64/stub-cache-x64.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Thu Sep 26 09:40:13 2013 UTC
+++ /branches/bleeding_edge/include/v8.h        Thu Sep 26 10:28:00 2013 UTC
@@ -2386,13 +2386,13 @@
  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 kHolderIndex = -5;
-  static const int kContextSaveIndex = -6;
+  static const int kContextSaveIndex = 0;
+  static const int kCalleeIndex = -1;
+  static const int kDataIndex = -2;
+  static const int kReturnValueIndex = -3;
+  static const int kReturnValueDefaultValueIndex = -4;
+  static const int kIsolateIndex = -5;
+  static const int kHolderIndex = -6;

   V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
                    internal::Object** values,
=======================================
--- /branches/bleeding_edge/src/arguments.h     Tue Sep 17 11:37:48 2013 UTC
+++ /branches/bleeding_edge/src/arguments.h     Thu Sep 26 10:28:00 2013 UTC
@@ -238,6 +238,12 @@
   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;
+  static const int kContextSaveIndex = T::kContextSaveIndex;

   FunctionCallbackArguments(internal::Isolate* isolate,
       internal::Object* data,
=======================================
--- /branches/bleeding_edge/src/arm/stub-cache-arm.cc Mon Sep 23 15:01:33 2013 UTC +++ /branches/bleeding_edge/src/arm/stub-cache-arm.cc Thu Sep 26 10:28:00 2013 UTC
@@ -842,27 +842,25 @@
                                       int argc,
                                       bool restore_context) {
   // ----------- S t a t e -------------
-  //  -- sp[0]              : context
-  //  -- sp[4]              : holder (set by CheckPrototypes)
-  //  -- sp[8]              : callee JS function
-  //  -- sp[12]             : call data
-  //  -- sp[16]             : isolate
-  //  -- sp[20]             : ReturnValue default value
-  //  -- sp[24]             : ReturnValue
+  //  -- sp[0] - sp[24]     : FunctionCallbackInfo, incl.
+  //                        :  holder (set by CheckPrototypes)
   //  -- sp[28]             : last JS argument
   //  -- ...
   //  -- sp[(argc + 6) * 4] : first JS argument
   //  -- sp[(argc + 7) * 4] : receiver
   // -----------------------------------
+  typedef FunctionCallbackArguments FCA;
+  const int kArgs = kFastApiCallArguments;
   // Save calling context.
-  __ str(cp, MemOperand(sp));
+  __ str(cp,
+ MemOperand(sp, (kArgs - 1 + FCA::kContextSaveIndex) * kPointerSize));
   // Get the function and setup the context.
   Handle<JSFunction> function = optimization.constant_function();
   __ LoadHeapObject(r5, function);
   __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset));
-  __ str(r5, MemOperand(sp, 2 * kPointerSize));
+ __ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kCalleeIndex) * kPointerSize));

-  // Pass the additional arguments.
+  // Construct the FunctionCallbackInfo.
   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)) {
@@ -872,17 +870,21 @@
     __ Move(r6, call_data);
   }
   // Store call data.
-  __ str(r6, MemOperand(sp, 3 * kPointerSize));
+  __ str(r6, MemOperand(sp, (kArgs - 1 + FCA::kDataIndex) * kPointerSize));
   // Store isolate.
   __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate())));
-  __ str(r5, MemOperand(sp, 4 * kPointerSize));
+ __ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kIsolateIndex) * kPointerSize));
   // Store ReturnValue default and ReturnValue.
   __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
-  __ str(r5, MemOperand(sp, 5 * kPointerSize));
-  __ str(r5, MemOperand(sp, 6 * kPointerSize));
+  __ str(r5,
+ MemOperand(sp, (kArgs - 1 + FCA::kReturnValueOffset) * kPointerSize));
+  __ str(
+      r5,
+      MemOperand(
+ sp, (kArgs - 1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize));

   // Prepare arguments.
-  __ add(r2, sp, Operand((kFastApiCallArguments - 1) * kPointerSize));
+  __ add(r2, sp, Operand((kArgs - 1) * kPointerSize));

   // Allocate the v8::Arguments structure in the arguments' space since
   // it's not controlled by GC.
@@ -906,7 +908,7 @@
   __ mov(ip, Operand::Zero());
   __ str(ip, MemOperand(r0, 3 * kPointerSize));

-  const int kStackUnwindSpace = argc + kFastApiCallArguments + 1;
+  const int kStackUnwindSpace = argc + kArgs + 1;
Address function_address = v8::ToCData<Address>(api_call_info->callback());
   ApiFunction fun(function_address);
   ExternalReference::Type type = ExternalReference::DIRECT_API_CALL;
@@ -921,9 +923,9 @@

   AllowExternalCallThatCantCauseGC scope(masm);
   MemOperand context_restore_operand(
-      fp, 2 * kPointerSize);
+      fp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize);
   MemOperand return_value_operand(
-      fp, (kFastApiCallArguments + 1) * kPointerSize);
+      fp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize);
   __ CallApiFunctionAndReturn(ref,
                               function_address,
                               thunk_ref,
=======================================
--- /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Tue Sep 17 11:37:48 2013 UTC +++ /branches/bleeding_edge/src/ia32/stub-cache-ia32.cc Thu Sep 26 10:28:00 2013 UTC
@@ -462,51 +462,48 @@
                                 bool restore_context) {
   // ----------- S t a t e -------------
   //  -- esp[0]              : return address
-  //  -- esp[4]              : context
-  //  -- esp[8]              : object passing the type check
-  //                           (last fast api call extra argument,
-  //                            set by CheckPrototypes)
-  //  -- esp[12]             : api function
-  //                           (first fast api call extra argument)
-  //  -- esp[16]             : api call data
-  //  -- esp[20]             : isolate
-  //  -- esp[24]             : ReturnValue default value
-  //  -- esp[28]             : ReturnValue
+  //  -- esp[4] - esp[28]    : FunctionCallbackInfo, incl.
+  //                         :  object passing the type check
+  //                            (set by CheckPrototypes)
   //  -- esp[32]             : last argument
   //  -- ...
   //  -- esp[(argc + 7) * 4] : first argument
   //  -- esp[(argc + 8) * 4] : receiver
   // -----------------------------------

+  typedef FunctionCallbackArguments FCA;
+  const int kArgs = kFastApiCallArguments;
   // Save calling context.
-  __ mov(Operand(esp, kPointerSize), esi);
+ __ mov(Operand(esp, (kArgs + FCA::kContextSaveIndex) * kPointerSize), esi);

   // Get the function and setup the context.
   Handle<JSFunction> function = optimization.constant_function();
   __ LoadHeapObject(edi, function);
   __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));

-  // Pass the additional arguments.
-  __ mov(Operand(esp, 3 * kPointerSize), edi);
+  // Construct the FunctionCallbackInfo.
+  __ mov(Operand(esp, (kArgs + FCA::kCalleeIndex) * kPointerSize), edi);
   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)) {
     __ mov(ecx, api_call_info);
     __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset));
-    __ mov(Operand(esp, 4 * kPointerSize), ebx);
+    __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), ebx);
   } else {
-    __ mov(Operand(esp, 4 * kPointerSize), Immediate(call_data));
+    __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize),
+           Immediate(call_data));
   }
-  __ mov(Operand(esp, 5 * kPointerSize),
+  __ mov(Operand(esp, (kArgs + FCA::kIsolateIndex) * kPointerSize),
          Immediate(reinterpret_cast<int>(masm->isolate())));
-  __ mov(Operand(esp, 6 * kPointerSize),
-         masm->isolate()->factory()->undefined_value());
-  __ mov(Operand(esp, 7 * kPointerSize),
+  __ mov(Operand(esp, (kArgs + FCA::kReturnValueOffset) * kPointerSize),
          masm->isolate()->factory()->undefined_value());
+  __ mov(
+ Operand(esp, (kArgs + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
+      masm->isolate()->factory()->undefined_value());

   // Prepare arguments.
-  STATIC_ASSERT(kFastApiCallArguments == 7);
-  __ lea(eax, Operand(esp, kFastApiCallArguments * kPointerSize));
+  STATIC_ASSERT(kArgs == 7);
+  __ lea(eax, Operand(esp, kArgs * kPointerSize));


   // API function gets reference to the v8::Arguments. If CPU profiler
@@ -539,13 +536,14 @@

   Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);

-  Operand context_restore_operand(ebp, 2 * kPointerSize);
+  Operand context_restore_operand(
+      ebp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize);
   Operand return_value_operand(
-      ebp, (kFastApiCallArguments + 1) * kPointerSize);
+      ebp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize);
   __ CallApiFunctionAndReturn(function_address,
                               thunk_address,
                               ApiParameterOperand(1),
-                              argc + kFastApiCallArguments + 1,
+                              argc + kArgs + 1,
                               return_value_operand,
                               restore_context ?
                                   &context_restore_operand : NULL);
=======================================
--- /branches/bleeding_edge/src/x64/stub-cache-x64.cc Tue Sep 17 11:37:48 2013 UTC +++ /branches/bleeding_edge/src/x64/stub-cache-x64.cc Thu Sep 26 10:28:00 2013 UTC
@@ -447,49 +447,45 @@
                                 bool restore_context) {
   // ----------- S t a t e -------------
   //  -- rsp[0]              : return address
-  //  -- rsp[8]              : context save
-  //  -- rsp[16]             : object passing the type check
-  //                           (last fast api call extra argument,
-  //                            set by CheckPrototypes)
-  //  -- rsp[24]             : api function
-  //                           (first fast api call extra argument)
-  //  -- rsp[32]             : api call data
-  //  -- rsp[40]             : isolate
-  //  -- rsp[48]             : ReturnValue default value
-  //  -- rsp[56]             : ReturnValue
-  //
+  //  -- rsp[8] - rsp[58]    : FunctionCallbackInfo, incl.
+  //                         :  object passing the type check
+  //                            (set by CheckPrototypes)
   //  -- rsp[64]             : last argument
   //  -- ...
   //  -- rsp[(argc + 7) * 8] : first argument
   //  -- rsp[(argc + 8) * 8] : receiver
   // -----------------------------------
-  int api_call_argc = argc + kFastApiCallArguments;
-  StackArgumentsAccessor args(rsp, api_call_argc);
+  typedef FunctionCallbackArguments FCA;
+  StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments);

   // Save calling context.
-  __ movq(args.GetArgumentOperand(api_call_argc), rsi);
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kContextSaveIndex), rsi);

   // Get the function and setup the context.
   Handle<JSFunction> function = optimization.constant_function();
   __ LoadHeapObject(rdi, function);
   __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
-  // Pass the additional arguments.
-  __ movq(args.GetArgumentOperand(api_call_argc - 2), 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 - 3), rbx);
+    __ movq(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), rbx);
   } else {
-    __ Move(args.GetArgumentOperand(api_call_argc - 3), call_data);
+ __ Move(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), call_data);
   }
   __ movq(kScratchRegister,
           ExternalReference::isolate_address(masm->isolate()));
-  __ movq(args.GetArgumentOperand(api_call_argc - 4), kScratchRegister);
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kIsolateIndex),
+          kScratchRegister);
   __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
-  __ movq(args.GetArgumentOperand(api_call_argc - 5), kScratchRegister);
-  __ movq(args.GetArgumentOperand(api_call_argc - 6), kScratchRegister);
+  __ movq(
+ args.GetArgumentOperand(argc + 1 - FCA::kReturnValueDefaultValueIndex),
+      kScratchRegister);
+  __ movq(args.GetArgumentOperand(argc + 1 - FCA::kReturnValueOffset),
+          kScratchRegister);

   // Prepare arguments.
   STATIC_ASSERT(kFastApiCallArguments == 7);
@@ -524,16 +520,18 @@

   Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);

-  Operand context_restore_operand(rbp, 2 * kPointerSize);
+  Operand context_restore_operand(
+ rbp, (kFastApiCallArguments + 1 + FCA::kContextSaveIndex) * kPointerSize);
   Operand return_value_operand(
-      rbp, (kFastApiCallArguments + 1) * kPointerSize);
-  __ CallApiFunctionAndReturn(function_address,
-                              thunk_address,
-                              callback_arg,
-                              api_call_argc + 1,
-                              return_value_operand,
-                              restore_context ?
-                                  &context_restore_operand : NULL);
+      rbp,
+ (kFastApiCallArguments + 1 + FCA::kReturnValueOffset) * kPointerSize);
+  __ CallApiFunctionAndReturn(
+      function_address,
+      thunk_address,
+      callback_arg,
+      argc + kFastApiCallArguments + 1,
+      return_value_operand,
+      restore_context ? &context_restore_operand : NULL);
 }


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