Commit 9da77812 authored by marja@chromium.org's avatar marja@chromium.org

Revert "Refactor PropertyCallbackInfo & FunctionCallbackInfo, part 3."

This reverts commit 977bfe3e9353ead1039878597590ffbd7dd5e725.

This might be responsible of the Linux Webkit test failures.

BUG=
TBR=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17021 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent fa742f84
...@@ -2394,13 +2394,13 @@ class FunctionCallbackInfo { ...@@ -2394,13 +2394,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 kHolderIndex = 0; static const int kContextSaveIndex = 0;
static const int kIsolateIndex = 1; static const int kCalleeIndex = -1;
static const int kReturnValueDefaultValueIndex = 2; static const int kDataIndex = -2;
static const int kReturnValueIndex = 3; static const int kReturnValueIndex = -3;
static const int kDataIndex = 4; static const int kReturnValueDefaultValueIndex = -4;
static const int kCalleeIndex = 5; static const int kIsolateIndex = -5;
static const int kContextSaveIndex = 6; static const int kHolderIndex = -6;
V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
internal::Object** values, internal::Object** values,
...@@ -2432,12 +2432,12 @@ class PropertyCallbackInfo { ...@@ -2432,12 +2432,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 kHolderIndex = 0; static const int kThisIndex = 0;
static const int kIsolateIndex = 1; static const int kDataIndex = -1;
static const int kReturnValueDefaultValueIndex = 2; static const int kReturnValueIndex = -2;
static const int kReturnValueIndex = 3; static const int kReturnValueDefaultValueIndex = -3;
static const int kDataIndex = 4; static const int kIsolateIndex = -4;
static const int kThisIndex = 5; static const int kHolderIndex = -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->begin()[kReturnValueOffset]; Object** handle = &this->end()[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(begin(), FunctionCallbackInfo<v8::Value> info(end(),
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(begin()); \ PropertyCallbackInfo<ReturnValue> info(end()); \
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(begin()); \ PropertyCallbackInfo<ReturnValue> info(end()); \
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(begin()); \ PropertyCallbackInfo<ReturnValue> info(end()); \
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(begin()); \ PropertyCallbackInfo<ReturnValue> info(end()); \
f(arg1, arg2, info); \ f(arg1, arg2, info); \
} }
...@@ -118,3 +118,4 @@ FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID) ...@@ -118,3 +118,4 @@ 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** begin() { return values_; } inline Object** end() { return values_ + kArrayLength - 1; }
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->begin()[kReturnValueOffset] = this->end()[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->begin()[T::kIsolateIndex]); return reinterpret_cast<Isolate*>(this->end()[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->begin(); Object** values = this->end();
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 = begin(); Object** values = end();
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,13 +850,15 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -850,13 +850,15 @@ 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, MemOperand(sp, FCA::kContextSaveIndex * kPointerSize)); __ str(cp,
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, FCA::kCalleeIndex * kPointerSize)); __ str(r5, MemOperand(sp, (kArgs - 1 + 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();
...@@ -868,17 +870,21 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -868,17 +870,21 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
__ Move(r6, call_data); __ Move(r6, call_data);
} }
// Store call data. // Store call data.
__ str(r6, MemOperand(sp, FCA::kDataIndex * kPointerSize)); __ str(r6, MemOperand(sp, (kArgs - 1 + 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, FCA::kIsolateIndex * kPointerSize)); __ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kIsolateIndex) * kPointerSize));
// Store ReturnValue default and ReturnValue. // Store ReturnValue default and ReturnValue.
__ LoadRoot(r5, Heap::kUndefinedValueRootIndex); __ LoadRoot(r5, Heap::kUndefinedValueRootIndex);
__ str(r5, MemOperand(sp, FCA::kReturnValueOffset * kPointerSize)); __ str(r5,
__ str(r5, MemOperand(sp, FCA::kReturnValueDefaultValueIndex * kPointerSize)); MemOperand(sp, (kArgs - 1 + FCA::kReturnValueOffset) * kPointerSize));
__ str(
r5,
MemOperand(
sp, (kArgs - 1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize));
// Prepare arguments. // Prepare arguments.
__ mov(r2, sp); __ add(r2, sp, Operand((kArgs - 1) * kPointerSize));
// 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.
...@@ -887,22 +893,22 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -887,22 +893,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 = FunctionCallbackInfo& // r0 = v8::Arguments&
// Arguments is after the return address. // Arguments is after the return address.
__ add(r0, sp, Operand(1 * kPointerSize)); __ add(r0, sp, Operand(1 * kPointerSize));
// FunctionCallbackInfo::implicit_args_ // v8::Arguments::implicit_args_
__ str(r2, MemOperand(r0, 0 * kPointerSize)); __ str(r2, MemOperand(r0, 0 * kPointerSize));
// FunctionCallbackInfo::values_ // v8::Arguments::values_
__ add(ip, r2, Operand((kFastApiCallArguments - 1 + argc) * kPointerSize)); __ add(ip, r2, Operand(argc * kPointerSize));
__ str(ip, MemOperand(r0, 1 * kPointerSize)); __ str(ip, MemOperand(r0, 1 * kPointerSize));
// FunctionCallbackInfo::length_ = argc // v8::Arguments::length_ = argc
__ mov(ip, Operand(argc)); __ mov(ip, Operand(argc));
__ str(ip, MemOperand(r0, 2 * kPointerSize)); __ str(ip, MemOperand(r0, 2 * kPointerSize));
// FunctionCallbackInfo::is_construct_call = 0 // v8::Arguments::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 + kFastApiCallArguments + 1; const int kStackUnwindSpace = argc + kArgs + 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;
...@@ -917,10 +923,9 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, ...@@ -917,10 +923,9 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm,
AllowExternalCallThatCantCauseGC scope(masm); AllowExternalCallThatCantCauseGC scope(masm);
MemOperand context_restore_operand( MemOperand context_restore_operand(
fp, (2 + FCA::kContextSaveIndex) * kPointerSize); fp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize);
MemOperand return_value_operand(fp, MemOperand return_value_operand(
(2 + FCA::kReturnValueOffset) * kPointerSize); fp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn(ref, __ CallApiFunctionAndReturn(ref,
function_address, function_address,
thunk_ref, thunk_ref,
...@@ -942,12 +947,13 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -942,12 +947,13 @@ 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, FCA::kHolderIndex * kPointerSize)); __ str(receiver, MemOperand(sp, 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));
...@@ -1197,6 +1203,8 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1197,6 +1203,8 @@ 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())));
...@@ -1211,9 +1219,8 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1211,9 +1219,8 @@ 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, FCA::kHolderIndex * kPointerSize)); __ str(reg, MemOperand(sp, kHolderIndex * kPointerSize));
} }
// Check the maps in the prototype chain. // Check the maps in the prototype chain.
...@@ -1272,7 +1279,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1272,7 +1279,7 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object,
} }
if (save_at_depth == depth) { if (save_at_depth == depth) {
__ str(reg, MemOperand(sp, FCA::kHolderIndex * kPointerSize)); __ str(reg, MemOperand(sp, kHolderIndex * kPointerSize));
} }
// Go to the next object in the prototype chain. // Go to the next object in the prototype chain.
...@@ -1431,17 +1438,17 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1431,17 +1438,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::kHolderIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -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(),
...@@ -1455,16 +1462,14 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1455,16 +1462,14 @@ 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); __ Push(scratch4(), reg, name());
__ 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 PropertyAccessorInfo instance on the stack above the exit frame with // Create AccessorInfo 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,8 +472,9 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -472,8 +472,9 @@ static void GenerateFastApiCall(MacroAssembler* masm,
// ----------------------------------- // -----------------------------------
typedef FunctionCallbackArguments FCA; typedef FunctionCallbackArguments FCA;
const int kArgs = kFastApiCallArguments;
// Save calling context. // Save calling context.
__ mov(Operand(esp, (1 + FCA::kContextSaveIndex) * kPointerSize), esi); __ mov(Operand(esp, (kArgs + 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();
...@@ -481,27 +482,29 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -481,27 +482,29 @@ 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, (1 + FCA::kCalleeIndex) * kPointerSize), edi); __ mov(Operand(esp, (kArgs + 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, (1 + FCA::kDataIndex) * kPointerSize), ebx); __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize), ebx);
} else { } else {
__ mov(Operand(esp, (1 + FCA::kDataIndex) * kPointerSize), __ mov(Operand(esp, (kArgs + FCA::kDataIndex) * kPointerSize),
Immediate(call_data)); Immediate(call_data));
} }
__ mov(Operand(esp, (1 + FCA::kIsolateIndex) * kPointerSize), __ mov(Operand(esp, (kArgs + FCA::kIsolateIndex) * kPointerSize),
Immediate(reinterpret_cast<int>(masm->isolate()))); Immediate(reinterpret_cast<int>(masm->isolate())));
__ mov(Operand(esp, (1 + FCA::kReturnValueOffset) * kPointerSize), __ mov(Operand(esp, (kArgs + FCA::kReturnValueOffset) * kPointerSize),
masm->isolate()->factory()->undefined_value());
__ mov(Operand(esp, (1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
masm->isolate()->factory()->undefined_value()); masm->isolate()->factory()->undefined_value());
__ mov(
Operand(esp, (kArgs + FCA::kReturnValueDefaultValueIndex) * kPointerSize),
masm->isolate()->factory()->undefined_value());
// Prepare arguments. // Prepare arguments.
STATIC_ASSERT(kFastApiCallArguments == 7); STATIC_ASSERT(kArgs == 7);
__ lea(eax, Operand(esp, 1 * kPointerSize)); __ lea(eax, Operand(esp, kArgs * 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
...@@ -517,14 +520,14 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -517,14 +520,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);
// FunctionCallbackInfo::implicit_args_. // v8::Arguments::implicit_args_.
__ mov(ApiParameterOperand(2), eax); __ mov(ApiParameterOperand(2), eax);
__ add(eax, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize)); __ add(eax, Immediate(argc * kPointerSize));
// FunctionCallbackInfo::values_. // v8::Arguments::values_.
__ mov(ApiParameterOperand(3), eax); __ mov(ApiParameterOperand(3), eax);
// FunctionCallbackInfo::length_. // v8::Arguments::length_.
__ Set(ApiParameterOperand(4), Immediate(argc)); __ Set(ApiParameterOperand(4), Immediate(argc));
// FunctionCallbackInfo::is_construct_call_. // v8::Arguments::is_construct_call_.
__ Set(ApiParameterOperand(5), Immediate(0)); __ Set(ApiParameterOperand(5), Immediate(0));
// v8::InvocationCallback's argument. // v8::InvocationCallback's argument.
...@@ -533,14 +536,14 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -533,14 +536,14 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
Operand context_restore_operand(ebp, Operand context_restore_operand(
(2 + FCA::kContextSaveIndex) * kPointerSize); ebp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize);
Operand return_value_operand(ebp, Operand return_value_operand(
(2 + FCA::kReturnValueOffset) * kPointerSize); ebp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn(function_address, __ CallApiFunctionAndReturn(function_address,
thunk_address, thunk_address,
ApiParameterOperand(1), ApiParameterOperand(1),
argc + kFastApiCallArguments + 1, argc + kArgs + 1,
return_value_operand, return_value_operand,
restore_context ? restore_context ?
&context_restore_operand : NULL); &context_restore_operand : NULL);
...@@ -558,7 +561,8 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -558,7 +561,8 @@ 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 = FunctionCallbackArguments::kHolderIndex + 1; const int kHolderIndex = kFastApiCallArguments +
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.
...@@ -1163,7 +1167,8 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1163,7 +1167,8 @@ 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 = FunctionCallbackArguments::kHolderIndex + 1; const int kHolderIndex = kFastApiCallArguments +
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()));
...@@ -1408,18 +1413,20 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1408,18 +1413,20 @@ 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::kHolderIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -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())) {
ASSERT(!scratch2().is(reg)); Register scratch = reg.is(scratch1()) ? receiver() : scratch1();
__ mov(scratch2(), Immediate(callback)); __ mov(scratch, Immediate(callback));
__ push(FieldOperand(scratch2(), ExecutableAccessorInfo::kDataOffset)); __ push(FieldOperand(scratch, ExecutableAccessorInfo::kDataOffset));
} else { } else {
__ push(Immediate(Handle<Object>(callback->data(), isolate()))); __ push(Immediate(Handle<Object>(callback->data(), isolate())));
} }
...@@ -1429,9 +1436,9 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1429,9 +1436,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. This will be // Save a pointer to where we pushed the arguments pointer. This will be
// passed as the const PropertyAccessorInfo& to the C++ callback. // passed as the const ExecutableAccessorInfo& to the C++ callback.
__ push(esp); __ push(scratch2());
__ 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[56] : FunctionCallbackInfo, incl. // -- rsp[8] - rsp[58] : 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.
int offset = argc + kFastApiCallArguments; __ movq(args.GetArgumentOperand(argc + 1 - FCA::kContextSaveIndex), rsi);
__ 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(offset - FCA::kCalleeIndex), rdi); __ movq(args.GetArgumentOperand(argc + 1 - 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(offset - FCA::kDataIndex), rbx); __ movq(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), rbx);
} else { } else {
__ Move(args.GetArgumentOperand(offset - FCA::kDataIndex), call_data); __ Move(args.GetArgumentOperand(argc + 1 - FCA::kDataIndex), call_data);
} }
__ movq(kScratchRegister, __ movq(kScratchRegister,
ExternalReference::isolate_address(masm->isolate())); ExternalReference::isolate_address(masm->isolate()));
__ movq(args.GetArgumentOperand(offset - FCA::kIsolateIndex), __ movq(args.GetArgumentOperand(argc + 1 - FCA::kIsolateIndex),
kScratchRegister); kScratchRegister);
__ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex);
__ movq(args.GetArgumentOperand(offset - FCA::kReturnValueDefaultValueIndex), __ movq(
kScratchRegister); args.GetArgumentOperand(argc + 1 - FCA::kReturnValueDefaultValueIndex),
__ movq(args.GetArgumentOperand(offset - FCA::kReturnValueOffset), kScratchRegister);
__ movq(args.GetArgumentOperand(argc + 1 - FCA::kReturnValueOffset),
kScratchRegister); kScratchRegister);
// Prepare arguments. // Prepare arguments.
STATIC_ASSERT(kFastApiCallArguments == 7); STATIC_ASSERT(kFastApiCallArguments == 7);
__ lea(rbx, Operand(rsp, 1 * kPointerSize)); __ lea(rbx, Operand(rsp, kFastApiCallArguments * 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); // FunctionCallbackInfo::implicit_args_. __ movq(StackSpaceOperand(0), rbx); // v8::Arguments::implicit_args_.
__ addq(rbx, Immediate((argc + kFastApiCallArguments - 1) * kPointerSize)); __ addq(rbx, Immediate(argc * kPointerSize));
__ movq(StackSpaceOperand(1), rbx); // FunctionCallbackInfo::values_. __ movq(StackSpaceOperand(1), rbx); // v8::Arguments::values_.
__ Set(StackSpaceOperand(2), argc); // FunctionCallbackInfo::length_. __ Set(StackSpaceOperand(2), argc); // v8::Arguments::length_.
// FunctionCallbackInfo::is_construct_call_. // v8::Arguments::is_construct_call_.
__ Set(StackSpaceOperand(3), 0); __ Set(StackSpaceOperand(3), 0);
#if defined(__MINGW64__) || defined(_WIN64) #if defined(__MINGW64__) || defined(_WIN64)
...@@ -520,10 +520,11 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -520,10 +520,11 @@ static void GenerateFastApiCall(MacroAssembler* masm,
Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback);
Operand context_restore_operand(rbp, Operand context_restore_operand(
(2 + FCA::kContextSaveIndex) * kPointerSize); rbp, (kFastApiCallArguments + 1 + FCA::kContextSaveIndex) * kPointerSize);
Operand return_value_operand(rbp, Operand return_value_operand(
(2 + FCA::kReturnValueOffset) * kPointerSize); rbp,
(kFastApiCallArguments + 1 + FCA::kReturnValueOffset) * kPointerSize);
__ CallApiFunctionAndReturn( __ CallApiFunctionAndReturn(
function_address, function_address,
thunk_address, thunk_address,
...@@ -545,7 +546,8 @@ static void GenerateFastApiCall(MacroAssembler* masm, ...@@ -545,7 +546,8 @@ 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 = FunctionCallbackArguments::kHolderIndex + 1; const int kHolderIndex = kFastApiCallArguments +
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.
...@@ -1094,7 +1096,8 @@ Register StubCompiler::CheckPrototypes(Handle<JSObject> object, ...@@ -1094,7 +1096,8 @@ 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 = FunctionCallbackArguments::kHolderIndex + 1; const int kHolderIndex = kFastApiCallArguments +
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()));
...@@ -1330,13 +1333,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1330,13 +1333,12 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
ASSERT(!scratch4().is(reg)); ASSERT(!scratch4().is(reg));
__ PopReturnAddressTo(scratch4()); __ PopReturnAddressTo(scratch4());
STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 0);
STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == -1);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == -2);
STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == -3);
STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == -4);
STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == -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));
...@@ -1354,7 +1356,7 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1354,7 +1356,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 PropertyAccessorInfo& to the C++ callback. // passed as the const ExecutableAccessorInfo& to the C++ callback.
Address getter_address = v8::ToCData<Address>(callback->getter()); Address getter_address = v8::ToCData<Address>(callback->getter());
...@@ -1379,9 +1381,10 @@ void BaseLoadStubCompiler::GenerateLoadCallback( ...@@ -1379,9 +1381,10 @@ void BaseLoadStubCompiler::GenerateLoadCallback(
const int kArgStackSpace = 1; const int kArgStackSpace = 1;
__ PrepareCallApiFunction(kArgStackSpace); __ PrepareCallApiFunction(kArgStackSpace);
__ lea(rax, Operand(name_arg, 1 * kPointerSize)); STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
__ lea(rax, Operand(name_arg, 6 * kPointerSize));
// v8::PropertyAccessorInfo::args_. // v8::AccessorInfo::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