Commit a81d7b1e authored by marja@chromium.org's avatar marja@chromium.org

Refactor PropertyCallbackInfo & FunctionCallbackInfo, part 3.

This CL starts using positive array indices instead of negative array indices
for the PropertyCallbackInfo and FunctionCallbackInfo fields. Also, the indices
match now, so they can be unified in the next step.

BUG=
R=dcarney@chromium.org, mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/24488006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17015 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 02b160f3
...@@ -2389,13 +2389,13 @@ class FunctionCallbackInfo { ...@@ -2389,13 +2389,13 @@ class FunctionCallbackInfo {
protected: protected:
friend class internal::FunctionCallbackArguments; friend class internal::FunctionCallbackArguments;
friend class internal::CustomArguments<FunctionCallbackInfo>; friend class internal::CustomArguments<FunctionCallbackInfo>;
static const int kContextSaveIndex = 0; static const int kHolderIndex = 0;
static const int kCalleeIndex = -1; static const int kIsolateIndex = 1;
static const int kDataIndex = -2; static const int kReturnValueDefaultValueIndex = 2;
static const int kReturnValueIndex = -3; static const int kReturnValueIndex = 3;
static const int kReturnValueDefaultValueIndex = -4; static const int kDataIndex = 4;
static const int kIsolateIndex = -5; static const int kCalleeIndex = 5;
static const int kHolderIndex = -6; static const int kContextSaveIndex = 6;
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
internal::Object** values, internal::Object** values,
...@@ -2427,12 +2427,12 @@ class PropertyCallbackInfo { ...@@ -2427,12 +2427,12 @@ class PropertyCallbackInfo {
friend class MacroAssembler; friend class MacroAssembler;
friend class internal::PropertyCallbackArguments; friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>; friend class internal::CustomArguments<PropertyCallbackInfo>;
static const int kThisIndex = 0; static const int kHolderIndex = 0;
static const int kDataIndex = -1; static const int kIsolateIndex = 1;
static const int kReturnValueIndex = -2; static const int kReturnValueDefaultValueIndex = 2;
static const int kReturnValueDefaultValueIndex = -3; static const int kReturnValueIndex = 3;
static const int kIsolateIndex = -4; static const int kDataIndex = 4;
static const int kHolderIndex = -5; static const int kThisIndex = 5;
V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {} V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
internal::Object** args_; internal::Object** args_;
......
...@@ -38,7 +38,7 @@ template<typename T> ...@@ -38,7 +38,7 @@ template<typename T>
template<typename V> template<typename V>
v8::Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) { v8::Handle<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
// Check the ReturnValue. // Check the ReturnValue.
Object** handle = &this->end()[kReturnValueOffset]; Object** handle = &this->begin()[kReturnValueOffset];
// Nothing was set, return empty handle as per previous behaviour. // Nothing was set, return empty handle as per previous behaviour.
if ((*handle)->IsTheHole()) return v8::Handle<V>(); if ((*handle)->IsTheHole()) return v8::Handle<V>();
return Utils::Convert<Object, V>(Handle<Object>(handle)); return Utils::Convert<Object, V>(Handle<Object>(handle));
...@@ -49,7 +49,7 @@ v8::Handle<v8::Value> FunctionCallbackArguments::Call(FunctionCallback f) { ...@@ -49,7 +49,7 @@ v8::Handle<v8::Value> FunctionCallbackArguments::Call(FunctionCallback f) {
Isolate* isolate = this->isolate(); Isolate* isolate = this->isolate();
VMState<EXTERNAL> state(isolate); VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
FunctionCallbackInfo<v8::Value> info(end(), FunctionCallbackInfo<v8::Value> info(begin(),
argv_, argv_,
argc_, argc_,
is_construct_call_); is_construct_call_);
...@@ -63,7 +63,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f) { \ ...@@ -63,7 +63,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f) { \
Isolate* isolate = this->isolate(); \ Isolate* isolate = this->isolate(); \
VMState<EXTERNAL> state(isolate); \ VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ReturnValue> info(end()); \ PropertyCallbackInfo<ReturnValue> info(begin()); \
f(info); \ f(info); \
return GetReturnValue<ReturnValue>(isolate); \ return GetReturnValue<ReturnValue>(isolate); \
} }
...@@ -75,7 +75,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \ ...@@ -75,7 +75,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \
Isolate* isolate = this->isolate(); \ Isolate* isolate = this->isolate(); \
VMState<EXTERNAL> state(isolate); \ VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ReturnValue> info(end()); \ PropertyCallbackInfo<ReturnValue> info(begin()); \
f(arg1, info); \ f(arg1, info); \
return GetReturnValue<ReturnValue>(isolate); \ return GetReturnValue<ReturnValue>(isolate); \
} }
...@@ -88,7 +88,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \ ...@@ -88,7 +88,7 @@ v8::Handle<ReturnValue> PropertyCallbackArguments::Call(Function f, \
Isolate* isolate = this->isolate(); \ Isolate* isolate = this->isolate(); \
VMState<EXTERNAL> state(isolate); \ VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ReturnValue> info(end()); \ PropertyCallbackInfo<ReturnValue> info(begin()); \
f(arg1, arg2, info); \ f(arg1, arg2, info); \
return GetReturnValue<ReturnValue>(isolate); \ return GetReturnValue<ReturnValue>(isolate); \
} }
...@@ -101,7 +101,7 @@ void PropertyCallbackArguments::Call(Function f, \ ...@@ -101,7 +101,7 @@ void PropertyCallbackArguments::Call(Function f, \
Isolate* isolate = this->isolate(); \ Isolate* isolate = this->isolate(); \
VMState<EXTERNAL> state(isolate); \ VMState<EXTERNAL> state(isolate); \
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
PropertyCallbackInfo<ReturnValue> info(end()); \ PropertyCallbackInfo<ReturnValue> info(begin()); \
f(arg1, arg2, info); \ f(arg1, arg2, info); \
} }
...@@ -118,4 +118,3 @@ FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID) ...@@ -118,4 +118,3 @@ FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
} } // namespace v8::internal } } // namespace v8::internal
...@@ -137,7 +137,7 @@ class CustomArgumentsBase : public Relocatable { ...@@ -137,7 +137,7 @@ class CustomArgumentsBase : public Relocatable {
v->VisitPointers(values_, values_ + kArrayLength); v->VisitPointers(values_, values_ + kArrayLength);
} }
protected: protected:
inline Object** end() { return values_ + kArrayLength - 1; } inline Object** begin() { return values_; }
explicit inline CustomArgumentsBase(Isolate* isolate) explicit inline CustomArgumentsBase(Isolate* isolate)
: Relocatable(isolate) {} : Relocatable(isolate) {}
Object* values_[kArrayLength]; Object* values_[kArrayLength];
...@@ -151,7 +151,7 @@ class CustomArguments : public CustomArgumentsBase<T::kArgsLength> { ...@@ -151,7 +151,7 @@ class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
typedef CustomArgumentsBase<T::kArgsLength> Super; typedef CustomArgumentsBase<T::kArgsLength> Super;
~CustomArguments() { ~CustomArguments() {
this->end()[kReturnValueOffset] = this->begin()[kReturnValueOffset] =
reinterpret_cast<Object*>(kHandleZapValue); reinterpret_cast<Object*>(kHandleZapValue);
} }
...@@ -162,7 +162,7 @@ class CustomArguments : public CustomArgumentsBase<T::kArgsLength> { ...@@ -162,7 +162,7 @@ class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
v8::Handle<V> GetReturnValue(Isolate* isolate); v8::Handle<V> GetReturnValue(Isolate* isolate);
inline Isolate* isolate() { inline Isolate* isolate() {
return reinterpret_cast<Isolate*>(this->end()[T::kIsolateIndex]); return reinterpret_cast<Isolate*>(this->begin()[T::kIsolateIndex]);
} }
}; };
...@@ -185,7 +185,7 @@ class PropertyCallbackArguments ...@@ -185,7 +185,7 @@ class PropertyCallbackArguments
Object* self, Object* self,
JSObject* holder) JSObject* holder)
: Super(isolate) { : Super(isolate) {
Object** values = this->end(); Object** values = this->begin();
values[T::kThisIndex] = self; values[T::kThisIndex] = self;
values[T::kHolderIndex] = holder; values[T::kHolderIndex] = holder;
values[T::kDataIndex] = data; values[T::kDataIndex] = data;
...@@ -256,7 +256,7 @@ class FunctionCallbackArguments ...@@ -256,7 +256,7 @@ class FunctionCallbackArguments
argv_(argv), argv_(argv),
argc_(argc), argc_(argc),
is_construct_call_(is_construct_call) { is_construct_call_(is_construct_call) {
Object** values = end(); Object** values = begin();
values[T::kDataIndex] = data; values[T::kDataIndex] = data;
values[T::kCalleeIndex] = callee; values[T::kCalleeIndex] = callee;
values[T::kHolderIndex] = holder; values[T::kHolderIndex] = holder;
......
...@@ -850,15 +850,13 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -850,15 +850,13 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
// -- sp[(argc + 7) * 4] : receiver // -- sp[(argc + 7) * 4] : receiver
// ----------------------------------- // -----------------------------------
typedef FunctionCallbackArguments FCA; typedef FunctionCallbackArguments FCA;
const int kArgs = kFastApiCallArguments;
// Save calling context. // Save calling context.
__ str(cp, __ str(cp, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize));
MemOperand(sp, (kArgs - 1 + FCA::kContextSaveIndex) * kPointerSize));
// Get the function and setup the context. // Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function(); Handle<JSFunction> function = optimization.constant_function();
__ LoadHeapObject(r5, function); __ LoadHeapObject(r5, function);
__ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset));
__ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kCalleeIndex) * kPointerSize)); __ str(r5, MemOperand(sp, FCA::kCalleeIndex * kPointerSize));
// Construct the FunctionCallbackInfo. // Construct the FunctionCallbackInfo.
Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
...@@ -870,21 +868,17 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -870,21 +868,17 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
__ Move(r6, call_data); __ Move(r6, call_data);
} }
// Store call data. // Store call data.
__ str(r6, MemOperand(sp, (kArgs - 1 + FCA::kDataIndex) * kPointerSize)); __ str(r6, MemOperand(sp, FCA::kDataIndex * kPointerSize));
// Store isolate. // Store isolate.
__ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate()))); __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate())));
__ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kIsolateIndex) * kPointerSize)); __ str(r5, MemOperand(sp, FCA::kIsolateIndex * kPointerSize));
// Store ReturnValue default and ReturnValue. // Store ReturnValue default and ReturnValue.
__ LoadRoot(r5, Heap::kUndefinedValueRootIndex); __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
__ str(r5, __ str(r5, MemOperand(sp, FCA::kReturnValueOffset * kPointerSize));
MemOperand(sp, (kArgs - 1 + FCA::kReturnValueOffset) * kPointerSize)); __ str(r5, MemOperand(sp, FCA::kReturnValueDefaultValueIndex * kPointerSize));
__ str(
r5,
MemOperand(
sp, (kArgs - 1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize));
// Prepare arguments. // Prepare arguments.
__ add(r2, sp, Operand((kArgs - 1) * kPointerSize)); __ mov(r2, sp);
// Allocate the v8::Arguments structure in the arguments' space since // Allocate the v8::Arguments structure in the arguments' space since
// it's not controlled by GC. // it's not controlled by GC.
...@@ -893,22 +887,22 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -893,22 +887,22 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
FrameScope frame_scope(masm, StackFrame::MANUAL); FrameScope frame_scope(masm, StackFrame::MANUAL);
__ EnterExitFrame(false, kApiStackSpace); __ EnterExitFrame(false, kApiStackSpace);
// r0 = v8::Arguments& // r0 = FunctionCallbackInfo&
// Arguments is after the return address. // Arguments is after the return address.
__ add(r0, sp, Operand(1 * kPointerSize)); __ add(r0, sp, Operand(1 * kPointerSize));
// v8::Arguments::implicit_args_ // FunctionCallbackInfo::implicit_args_
__ str(r2, MemOperand(r0, 0 * kPointerSize)); __ str(r2, MemOperand(r0, 0 * kPointerSize));
// v8::Arguments::values_ // FunctionCallbackInfo::values_
__ add(ip, r2, Operand(argc * kPointerSize)); __ add(ip, r2, Operand((kFastApiCallArguments - 1 + argc) * kPointerSize));
__ str(ip, MemOperand(r0, 1 * kPointerSize)); __ str(ip, MemOperand(r0, 1 * kPointerSize));
// v8::Arguments::length_ = argc // FunctionCallbackInfo::length_ = argc
__ mov(ip, Operand(argc)); __ mov(ip, Operand(argc));
__ str(ip, MemOperand(r0, 2 * kPointerSize)); __ str(ip, MemOperand(r0, 2 * kPointerSize));
// v8::Arguments::is_construct_call = 0 // FunctionCallbackInfo::is_construct_call = 0
__ mov(ip, Operand::Zero()); __ mov(ip, Operand::Zero());
__ str(ip, MemOperand(r0, 3 * kPointerSize)); __ str(ip, MemOperand(r0, 3 * kPointerSize));
const int kStackUnwindSpace = argc + kArgs + 1; const int kStackUnwindSpace = argc + kFastApiCallArguments + 1;
Address function_address = v8::ToCData<Address>(api_call_info->callback()); Address function_address = v8::ToCData<Address>(api_call_info->callback());
ApiFunction fun(function_address); ApiFunction fun(function_address);
ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; ExternalReference::Type type = ExternalReference::DIRECT_API_CALL;
...@@ -923,9 +917,10 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -923,9 +917,10 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
MemOperand context_restore_operand( MemOperand context_restore_operand(
fp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize); fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
MemOperand return_value_operand( MemOperand return_value_operand(fp,
fp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize); (2 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn(ref, __ CallApiFunctionAndReturn(ref,
function_address, function_address,
thunk_ref, thunk_ref,
...@@ -947,13 +942,12 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -947,13 +942,12 @@ static void GenerateFastApiCall(MacroAssembler* masm,
ASSERT(optimization.is_simple_api_call()); ASSERT(optimization.is_simple_api_call());
ASSERT(!receiver.is(scratch)); ASSERT(!receiver.is(scratch));
typedef FunctionCallbackArguments FCA;
const int stack_space = kFastApiCallArguments + argc + 1; const int stack_space = kFastApiCallArguments + argc + 1;
const int kHolderIndex = kFastApiCallArguments +
FunctionCallbackArguments::kHolderIndex - 1;
// Assign stack space for the call arguments. // Assign stack space for the call arguments.
__ sub(sp, sp, Operand(stack_space * kPointerSize)); __ sub(sp, sp, Operand(stack_space * kPointerSize));
// Write holder to stack frame. // Write holder to stack frame.
__ str(receiver, MemOperand(sp, kHolderIndex * kPointerSize)); __ str(receiver, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
// Write receiver to stack frame. // Write receiver to stack frame.
int index = stack_space - 1; int index = stack_space - 1;
__ str(receiver, MemOperand(sp, index * kPointerSize)); __ str(receiver, MemOperand(sp, index * kPointerSize));
...@@ -1203,8 +1197,6 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1203,8 +1197,6 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
int save_at_depth, int save_at_depth,
Label* miss, Label* miss,
PrototypeCheckType check) { PrototypeCheckType check) {
const int kHolderIndex = kFastApiCallArguments +
FunctionCallbackArguments::kHolderIndex - 1;
// Make sure that the type feedback oracle harvests the receiver map. // Make sure that the type feedback oracle harvests the receiver map.
// TODO(svenpanne) Remove this hack when all ICs are reworked. // TODO(svenpanne) Remove this hack when all ICs are reworked.
__ mov(scratch1, Operand(Handle<Map>(object->map()))); __ mov(scratch1, Operand(Handle<Map>(object->map())));
...@@ -1219,8 +1211,9 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1219,8 +1211,9 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
Register reg = object_reg; Register reg = object_reg;
int depth = 0; int depth = 0;
typedef FunctionCallbackArguments FCA;
if (save_at_depth == depth) { if (save_at_depth == depth) {
__ str(reg, MemOperand(sp, kHolderIndex * kPointerSize)); __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
} }
// Check the maps in the prototype chain. // Check the maps in the prototype chain.
...@@ -1279,7 +1272,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1279,7 +1272,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
} }
if (save_at_depth == depth) { if (save_at_depth == depth) {
__ str(reg, MemOperand(sp, kHolderIndex * kPointerSize)); __ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize));
} }
// Go to the next object in the prototype chain. // Go to the next object in the prototype chain.
...@@ -1438,17 +1431,17 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1438,17 +1431,17 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
Handle<ExecutableAccessorInfo> callback) { Handle<ExecutableAccessorInfo> callback) {
// Build AccessorInfo::args_ list on the stack and push property name below // 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. // the exit frame to make GC aware of them and store pointers to them.
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
ASSERT(!scratch2().is(reg)); ASSERT(!scratch2().is(reg));
ASSERT(!scratch3().is(reg)); ASSERT(!scratch3().is(reg));
ASSERT(!scratch4().is(reg)); ASSERT(!scratch4().is(reg));
__ push(receiver()); __ push(receiver());
__ mov(scratch2(), sp); // scratch2 = AccessorInfo::args_
if (heap()->InNewSpace(callback->data())) { if (heap()->InNewSpace(callback->data())) {
__ Move(scratch3(), callback); __ Move(scratch3(), callback);
__ ldr(scratch3(), FieldMemOperand(scratch3(), __ ldr(scratch3(), FieldMemOperand(scratch3(),
...@@ -1462,14 +1455,16 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1462,14 +1455,16 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ Push(scratch3(), scratch4()); __ Push(scratch3(), scratch4());
__ mov(scratch4(), __ mov(scratch4(),
Operand(ExternalReference::isolate_address(isolate()))); Operand(ExternalReference::isolate_address(isolate())));
__ Push(scratch4(), reg, name()); __ Push(scratch4(), reg);
__ mov(scratch2(), sp); // scratch2 = PropertyAccessorInfo::args_
__ push(name());
__ mov(r0, sp); // r0 = Handle<Name> __ mov(r0, sp); // r0 = Handle<Name>
const int kApiStackSpace = 1; const int kApiStackSpace = 1;
FrameScope frame_scope(masm(), StackFrame::MANUAL); FrameScope frame_scope(masm(), StackFrame::MANUAL);
__ EnterExitFrame(false, kApiStackSpace); __ EnterExitFrame(false, kApiStackSpace);
// Create AccessorInfo instance on the stack above the exit frame with // Create PropertyAccessorInfo instance on the stack above the exit frame with
// scratch2 (internal::Object** args_) as the data. // scratch2 (internal::Object** args_) as the data.
__ str(scratch2(), MemOperand(sp, 1 * kPointerSize)); __ str(scratch2(), MemOperand(sp, 1 * kPointerSize));
__ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo& __ add(r1, sp, Operand(1 * kPointerSize)); // r1 = AccessorInfo&
......
...@@ -472,9 +472,8 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -472,9 +472,8 @@ static void GenerateFastApiCall(MacroAssembler* masm,
// ----------------------------------- // -----------------------------------
typedef FunctionCallbackArguments FCA; typedef FunctionCallbackArguments FCA;
const int kArgs = kFastApiCallArguments;
// Save calling context. // Save calling context.
__ mov(Operand(esp, (kArgs + FCA::kContextSaveIndex) * kPointerSize), esi); __ mov(Operand(esp, (1 + FCA::kContextSaveIndex) * kPointerSize), esi);
// Get the function and setup the context. // Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function(); Handle<JSFunction> function = optimization.constant_function();
...@@ -482,29 +481,27 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -482,29 +481,27 @@ static void GenerateFastApiCall(MacroAssembler* masm,
__ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// Construct the FunctionCallbackInfo. // Construct the FunctionCallbackInfo.
__ mov(Operand(esp, (kArgs + FCA::kCalleeIndex) * kPointerSize), edi); __ mov(Operand(esp, (1 + FCA::kCalleeIndex) * kPointerSize), edi);
Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
Handle<Object> call_data(api_call_info->data(), masm->isolate()); Handle<Object> call_data(api_call_info->data(), masm->isolate());
if (masm->isolate()->heap()->InNewSpace(*call_data)) { if (masm->isolate()->heap()->InNewSpace(*call_data)) {
__ mov(ecx, api_call_info); __ mov(ecx, api_call_info);
__ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset)); __ mov(ebx, FieldOperand(ecx, CallHandlerInfo::kDataOffset));
__ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), ebx); __ mov(Operand(esp, (1 + FCA::kDataIndex) * kPointerSize), ebx);
} else { } else {
__ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), __ mov(Operand(esp, (1 + FCA::kDataIndex) * kPointerSize),
Immediate(call_data)); Immediate(call_data));
} }
__ mov(Operand(esp, (kArgs + FCA::kIsolateIndex) * kPointerSize), __ mov(Operand(esp, (1 + FCA::kIsolateIndex) * kPointerSize),
Immediate(reinterpret_cast<int>(masm->isolate()))); Immediate(reinterpret_cast<int>(masm->isolate())));
__ mov(Operand(esp, (kArgs + FCA::kReturnValueOffset) * kPointerSize), __ mov(Operand(esp, (1 + FCA::kReturnValueOffset) * kPointerSize),
masm->isolate()->factory()->undefined_value()); masm->isolate()->factory()->undefined_value());
__ mov( __ mov(Operand(esp, (1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
Operand(esp, (kArgs + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
masm->isolate()->factory()->undefined_value()); masm->isolate()->factory()->undefined_value());
// Prepare arguments. // Prepare arguments.
STATIC_ASSERT(kArgs == 7); STATIC_ASSERT(kFastApiCallArguments == 7);
__ lea(eax, Operand(esp, kArgs * kPointerSize)); __ lea(eax, Operand(esp, 1 * kPointerSize));
// API function gets reference to the v8::Arguments. If CPU profiler // API function gets reference to the v8::Arguments. If CPU profiler
// is enabled wrapper function will be called and we need to pass // is enabled wrapper function will be called and we need to pass
...@@ -520,14 +517,14 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -520,14 +517,14 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Address function_address = v8::ToCData<Address>(api_call_info->callback()); Address function_address = v8::ToCData<Address>(api_call_info->callback());
__ PrepareCallApiFunction(kApiArgc + kApiStackSpace); __ PrepareCallApiFunction(kApiArgc + kApiStackSpace);
// v8::Arguments::implicit_args_. // FunctionCallbackInfo::implicit_args_.
__ mov(ApiParameterOperand(2), eax); __ mov(ApiParameterOperand(2), eax);
__ add(eax, Immediate(argc * kPointerSize)); __ add(eax, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize));
// v8::Arguments::values_. // FunctionCallbackInfo::values_.
__ mov(ApiParameterOperand(3), eax); __ mov(ApiParameterOperand(3), eax);
// v8::Arguments::length_. // FunctionCallbackInfo::length_.
__ Set(ApiParameterOperand(4), Immediate(argc)); __ Set(ApiParameterOperand(4), Immediate(argc));
// v8::Arguments::is_construct_call_. // FunctionCallbackInfo::is_construct_call_.
__ Set(ApiParameterOperand(5), Immediate(0)); __ Set(ApiParameterOperand(5), Immediate(0));
// v8::InvocationCallback's argument. // v8::InvocationCallback's argument.
...@@ -536,14 +533,14 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -536,14 +533,14 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
Operand context_restore_operand( Operand context_restore_operand(ebp,
ebp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize); (2 + FCA::kContextSaveIndex) * kPointerSize);
Operand return_value_operand( Operand return_value_operand(ebp,
ebp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize); (2 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn(function_address, __ CallApiFunctionAndReturn(function_address,
thunk_address, thunk_address,
ApiParameterOperand(1), ApiParameterOperand(1),
argc + kArgs + 1, argc + kFastApiCallArguments + 1,
return_value_operand, return_value_operand,
restore_context ? restore_context ?
&context_restore_operand : NULL); &context_restore_operand : NULL);
...@@ -561,8 +558,7 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -561,8 +558,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
ASSERT(!receiver.is(scratch)); ASSERT(!receiver.is(scratch));
const int stack_space = kFastApiCallArguments + argc + 1; const int stack_space = kFastApiCallArguments + argc + 1;
const int kHolderIndex = kFastApiCallArguments + const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
FunctionCallbackArguments::kHolderIndex;
// Copy return value. // Copy return value.
__ mov(scratch, Operand(esp, 0)); __ mov(scratch, Operand(esp, 0));
// Assign stack space for the call arguments. // Assign stack space for the call arguments.
...@@ -1167,8 +1163,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1167,8 +1163,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
int save_at_depth, int save_at_depth,
Label* miss, Label* miss,
PrototypeCheckType check) { PrototypeCheckType check) {
const int kHolderIndex = kFastApiCallArguments + const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
FunctionCallbackArguments::kHolderIndex;
// Make sure that the type feedback oracle harvests the receiver map. // Make sure that the type feedback oracle harvests the receiver map.
// TODO(svenpanne) Remove this hack when all ICs are reworked. // TODO(svenpanne) Remove this hack when all ICs are reworked.
__ mov(scratch1, Handle<Map>(object->map())); __ mov(scratch1, Handle<Map>(object->map()));
...@@ -1413,20 +1408,18 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1413,20 +1408,18 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
ASSERT(!scratch3().is(reg)); ASSERT(!scratch3().is(reg));
__ pop(scratch3()); // Get return address to place it below. __ pop(scratch3()); // Get return address to place it below.
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
__ push(receiver()); // receiver __ push(receiver()); // receiver
__ mov(scratch2(), esp);
ASSERT(!scratch2().is(reg));
// Push data from ExecutableAccessorInfo. // Push data from ExecutableAccessorInfo.
if (isolate()->heap()->InNewSpace(callback->data())) { if (isolate()->heap()->InNewSpace(callback->data())) {
Register scratch = reg.is(scratch1()) ? receiver() : scratch1(); ASSERT(!scratch2().is(reg));
__ mov(scratch, Immediate(callback)); __ mov(scratch2(), Immediate(callback));
__ push(FieldOperand(scratch, ExecutableAccessorInfo::kDataOffset)); __ push(FieldOperand(scratch2(), ExecutableAccessorInfo::kDataOffset));
} else { } else {
__ push(Immediate(Handle<Object>(callback->data(), isolate()))); __ push(Immediate(Handle<Object>(callback->data(), isolate())));
} }
...@@ -1436,9 +1429,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1436,9 +1429,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ push(Immediate(reinterpret_cast<int>(isolate()))); __ push(Immediate(reinterpret_cast<int>(isolate())));
__ push(reg); // holder __ push(reg); // holder
// Save a pointer to where we pushed the arguments pointer. This will be // Save a pointer to where we pushed the arguments. This will be
// passed as the const ExecutableAccessorInfo& to the C++ callback. // passed as the const PropertyAccessorInfo& to the C++ callback.
__ push(scratch2()); __ push(esp);
__ push(name()); // name __ push(name()); // name
__ mov(ebx, esp); // esp points to reference to name (handler). __ mov(ebx, esp); // esp points to reference to name (handler).
......
...@@ -447,7 +447,7 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -447,7 +447,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
bool restore_context) { bool restore_context) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- rsp[0] : return address // -- rsp[0] : return address
// -- rsp[8] - rsp[58] : FunctionCallbackInfo, incl. // -- rsp[8] - rsp[56] : FunctionCallbackInfo, incl.
// : object passing the type check // : object passing the type check
// (set by CheckPrototypes) // (set by CheckPrototypes)
// -- rsp[64] : last argument // -- rsp[64] : last argument
...@@ -459,37 +459,37 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -459,37 +459,37 @@ static void GenerateFastApiCall(MacroAssembler* masm,
StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments); StackArgumentsAccessor args(rsp, argc + kFastApiCallArguments);
// Save calling context. // Save calling context.
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kContextSaveIndex), rsi); int offset = argc + kFastApiCallArguments;
__ movq(args.GetArgumentOperand(offset - FCA::kContextSaveIndex), rsi);
// Get the function and setup the context. // Get the function and setup the context.
Handle<JSFunction> function = optimization.constant_function(); Handle<JSFunction> function = optimization.constant_function();
__ LoadHeapObject(rdi, function); __ LoadHeapObject(rdi, function);
__ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// Construct the FunctionCallbackInfo on the stack. // Construct the FunctionCallbackInfo on the stack.
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kCalleeIndex), rdi); __ movq(args.GetArgumentOperand(offset - FCA::kCalleeIndex), rdi);
Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
Handle<Object> call_data(api_call_info->data(), masm->isolate()); Handle<Object> call_data(api_call_info->data(), masm->isolate());
if (masm->isolate()->heap()->InNewSpace(*call_data)) { if (masm->isolate()->heap()->InNewSpace(*call_data)) {
__ Move(rcx, api_call_info); __ Move(rcx, api_call_info);
__ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset)); __ movq(rbx, FieldOperand(rcx, CallHandlerInfo::kDataOffset));
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), rbx); __ movq(args.GetArgumentOperand(offset - FCA::kDataIndex), rbx);
} else { } else {
__ Move(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), call_data); __ Move(args.GetArgumentOperand(offset - FCA::kDataIndex), call_data);
} }
__ movq(kScratchRegister, __ movq(kScratchRegister,
ExternalReference::isolate_address(masm->isolate())); ExternalReference::isolate_address(masm->isolate()));
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kIsolateIndex), __ movq(args.GetArgumentOperand(offset - FCA::kIsolateIndex),
kScratchRegister); kScratchRegister);
__ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
__ movq( __ movq(args.GetArgumentOperand(offset - FCA::kReturnValueDefaultValueIndex),
args.GetArgumentOperand(argc + 1 - FCA::kReturnValueDefaultValueIndex),
kScratchRegister); kScratchRegister);
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kReturnValueOffset), __ movq(args.GetArgumentOperand(offset - FCA::kReturnValueOffset),
kScratchRegister); kScratchRegister);
// Prepare arguments. // Prepare arguments.
STATIC_ASSERT(kFastApiCallArguments == 7); STATIC_ASSERT(kFastApiCallArguments == 7);
__ lea(rbx, Operand(rsp, kFastApiCallArguments * kPointerSize)); __ lea(rbx, Operand(rsp, 1 * kPointerSize));
// Function address is a foreign pointer outside V8's heap. // Function address is a foreign pointer outside V8's heap.
Address function_address = v8::ToCData<Address>(api_call_info->callback()); Address function_address = v8::ToCData<Address>(api_call_info->callback());
...@@ -500,11 +500,11 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -500,11 +500,11 @@ static void GenerateFastApiCall(MacroAssembler* masm,
__ PrepareCallApiFunction(kApiStackSpace); __ PrepareCallApiFunction(kApiStackSpace);
__ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_. __ movq(StackSpaceOperand(0), rbx); // FunctionCallbackInfo::implicit_args_.
__ addq(rbx, Immediate(argc * kPointerSize)); __ addq(rbx, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize));
__ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_. __ movq(StackSpaceOperand(1), rbx); // FunctionCallbackInfo::values_.
__ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_. __ Set(StackSpaceOperand(2), argc); // FunctionCallbackInfo::length_.
// v8::Arguments::is_construct_call_. // FunctionCallbackInfo::is_construct_call_.
__ Set(StackSpaceOperand(3), 0); __ Set(StackSpaceOperand(3), 0);
#if defined(__MINGW64__) || defined(_WIN64) #if defined(__MINGW64__) || defined(_WIN64)
...@@ -520,11 +520,10 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -520,11 +520,10 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
Operand context_restore_operand( Operand context_restore_operand(rbp,
rbp, (kFastApiCallArguments + 1 + FCA::kContextSaveIndex) * kPointerSize); (2 + FCA::kContextSaveIndex) * kPointerSize);
Operand return_value_operand( Operand return_value_operand(rbp,
rbp, (2 + FCA::kReturnValueOffset) * kPointerSize);
(kFastApiCallArguments + 1 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn( __ CallApiFunctionAndReturn(
function_address, function_address,
thunk_address, thunk_address,
...@@ -546,8 +545,7 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -546,8 +545,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
ASSERT(!receiver.is(scratch)); ASSERT(!receiver.is(scratch));
const int stack_space = kFastApiCallArguments + argc + 1; const int stack_space = kFastApiCallArguments + argc + 1;
const int kHolderIndex = kFastApiCallArguments + const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
FunctionCallbackArguments::kHolderIndex;
// Copy return value. // Copy return value.
__ movq(scratch, Operand(rsp, 0)); __ movq(scratch, Operand(rsp, 0));
// Assign stack space for the call arguments. // Assign stack space for the call arguments.
...@@ -1096,8 +1094,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1096,8 +1094,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
int save_at_depth, int save_at_depth,
Label* miss, Label* miss,
PrototypeCheckType check) { PrototypeCheckType check) {
const int kHolderIndex = kFastApiCallArguments + const int kHolderIndex = FunctionCallbackArguments::kHolderIndex + 1;
FunctionCallbackArguments::kHolderIndex;
// Make sure that the type feedback oracle harvests the receiver map. // Make sure that the type feedback oracle harvests the receiver map.
// TODO(svenpanne) Remove this hack when all ICs are reworked. // TODO(svenpanne) Remove this hack when all ICs are reworked.
__ Move(scratch1, Handle<Map>(object->map())); __ Move(scratch1, Handle<Map>(object->map()));
...@@ -1333,12 +1330,13 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1333,12 +1330,13 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
ASSERT(!scratch4().is(reg)); ASSERT(!scratch4().is(reg));
__ PopReturnAddressTo(scratch4()); __ PopReturnAddressTo(scratch4());
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -5); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
__ push(receiver()); // receiver __ push(receiver()); // receiver
if (heap()->InNewSpace(callback->data())) { if (heap()->InNewSpace(callback->data())) {
ASSERT(!scratch2().is(reg)); ASSERT(!scratch2().is(reg));
...@@ -1356,7 +1354,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1356,7 +1354,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
__ push(reg); // holder __ push(reg); // holder
__ push(name()); // name __ push(name()); // name
// Save a pointer to where we pushed the arguments pointer. This will be // Save a pointer to where we pushed the arguments pointer. This will be
// passed as the const ExecutableAccessorInfo& to the C++ callback. // passed as the const PropertyAccessorInfo& to the C++ callback.
Address getter_address = v8::ToCData<Address>(callback->getter()); Address getter_address = v8::ToCData<Address>(callback->getter());
...@@ -1381,10 +1379,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1381,10 +1379,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
const int kArgStackSpace = 1; const int kArgStackSpace = 1;
__ PrepareCallApiFunction(kArgStackSpace); __ PrepareCallApiFunction(kArgStackSpace);
STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); __ lea(rax, Operand(name_arg, 1 * kPointerSize));
__ lea(rax, Operand(name_arg, 6 * kPointerSize));
// v8::AccessorInfo::args_. // v8::PropertyAccessorInfo::args_.
__ movq(StackSpaceOperand(0), rax); __ movq(StackSpaceOperand(0), rax);
// The context register (rsi) has been saved in PrepareCallApiFunction and // The context register (rsi) has been saved in PrepareCallApiFunction and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment