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