Reviewers: dcarney, Michael Starzinger,

Message:
mstarzinger, could you review this?

Description:
Refactoring PropertyCallbackInfo & FunctionCallbackInfo, step 1.

The goal is to unify PropertyCallbackInfo and FunctionCallbackInfo so that they
contain the same fields.

The field order will be:
holder
isolate
return value default value
return value
data
this

This step 1 reorders the PropertyCallbackInfo fields.

BUG=

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

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

Affected files (+71, -23 lines):
  M include/v8.h
  M src/arguments.h
  M src/arm/stub-cache-arm.cc
  M src/ia32/stub-cache-ia32.cc
  M src/stub-cache.cc
  M src/x64/stub-cache-x64.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 9e9ea8adcd008b6c81ceee3c58deef9470acaa5b..7e3ed4a4bb348e50849400c484f490cea6a09bbf 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2410,11 +2410,11 @@ class PropertyCallbackInfo {
   friend class internal::PropertyCallbackArguments;
   friend class internal::CustomArguments<PropertyCallbackInfo>;
   static const int kThisIndex = 0;
-  static const int kHolderIndex = -1;
-  static const int kDataIndex = -2;
-  static const int kReturnValueIndex = -3;
-  static const int kReturnValueDefaultValueIndex = -4;
-  static const int kIsolateIndex = -5;
+  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(PropertyCallbackInfo(internal::Object** args))
       : args_(args) { }
Index: src/arguments.h
diff --git a/src/arguments.h b/src/arguments.h
index 169528b9cff052939e820ee97af649fb3d9b988f..c1db98b53dbf6583190889b729fce0db4ff17823 100644
--- a/src/arguments.h
+++ b/src/arguments.h
@@ -175,6 +175,10 @@ class PropertyCallbackArguments
   static const int kArgsLength = T::kArgsLength;
   static const int kThisIndex = T::kThisIndex;
   static const int kHolderIndex = T::kHolderIndex;
+  static const int kDataIndex = T::kDataIndex;
+  static const int kReturnValueDefaultValueIndex =
+      T::kReturnValueDefaultValueIndex;
+  static const int kIsolateIndex = T::kIsolateIndex;

   PropertyCallbackArguments(Isolate* isolate,
                             Object* data,
Index: src/arm/stub-cache-arm.cc
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index c1c87d954e1cc0ea479db95c2594499367deffc6..5b24ca880eaf88814b6dc3e734da32b71c6e0536 100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -791,12 +791,16 @@ static void PushInterceptorArguments(MacroAssembler* masm,
   Register scratch = name;
   __ mov(scratch, Operand(interceptor));
   __ push(scratch);
+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver);
-  __ push(holder);
   __ ldr(scratch, FieldMemOperand(scratch, InterceptorInfo::kDataOffset));
   __ push(scratch);
__ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate())));
   __ push(scratch);
+  __ push(holder);
 }


@@ -1420,6 +1424,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
     Handle<ExecutableAccessorInfo> callback) {
// Build AccessorInfo::args_ list on the stack and push property name below
   // the exit frame to make GC aware of them and store pointers to them.
+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver());
   __ mov(scratch2(), sp);  // scratch2 = AccessorInfo::args_
   if (heap()->InNewSpace(callback->data())) {
@@ -1429,13 +1439,15 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
   } else {
     __ Move(scratch3(), Handle<Object>(callback->data(), isolate()));
   }
-  __ Push(reg, scratch3());
+  __ push(scratch3());
   __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex);
   __ mov(scratch4(), scratch3());
   __ Push(scratch3(), scratch4());
   __ mov(scratch4(),
          Operand(ExternalReference::isolate_address(isolate())));
-  __ Push(scratch4(), name());
+
+  __ Push(scratch4(), reg);
+  __ push(name());
   __ mov(r0, sp);  // r0 = Handle<Name>

   const int kApiStackSpace = 1;
@@ -1465,7 +1477,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
                               thunk_ref,
                               r2,
                               kStackUnwindSpace,
-                              5);
+                              6);
 }


Index: src/ia32/stub-cache-ia32.cc
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index bcf64ce0d49b82aa5f374182f2724742fc1cde8a..5f3e01a0a97846c05fe76d51ec6c48da64edb6e4 100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -398,10 +398,14 @@ static void PushInterceptorArguments(MacroAssembler* masm,
   Register scratch = name;
   __ mov(scratch, Immediate(interceptor));
   __ push(scratch);
+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver);
-  __ push(holder);
   __ push(FieldOperand(scratch, InterceptorInfo::kDataOffset));
   __ push(Immediate(reinterpret_cast<int>(masm->isolate())));
+  __ push(holder);
 }


@@ -1401,12 +1405,18 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
   ASSERT(!scratch3().is(reg));
   __ pop(scratch3());  // Get return address to place it below.

+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver());  // receiver
   __ mov(scratch2(), esp);
   ASSERT(!scratch2().is(reg));
