Split off api-arguments.[h|cc] from arguments.[h|cc]
NOPRESUBMIT=true BUG= Review URL: https://codereview.chromium.org/1776353002 Cr-Commit-Position: refs/heads/master@{#34664}
This commit is contained in:
parent
e7f99c1ed5
commit
5c73b25ff5
2
BUILD.gn
2
BUILD.gn
@ -640,6 +640,8 @@ source_set("v8_base") {
|
||||
"src/allocation-site-scopes.h",
|
||||
"src/api.cc",
|
||||
"src/api.h",
|
||||
"src/api-arguments.cc",
|
||||
"src/api-arguments.h",
|
||||
"src/api-experimental.cc",
|
||||
"src/api-experimental.h",
|
||||
"src/api-natives.cc",
|
||||
|
85
src/api-arguments.cc
Normal file
85
src/api-arguments.cc
Normal file
@ -0,0 +1,85 @@
|
||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
template <typename T>
|
||||
template <typename V>
|
||||
v8::Local<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
|
||||
// Check the ReturnValue.
|
||||
Object** handle = &this->begin()[kReturnValueOffset];
|
||||
// Nothing was set, return empty handle as per previous behaviour.
|
||||
if ((*handle)->IsTheHole()) return v8::Local<V>();
|
||||
return Utils::Convert<Object, V>(Handle<Object>(handle));
|
||||
}
|
||||
|
||||
v8::Local<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(begin(), argv_, argc_,
|
||||
is_construct_call_);
|
||||
f(info);
|
||||
return GetReturnValue<v8::Value>(isolate);
|
||||
}
|
||||
|
||||
#define WRITE_CALL_0(Function, ReturnValue) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
#define WRITE_CALL_1(Function, ReturnValue, Arg1) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f, \
|
||||
Arg1 arg1) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call( \
|
||||
Function f, Arg1 arg1, Arg2 arg2) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, arg2, info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
|
||||
void PropertyCallbackArguments::Call(Function f, Arg1 arg1, Arg2 arg2) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, arg2, info); \
|
||||
}
|
||||
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
|
||||
|
||||
#undef WRITE_CALL_0
|
||||
#undef WRITE_CALL_1
|
||||
#undef WRITE_CALL_2
|
||||
#undef WRITE_CALL_2_VOID
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
201
src/api-arguments.h
Normal file
201
src/api-arguments.h
Normal file
@ -0,0 +1,201 @@
|
||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_API_ARGUMENTS_H_
|
||||
#define V8_API_ARGUMENTS_H_
|
||||
|
||||
#include "src/isolate.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// For each type of callback, we have a list of arguments
|
||||
// They are used to generate the Call() functions below
|
||||
// These aren't included in the list as they have duplicate signatures
|
||||
// F(GenericNamedPropertyEnumeratorCallback, ...)
|
||||
// F(GenericNamedPropertyGetterCallback, ...)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_0(F) \
|
||||
F(IndexedPropertyEnumeratorCallback, v8::Array)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_1(F) \
|
||||
F(AccessorNameGetterCallback, v8::Value, v8::Local<v8::Name>) \
|
||||
F(GenericNamedPropertyQueryCallback, v8::Integer, v8::Local<v8::Name>) \
|
||||
F(GenericNamedPropertyDeleterCallback, v8::Boolean, v8::Local<v8::Name>) \
|
||||
F(IndexedPropertyGetterCallback, v8::Value, uint32_t) \
|
||||
F(IndexedPropertyQueryCallback, v8::Integer, uint32_t) \
|
||||
F(IndexedPropertyDeleterCallback, v8::Boolean, uint32_t)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2(F) \
|
||||
F(GenericNamedPropertySetterCallback, v8::Value, v8::Local<v8::Name>, \
|
||||
v8::Local<v8::Value>) \
|
||||
F(IndexedPropertySetterCallback, v8::Value, uint32_t, v8::Local<v8::Value>)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(F) \
|
||||
F(AccessorNameSetterCallback, void, v8::Local<v8::Name>, v8::Local<v8::Value>)
|
||||
|
||||
// Custom arguments replicate a small segment of stack that can be
|
||||
// accessed through an Arguments object the same way the actual stack
|
||||
// can.
|
||||
template <int kArrayLength>
|
||||
class CustomArgumentsBase : public Relocatable {
|
||||
public:
|
||||
virtual inline void IterateInstance(ObjectVisitor* v) {
|
||||
v->VisitPointers(values_, values_ + kArrayLength);
|
||||
}
|
||||
|
||||
protected:
|
||||
inline Object** begin() { return values_; }
|
||||
explicit inline CustomArgumentsBase(Isolate* isolate)
|
||||
: Relocatable(isolate) {}
|
||||
Object* values_[kArrayLength];
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
|
||||
public:
|
||||
static const int kReturnValueOffset = T::kReturnValueIndex;
|
||||
|
||||
typedef CustomArgumentsBase<T::kArgsLength> Super;
|
||||
~CustomArguments() {
|
||||
this->begin()[kReturnValueOffset] =
|
||||
reinterpret_cast<Object*>(kHandleZapValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit inline CustomArguments(Isolate* isolate) : Super(isolate) {}
|
||||
|
||||
template <typename V>
|
||||
v8::Local<V> GetReturnValue(Isolate* isolate);
|
||||
|
||||
inline Isolate* isolate() {
|
||||
return reinterpret_cast<Isolate*>(this->begin()[T::kIsolateIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
class PropertyCallbackArguments
|
||||
: public CustomArguments<PropertyCallbackInfo<Value> > {
|
||||
public:
|
||||
typedef PropertyCallbackInfo<Value> T;
|
||||
typedef CustomArguments<T> Super;
|
||||
static const int kArgsLength = T::kArgsLength;
|
||||
static const int kThisIndex = T::kThisIndex;
|
||||
static const int kHolderIndex = T::kHolderIndex;
|
||||
static const int kDataIndex = T::kDataIndex;
|
||||
static const int kReturnValueDefaultValueIndex =
|
||||
T::kReturnValueDefaultValueIndex;
|
||||
static const int kIsolateIndex = T::kIsolateIndex;
|
||||
static const int kShouldThrowOnErrorIndex = T::kShouldThrowOnErrorIndex;
|
||||
|
||||
PropertyCallbackArguments(Isolate* isolate, Object* data, Object* self,
|
||||
JSObject* holder, Object::ShouldThrow should_throw)
|
||||
: Super(isolate) {
|
||||
Object** values = this->begin();
|
||||
values[T::kThisIndex] = self;
|
||||
values[T::kHolderIndex] = holder;
|
||||
values[T::kDataIndex] = data;
|
||||
values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate);
|
||||
values[T::kShouldThrowOnErrorIndex] =
|
||||
Smi::FromInt(should_throw == Object::THROW_ON_ERROR ? 1 : 0);
|
||||
|
||||
// Here the hole is set as default value.
|
||||
// It cannot escape into js as it's remove in Call below.
|
||||
values[T::kReturnValueDefaultValueIndex] =
|
||||
isolate->heap()->the_hole_value();
|
||||
values[T::kReturnValueIndex] = isolate->heap()->the_hole_value();
|
||||
DCHECK(values[T::kHolderIndex]->IsHeapObject());
|
||||
DCHECK(values[T::kIsolateIndex]->IsSmi());
|
||||
}
|
||||
|
||||
/*
|
||||
* The following Call functions wrap the calling of all callbacks to handle
|
||||
* calling either the old or the new style callbacks depending on which one
|
||||
* has been registered.
|
||||
* For old callbacks which return an empty handle, the ReturnValue is checked
|
||||
* and used if it's been set to anything inside the callback.
|
||||
* New style callbacks always use the return value.
|
||||
*/
|
||||
#define WRITE_CALL_0(Function, ReturnValue) \
|
||||
v8::Local<ReturnValue> Call(Function f);
|
||||
|
||||
#define WRITE_CALL_1(Function, ReturnValue, Arg1) \
|
||||
v8::Local<ReturnValue> Call(Function f, Arg1 arg1);
|
||||
|
||||
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
|
||||
v8::Local<ReturnValue> Call(Function f, Arg1 arg1, Arg2 arg2);
|
||||
|
||||
#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
|
||||
void Call(Function f, Arg1 arg1, Arg2 arg2);
|
||||
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
|
||||
|
||||
#undef WRITE_CALL_0
|
||||
#undef WRITE_CALL_1
|
||||
#undef WRITE_CALL_2
|
||||
#undef WRITE_CALL_2_VOID
|
||||
};
|
||||
|
||||
class FunctionCallbackArguments
|
||||
: public CustomArguments<FunctionCallbackInfo<Value> > {
|
||||
public:
|
||||
typedef FunctionCallbackInfo<Value> T;
|
||||
typedef CustomArguments<T> Super;
|
||||
static const int kArgsLength = T::kArgsLength;
|
||||
static const int kHolderIndex = T::kHolderIndex;
|
||||
static const int kDataIndex = T::kDataIndex;
|
||||
static const int kReturnValueDefaultValueIndex =
|
||||
T::kReturnValueDefaultValueIndex;
|
||||
static const int kIsolateIndex = T::kIsolateIndex;
|
||||
static const int kCalleeIndex = T::kCalleeIndex;
|
||||
static const int kContextSaveIndex = T::kContextSaveIndex;
|
||||
|
||||
FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data,
|
||||
internal::HeapObject* callee,
|
||||
internal::Object* holder, internal::Object** argv,
|
||||
int argc, bool is_construct_call)
|
||||
: Super(isolate),
|
||||
argv_(argv),
|
||||
argc_(argc),
|
||||
is_construct_call_(is_construct_call) {
|
||||
Object** values = begin();
|
||||
values[T::kDataIndex] = data;
|
||||
values[T::kCalleeIndex] = callee;
|
||||
values[T::kHolderIndex] = holder;
|
||||
values[T::kContextSaveIndex] = isolate->heap()->the_hole_value();
|
||||
values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate);
|
||||
// Here the hole is set as default value.
|
||||
// It cannot escape into js as it's remove in Call below.
|
||||
values[T::kReturnValueDefaultValueIndex] =
|
||||
isolate->heap()->the_hole_value();
|
||||
values[T::kReturnValueIndex] = isolate->heap()->the_hole_value();
|
||||
DCHECK(values[T::kCalleeIndex]->IsJSFunction() ||
|
||||
values[T::kCalleeIndex]->IsFunctionTemplateInfo());
|
||||
DCHECK(values[T::kHolderIndex]->IsHeapObject());
|
||||
DCHECK(values[T::kIsolateIndex]->IsSmi());
|
||||
}
|
||||
|
||||
/*
|
||||
* The following Call function wraps the calling of all callbacks to handle
|
||||
* calling either the old or the new style callbacks depending on which one
|
||||
* has been registered.
|
||||
* For old callbacks which return an empty handle, the ReturnValue is checked
|
||||
* and used if it's been set to anything inside the callback.
|
||||
* New style callbacks always use the return value.
|
||||
*/
|
||||
v8::Local<v8::Value> Call(FunctionCallback f);
|
||||
|
||||
private:
|
||||
internal::Object** argv_;
|
||||
int argc_;
|
||||
bool is_construct_call_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_API_ARGUMENTS_H_
|
@ -4,93 +4,9 @@
|
||||
|
||||
#include "src/arguments.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
||||
template <typename T>
|
||||
template <typename V>
|
||||
v8::Local<V> CustomArguments<T>::GetReturnValue(Isolate* isolate) {
|
||||
// Check the ReturnValue.
|
||||
Object** handle = &this->begin()[kReturnValueOffset];
|
||||
// Nothing was set, return empty handle as per previous behaviour.
|
||||
if ((*handle)->IsTheHole()) return v8::Local<V>();
|
||||
return Utils::Convert<Object, V>(Handle<Object>(handle));
|
||||
}
|
||||
|
||||
|
||||
v8::Local<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(begin(),
|
||||
argv_,
|
||||
argc_,
|
||||
is_construct_call_);
|
||||
f(info);
|
||||
return GetReturnValue<v8::Value>(isolate);
|
||||
}
|
||||
|
||||
|
||||
#define WRITE_CALL_0(Function, ReturnValue) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
|
||||
#define WRITE_CALL_1(Function, ReturnValue, Arg1) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call(Function f, \
|
||||
Arg1 arg1) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
|
||||
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
|
||||
v8::Local<ReturnValue> PropertyCallbackArguments::Call( \
|
||||
Function f, Arg1 arg1, Arg2 arg2) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, arg2, info); \
|
||||
return GetReturnValue<ReturnValue>(isolate); \
|
||||
}
|
||||
|
||||
|
||||
#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
|
||||
void PropertyCallbackArguments::Call(Function f, Arg1 arg1, Arg2 arg2) { \
|
||||
Isolate* isolate = this->isolate(); \
|
||||
VMState<EXTERNAL> state(isolate); \
|
||||
ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
|
||||
PropertyCallbackInfo<ReturnValue> info(begin()); \
|
||||
f(arg1, arg2, info); \
|
||||
}
|
||||
|
||||
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
|
||||
|
||||
#undef WRITE_CALL_0
|
||||
#undef WRITE_CALL_1
|
||||
#undef WRITE_CALL_2
|
||||
#undef WRITE_CALL_2_VOID
|
||||
|
||||
|
||||
double ClobberDoubleRegisters(double x1, double x2, double x3, double x4) {
|
||||
// TODO(ulan): This clobbers only subset of registers depending on compiler,
|
||||
// Rewrite this in assembly to really clobber all registers.
|
||||
@ -98,6 +14,5 @@ double ClobberDoubleRegisters(double x1, double x2, double x3, double x4) {
|
||||
return x1 * 1.01 + x2 * 2.02 + x3 * 3.03 + x4 * 4.04;
|
||||
}
|
||||
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
195
src/arguments.h
195
src/arguments.h
@ -6,7 +6,7 @@
|
||||
#define V8_ARGUMENTS_H_
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -71,201 +71,8 @@ class Arguments BASE_EMBEDDED {
|
||||
Object** arguments_;
|
||||
};
|
||||
|
||||
|
||||
// For each type of callback, we have a list of arguments
|
||||
// They are used to generate the Call() functions below
|
||||
// These aren't included in the list as they have duplicate signatures
|
||||
// F(GenericNamedPropertyEnumeratorCallback, ...)
|
||||
// F(GenericNamedPropertyGetterCallback, ...)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_0(F) \
|
||||
F(IndexedPropertyEnumeratorCallback, v8::Array)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_1(F) \
|
||||
F(AccessorNameGetterCallback, v8::Value, v8::Local<v8::Name>) \
|
||||
F(GenericNamedPropertyQueryCallback, v8::Integer, v8::Local<v8::Name>) \
|
||||
F(GenericNamedPropertyDeleterCallback, v8::Boolean, v8::Local<v8::Name>) \
|
||||
F(IndexedPropertyGetterCallback, v8::Value, uint32_t) \
|
||||
F(IndexedPropertyQueryCallback, v8::Integer, uint32_t) \
|
||||
F(IndexedPropertyDeleterCallback, v8::Boolean, uint32_t)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2(F) \
|
||||
F(GenericNamedPropertySetterCallback, v8::Value, v8::Local<v8::Name>, \
|
||||
v8::Local<v8::Value>) \
|
||||
F(IndexedPropertySetterCallback, v8::Value, uint32_t, v8::Local<v8::Value>)
|
||||
|
||||
#define FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(F) \
|
||||
F(AccessorNameSetterCallback, \
|
||||
void, \
|
||||
v8::Local<v8::Name>, \
|
||||
v8::Local<v8::Value>) \
|
||||
|
||||
|
||||
// Custom arguments replicate a small segment of stack that can be
|
||||
// accessed through an Arguments object the same way the actual stack
|
||||
// can.
|
||||
template<int kArrayLength>
|
||||
class CustomArgumentsBase : public Relocatable {
|
||||
public:
|
||||
virtual inline void IterateInstance(ObjectVisitor* v) {
|
||||
v->VisitPointers(values_, values_ + kArrayLength);
|
||||
}
|
||||
protected:
|
||||
inline Object** begin() { return values_; }
|
||||
explicit inline CustomArgumentsBase(Isolate* isolate)
|
||||
: Relocatable(isolate) {}
|
||||
Object* values_[kArrayLength];
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class CustomArguments : public CustomArgumentsBase<T::kArgsLength> {
|
||||
public:
|
||||
static const int kReturnValueOffset = T::kReturnValueIndex;
|
||||
|
||||
typedef CustomArgumentsBase<T::kArgsLength> Super;
|
||||
~CustomArguments() {
|
||||
this->begin()[kReturnValueOffset] =
|
||||
reinterpret_cast<Object*>(kHandleZapValue);
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit inline CustomArguments(Isolate* isolate) : Super(isolate) {}
|
||||
|
||||
template <typename V>
|
||||
v8::Local<V> GetReturnValue(Isolate* isolate);
|
||||
|
||||
inline Isolate* isolate() {
|
||||
return reinterpret_cast<Isolate*>(this->begin()[T::kIsolateIndex]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PropertyCallbackArguments
|
||||
: public CustomArguments<PropertyCallbackInfo<Value> > {
|
||||
public:
|
||||
typedef PropertyCallbackInfo<Value> T;
|
||||
typedef CustomArguments<T> Super;
|
||||
static const int kArgsLength = T::kArgsLength;
|
||||
static const int kThisIndex = T::kThisIndex;
|
||||
static const int kHolderIndex = T::kHolderIndex;
|
||||
static const int kDataIndex = T::kDataIndex;
|
||||
static const int kReturnValueDefaultValueIndex =
|
||||
T::kReturnValueDefaultValueIndex;
|
||||
static const int kIsolateIndex = T::kIsolateIndex;
|
||||
static const int kShouldThrowOnErrorIndex = T::kShouldThrowOnErrorIndex;
|
||||
|
||||
PropertyCallbackArguments(Isolate* isolate, Object* data, Object* self,
|
||||
JSObject* holder, Object::ShouldThrow should_throw)
|
||||
: Super(isolate) {
|
||||
Object** values = this->begin();
|
||||
values[T::kThisIndex] = self;
|
||||
values[T::kHolderIndex] = holder;
|
||||
values[T::kDataIndex] = data;
|
||||
values[T::kIsolateIndex] = reinterpret_cast<Object*>(isolate);
|
||||
values[T::kShouldThrowOnErrorIndex] =
|
||||
Smi::FromInt(should_throw == Object::THROW_ON_ERROR ? 1 : 0);
|
||||
|
||||
// Here the hole is set as default value.
|
||||
// It cannot escape into js as it's remove in Call below.
|
||||
values[T::kReturnValueDefaultValueIndex] =
|
||||
isolate->heap()->the_hole_value();
|
||||
values[T::kReturnValueIndex] = isolate->heap()->the_hole_value();
|
||||
DCHECK(values[T::kHolderIndex]->IsHeapObject());
|
||||
DCHECK(values[T::kIsolateIndex]->IsSmi());
|
||||
}
|
||||
|
||||
/*
|
||||
* The following Call functions wrap the calling of all callbacks to handle
|
||||
* calling either the old or the new style callbacks depending on which one
|
||||
* has been registered.
|
||||
* For old callbacks which return an empty handle, the ReturnValue is checked
|
||||
* and used if it's been set to anything inside the callback.
|
||||
* New style callbacks always use the return value.
|
||||
*/
|
||||
#define WRITE_CALL_0(Function, ReturnValue) \
|
||||
v8::Local<ReturnValue> Call(Function f);
|
||||
|
||||
#define WRITE_CALL_1(Function, ReturnValue, Arg1) \
|
||||
v8::Local<ReturnValue> Call(Function f, Arg1 arg1);
|
||||
|
||||
#define WRITE_CALL_2(Function, ReturnValue, Arg1, Arg2) \
|
||||
v8::Local<ReturnValue> Call(Function f, Arg1 arg1, Arg2 arg2);
|
||||
|
||||
#define WRITE_CALL_2_VOID(Function, ReturnValue, Arg1, Arg2) \
|
||||
void Call(Function f, Arg1 arg1, Arg2 arg2); \
|
||||
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_0(WRITE_CALL_0)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_1(WRITE_CALL_1)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2(WRITE_CALL_2)
|
||||
FOR_EACH_CALLBACK_TABLE_MAPPING_2_VOID_RETURN(WRITE_CALL_2_VOID)
|
||||
|
||||
#undef WRITE_CALL_0
|
||||
#undef WRITE_CALL_1
|
||||
#undef WRITE_CALL_2
|
||||
#undef WRITE_CALL_2_VOID
|
||||
};
|
||||
|
||||
|
||||
class FunctionCallbackArguments
|
||||
: public CustomArguments<FunctionCallbackInfo<Value> > {
|
||||
public:
|
||||
typedef FunctionCallbackInfo<Value> T;
|
||||
typedef CustomArguments<T> Super;
|
||||
static const int kArgsLength = T::kArgsLength;
|
||||
static const int kHolderIndex = T::kHolderIndex;
|
||||
static const int kDataIndex = T::kDataIndex;
|
||||
static const int kReturnValueDefaultValueIndex =
|
||||
T::kReturnValueDefaultValueIndex;
|
||||
static const int kIsolateIndex = T::kIsolateIndex;
|
||||
static const int kCalleeIndex = T::kCalleeIndex;
|
||||
static const int kContextSaveIndex = T::kContextSaveIndex;
|
||||
|
||||
FunctionCallbackArguments(internal::Isolate* isolate, internal::Object* data,
|
||||
internal::HeapObject* callee,
|
||||
internal::Object* holder, internal::Object** argv,
|
||||
int argc, bool is_construct_call)
|
||||
: Super(isolate),
|
||||
argv_(argv),
|
||||
argc_(argc),
|
||||
is_construct_call_(is_construct_call) {
|
||||
Object** values = begin();
|
||||
values[T::kDataIndex] = data;
|
||||
values[T::kCalleeIndex] = callee;
|
||||
values[T::kHolderIndex] = holder;
|
||||
values[T::kContextSaveIndex] = isolate->heap()->the_hole_value();
|
||||
values[T::kIsolateIndex] = reinterpret_cast<internal::Object*>(isolate);
|
||||
// Here the hole is set as default value.
|
||||
// It cannot escape into js as it's remove in Call below.
|
||||
values[T::kReturnValueDefaultValueIndex] =
|
||||
isolate->heap()->the_hole_value();
|
||||
values[T::kReturnValueIndex] = isolate->heap()->the_hole_value();
|
||||
DCHECK(values[T::kCalleeIndex]->IsJSFunction() ||
|
||||
values[T::kCalleeIndex]->IsFunctionTemplateInfo());
|
||||
DCHECK(values[T::kHolderIndex]->IsHeapObject());
|
||||
DCHECK(values[T::kIsolateIndex]->IsSmi());
|
||||
}
|
||||
|
||||
/*
|
||||
* The following Call function wraps the calling of all callbacks to handle
|
||||
* calling either the old or the new style callbacks depending on which one
|
||||
* has been registered.
|
||||
* For old callbacks which return an empty handle, the ReturnValue is checked
|
||||
* and used if it's been set to anything inside the callback.
|
||||
* New style callbacks always use the return value.
|
||||
*/
|
||||
v8::Local<v8::Value> Call(FunctionCallback f);
|
||||
|
||||
private:
|
||||
internal::Object** argv_;
|
||||
int argc_;
|
||||
bool is_construct_call_;
|
||||
};
|
||||
|
||||
|
||||
double ClobberDoubleRegisters(double x1, double x2, double x3, double x4);
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define CLOBBER_DOUBLE_REGISTERS() ClobberDoubleRegisters(1, 2, 3, 4);
|
||||
#else
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#if V8_TARGET_ARCH_ARM
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
#if V8_TARGET_ARCH_ARM64
|
||||
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include "src/builtins.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/api-natives.h"
|
||||
#include "src/arguments.h"
|
||||
#include "src/api.h"
|
||||
#include "src/base/once.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/dateparser-inl.h"
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#if V8_TARGET_ARCH_IA32
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ia32/code-stubs-ia32.h"
|
||||
#include "src/ia32/frames-ia32.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "src/ic/ic.h"
|
||||
|
||||
#include "src/accessors.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/api.h"
|
||||
#include "src/arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
@ -15,14 +16,14 @@
|
||||
#include "src/frames-inl.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic-inl.h"
|
||||
#include "src/ic/ic-compiler.h"
|
||||
#include "src/ic/ic-inl.h"
|
||||
#include "src/ic/stub-cache.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/prototype.h"
|
||||
#include "src/runtime/runtime.h"
|
||||
#include "src/runtime/runtime-utils.h"
|
||||
#include "src/runtime/runtime.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/ic/handler-compiler.h"
|
||||
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/field-type.h"
|
||||
#include "src/ic/call-optimization.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#if V8_TARGET_ARCH_MIPS
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
#if V8_TARGET_ARCH_MIPS64
|
||||
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -10,9 +10,9 @@
|
||||
|
||||
#include "src/accessors.h"
|
||||
#include "src/allocation-site-scopes.h"
|
||||
#include "src/api.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/api-natives.h"
|
||||
#include "src/arguments.h"
|
||||
#include "src/api.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/utils/random-number-generator.h"
|
||||
#include "src/bootstrapper.h"
|
||||
@ -40,8 +40,8 @@
|
||||
#include "src/lookup.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects-body-descriptors-inl.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/profiler/cpu-profiler.h"
|
||||
#include "src/property-descriptor.h"
|
||||
#include "src/prototype.h"
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#if V8_TARGET_ARCH_PPC
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
#if V8_TARGET_ARCH_S390
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/codegen.h"
|
||||
|
@ -4,8 +4,9 @@
|
||||
|
||||
#if V8_TARGET_ARCH_X64
|
||||
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#if V8_TARGET_ARCH_X87
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/api-arguments.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/ic/handler-compiler.h"
|
||||
#include "src/ic/ic.h"
|
||||
|
@ -459,6 +459,8 @@
|
||||
'../../src/api-experimental.h',
|
||||
'../../src/api.cc',
|
||||
'../../src/api.h',
|
||||
'../../src/api-arguments.cc',
|
||||
'../../src/api-arguments.h',
|
||||
'../../src/api-natives.cc',
|
||||
'../../src/api-natives.h',
|
||||
'../../src/arguments.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user