-  __ push(reg);  // holder
   // Push data from ExecutableAccessorInfo.
   if (isolate()->heap()->InNewSpace(callback->data())) {
+    ASSERT(!scratch1().is(reg));
     __ mov(scratch1(), Immediate(callback));
     __ push(FieldOperand(scratch1(), ExecutableAccessorInfo::kDataOffset));
   } else {
@@ -1416,6 +1426,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
   // ReturnValue default value
   __ push(Immediate(isolate()->factory()->undefined_value()));
   __ push(Immediate(reinterpret_cast<int>(isolate())));
+  __ push(reg);  // holder

   // Save a pointer to where we pushed the arguments pointer.  This will be
   // passed as the const ExecutableAccessorInfo& to the C++ callback.
@@ -1450,7 +1461,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
                               thunk_address,
                               ApiParameterOperand(2),
                               kStackSpace,
-                              6);
+                              7);
 }


Index: src/stub-cache.cc
diff --git a/src/stub-cache.cc b/src/stub-cache.cc
index f83a7d2a88f6eabbc472f65e6471416a01a5bbac..f3dbd64f147045e5a06b33f769c13d7f7b183179 100644
--- a/src/stub-cache.cc
+++ b/src/stub-cache.cc
@@ -1278,10 +1278,14 @@ RUNTIME_FUNCTION(MaybeObject*, LoadPropertyWithInterceptorOnly) {
       FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address);
   ASSERT(getter != NULL);

-  Handle<JSObject> receiver =
-      args.at<JSObject>(kArgsOffset - PCA::kThisIndex);
-  Handle<JSObject> holder =
-      args.at<JSObject>(kArgsOffset - PCA::kHolderIndex);
+  int this_index = kArgsOffset - PCA::kThisIndex;
+  int holder_index = kArgsOffset - PCA::kHolderIndex;
+  if (PCA::kThisIndex < PCA::kReturnValueOffset)
+      this_index -= 2;
+  if (PCA::kHolderIndex < PCA::kReturnValueOffset)
+      holder_index -= 2;
+  Handle<JSObject> receiver = args.at<JSObject>(this_index);
+  Handle<JSObject> holder = args.at<JSObject>(holder_index);
   PropertyCallbackArguments callback_args(isolate,
                                           interceptor_info->data(),
                                           *receiver,
@@ -1330,10 +1334,14 @@ static MaybeObject* LoadWithInterceptor(Arguments* args,
   ASSERT(kArgsOffset == 2);
   // No ReturnValue in interceptors.
   ASSERT_EQ(kArgsOffset + PCA::kArgsLength - 2, args->length());
-  Handle<JSObject> receiver_handle =
-      args->at<JSObject>(kArgsOffset - PCA::kThisIndex);
-  Handle<JSObject> holder_handle =
-      args->at<JSObject>(kArgsOffset - PCA::kHolderIndex);
+  int this_index = kArgsOffset - PCA::kThisIndex;
+  int holder_index = kArgsOffset - PCA::kHolderIndex;
+  if (PCA::kThisIndex < PCA::kReturnValueOffset)
+      this_index -= 2;
+  if (PCA::kHolderIndex < PCA::kReturnValueOffset)
+      holder_index -= 2;
+  Handle<JSObject> receiver_handle = args->at<JSObject>(this_index);
+  Handle<JSObject> holder_handle = args->at<JSObject>(holder_index);

   Isolate* isolate = receiver_handle->GetIsolate();

Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index 31f60be565e2de24697de08cca2a78ded9ec27c2..38a36d6c0f742782d4255c12559534f73e9b5d2a 100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -29,6 +29,7 @@

 #if V8_TARGET_ARCH_X64

+#include "arguments.h"
 #include "ic-inl.h"
 #include "codegen.h"
 #include "stub-cache.h"
@@ -371,10 +372,14 @@ static void PushInterceptorArguments(MacroAssembler* masm,
   ASSERT(!masm->isolate()->heap()->InNewSpace(*interceptor));
   __ Move(kScratchRegister, interceptor);
   __ push(kScratchRegister);
+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver);
-  __ push(holder);
   __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset));
   __ PushAddress(ExternalReference::isolate_address(masm->isolate()));
+  __ push(holder);
 }


@@ -1322,19 +1327,27 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
   ASSERT(!scratch4().is(reg));
   __ PopReturnAddressTo(scratch4());

+  STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
+  STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
+  STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
+ STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
+  STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
+  STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5);
   __ push(receiver());  // receiver
-  __ push(reg);  // holder
   if (heap()->InNewSpace(callback->data())) {
+    ASSERT(!scratch1().is(reg));
     __ Move(scratch1(), callback);
     __ push(FieldOperand(scratch1(),
                          ExecutableAccessorInfo::kDataOffset));  // data
   } else {
     __ Push(Handle<Object>(callback->data(), isolate()));
   }
+  ASSERT(!kScratchRegister.is(reg));
   __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
   __ push(kScratchRegister);  // return value
   __ push(kScratchRegister);  // return value default
   __ PushAddress(ExternalReference::isolate_address(isolate()));
+  __ push(reg);  // holder
   __ push(name());  // name
   // Save a pointer to where we pushed the arguments pointer.  This will be
   // passed as the const ExecutableAccessorInfo& to the C++ callback.
@@ -1378,7 +1391,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
                               thunk_address,
                               getter_arg,
                               kStackSpace,
-                              5);
+                              6);
 }




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