v8.h   v8.h 
skipping to change at line 212 skipping to change at line 212
* dereferencing the handle (for instance, to extract the Object* from * dereferencing the handle (for instance, to extract the Object* from
* a Handle<Object>); the value will still be governed by a handle * a Handle<Object>); the value will still be governed by a handle
* behind the scenes and the same rules apply to these values as to * behind the scenes and the same rules apply to these values as to
* their handles. * their handles.
*/ */
template <class T> class Handle { template <class T> class Handle {
public: public:
/** /**
* Creates an empty handle. * Creates an empty handle.
*/ */
V8_INLINE(Handle()) : val_(0) {} V8_INLINE Handle() : val_(0) {}
/** /**
* Creates a handle for the contents of the specified handle. This * Creates a handle for the contents of the specified handle. This
* constructor allows you to pass handles as arguments by value and * constructor allows you to pass handles as arguments by value and
* to assign between handles. However, if you try to assign between * to assign between handles. However, if you try to assign between
* incompatible handles, for instance from a Handle<String> to a * incompatible handles, for instance from a Handle<String> to a
* Handle<Number> it will cause a compile-time error. Assigning * Handle<Number> it will cause a compile-time error. Assigning
* between compatible handles, for instance assigning a * between compatible handles, for instance assigning a
* Handle<String> to a variable declared as Handle<Value>, is legal * Handle<String> to a variable declared as Handle<Value>, is legal
* because String is a subclass of Value. * because String is a subclass of Value.
*/ */
template <class S> V8_INLINE(Handle(Handle<S> that)) template <class S> V8_INLINE Handle(Handle<S> that)
: val_(reinterpret_cast<T*>(*that)) { : val_(reinterpret_cast<T*>(*that)) {
/** /**
* This check fails when trying to convert between incompatible * This check fails when trying to convert between incompatible
* handles. For example, converting from a Handle<String> to a * handles. For example, converting from a Handle<String> to a
* Handle<Number>. * Handle<Number>.
*/ */
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* Returns true if the handle is empty. * Returns true if the handle is empty.
*/ */
V8_INLINE(bool IsEmpty() const) { return val_ == 0; } V8_INLINE bool IsEmpty() const { return val_ == 0; }
/** /**
* Sets the handle to be empty. IsEmpty() will then return true. * Sets the handle to be empty. IsEmpty() will then return true.
*/ */
V8_INLINE(void Clear()) { val_ = 0; } V8_INLINE void Clear() { val_ = 0; }
V8_INLINE(T* operator->() const) { return val_; } V8_INLINE T* operator->() const { return val_; }
V8_INLINE(T* operator*() const) { return val_; } V8_INLINE T* operator*() const { return val_; }
/** /**
* Checks whether two handles are the same. * Checks whether two handles are the same.
* Returns true if both are empty, or if the objects * Returns true if both are empty, or if the objects
* to which they refer are identical. * to which they refer are identical.
* The handles' references are not checked. * The handles' references are not checked.
*/ */
template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const ) { template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(**this); internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that); internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0; if (a == 0) return b == 0;
if (b == 0) return false; if (b == 0) return false;
return *a == *b; return *a == *b;
} }
template <class S> V8_INLINE( template <class S> V8_INLINE bool operator==(
bool operator==(const Persistent<S>& that) const) { const Persistent<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(**this); internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that); internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0; if (a == 0) return b == 0;
if (b == 0) return false; if (b == 0) return false;
return *a == *b; return *a == *b;
} }
/** /**
* Checks whether two handles are different. * Checks whether two handles are different.
* Returns true if only one of the handles is empty, or if * Returns true if only one of the handles is empty, or if
* the objects to which they refer are different. * the objects to which they refer are different.
* The handles' references are not checked. * The handles' references are not checked.
*/ */
template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const ) { template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
return !operator==(that); return !operator==(that);
} }
template <class S> V8_INLINE( template <class S> V8_INLINE bool operator!=(
bool operator!=(const Persistent<S>& that) const) { const Persistent<S>& that) const {
return !operator==(that); return !operator==(that);
} }
template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { template <class S> V8_INLINE static Handle<T> Cast(Handle<S> that) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check // If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast. // that the handle isn't empty before doing the checked cast.
if (that.IsEmpty()) return Handle<T>(); if (that.IsEmpty()) return Handle<T>();
#endif #endif
return Handle<T>(T::Cast(*that)); return Handle<T>(T::Cast(*that));
} }
template <class S> V8_INLINE(Handle<S> As()) { template <class S> V8_INLINE Handle<S> As() {
return Handle<S>::Cast(*this); return Handle<S>::Cast(*this);
} }
V8_INLINE(static Handle<T> New(Isolate* isolate, Handle<T> that)) { V8_INLINE static Handle<T> New(Isolate* isolate, Handle<T> that) {
return New(isolate, that.val_); return New(isolate, that.val_);
} }
V8_INLINE(static Handle<T> New(Isolate* isolate, const Persistent<T>& tha t)) { V8_INLINE static Handle<T> New(Isolate* isolate, const Persistent<T>& tha t) {
return New(isolate, that.val_); return New(isolate, that.val_);
} }
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private: private:
#endif #endif
/** /**
* Creates a new handle for the specified value. * Creates a new handle for the specified value.
*/ */
V8_INLINE(explicit Handle(T* val)) : val_(val) {} V8_INLINE explicit Handle(T* val) : val_(val) {}
private: private:
friend class Utils; friend class Utils;
template<class F, class M> friend class Persistent; template<class F, class M> friend class Persistent;
template<class F> friend class Local; template<class F> friend class Local;
template<class F> friend class FunctionCallbackInfo; template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo; template<class F> friend class PropertyCallbackInfo;
template<class F> friend class internal::CustomArguments; template<class F> friend class internal::CustomArguments;
friend Handle<Primitive> Undefined(Isolate* isolate); friend Handle<Primitive> Undefined(Isolate* isolate);
friend Handle<Primitive> Null(Isolate* isolate); friend Handle<Primitive> Null(Isolate* isolate);
friend Handle<Boolean> True(Isolate* isolate); friend Handle<Boolean> True(Isolate* isolate);
friend Handle<Boolean> False(Isolate* isolate); friend Handle<Boolean> False(Isolate* isolate);
friend class Context; friend class Context;
friend class HandleScope; friend class HandleScope;
V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); V8_INLINE static Handle<T> New(Isolate* isolate, T* that);
T* val_; T* val_;
}; };
/** /**
* A light-weight stack-allocated object handle. All operations * A light-weight stack-allocated object handle. All operations
* that return objects from within v8 return them in local handles. They * that return objects from within v8 return them in local handles. They
* are created within HandleScopes, and all local handles allocated within a * are created within HandleScopes, and all local handles allocated within a
* handle scope are destroyed when the handle scope is destroyed. Hence it * handle scope are destroyed when the handle scope is destroyed. Hence it
* is not necessary to explicitly deallocate local handles. * is not necessary to explicitly deallocate local handles.
*/ */
template <class T> class Local : public Handle<T> { template <class T> class Local : public Handle<T> {
public: public:
V8_INLINE(Local()); V8_INLINE Local();
template <class S> V8_INLINE(Local(Local<S> that)) template <class S> V8_INLINE Local(Local<S> that)
: Handle<T>(reinterpret_cast<T*>(*that)) { : Handle<T>(reinterpret_cast<T*>(*that)) {
/** /**
* This check fails when trying to convert between incompatible * This check fails when trying to convert between incompatible
* handles. For example, converting from a Handle<String> to a * handles. For example, converting from a Handle<String> to a
* Handle<Number>. * Handle<Number>.
*/ */
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
template <class S> V8_INLINE(static Local<T> Cast(Local<S> that)) { template <class S> V8_INLINE static Local<T> Cast(Local<S> that) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check // If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast. // that the handle isn't empty before doing the checked cast.
if (that.IsEmpty()) return Local<T>(); if (that.IsEmpty()) return Local<T>();
#endif #endif
return Local<T>(T::Cast(*that)); return Local<T>(T::Cast(*that));
} }
template <class S> V8_INLINE(Local(Handle<S> that)) template <class S> V8_INLINE Local(Handle<S> that)
: Handle<T>(reinterpret_cast<T*>(*that)) { : Handle<T>(reinterpret_cast<T*>(*that)) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
template <class S> V8_INLINE(Local<S> As()) { template <class S> V8_INLINE Local<S> As() {
return Local<S>::Cast(*this); return Local<S>::Cast(*this);
} }
/** /**
* Create a local handle for the content of another handle. * Create a local handle for the content of another handle.
* The referee is kept alive by the local handle even when * The referee is kept alive by the local handle even when
* the original handle is destroyed/disposed. * the original handle is destroyed/disposed.
*/ */
V8_INLINE(static Local<T> New(Handle<T> that)); V8_INLINE static Local<T> New(Handle<T> that);
V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
template<class M> template<class M>
V8_INLINE(static Local<T> New(Isolate* isolate, V8_INLINE static Local<T> New(Isolate* isolate,
const Persistent<T, M>& that)); const Persistent<T, M>& that);
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private: private:
#endif #endif
template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { }
private: private:
friend class Utils; friend class Utils;
template<class F> friend class Eternal; template<class F> friend class Eternal;
template<class F, class M> friend class Persistent; template<class F, class M> friend class Persistent;
template<class F> friend class Handle; template<class F> friend class Handle;
template<class F> friend class FunctionCallbackInfo; template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo; template<class F> friend class PropertyCallbackInfo;
friend class String; friend class String;
friend class Object; friend class Object;
friend class Context; friend class Context;
template<class F> friend class internal::CustomArguments; template<class F> friend class internal::CustomArguments;
friend class HandleScope; friend class HandleScope;
V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); V8_INLINE static Local<T> New(Isolate* isolate, T* that);
}; };
// Eternal handles are set-once handles that live for the life of the isola te. // Eternal handles are set-once handles that live for the life of the isola te.
template <class T> class Eternal { template <class T> class Eternal {
public: public:
V8_INLINE(Eternal()) : index_(kInitialValue) { } V8_INLINE Eternal() : index_(kInitialValue) { }
template<class S> template<class S>
V8_INLINE(Eternal(Isolate* isolate, Local<S> handle)) V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialVal
: index_(kInitialValue) { ue) {
Set(isolate, handle); Set(isolate, handle);
} }
// Can only be safely called if already set. // Can only be safely called if already set.
V8_INLINE(Local<T> Get(Isolate* isolate)); V8_INLINE Local<T> Get(Isolate* isolate);
V8_INLINE(bool IsEmpty()) { return index_ == kInitialValue; } V8_INLINE bool IsEmpty() { return index_ == kInitialValue; }
template<class S> template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
V8_INLINE(void Set(Isolate* isolate, Local<S> handle));
private: private:
static const int kInitialValue = -1; static const int kInitialValue = -1;
int index_; int index_;
}; };
template<class T, class P> template<class T, class P>
class WeakCallbackData { class WeakCallbackData {
public: public:
typedef void (*Callback)(const WeakCallbackData<T, P>& data); typedef void (*Callback)(const WeakCallbackData<T, P>& data);
V8_INLINE(Isolate* GetIsolate()) const { return isolate_; } V8_INLINE Isolate* GetIsolate() const { return isolate_; }
V8_INLINE(Local<T> GetValue()) const { return handle_; } V8_INLINE Local<T> GetValue() const { return handle_; }
V8_INLINE(P* GetParameter()) const { return parameter_; } V8_INLINE P* GetParameter() const { return parameter_; }
private: private:
friend class internal::GlobalHandles; friend class internal::GlobalHandles;
WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter) WeakCallbackData(Isolate* isolate, Local<T> handle, P* parameter)
: isolate_(isolate), handle_(handle), parameter_(parameter) { } : isolate_(isolate), handle_(handle), parameter_(parameter) { }
Isolate* isolate_; Isolate* isolate_;
Local<T> handle_; Local<T> handle_;
P* parameter_; P* parameter_;
}; };
skipping to change at line 465 skipping to change at line 463
* use of the copy constructor or assignment operator. * use of the copy constructor or assignment operator.
* At present kResetInDestructor is not set, but that will change in a futu re * At present kResetInDestructor is not set, but that will change in a futu re
* version. * version.
*/ */
template<class T> template<class T>
class NonCopyablePersistentTraits { class NonCopyablePersistentTraits {
public: public:
typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersist ent; typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersist ent;
static const bool kResetInDestructor = false; static const bool kResetInDestructor = false;
template<class S, class M> template<class S, class M>
V8_INLINE(static void Copy(const Persistent<S, M>& source, V8_INLINE static void Copy(const Persistent<S, M>& source,
NonCopyablePersistent* dest)) { NonCopyablePersistent* dest) {
Uncompilable<Object>(); Uncompilable<Object>();
} }
// TODO(dcarney): come up with a good compile error here. // TODO(dcarney): come up with a good compile error here.
template<class O> template<class O> V8_INLINE static void Uncompilable() {
V8_INLINE(static void Uncompilable()) {
TYPE_CHECK(O, Primitive); TYPE_CHECK(O, Primitive);
} }
}; };
/** /**
* An object reference that is independent of any handle scope. Where * An object reference that is independent of any handle scope. Where
* a Local handle only lives as long as the HandleScope in which it was * a Local handle only lives as long as the HandleScope in which it was
* allocated, a Persistent handle remains valid until it is explicitly * allocated, a Persistent handle remains valid until it is explicitly
* disposed. * disposed.
* *
skipping to change at line 496 skipping to change at line 493
* existing handles can be disposed using Persistent::Reset. * existing handles can be disposed using Persistent::Reset.
* *
* Copy, assignment and destructor bevavior is controlled by the traits * Copy, assignment and destructor bevavior is controlled by the traits
* class M. * class M.
*/ */
template <class T, class M> class Persistent { template <class T, class M> class Persistent {
public: public:
/** /**
* A Persistent with no storage cell. * A Persistent with no storage cell.
*/ */
V8_INLINE(Persistent()) : val_(0) { } V8_INLINE Persistent() : val_(0) { }
/** /**
* Construct a Persistent from a Handle. * Construct a Persistent from a Handle.
* When the Handle is non-empty, a new storage cell is created * When the Handle is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set. * pointing to the same object, and no flags are set.
*/ */
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that) ) template <class S> V8_INLINE Persistent(Isolate* isolate, Handle<S> that)
: val_(New(isolate, *that)) { : val_(New(isolate, *that)) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* Construct a Persistent from a Persistent. * Construct a Persistent from a Persistent.
* When the Persistent is non-empty, a new storage cell is created * When the Persistent is non-empty, a new storage cell is created
* pointing to the same object, and no flags are set. * pointing to the same object, and no flags are set.
*/ */
template <class S, class M2> template <class S, class M2>
V8_INLINE(Persistent(Isolate* isolate, const Persistent<S, M2>& that)) V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that)
: val_(New(isolate, *that)) { : val_(New(isolate, *that)) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* The copy constructors and assignment operator create a Persistent * The copy constructors and assignment operator create a Persistent
* exactly as the Persistent constructor, but the Copy function from the * exactly as the Persistent constructor, but the Copy function from the
* traits class is called, allowing the setting of flags based on the * traits class is called, allowing the setting of flags based on the
* copied Persistent. * copied Persistent.
*/ */
V8_INLINE(Persistent(const Persistent& that)) : val_(0) { V8_INLINE Persistent(const Persistent& that) : val_(0) {
Copy(that); Copy(that);
} }
template <class S, class M2> template <class S, class M2>
V8_INLINE(Persistent(const Persistent<S, M2>& that)) : val_(0) { V8_INLINE Persistent(const Persistent<S, M2>& that) : val_(0) {
Copy(that); Copy(that);
} }
V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT
Copy(that); Copy(that);
return *this; return *this;
} }
template <class S, class M2> template <class S, class M2>
V8_INLINE(Persistent& operator=(const Persistent<S, M2>& that)) { // NOLI NT V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLIN T
Copy(that); Copy(that);
return *this; return *this;
} }
/** /**
* The destructor will dispose the Persistent based on the * The destructor will dispose the Persistent based on the
* kResetInDestructor flags in the traits class. Since not calling dispo se * kResetInDestructor flags in the traits class. Since not calling dispo se
* can result in a memory leak, it is recommended to always set this flag . * can result in a memory leak, it is recommended to always set this flag .
*/ */
V8_INLINE(~Persistent()) { V8_INLINE ~Persistent() {
if (M::kResetInDestructor) Reset(); if (M::kResetInDestructor) Reset();
} }
/** /**
* If non-empty, destroy the underlying storage cell * If non-empty, destroy the underlying storage cell
* IsEmpty() will return true after this call. * IsEmpty() will return true after this call.
*/ */
V8_INLINE(void Reset()); V8_INLINE void Reset();
template <class S>
/** /**
* If non-empty, destroy the underlying storage cell * If non-empty, destroy the underlying storage cell
* and create a new one with the contents of other if other is non empty * and create a new one with the contents of other if other is non empty
*/ */
V8_INLINE(void Reset(Isolate* isolate, const Handle<S>& other)); template <class S>
V8_INLINE void Reset(Isolate* isolate, const Handle<S>& other);
/** /**
* If non-empty, destroy the underlying storage cell * If non-empty, destroy the underlying storage cell
* and create a new one with the contents of other if other is non empty * and create a new one with the contents of other if other is non empty
*/ */
template <class S, class M2> template <class S, class M2>
V8_INLINE(void Reset(Isolate* isolate, const Persistent<S, M2>& other)); V8_INLINE void Reset(Isolate* isolate, const Persistent<S, M2>& other);
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
V8_INLINE(void Dispose()) { Reset(); } V8_INLINE void Dispose() { Reset(); }
V8_DEPRECATED(V8_INLINE(void Dispose(Isolate* isolate))) { Reset(); } V8_DEPRECATED(V8_INLINE void Dispose(Isolate* isolate)) { Reset(); }
V8_INLINE(bool IsEmpty() const) { return val_ == 0; } V8_INLINE bool IsEmpty() const { return val_ == 0; }
// TODO(dcarney): this is pretty useless, fix or remove // TODO(dcarney): this is pretty useless, fix or remove
template <class S> template <class S>
V8_INLINE(static Persistent<T>& Cast(Persistent<S>& that)) { // NOLINT V8_INLINE static Persistent<T>& Cast(Persistent<S>& that) { // NOLINT
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
// If we're going to perform the type check then we have to check // If we're going to perform the type check then we have to check
// that the handle isn't empty before doing the checked cast. // that the handle isn't empty before doing the checked cast.
if (!that.IsEmpty()) T::Cast(*that); if (!that.IsEmpty()) T::Cast(*that);
#endif #endif
return reinterpret_cast<Persistent<T>&>(that); return reinterpret_cast<Persistent<T>&>(that);
} }
// TODO(dcarney): this is pretty useless, fix or remove // TODO(dcarney): this is pretty useless, fix or remove
template <class S> V8_INLINE(Persistent<S>& As()) { // NOLINT template <class S> V8_INLINE Persistent<S>& As() { // NOLINT
return Persistent<S>::Cast(*this); return Persistent<S>::Cast(*this);
} }
template <class S, class M2> V8_INLINE( template <class S, class M2>
bool operator==(const Persistent<S, M2>& that) const) { V8_INLINE bool operator==(const Persistent<S, M2>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(**this); internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that); internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0; if (a == 0) return b == 0;
if (b == 0) return false; if (b == 0) return false;
return *a == *b; return *a == *b;
} }
template <class S> V8_INLINE(bool operator==(const Handle<S>& that) const ) { template <class S> V8_INLINE bool operator==(const Handle<S>& that) const {
internal::Object** a = reinterpret_cast<internal::Object**>(**this); internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that); internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0; if (a == 0) return b == 0;
if (b == 0) return false; if (b == 0) return false;
return *a == *b; return *a == *b;
} }
template <class S, class M2> V8_INLINE( template <class S, class M2>
bool operator!=(const Persistent<S, M2>& that) const) { V8_INLINE bool operator!=(const Persistent<S, M2>& that) const {
return !operator==(that); return !operator==(that);
} }
template <class S> V8_INLINE(bool operator!=(const Handle<S>& that) const ) { template <class S> V8_INLINE bool operator!=(const Handle<S>& that) const {
return !operator==(that); return !operator==(that);
} }
template<typename P> template<typename P>
V8_INLINE(void SetWeak( V8_INLINE void SetWeak(
P* parameter, P* parameter,
typename WeakCallbackData<T, P>::Callback callback)); typename WeakCallbackData<T, P>::Callback callback);
template<typename S, typename P> template<typename S, typename P>
V8_INLINE(void SetWeak( V8_INLINE void SetWeak(
P* parameter, P* parameter,
typename WeakCallbackData<S, P>::Callback callback)); typename WeakCallbackData<S, P>::Callback callback);
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
template<typename S, typename P> template<typename S, typename P>
V8_INLINE(void MakeWeak( V8_INLINE void MakeWeak(
P* parameter, P* parameter,
typename WeakReferenceCallbacks<S, P>::Revivable callback)); typename WeakReferenceCallbacks<S, P>::Revivable callback);
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
template<typename P> template<typename P>
V8_INLINE(void MakeWeak( V8_INLINE void MakeWeak(
P* parameter, P* parameter,
typename WeakReferenceCallbacks<T, P>::Revivable callback)); typename WeakReferenceCallbacks<T, P>::Revivable callback);
V8_INLINE(void ClearWeak()); V8_INLINE void ClearWeak();
V8_DEPRECATED(V8_INLINE(void ClearWeak(Isolate* isolate))) { ClearWeak(); } V8_DEPRECATED(V8_INLINE void ClearWeak(Isolate* isolate)) { ClearWeak(); }
/** /**
* Marks the reference to this object independent. Garbage collector is f ree * Marks the reference to this object independent. Garbage collector is f ree
* to ignore any object groups containing this object. Weak callback for an * to ignore any object groups containing this object. Weak callback for an
* independent handle should not assume that it will be preceded by a glo bal * independent handle should not assume that it will be preceded by a glo bal
* GC prologue callback or followed by a global GC epilogue callback. * GC prologue callback or followed by a global GC epilogue callback.
*/ */
V8_INLINE(void MarkIndependent()); V8_INLINE void MarkIndependent();
V8_DEPRECATED(V8_INLINE(void MarkIndependent(Isolate* isolate))) { V8_DEPRECATED(V8_INLINE void MarkIndependent(Isolate* isolate)) {
MarkIndependent(); MarkIndependent();
} }
/** /**
* Marks the reference to this object partially dependent. Partially depe ndent * Marks the reference to this object partially dependent. Partially depe ndent
* handles only depend on other partially dependent handles and these * handles only depend on other partially dependent handles and these
* dependencies are provided through object groups. It provides a way to build * dependencies are provided through object groups. It provides a way to build
* smaller object groups for young objects that represent only a subset o f all * smaller object groups for young objects that represent only a subset o f all
* external dependencies. This mark is automatically cleared after each * external dependencies. This mark is automatically cleared after each
* garbage collection. * garbage collection.
*/ */
V8_INLINE(void MarkPartiallyDependent()); V8_INLINE void MarkPartiallyDependent();
V8_DEPRECATED(V8_INLINE(void MarkPartiallyDependent(Isolate* isolate))) { V8_DEPRECATED(V8_INLINE void MarkPartiallyDependent(Isolate* isolate)) {
MarkPartiallyDependent(); MarkPartiallyDependent();
} }
V8_INLINE(bool IsIndependent() const); V8_INLINE bool IsIndependent() const;
V8_DEPRECATED(V8_INLINE(bool IsIndependent(Isolate* isolate)) const) { V8_DEPRECATED(V8_INLINE bool IsIndependent(Isolate* isolate) const) {
return IsIndependent(); return IsIndependent();
} }
/** Checks if the handle holds the only reference to an object. */ /** Checks if the handle holds the only reference to an object. */
V8_INLINE(bool IsNearDeath() const); V8_INLINE bool IsNearDeath() const;
V8_DEPRECATED(V8_INLINE(bool IsNearDeath(Isolate* isolate)) const) { V8_DEPRECATED(V8_INLINE bool IsNearDeath(Isolate* isolate) const) {
return IsNearDeath(); return IsNearDeath();
} }
/** Returns true if the handle's reference is weak. */ /** Returns true if the handle's reference is weak. */
V8_INLINE(bool IsWeak() const); V8_INLINE bool IsWeak() const;
V8_DEPRECATED(V8_INLINE(bool IsWeak(Isolate* isolate)) const) { V8_DEPRECATED(V8_INLINE bool IsWeak(Isolate* isolate) const) {
return IsWeak(); return IsWeak();
} }
/** /**
* Assigns a wrapper class ID to the handle. See RetainedObjectInfo inter face * Assigns a wrapper class ID to the handle. See RetainedObjectInfo inter face
* description in v8-profiler.h for details. * description in v8-profiler.h for details.
*/ */
V8_INLINE(void SetWrapperClassId(uint16_t class_id)); V8_INLINE void SetWrapperClassId(uint16_t class_id);
V8_DEPRECATED( V8_DEPRECATED(
V8_INLINE(void SetWrapperClassId(Isolate * isolate, uint16_t class_id ))) { V8_INLINE void SetWrapperClassId(Isolate * isolate, uint16_t class_id )) {
SetWrapperClassId(class_id); SetWrapperClassId(class_id);
} }
/** /**
* Returns the class ID previously assigned to this handle or 0 if no cla ss ID * Returns the class ID previously assigned to this handle or 0 if no cla ss ID
* was previously assigned. * was previously assigned.
*/ */
V8_INLINE(uint16_t WrapperClassId() const); V8_INLINE uint16_t WrapperClassId() const;
V8_DEPRECATED(V8_INLINE(uint16_t WrapperClassId(Isolate* isolate)) const) { V8_DEPRECATED(V8_INLINE uint16_t WrapperClassId(Isolate* isolate) const) {
return WrapperClassId(); return WrapperClassId();
} }
// TODO(dcarney): remove // TODO(dcarney): remove
V8_INLINE(T* ClearAndLeak()); V8_INLINE T* ClearAndLeak();
// TODO(dcarney): remove // TODO(dcarney): remove
V8_INLINE(void Clear()) { val_ = 0; } V8_INLINE void Clear() { val_ = 0; }
// TODO(dcarney): remove // TODO(dcarney): remove
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private: private:
#endif #endif
template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } template <class S> V8_INLINE Persistent(S* that) : val_(that) { }
V8_INLINE(T* operator*() const) { return val_; } V8_INLINE T* operator*() const { return val_; }
private: private:
friend class Utils; friend class Utils;
template<class F> friend class Handle; template<class F> friend class Handle;
template<class F> friend class Local; template<class F> friend class Local;
template<class F1, class F2> friend class Persistent; template<class F1, class F2> friend class Persistent;
template<class F> friend class ReturnValue; template<class F> friend class ReturnValue;
V8_INLINE(static T* New(Isolate* isolate, T* that)); V8_INLINE static T* New(Isolate* isolate, T* that);
template<class S, class M2> template<class S, class M2>
V8_INLINE(void Copy(const Persistent<S, M2>& that)); V8_INLINE void Copy(const Persistent<S, M2>& that);
T* val_; T* val_;
}; };
/** /**
* A stack-allocated class that governs a number of local handles. * A stack-allocated class that governs a number of local handles.
* After a handle scope has been created, all local handles will be * After a handle scope has been created, all local handles will be
* allocated within that handle scope until either the handle scope is * allocated within that handle scope until either the handle scope is
* deleted or another handle scope is created. If there is already a * deleted or another handle scope is created. If there is already a
* handle scope and a new one is created, all allocations will take * handle scope and a new one is created, all allocations will take
skipping to change at line 789 skipping to change at line 786
void* operator new(size_t size); void* operator new(size_t size);
void operator delete(void*, size_t); void operator delete(void*, size_t);
// This Data class is accessible internally as HandleScopeData through a // This Data class is accessible internally as HandleScopeData through a
// typedef in the ImplementationUtilities class. // typedef in the ImplementationUtilities class.
class V8_EXPORT Data { class V8_EXPORT Data {
public: public:
internal::Object** next; internal::Object** next;
internal::Object** limit; internal::Object** limit;
int level; int level;
V8_INLINE(void Initialize()) { V8_INLINE void Initialize() {
next = limit = NULL; next = limit = NULL;
level = 0; level = 0;
} }
}; };
void Initialize(Isolate* isolate); void Initialize(Isolate* isolate);
void Leave(); void Leave();
internal::Isolate* isolate_; internal::Isolate* isolate_;
internal::Object** prev_next_; internal::Object** prev_next_;
skipping to change at line 893 skipping to change at line 890
* Returns true if the source code could not be parsed. * Returns true if the source code could not be parsed.
*/ */
virtual bool HasError() = 0; virtual bool HasError() = 0;
}; };
/** /**
* The origin, within a file, of a script. * The origin, within a file, of a script.
*/ */
class ScriptOrigin { class ScriptOrigin {
public: public:
V8_INLINE(ScriptOrigin( V8_INLINE ScriptOrigin(
Handle<Value> resource_name, Handle<Value> resource_name,
Handle<Integer> resource_line_offset = Handle<Integer>(), Handle<Integer> resource_line_offset = Handle<Integer>(),
Handle<Integer> resource_column_offset = Handle<Integer>(), Handle<Integer> resource_column_offset = Handle<Integer>(),
Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>())) Handle<Boolean> resource_is_shared_cross_origin = Handle<Boolean>())
: resource_name_(resource_name), : resource_name_(resource_name),
resource_line_offset_(resource_line_offset), resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset), resource_column_offset_(resource_column_offset),
resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { } resource_is_shared_cross_origin_(resource_is_shared_cross_origin) { }
V8_INLINE(Handle<Value> ResourceName() const); V8_INLINE Handle<Value> ResourceName() const;
V8_INLINE(Handle<Integer> ResourceLineOffset() const); V8_INLINE Handle<Integer> ResourceLineOffset() const;
V8_INLINE(Handle<Integer> ResourceColumnOffset() const); V8_INLINE Handle<Integer> ResourceColumnOffset() const;
V8_INLINE(Handle<Boolean> ResourceIsSharedCrossOrigin() const); V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const;
private: private:
Handle<Value> resource_name_; Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_; Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_; Handle<Integer> resource_column_offset_;
Handle<Boolean> resource_is_shared_cross_origin_; Handle<Boolean> resource_is_shared_cross_origin_;
}; };
/** /**
* A compiled JavaScript script. * A compiled JavaScript script.
*/ */
skipping to change at line 1239 skipping to change at line 1236
/** /**
* The superclass of all JavaScript values and objects. * The superclass of all JavaScript values and objects.
*/ */
class V8_EXPORT Value : public Data { class V8_EXPORT Value : public Data {
public: public:
/** /**
* Returns true if this value is the undefined value. See ECMA-262 * Returns true if this value is the undefined value. See ECMA-262
* 4.3.10. * 4.3.10.
*/ */
V8_INLINE(bool IsUndefined() const); V8_INLINE bool IsUndefined() const;
/** /**
* Returns true if this value is the null value. See ECMA-262 * Returns true if this value is the null value. See ECMA-262
* 4.3.11. * 4.3.11.
*/ */
V8_INLINE(bool IsNull() const); V8_INLINE bool IsNull() const;
/** /**
* Returns true if this value is true. * Returns true if this value is true.
*/ */
bool IsTrue() const; bool IsTrue() const;
/** /**
* Returns true if this value is false. * Returns true if this value is false.
*/ */
bool IsFalse() const; bool IsFalse() const;
/** /**
* Returns true if this value is an instance of the String type. * Returns true if this value is an instance of the String type.
* See ECMA-262 8.4. * See ECMA-262 8.4.
*/ */
V8_INLINE(bool IsString() const); V8_INLINE bool IsString() const;
/** /**
* Returns true if this value is a symbol. * Returns true if this value is a symbol.
* This is an experimental feature. * This is an experimental feature.
*/ */
bool IsSymbol() const; bool IsSymbol() const;
/** /**
* Returns true if this value is a function. * Returns true if this value is a function.
*/ */
skipping to change at line 1448 skipping to change at line 1445
bool BooleanValue() const; bool BooleanValue() const;
double NumberValue() const; double NumberValue() const;
int64_t IntegerValue() const; int64_t IntegerValue() const;
uint32_t Uint32Value() const; uint32_t Uint32Value() const;
int32_t Int32Value() const; int32_t Int32Value() const;
/** JS == */ /** JS == */
bool Equals(Handle<Value> that) const; bool Equals(Handle<Value> that) const;
bool StrictEquals(Handle<Value> that) const; bool StrictEquals(Handle<Value> that) const;
template <class T> V8_INLINE(static Value* Cast(T* value)); template <class T> V8_INLINE static Value* Cast(T* value);
private: private:
V8_INLINE(bool QuickIsUndefined() const); V8_INLINE bool QuickIsUndefined() const;
V8_INLINE(bool QuickIsNull() const); V8_INLINE bool QuickIsNull() const;
V8_INLINE(bool QuickIsString() const); V8_INLINE bool QuickIsString() const;
bool FullIsUndefined() const; bool FullIsUndefined() const;
bool FullIsNull() const; bool FullIsNull() const;
bool FullIsString() const; bool FullIsString() const;
}; };
/** /**
* The superclass of primitive values. See ECMA-262 4.3.2. * The superclass of primitive values. See ECMA-262 4.3.2.
*/ */
class V8_EXPORT Primitive : public Value { }; class V8_EXPORT Primitive : public Value { };
/** /**
* A primitive boolean value (ECMA-262, 4.3.14). Either the true * A primitive boolean value (ECMA-262, 4.3.14). Either the true
* or false value. * or false value.
*/ */
class V8_EXPORT Boolean : public Primitive { class V8_EXPORT Boolean : public Primitive {
public: public:
bool Value() const; bool Value() const;
V8_INLINE(static Handle<Boolean> New(bool value)); V8_INLINE static Handle<Boolean> New(bool value);
}; };
/** /**
* A JavaScript string value (ECMA-262, 4.3.17). * A JavaScript string value (ECMA-262, 4.3.17).
*/ */
class V8_EXPORT String : public Primitive { class V8_EXPORT String : public Primitive {
public: public:
enum Encoding { enum Encoding {
UNKNOWN_ENCODING = 0x1, UNKNOWN_ENCODING = 0x1,
TWO_BYTE_ENCODING = 0x0, TWO_BYTE_ENCODING = 0x0,
skipping to change at line 1499 skipping to change at line 1496
/** /**
* Returns the number of bytes in the UTF-8 encoded * Returns the number of bytes in the UTF-8 encoded
* representation of this string. * representation of this string.
*/ */
int Utf8Length() const; int Utf8Length() const;
/** /**
* This function is no longer useful. * This function is no longer useful.
*/ */
V8_DEPRECATED(V8_INLINE(bool MayContainNonAscii()) const) { return true; } V8_DEPRECATED(V8_INLINE bool MayContainNonAscii() const) { return true; }
/** /**
* Returns whether this string is known to contain only one byte data. * Returns whether this string is known to contain only one byte data.
* Does not read the string. * Does not read the string.
* False negatives are possible. * False negatives are possible.
*/ */
bool IsOneByte() const; bool IsOneByte() const;
/** /**
* Returns whether this string contain only one byte data. * Returns whether this string contain only one byte data.
skipping to change at line 1571 skipping to change at line 1568
// UTF-8 encoded characters. // UTF-8 encoded characters.
int WriteUtf8(char* buffer, int WriteUtf8(char* buffer,
int length = -1, int length = -1,
int* nchars_ref = NULL, int* nchars_ref = NULL,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
/** /**
* A zero length string. * A zero length string.
*/ */
static v8::Local<v8::String> Empty(); static v8::Local<v8::String> Empty();
V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); V8_INLINE static v8::Local<v8::String> Empty(Isolate* isolate);
/** /**
* Returns true if the string is external * Returns true if the string is external
*/ */
bool IsExternal() const; bool IsExternal() const;
/** /**
* Returns true if the string is both external and ASCII * Returns true if the string is both external and ASCII
*/ */
bool IsExternalAscii() const; bool IsExternalAscii() const;
skipping to change at line 1669 skipping to change at line 1666
ExternalAsciiStringResource() {} ExternalAsciiStringResource() {}
}; };
typedef ExternalAsciiStringResource ExternalOneByteStringResource; typedef ExternalAsciiStringResource ExternalOneByteStringResource;
/** /**
* If the string is an external string, return the ExternalStringResource Base * If the string is an external string, return the ExternalStringResource Base
* regardless of the encoding, otherwise return NULL. The encoding of th e * regardless of the encoding, otherwise return NULL. The encoding of th e
* string is returned in encoding_out. * string is returned in encoding_out.
*/ */
V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase(
Encoding* encoding_out) const); Encoding* encoding_out) const;
/** /**
* Get the ExternalStringResource for an external string. Returns * Get the ExternalStringResource for an external string. Returns
* NULL if IsExternal() doesn't return true. * NULL if IsExternal() doesn't return true.
*/ */
V8_INLINE(ExternalStringResource* GetExternalStringResource() const); V8_INLINE ExternalStringResource* GetExternalStringResource() const;
/** /**
* Get the ExternalAsciiStringResource for an external ASCII string. * Get the ExternalAsciiStringResource for an external ASCII string.
* Returns NULL if IsExternalAscii() doesn't return true. * Returns NULL if IsExternalAscii() doesn't return true.
*/ */
const ExternalAsciiStringResource* GetExternalAsciiStringResource() const ; const ExternalAsciiStringResource* GetExternalAsciiStringResource() const ;
V8_INLINE(static String* Cast(v8::Value* obj)); V8_INLINE static String* Cast(v8::Value* obj);
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
/** /**
* Allocates a new string from either UTF-8 encoded or ASCII data. * Allocates a new string from either UTF-8 encoded or ASCII data.
* The second parameter 'length' gives the buffer length. If omitted, * The second parameter 'length' gives the buffer length. If omitted,
* the function calls 'strlen' to determine the buffer length. * the function calls 'strlen' to determine the buffer length.
*/ */
V8_INLINE(static Local<String> New(const char* data, int length = -1)); V8_INLINE static Local<String> New(const char* data, int length = -1);
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
/** Allocates a new string from 16-bit character codes.*/ /** Allocates a new string from 16-bit character codes.*/
V8_INLINE(static Local<String> New(const uint16_t* data, int length = -1) ); V8_INLINE static Local<String> New(const uint16_t* data, int length = -1) ;
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
/** /**
* Creates an internalized string (historically called a "symbol", * Creates an internalized string (historically called a "symbol",
* not to be confused with ES6 symbols). Returns one if it exists already . * not to be confused with ES6 symbols). Returns one if it exists already .
*/ */
V8_INLINE(static Local<String> NewSymbol(const char* data, int length = - 1)); V8_INLINE static Local<String> NewSymbol(const char* data, int length = - 1);
enum NewStringType { enum NewStringType {
kNormalString, kInternalizedString, kUndetectableString kNormalString, kInternalizedString, kUndetectableString
}; };
/** Allocates a new string from UTF-8 data.*/ /** Allocates a new string from UTF-8 data.*/
static Local<String> NewFromUtf8(Isolate* isolate, static Local<String> NewFromUtf8(Isolate* isolate,
const char* data, const char* data,
NewStringType type = kNormalString, NewStringType type = kNormalString,
int length = -1); int length = -1);
skipping to change at line 1784 skipping to change at line 1781
*/ */
bool MakeExternal(ExternalAsciiStringResource* resource); bool MakeExternal(ExternalAsciiStringResource* resource);
/** /**
* Returns true if this string can be made external. * Returns true if this string can be made external.
*/ */
bool CanMakeExternal(); bool CanMakeExternal();
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
/** Creates an undetectable string from the supplied ASCII or UTF-8 data. */ /** Creates an undetectable string from the supplied ASCII or UTF-8 data. */
V8_INLINE( V8_INLINE static Local<String> NewUndetectable(const char* data,
static Local<String> NewUndetectable(const char* data, int length = - int length = -1);
1));
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
/** Creates an undetectable string from the supplied 16-bit character cod es.*/ /** Creates an undetectable string from the supplied 16-bit character cod es.*/
V8_INLINE(static Local<String> NewUndetectable( V8_INLINE static Local<String> NewUndetectable(const uint16_t* data,
const uint16_t* data, int length = -1)); int length = -1);
/** /**
* Converts an object to a UTF-8-encoded character array. Useful if * Converts an object to a UTF-8-encoded character array. Useful if
* you want to print the object. If conversion to a string fails * you want to print the object. If conversion to a string fails
* (e.g. due to an exception in the toString() method of the object) * (e.g. due to an exception in the toString() method of the object)
* then the length() method returns 0 and the * operator returns * then the length() method returns 0 and the * operator returns
* NULL. * NULL.
*/ */
class V8_EXPORT Utf8Value { class V8_EXPORT Utf8Value {
public: public:
skipping to change at line 1884 skipping to change at line 1881
public: public:
// Returns the print name string of the symbol, or undefined if none. // Returns the print name string of the symbol, or undefined if none.
Local<Value> Name() const; Local<Value> Name() const;
// Create a symbol without a print name. // Create a symbol without a print name.
static Local<Symbol> New(Isolate* isolate); static Local<Symbol> New(Isolate* isolate);
// Create a symbol with a print name. // Create a symbol with a print name.
static Local<Symbol> New(Isolate *isolate, const char* data, int length = -1); static Local<Symbol> New(Isolate *isolate, const char* data, int length = -1);
V8_INLINE(static Symbol* Cast(v8::Value* obj)); V8_INLINE static Symbol* Cast(v8::Value* obj);
private: private:
Symbol(); Symbol();
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript number value (ECMA-262, 4.3.20) * A JavaScript number value (ECMA-262, 4.3.20)
*/ */
class V8_EXPORT Number : public Primitive { class V8_EXPORT Number : public Primitive {
public: public:
double Value() const; double Value() const;
static Local<Number> New(double value); static Local<Number> New(double value);
static Local<Number> New(Isolate* isolate, double value); static Local<Number> New(Isolate* isolate, double value);
V8_INLINE(static Number* Cast(v8::Value* obj)); V8_INLINE static Number* Cast(v8::Value* obj);
private: private:
Number(); Number();
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value representing a signed integer. * A JavaScript value representing a signed integer.
*/ */
class V8_EXPORT Integer : public Number { class V8_EXPORT Integer : public Number {
public: public:
static Local<Integer> New(int32_t value); static Local<Integer> New(int32_t value);
static Local<Integer> NewFromUnsigned(uint32_t value); static Local<Integer> NewFromUnsigned(uint32_t value);
static Local<Integer> New(int32_t value, Isolate*); static Local<Integer> New(int32_t value, Isolate*);
static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
int64_t Value() const; int64_t Value() const;
V8_INLINE(static Integer* Cast(v8::Value* obj)); V8_INLINE static Integer* Cast(v8::Value* obj);
private: private:
Integer(); Integer();
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value representing a 32-bit signed integer. * A JavaScript value representing a 32-bit signed integer.
*/ */
class V8_EXPORT Int32 : public Integer { class V8_EXPORT Int32 : public Integer {
public: public:
skipping to change at line 2109 skipping to change at line 2106
/** /**
* Returns the name of the function invoked as a constructor for this obj ect. * Returns the name of the function invoked as a constructor for this obj ect.
*/ */
Local<String> GetConstructorName(); Local<String> GetConstructorName();
/** Gets the number of internal fields for this Object. */ /** Gets the number of internal fields for this Object. */
int InternalFieldCount(); int InternalFieldCount();
/** Gets the value from an internal field. */ /** Gets the value from an internal field. */
V8_INLINE(Local<Value> GetInternalField(int index)); V8_INLINE Local<Value> GetInternalField(int index);
/** Sets the value in an internal field. */ /** Sets the value in an internal field. */
void SetInternalField(int index, Handle<Value> value); void SetInternalField(int index, Handle<Value> value);
/** /**
* Gets a 2-byte-aligned native pointer from an internal field. This fiel d * Gets a 2-byte-aligned native pointer from an internal field. This fiel d
* must have been set by SetAlignedPointerInInternalField, everything els e * must have been set by SetAlignedPointerInInternalField, everything els e
* leads to undefined behavior. * leads to undefined behavior.
*/ */
V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); V8_INLINE void* GetAlignedPointerFromInternalField(int index);
/** /**
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve such * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
* a field, GetAlignedPointerFromInternalField must be used, everything e lse * a field, GetAlignedPointerFromInternalField must be used, everything e lse
* leads to undefined behavior. * leads to undefined behavior.
*/ */
void SetAlignedPointerInInternalField(int index, void* value); void SetAlignedPointerInInternalField(int index, void* value);
// Testers for local properties. // Testers for local properties.
bool HasOwnProperty(Handle<String> key); bool HasOwnProperty(Handle<String> key);
skipping to change at line 2249 skipping to change at line 2246
Handle<Value> argv[]); Handle<Value> argv[]);
/** /**
* Call an Object as a constructor if a callback is set by the * Call an Object as a constructor if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method. * ObjectTemplate::SetCallAsFunctionHandler method.
* Note: This method behaves like the Function::NewInstance method. * Note: This method behaves like the Function::NewInstance method.
*/ */
Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]); Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
static Local<Object> New(); static Local<Object> New();
V8_INLINE(static Object* Cast(Value* obj)); V8_INLINE static Object* Cast(Value* obj);
private: private:
Object(); Object();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
Local<Value> SlowGetInternalField(int index); Local<Value> SlowGetInternalField(int index);
void* SlowGetAlignedPointerFromInternalField(int index); void* SlowGetAlignedPointerFromInternalField(int index);
}; };
/** /**
* An instance of the built-in array constructor (ECMA-262, 15.4.2). * An instance of the built-in array constructor (ECMA-262, 15.4.2).
skipping to change at line 2277 skipping to change at line 2274
* handle if cloning fails (for any reason). * handle if cloning fails (for any reason).
*/ */
Local<Object> CloneElementAt(uint32_t index); Local<Object> CloneElementAt(uint32_t index);
/** /**
* Creates a JavaScript array with the given length. If the length * Creates a JavaScript array with the given length. If the length
* is negative the returned array will have length 0. * is negative the returned array will have length 0.
*/ */
static Local<Array> New(int length = 0); static Local<Array> New(int length = 0);
V8_INLINE(static Array* Cast(Value* obj)); V8_INLINE static Array* Cast(Value* obj);
private: private:
Array(); Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
template<typename T> template<typename T>
class ReturnValue { class ReturnValue {
public: public:
template <class S> V8_INLINE(ReturnValue(const ReturnValue<S>& that)) template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that)
: value_(that.value_) { : value_(that.value_) {
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
// Handle setters // Handle setters
template <typename S> V8_INLINE(void Set(const Persistent<S>& handle)); template <typename S> V8_INLINE void Set(const Persistent<S>& handle);
template <typename S> V8_INLINE(void Set(const Handle<S> handle)); template <typename S> V8_INLINE void Set(const Handle<S> handle);
// Fast primitive setters // Fast primitive setters
V8_INLINE(void Set(bool value)); V8_INLINE void Set(bool value);
V8_INLINE(void Set(double i)); V8_INLINE void Set(double i);
V8_INLINE(void Set(int32_t i)); V8_INLINE void Set(int32_t i);
V8_INLINE(void Set(uint32_t i)); V8_INLINE void Set(uint32_t i);
// Fast JS primitive setters // Fast JS primitive setters
V8_INLINE(void SetNull()); V8_INLINE void SetNull();
V8_INLINE(void SetUndefined()); V8_INLINE void SetUndefined();
V8_INLINE(void SetEmptyString()); V8_INLINE void SetEmptyString();
// Convenience getter for Isolate // Convenience getter for Isolate
V8_INLINE(Isolate* GetIsolate()); V8_INLINE Isolate* GetIsolate();
private: private:
template<class F> friend class ReturnValue; template<class F> friend class ReturnValue;
template<class F> friend class FunctionCallbackInfo; template<class F> friend class FunctionCallbackInfo;
template<class F> friend class PropertyCallbackInfo; template<class F> friend class PropertyCallbackInfo;
V8_INLINE(internal::Object* GetDefaultValue()); V8_INLINE internal::Object* GetDefaultValue();
V8_INLINE(explicit ReturnValue(internal::Object** slot)); V8_INLINE explicit ReturnValue(internal::Object** slot);
internal::Object** value_; internal::Object** value_;
}; };
/** /**
* The argument information given to function call callbacks. This * The argument information given to function call callbacks. This
* class provides access to information about the context of the call, * class provides access to information about the context of the call,
* including the receiver, the number and values of arguments, and * including the receiver, the number and values of arguments, and
* the holder of the function. * the holder of the function.
*/ */
template<typename T> template<typename T>
class FunctionCallbackInfo { class FunctionCallbackInfo {
public: public:
V8_INLINE(int Length() const); V8_INLINE int Length() const;
V8_INLINE(Local<Value> operator[](int i) const); V8_INLINE Local<Value> operator[](int i) const;
V8_INLINE(Local<Function> Callee() const); V8_INLINE Local<Function> Callee() const;
V8_INLINE(Local<Object> This() const); V8_INLINE Local<Object> This() const;
V8_INLINE(Local<Object> Holder() const); V8_INLINE Local<Object> Holder() const;
V8_INLINE(bool IsConstructCall() const); V8_INLINE bool IsConstructCall() const;
V8_INLINE(Local<Value> Data() const); V8_INLINE Local<Value> Data() const;
V8_INLINE(Isolate* GetIsolate() const); V8_INLINE Isolate* GetIsolate() const;
V8_INLINE(ReturnValue<T> GetReturnValue() const); V8_INLINE ReturnValue<T> GetReturnValue() const;
// This shouldn't be public, but the arm compiler needs it. // This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 6; static const int kArgsLength = 6;
protected: protected:
friend class internal::FunctionCallbackArguments; friend class internal::FunctionCallbackArguments;
friend class internal::CustomArguments<FunctionCallbackInfo>; friend class internal::CustomArguments<FunctionCallbackInfo>;
static const int kReturnValueIndex = 0; static const int kReturnValueIndex = 0;
static const int kReturnValueDefaultValueIndex = -1; static const int kReturnValueDefaultValueIndex = -1;
static const int kIsolateIndex = -2; static const int kIsolateIndex = -2;
static const int kDataIndex = -3; static const int kDataIndex = -3;
static const int kCalleeIndex = -4; static const int kCalleeIndex = -4;
static const int kHolderIndex = -5; static const int kHolderIndex = -5;
V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args,
internal::Object** values, internal::Object** values,
int length, int length,
bool is_construct_call)); bool is_construct_call);
internal::Object** implicit_args_; internal::Object** implicit_args_;
internal::Object** values_; internal::Object** values_;
int length_; int length_;
bool is_construct_call_; bool is_construct_call_;
}; };
/** /**
* The information passed to a property callback about the context * The information passed to a property callback about the context
* of the property access. * of the property access.
*/ */
template<typename T> template<typename T>
class PropertyCallbackInfo { class PropertyCallbackInfo {
public: public:
V8_INLINE(Isolate* GetIsolate() const); V8_INLINE Isolate* GetIsolate() const;
V8_INLINE(Local<Value> Data() const); V8_INLINE Local<Value> Data() const;
V8_INLINE(Local<Object> This() const); V8_INLINE Local<Object> This() const;
V8_INLINE(Local<Object> Holder() const); V8_INLINE Local<Object> Holder() const;
V8_INLINE(ReturnValue<T> GetReturnValue() const); V8_INLINE ReturnValue<T> GetReturnValue() const;
// This shouldn't be public, but the arm compiler needs it. // This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 6; static const int kArgsLength = 6;
protected: protected:
friend class MacroAssembler; friend class MacroAssembler;
friend class internal::PropertyCallbackArguments; friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>; friend class internal::CustomArguments<PropertyCallbackInfo>;
static const int kThisIndex = 0; static const int kThisIndex = 0;
static const int kHolderIndex = -1; static const int kDataIndex = -1;
static const int kDataIndex = -2; static const int kReturnValueIndex = -2;
static const int kReturnValueIndex = -3; static const int kReturnValueDefaultValueIndex = -3;
static const int kReturnValueDefaultValueIndex = -4; static const int kIsolateIndex = -4;
static const int kIsolateIndex = -5; static const int kHolderIndex = -5;
V8_INLINE(PropertyCallbackInfo(internal::Object** args)) V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {}
: args_(args) { }
internal::Object** args_; internal::Object** args_;
}; };
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
/** /**
* A JavaScript function object (ECMA-262, 15.3). * A JavaScript function object (ECMA-262, 15.3).
*/ */
class V8_EXPORT Function : public Object { class V8_EXPORT Function : public Object {
public: public:
skipping to change at line 2439 skipping to change at line 2435
* DEPRECATED: use ScriptId() instead. * DEPRECATED: use ScriptId() instead.
*/ */
Handle<Value> GetScriptId() const; Handle<Value> GetScriptId() const;
/** /**
* Returns scriptId. * Returns scriptId.
*/ */
int ScriptId() const; int ScriptId() const;
ScriptOrigin GetScriptOrigin() const; ScriptOrigin GetScriptOrigin() const;
V8_INLINE(static Function* Cast(Value* obj)); V8_INLINE static Function* Cast(Value* obj);
static const int kLineOffsetNotFound; static const int kLineOffsetNotFound;
private: private:
Function(); Function();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT #ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder. // The number of required internal fields can be defined by embedder.
#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 #define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2
skipping to change at line 2557 skipping to change at line 2553
* Make this ArrayBuffer external. The pointer to underlying memory block * Make this ArrayBuffer external. The pointer to underlying memory block
* and byte length are returned as |Contents| structure. After ArrayBuffe r * and byte length are returned as |Contents| structure. After ArrayBuffe r
* had been etxrenalized, it does no longer owns the memory block. The ca ller * had been etxrenalized, it does no longer owns the memory block. The ca ller
* should take steps to free memory when it is no longer needed. * should take steps to free memory when it is no longer needed.
* *
* The memory block is guaranteed to be allocated with |Allocator::Alloca te| * The memory block is guaranteed to be allocated with |Allocator::Alloca te|
* that has been set with V8::SetArrayBufferAllocator. * that has been set with V8::SetArrayBufferAllocator.
*/ */
Contents Externalize(); Contents Externalize();
V8_INLINE(static ArrayBuffer* Cast(Value* obj)); V8_INLINE static ArrayBuffer* Cast(Value* obj);
static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COU NT; static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COU NT;
private: private:
ArrayBuffer(); ArrayBuffer();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT #ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT
// The number of required internal fields can be defined by embedder. // The number of required internal fields can be defined by embedder.
skipping to change at line 2596 skipping to change at line 2592
size_t ByteOffset(); size_t ByteOffset();
/** /**
* Size of a view in bytes. * Size of a view in bytes.
*/ */
size_t ByteLength(); size_t ByteLength();
/** /**
* Base address of a view. * Base address of a view.
*/ */
void* BaseAddress(); void* BaseAddress();
V8_INLINE(static ArrayBufferView* Cast(Value* obj)); V8_INLINE static ArrayBufferView* Cast(Value* obj);
static const int kInternalFieldCount = static const int kInternalFieldCount =
V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT;
private: private:
ArrayBufferView(); ArrayBufferView();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
skipping to change at line 2619 skipping to change at line 2615
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT TypedArray : public ArrayBufferView { class V8_EXPORT TypedArray : public ArrayBufferView {
public: public:
/** /**
* Number of elements in this typed array * Number of elements in this typed array
* (e.g. for Int16Array, |ByteLength|/2). * (e.g. for Int16Array, |ByteLength|/2).
*/ */
size_t Length(); size_t Length();
V8_INLINE(static TypedArray* Cast(Value* obj)); V8_INLINE static TypedArray* Cast(Value* obj);
private: private:
TypedArray(); TypedArray();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Uint8Array constructor (ES6 draft 15.13.6). * An instance of Uint8Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Uint8Array : public TypedArray { class V8_EXPORT Uint8Array : public TypedArray {
public: public:
static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer, static Local<Uint8Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Uint8Array* Cast(Value* obj)); V8_INLINE static Uint8Array* Cast(Value* obj);
private: private:
Uint8Array(); Uint8Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Uint8ClampedArray : public TypedArray { class V8_EXPORT Uint8ClampedArray : public TypedArray {
public: public:
static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer, static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Uint8ClampedArray* Cast(Value* obj)); V8_INLINE static Uint8ClampedArray* Cast(Value* obj);
private: private:
Uint8ClampedArray(); Uint8ClampedArray();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Int8Array constructor (ES6 draft 15.13.6). * An instance of Int8Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Int8Array : public TypedArray { class V8_EXPORT Int8Array : public TypedArray {
public: public:
static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer, static Local<Int8Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Int8Array* Cast(Value* obj)); V8_INLINE static Int8Array* Cast(Value* obj);
private: private:
Int8Array(); Int8Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Uint16Array constructor (ES6 draft 15.13.6). * An instance of Uint16Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Uint16Array : public TypedArray { class V8_EXPORT Uint16Array : public TypedArray {
public: public:
static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer, static Local<Uint16Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Uint16Array* Cast(Value* obj)); V8_INLINE static Uint16Array* Cast(Value* obj);
private: private:
Uint16Array(); Uint16Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Int16Array constructor (ES6 draft 15.13.6). * An instance of Int16Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Int16Array : public TypedArray { class V8_EXPORT Int16Array : public TypedArray {
public: public:
static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer, static Local<Int16Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Int16Array* Cast(Value* obj)); V8_INLINE static Int16Array* Cast(Value* obj);
private: private:
Int16Array(); Int16Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Uint32Array constructor (ES6 draft 15.13.6). * An instance of Uint32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Uint32Array : public TypedArray { class V8_EXPORT Uint32Array : public TypedArray {
public: public:
static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer, static Local<Uint32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Uint32Array* Cast(Value* obj)); V8_INLINE static Uint32Array* Cast(Value* obj);
private: private:
Uint32Array(); Uint32Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Int32Array constructor (ES6 draft 15.13.6). * An instance of Int32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Int32Array : public TypedArray { class V8_EXPORT Int32Array : public TypedArray {
public: public:
static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer, static Local<Int32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Int32Array* Cast(Value* obj)); V8_INLINE static Int32Array* Cast(Value* obj);
private: private:
Int32Array(); Int32Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Float32Array constructor (ES6 draft 15.13.6). * An instance of Float32Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Float32Array : public TypedArray { class V8_EXPORT Float32Array : public TypedArray {
public: public:
static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer, static Local<Float32Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Float32Array* Cast(Value* obj)); V8_INLINE static Float32Array* Cast(Value* obj);
private: private:
Float32Array(); Float32Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of Float64Array constructor (ES6 draft 15.13.6). * An instance of Float64Array constructor (ES6 draft 15.13.6).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT Float64Array : public TypedArray { class V8_EXPORT Float64Array : public TypedArray {
public: public:
static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer, static Local<Float64Array> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static Float64Array* Cast(Value* obj)); V8_INLINE static Float64Array* Cast(Value* obj);
private: private:
Float64Array(); Float64Array();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of DataView constructor (ES6 draft 15.13.7). * An instance of DataView constructor (ES6 draft 15.13.7).
* This API is experimental and may change significantly. * This API is experimental and may change significantly.
*/ */
class V8_EXPORT DataView : public ArrayBufferView { class V8_EXPORT DataView : public ArrayBufferView {
public: public:
static Local<DataView> New(Handle<ArrayBuffer> array_buffer, static Local<DataView> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length); size_t byte_offset, size_t length);
V8_INLINE(static DataView* Cast(Value* obj)); V8_INLINE static DataView* Cast(Value* obj);
private: private:
DataView(); DataView();
static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of the built-in Date constructor (ECMA-262, 15.9). * An instance of the built-in Date constructor (ECMA-262, 15.9).
*/ */
class V8_EXPORT Date : public Object { class V8_EXPORT Date : public Object {
skipping to change at line 2793 skipping to change at line 2789
// Deprecated, use Date::ValueOf() instead. // Deprecated, use Date::ValueOf() instead.
// TODO(svenpanne) Actually deprecate when Chrome is adapted. // TODO(svenpanne) Actually deprecate when Chrome is adapted.
double NumberValue() const { return ValueOf(); } double NumberValue() const { return ValueOf(); }
/** /**
* A specialization of Value::NumberValue that is more efficient * A specialization of Value::NumberValue that is more efficient
* because we know the structure of this object. * because we know the structure of this object.
*/ */
double ValueOf() const; double ValueOf() const;
V8_INLINE(static Date* Cast(v8::Value* obj)); V8_INLINE static Date* Cast(v8::Value* obj);
/** /**
* Notification that the embedder has changed the time zone, * Notification that the embedder has changed the time zone,
* daylight savings time, or other date / time configuration * daylight savings time, or other date / time configuration
* parameters. V8 keeps a cache of various values used for * parameters. V8 keeps a cache of various values used for
* date / time computation. This notification will reset * date / time computation. This notification will reset
* those cached values for the current context so that date / * those cached values for the current context so that date /
* time configuration changes would be reflected in the Date * time configuration changes would be reflected in the Date
* object. * object.
* *
skipping to change at line 2829 skipping to change at line 2825
// Deprecated, use NumberObject::ValueOf() instead. // Deprecated, use NumberObject::ValueOf() instead.
// TODO(svenpanne) Actually deprecate when Chrome is adapted. // TODO(svenpanne) Actually deprecate when Chrome is adapted.
double NumberValue() const { return ValueOf(); } double NumberValue() const { return ValueOf(); }
/** /**
* Returns the Number held by the object. * Returns the Number held by the object.
*/ */
double ValueOf() const; double ValueOf() const;
V8_INLINE(static NumberObject* Cast(v8::Value* obj)); V8_INLINE static NumberObject* Cast(v8::Value* obj);
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A Boolean object (ECMA-262, 4.3.15). * A Boolean object (ECMA-262, 4.3.15).
*/ */
class V8_EXPORT BooleanObject : public Object { class V8_EXPORT BooleanObject : public Object {
public: public:
skipping to change at line 2851 skipping to change at line 2847
// Deprecated, use BooleanObject::ValueOf() instead. // Deprecated, use BooleanObject::ValueOf() instead.
// TODO(svenpanne) Actually deprecate when Chrome is adapted. // TODO(svenpanne) Actually deprecate when Chrome is adapted.
bool BooleanValue() const { return ValueOf(); } bool BooleanValue() const { return ValueOf(); }
/** /**
* Returns the Boolean held by the object. * Returns the Boolean held by the object.
*/ */
bool ValueOf() const; bool ValueOf() const;
V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); V8_INLINE static BooleanObject* Cast(v8::Value* obj);
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A String object (ECMA-262, 4.3.18). * A String object (ECMA-262, 4.3.18).
*/ */
class V8_EXPORT StringObject : public Object { class V8_EXPORT StringObject : public Object {
public: public:
skipping to change at line 2873 skipping to change at line 2869
// Deprecated, use StringObject::ValueOf() instead. // Deprecated, use StringObject::ValueOf() instead.
// TODO(svenpanne) Actually deprecate when Chrome is adapted. // TODO(svenpanne) Actually deprecate when Chrome is adapted.
Local<String> StringValue() const { return ValueOf(); } Local<String> StringValue() const { return ValueOf(); }
/** /**
* Returns the String held by the object. * Returns the String held by the object.
*/ */
Local<String> ValueOf() const; Local<String> ValueOf() const;
V8_INLINE(static StringObject* Cast(v8::Value* obj)); V8_INLINE static StringObject* Cast(v8::Value* obj);
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A Symbol object (ECMA-262 edition 6). * A Symbol object (ECMA-262 edition 6).
* *
* This is an experimental feature. Use at your own risk. * This is an experimental feature. Use at your own risk.
*/ */
skipping to change at line 2897 skipping to change at line 2893
// Deprecated, use SymbolObject::ValueOf() instead. // Deprecated, use SymbolObject::ValueOf() instead.
// TODO(svenpanne) Actually deprecate when Chrome is adapted. // TODO(svenpanne) Actually deprecate when Chrome is adapted.
Local<Symbol> SymbolValue() const { return ValueOf(); } Local<Symbol> SymbolValue() const { return ValueOf(); }
/** /**
* Returns the Symbol held by the object. * Returns the Symbol held by the object.
*/ */
Local<Symbol> ValueOf() const; Local<Symbol> ValueOf() const;
V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); V8_INLINE static SymbolObject* Cast(v8::Value* obj);
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* An instance of the built-in RegExp constructor (ECMA-262, 15.10). * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
*/ */
class V8_EXPORT RegExp : public Object { class V8_EXPORT RegExp : public Object {
public: public:
skipping to change at line 2942 skipping to change at line 2938
* Returns the value of the source property: a string representing * Returns the value of the source property: a string representing
* the regular expression. * the regular expression.
*/ */
Local<String> GetSource() const; Local<String> GetSource() const;
/** /**
* Returns the flags bit field. * Returns the flags bit field.
*/ */
Flags GetFlags() const; Flags GetFlags() const;
V8_INLINE(static RegExp* Cast(v8::Value* obj)); V8_INLINE static RegExp* Cast(v8::Value* obj);
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value that wraps a C++ void*. This type of value is mainly used * A JavaScript value that wraps a C++ void*. This type of value is mainly used
* to associate C++ data structures with JavaScript objects. * to associate C++ data structures with JavaScript objects.
*/ */
class V8_EXPORT External : public Value { class V8_EXPORT External : public Value {
public: public:
static Local<External> New(void* value); static Local<External> New(void* value);
V8_INLINE(static External* Cast(Value* obj)); V8_INLINE static External* Cast(Value* obj);
void* Value() const; void* Value() const;
private: private:
static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
// --- Templates --- // --- Templates ---
/** /**
* The superclass of object and function templates. * The superclass of object and function templates.
*/ */
class V8_EXPORT Template : public Data { class V8_EXPORT Template : public Data {
public: public:
/** Adds a property to each instance created by this template.*/ /** Adds a property to each instance created by this template.*/
void Set(Handle<String> name, Handle<Data> value, void Set(Handle<String> name, Handle<Data> value,
PropertyAttribute attributes = None); PropertyAttribute attributes = None);
V8_INLINE(void Set(const char* name, Handle<Data> value)); V8_INLINE void Set(const char* name, Handle<Data> value);
void SetAccessorProperty( void SetAccessorProperty(
Local<String> name, Local<String> name,
Local<FunctionTemplate> getter = Local<FunctionTemplate>(), Local<FunctionTemplate> getter = Local<FunctionTemplate>(),
Local<FunctionTemplate> setter = Local<FunctionTemplate>(), Local<FunctionTemplate> setter = Local<FunctionTemplate>(),
PropertyAttribute attribute = None, PropertyAttribute attribute = None,
AccessControl settings = DEFAULT); AccessControl settings = DEFAULT);
/** /**
* Whenever the property with the given name is accessed on objects * Whenever the property with the given name is accessed on objects
skipping to change at line 3623 skipping to change at line 3619
void operator=(const Extension&); void operator=(const Extension&);
}; };
void V8_EXPORT RegisterExtension(Extension* extension); void V8_EXPORT RegisterExtension(Extension* extension);
/** /**
* Ignore * Ignore
*/ */
class V8_EXPORT DeclareExtension { class V8_EXPORT DeclareExtension {
public: public:
V8_INLINE(DeclareExtension(Extension* extension)) { V8_INLINE DeclareExtension(Extension* extension) {
RegisterExtension(extension); RegisterExtension(extension);
} }
}; };
// --- Statics --- // --- Statics ---
Handle<Primitive> V8_EXPORT Undefined(); Handle<Primitive> V8_EXPORT Undefined();
Handle<Primitive> V8_EXPORT Null(); Handle<Primitive> V8_EXPORT Null();
Handle<Boolean> V8_EXPORT True(); Handle<Boolean> V8_EXPORT True();
Handle<Boolean> V8_EXPORT False(); Handle<Boolean> V8_EXPORT False();
V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate)); V8_INLINE Handle<Primitive> Undefined(Isolate* isolate);
V8_INLINE(Handle<Primitive> Null(Isolate* isolate)); V8_INLINE Handle<Primitive> Null(Isolate* isolate);
V8_INLINE(Handle<Boolean> True(Isolate* isolate)); V8_INLINE Handle<Boolean> True(Isolate* isolate);
V8_INLINE(Handle<Boolean> False(Isolate* isolate)); V8_INLINE Handle<Boolean> False(Isolate* isolate);
/** /**
* A set of constraints that specifies the limits of the runtime's memory u se. * A set of constraints that specifies the limits of the runtime's memory u se.
* You must set the heap size before initializing the VM - the size cannot be * You must set the heap size before initializing the VM - the size cannot be
* adjusted after the VM is initialized. * adjusted after the VM is initialized.
* *
* If you are using threads then you should hold the V8::Locker lock while * If you are using threads then you should hold the V8::Locker lock while
* setting the stack limit and you must set a non-default stack limit separ ately * setting the stack limit and you must set a non-default stack limit separ ately
* for each thread. * for each thread.
*/ */
skipping to change at line 3887 skipping to change at line 3883
/** /**
* Disposes the isolate. The isolate must not be entered by any * Disposes the isolate. The isolate must not be entered by any
* thread to be disposable. * thread to be disposable.
*/ */
void Dispose(); void Dispose();
/** /**
* Associate embedder-specific data with the isolate * Associate embedder-specific data with the isolate
*/ */
V8_INLINE(void SetData(void* data)); V8_INLINE void SetData(void* data);
/** /**
* Retrieve embedder-specific data from the isolate. * Retrieve embedder-specific data from the isolate.
* Returns NULL if SetData has never been called. * Returns NULL if SetData has never been called.
*/ */
V8_INLINE(void* GetData()); V8_INLINE void* GetData();
/** /**
* Get statistics about the heap memory usage. * Get statistics about the heap memory usage.
*/ */
void GetHeapStatistics(HeapStatistics* heap_statistics); void GetHeapStatistics(HeapStatistics* heap_statistics);
/** /**
* Adjusts the amount of registered external memory. Used to give V8 an * Adjusts the amount of registered external memory. Used to give V8 an
* indication of the amount of externally allocated memory that is kept a live * indication of the amount of externally allocated memory that is kept a live
* by JavaScript objects. V8 uses this to decide when to perform global * by JavaScript objects. V8 uses this to decide when to perform global
skipping to change at line 4155 skipping to change at line 4151
}; };
/** /**
* Asserts that no action is performed that could cause a handle's value * Asserts that no action is performed that could cause a handle's value
* to be modified. Useful when otherwise unsafe handle operations need to * to be modified. Useful when otherwise unsafe handle operations need to
* be performed. * be performed.
*/ */
class V8_EXPORT AssertNoGCScope { class V8_EXPORT AssertNoGCScope {
#ifndef DEBUG #ifndef DEBUG
// TODO(yangguo): remove isolate argument. // TODO(yangguo): remove isolate argument.
V8_INLINE(AssertNoGCScope(Isolate* isolate)) { } V8_INLINE AssertNoGCScope(Isolate* isolate) {}
#else #else
AssertNoGCScope(Isolate* isolate); AssertNoGCScope(Isolate* isolate);
~AssertNoGCScope(); ~AssertNoGCScope();
private: private:
void* disallow_heap_allocation_; void* disallow_heap_allocation_;
#endif #endif
}; };
/** /**
* Container class for static utility functions. * Container class for static utility functions.
skipping to change at line 4853 skipping to change at line 4849
static bool InContext(); static bool InContext();
/** Returns an isolate associated with a current context. */ /** Returns an isolate associated with a current context. */
v8::Isolate* GetIsolate(); v8::Isolate* GetIsolate();
/** /**
* Gets the embedder data with the given index, which must have been set by a * Gets the embedder data with the given index, which must have been set by a
* previous call to SetEmbedderData with the same index. Note that index 0 * previous call to SetEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger. * currently has a special meaning for Chrome's debugger.
*/ */
V8_INLINE(Local<Value> GetEmbedderData(int index)); V8_INLINE Local<Value> GetEmbedderData(int index);
/** /**
* Sets the embedder data with the given index, growing the data as * Sets the embedder data with the given index, growing the data as
* needed. Note that index 0 currently has a special meaning for Chrome's * needed. Note that index 0 currently has a special meaning for Chrome's
* debugger. * debugger.
*/ */
void SetEmbedderData(int index, Handle<Value> value); void SetEmbedderData(int index, Handle<Value> value);
/** /**
* Gets a 2-byte-aligned native pointer from the embedder data with the g iven * Gets a 2-byte-aligned native pointer from the embedder data with the g iven
* index, which must have bees set by a previous call to * index, which must have bees set by a previous call to
* SetAlignedPointerInEmbedderData with the same index. Note that index 0 * SetAlignedPointerInEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger. * currently has a special meaning for Chrome's debugger.
*/ */
V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); V8_INLINE void* GetAlignedPointerFromEmbedderData(int index);
/** /**
* Sets a 2-byte-aligned native pointer in the embedder data with the giv en * Sets a 2-byte-aligned native pointer in the embedder data with the giv en
* index, growing the data as needed. Note that index 0 currently has a * index, growing the data as needed. Note that index 0 currently has a
* special meaning for Chrome's debugger. * special meaning for Chrome's debugger.
*/ */
void SetAlignedPointerInEmbedderData(int index, void* value); void SetAlignedPointerInEmbedderData(int index, void* value);
/** /**
* Control whether code generation from strings is allowed. Calling * Control whether code generation from strings is allowed. Calling
skipping to change at line 4911 skipping to change at line 4907
* constructor are called. * constructor are called.
*/ */
void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message);
/** /**
* Stack-allocated class which sets the execution context for all * Stack-allocated class which sets the execution context for all
* operations executed within a local scope. * operations executed within a local scope.
*/ */
class Scope { class Scope {
public: public:
explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) { explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
context_->Enter(); context_->Enter();
} }
// TODO(dcarney): deprecate // TODO(dcarney): deprecate
V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOL INT V8_INLINE Scope(Isolate* isolate, Persistent<Context>& context) // NOLI NT
: context_(Handle<Context>::New(isolate, context)) { : context_(Handle<Context>::New(isolate, context)) {
context_->Enter(); context_->Enter();
} }
V8_INLINE(~Scope()) { context_->Exit(); } V8_INLINE ~Scope() { context_->Exit(); }
private: private:
Handle<Context> context_; Handle<Context> context_;
}; };
private: private:
friend class Value; friend class Value;
friend class Script; friend class Script;
friend class Object; friend class Object;
friend class Function; friend class Function;
skipping to change at line 5016 skipping to change at line 5012
* // V8 still locked (1 level). * // V8 still locked (1 level).
* } * }
* // V8 Now no longer locked. * // V8 Now no longer locked.
* \endcode * \endcode
*/ */
class V8_EXPORT Unlocker { class V8_EXPORT Unlocker {
public: public:
/** /**
* Initialize Unlocker for a given Isolate. * Initialize Unlocker for a given Isolate.
*/ */
V8_INLINE(explicit Unlocker(Isolate* isolate)) { Initialize(isolate); } V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); }
/** Deprecated. Use Isolate version instead. */ /** Deprecated. Use Isolate version instead. */
V8_DEPRECATED(Unlocker()); V8_DEPRECATED(Unlocker());
~Unlocker(); ~Unlocker();
private: private:
void Initialize(Isolate* isolate); void Initialize(Isolate* isolate);
internal::Isolate* isolate_; internal::Isolate* isolate_;
}; };
class V8_EXPORT Locker { class V8_EXPORT Locker {
public: public:
/** /**
* Initialize Locker for a given Isolate. * Initialize Locker for a given Isolate.
*/ */
V8_INLINE(explicit Locker(Isolate* isolate)) { Initialize(isolate); } V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); }
/** Deprecated. Use Isolate version instead. */ /** Deprecated. Use Isolate version instead. */
V8_DEPRECATED(Locker()); V8_DEPRECATED(Locker());
~Locker(); ~Locker();
/** /**
* Start preemption. * Start preemption.
* *
* When preemption is started, a timer is fired every n milliseconds * When preemption is started, a timer is fired every n milliseconds
skipping to change at line 5157 skipping to change at line 5153
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
// Tag information for Smi. // Tag information for Smi.
const int kSmiTag = 0; const int kSmiTag = 0;
const int kSmiTagSize = 1; const int kSmiTagSize = 1;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
template <size_t ptr_size> struct SmiTagging; template <size_t ptr_size> struct SmiTagging;
template<int kSmiShiftSize> template<int kSmiShiftSize>
V8_INLINE(internal::Object* IntToSmi(int value)) { V8_INLINE internal::Object* IntToSmi(int value) {
int smi_shift_bits = kSmiTagSize + kSmiShiftSize; int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
intptr_t tagged_value = intptr_t tagged_value =
(static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag; (static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag;
return reinterpret_cast<internal::Object*>(tagged_value); return reinterpret_cast<internal::Object*>(tagged_value);
} }
// Smi constants for 32-bit systems. // Smi constants for 32-bit systems.
template <> struct SmiTagging<4> { template <> struct SmiTagging<4> {
static const int kSmiShiftSize = 0; static const int kSmiShiftSize = 0;
static const int kSmiValueSize = 31; static const int kSmiValueSize = 31;
V8_INLINE(static int SmiToInt(internal::Object* value)) { V8_INLINE static int SmiToInt(internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize; int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign extend ing). // Throw away top 32 bits and shift down (requires >> to be sign extend ing).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s; return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s;
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) { V8_INLINE static internal::Object* IntToSmi(int value) {
return internal::IntToSmi<kSmiShiftSize>(value); return internal::IntToSmi<kSmiShiftSize>(value);
} }
V8_INLINE(static bool IsValidSmi(intptr_t value)) { V8_INLINE static bool IsValidSmi(intptr_t value) {
// To be representable as an tagged small integer, the two // To be representable as an tagged small integer, the two
// most-significant bits of 'value' must be either 00 or 11 due to // most-significant bits of 'value' must be either 00 or 11 due to
// sign-extension. To check this we add 01 to the two // sign-extension. To check this we add 01 to the two
// most-significant bits, and check if the most-significant bit is 0 // most-significant bits, and check if the most-significant bit is 0
// //
// CAUTION: The original code below: // CAUTION: The original code below:
// bool result = ((value + 0x40000000) & 0x80000000) == 0; // bool result = ((value + 0x40000000) & 0x80000000) == 0;
// may lead to incorrect results according to the C language spec, and // may lead to incorrect results according to the C language spec, and
// in fact doesn't work correctly with gcc4.1.1 in some cases: The // in fact doesn't work correctly with gcc4.1.1 in some cases: The
// compiler may produce undefined results in case of signed integer // compiler may produce undefined results in case of signed integer
// overflow. The computation must be done w/ unsigned ints. // overflow. The computation must be done w/ unsigned ints.
return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
} }
}; };
// Smi constants for 64-bit systems. // Smi constants for 64-bit systems.
template <> struct SmiTagging<8> { template <> struct SmiTagging<8> {
static const int kSmiShiftSize = 31; static const int kSmiShiftSize = 31;
static const int kSmiValueSize = 32; static const int kSmiValueSize = 32;
V8_INLINE(static int SmiToInt(internal::Object* value)) { V8_INLINE static int SmiToInt(internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize; int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits. // Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits ); return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits );
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) { V8_INLINE static internal::Object* IntToSmi(int value) {
return internal::IntToSmi<kSmiShiftSize>(value); return internal::IntToSmi<kSmiShiftSize>(value);
} }
V8_INLINE(static bool IsValidSmi(intptr_t value)) { V8_INLINE static bool IsValidSmi(intptr_t value) {
// To be representable as a long smi, the value must be a 32-bit intege r. // To be representable as a long smi, the value must be a 32-bit intege r.
return (value == static_cast<int32_t>(value)); return (value == static_cast<int32_t>(value));
} }
}; };
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
V8_INLINE(static bool SmiValuesAre31Bits()) { return kSmiValueSize == 31; } V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; }
V8_INLINE(static bool SmiValuesAre32Bits()) { return kSmiValueSize == 32; } V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; }
/** /**
* This class exports constants and functionality from within v8 that * This class exports constants and functionality from within v8 that
* is necessary to implement inline functions in the v8 api. Don't * is necessary to implement inline functions in the v8 api. Don't
* depend on functions and constants defined here. * depend on functions and constants defined here.
*/ */
class Internals { class Internals {
public: public:
// These values match non-compiler-dependent values defined within // These values match non-compiler-dependent values defined within
// the implementation of v8. // the implementation of v8.
skipping to change at line 5266 skipping to change at line 5262
static const int kJSObjectType = 0xb1; static const int kJSObjectType = 0xb1;
static const int kFirstNonstringType = 0x80; static const int kFirstNonstringType = 0x80;
static const int kOddballType = 0x83; static const int kOddballType = 0x83;
static const int kForeignType = 0x87; static const int kForeignType = 0x87;
static const int kUndefinedOddballKind = 5; static const int kUndefinedOddballKind = 5;
static const int kNullOddballKind = 3; static const int kNullOddballKind = 3;
static void CheckInitializedImpl(v8::Isolate* isolate); static void CheckInitializedImpl(v8::Isolate* isolate);
V8_INLINE(static void CheckInitialized(v8::Isolate* isolate)) { V8_INLINE static void CheckInitialized(v8::Isolate* isolate) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckInitializedImpl(isolate); CheckInitializedImpl(isolate);
#endif #endif
} }
V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { V8_INLINE static bool HasHeapObjectTag(internal::Object* value) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag); kHeapObjectTag);
} }
V8_INLINE(static int SmiValue(internal::Object* value)) { V8_INLINE static int SmiValue(internal::Object* value) {
return PlatformSmiTagging::SmiToInt(value); return PlatformSmiTagging::SmiToInt(value);
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) { V8_INLINE static internal::Object* IntToSmi(int value) {
return PlatformSmiTagging::IntToSmi(value); return PlatformSmiTagging::IntToSmi(value);
} }
V8_INLINE(static bool IsValidSmi(intptr_t value)) { V8_INLINE static bool IsValidSmi(intptr_t value) {
return PlatformSmiTagging::IsValidSmi(value); return PlatformSmiTagging::IsValidSmi(value);
} }
V8_INLINE(static int GetInstanceType(internal::Object* obj)) { V8_INLINE static int GetInstanceType(internal::Object* obj) {
typedef internal::Object O; typedef internal::Object O;
O* map = ReadField<O*>(obj, kHeapObjectMapOffset); O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
return ReadField<uint8_t>(map, kMapInstanceTypeOffset); return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
} }
V8_INLINE(static int GetOddballKind(internal::Object* obj)) { V8_INLINE static int GetOddballKind(internal::Object* obj) {
typedef internal::Object O; typedef internal::Object O;
return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
} }
V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { V8_INLINE static bool IsExternalTwoByteString(int instance_type) {
int representation = (instance_type & kFullStringRepresentationMask); int representation = (instance_type & kFullStringRepresentationMask);
return representation == kExternalTwoByteRepresentationTag; return representation == kExternalTwoByteRepresentationTag;
} }
V8_INLINE(static uint8_t GetNodeFlag(internal::Object** obj, int shift)) { V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & static_cast<uint8_t>(1U << shift); return *addr & static_cast<uint8_t>(1U << shift);
} }
V8_INLINE(static void UpdateNodeFlag(internal::Object** obj, V8_INLINE static void UpdateNodeFlag(internal::Object** obj,
bool value, int shift)) { bool value, int shift) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
uint8_t mask = static_cast<uint8_t>(1 << shift); uint8_t mask = static_cast<uint8_t>(1 << shift);
*addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift));
} }
V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) { V8_INLINE static uint8_t GetNodeState(internal::Object** obj) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
return *addr & kNodeStateMask; return *addr & kNodeStateMask;
} }
V8_INLINE(static void UpdateNodeState(internal::Object** obj, V8_INLINE static void UpdateNodeState(internal::Object** obj,
uint8_t value)) { uint8_t value) {
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset;
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
} }
V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, void* data) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset; kIsolateEmbedderDataOffset;
*reinterpret_cast<void**>(addr) = data; *reinterpret_cast<void**>(addr) = data;
} }
V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
kIsolateEmbedderDataOffset; kIsolateEmbedderDataOffset;
return *reinterpret_cast<void**>(addr); return *reinterpret_cast<void**>(addr);
} }
V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
int index)) { int index) {
uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffs et; uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffs et;
return reinterpret_cast<internal::Object**>(addr + index * kApiPointerS ize); return reinterpret_cast<internal::Object**>(addr + index * kApiPointerS ize);
} }
template <typename T> template <typename T> V8_INLINE static T ReadField(Object* ptr, int offse
V8_INLINE(static T ReadField(Object* ptr, int offset)) { t) {
uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT ag; uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectT ag;
return *reinterpret_cast<T*>(addr); return *reinterpret_cast<T*>(addr);
} }
template <typename T> template <typename T>
V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { V8_INLINE static T ReadEmbedderData(Context* context, int index) {
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* ctx = *reinterpret_cast<O**>(context); O* ctx = *reinterpret_cast<O**>(context);
int embedder_data_offset = I::kContextHeaderSize + int embedder_data_offset = I::kContextHeaderSize +
(internal::kApiPointerSize * I::kContextEmbedderDataIndex); (internal::kApiPointerSize * I::kContextEmbedderDataIndex);
O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
int value_offset = int value_offset =
I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index);
return I::ReadField<T>(embedder_data, value_offset); return I::ReadField<T>(embedder_data, value_offset);
} }
V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } V8_INLINE static bool CanCastToHeapObject(void* o) { return false; }
V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } V8_INLINE static bool CanCastToHeapObject(Context* o) { return true; }
V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } V8_INLINE static bool CanCastToHeapObject(String* o) { return true; }
V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } V8_INLINE static bool CanCastToHeapObject(Object* o) { return true; }
V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } V8_INLINE static bool CanCastToHeapObject(Message* o) { return true; }
V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; V8_INLINE static bool CanCastToHeapObject(StackTrace* o) { return true; }
} V8_INLINE static bool CanCastToHeapObject(StackFrame* o) { return true; }
V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true;
}
}; };
} // namespace internal } // namespace internal
template <class T> template <class T>
Local<T>::Local() : Handle<T>() { } Local<T>::Local() : Handle<T>() { }
template <class T> template <class T>
Local<T> Local<T>::New(Handle<T> that) { Local<T> Local<T>::New(Handle<T> that) {
if (that.IsEmpty()) return Local<T>(); if (that.IsEmpty()) return Local<T>();
 End of changes. 178 change blocks. 
244 lines changed or deleted 238 lines changed or added


 v8config.h   v8config.h 
skipping to change at line 291 skipping to change at line 291
# define V8_HAS_DECLSPEC_NOINLINE 1 # define V8_HAS_DECLSPEC_NOINLINE 1
# define V8_HAS___FORCEINLINE 1 # define V8_HAS___FORCEINLINE 1
#endif #endif
// ------------------------------------------------------------------------ ----- // ------------------------------------------------------------------------ -----
// Helper macros // Helper macros
// A macro used to make better inlining. Don't bother for debug builds. // A macro used to make better inlining. Don't bother for debug builds.
// Use like:
// V8_INLINE int GetZero() { return 0; }
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE
# define V8_INLINE(declarator) inline __attribute__((always_inline)) declar ator # define V8_INLINE inline __attribute__((always_inline))
#elif !defined(DEBUG) && V8_HAS___FORCEINLINE #elif !defined(DEBUG) && V8_HAS___FORCEINLINE
# define V8_INLINE(declarator) __forceinline declarator # define V8_INLINE __forceinline
#else #else
# define V8_INLINE(declarator) inline declarator # define V8_INLINE inline
#endif #endif
// A macro used to tell the compiler to never inline a particular function. // A macro used to tell the compiler to never inline a particular function.
// Don't bother for debug builds. // Don't bother for debug builds.
// Use like:
// V8_NOINLINE int GetMinusOne() { return -1; }
#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE
# define V8_NOINLINE(declarator) __attribute__((noinline)) declarator # define V8_NOINLINE __attribute__((noinline))
#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE
# define V8_NOINLINE(declarator) __declspec(noinline) declarator # define V8_NOINLINE __declspec(noinline)
#else #else
# define V8_NOINLINE(declarator) declarator # define V8_NOINLINE /* NOT SUPPORTED */
#endif #endif
// A macro to mark classes or functions as deprecated. // A macro to mark classes or functions as deprecated.
#if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED #if !V8_DISABLE_DEPRECATIONS && V8_HAS_ATTRIBUTE_DEPRECATED
# define V8_DEPRECATED(declarator) declarator __attribute__((deprecated)) # define V8_DEPRECATED(declarator) declarator __attribute__((deprecated))
#elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED #elif !V8_DISABLE_DEPRECATIONS && V8_HAS_DECLSPEC_DEPRECATED
# define V8_DEPRECATED(declarator) __declspec(deprecated) declarator # define V8_DEPRECATED(declarator) __declspec(deprecated) declarator
#else #else
# define V8_DEPRECATED(declarator) declarator # define V8_DEPRECATED(declarator) declarator
#endif #endif
 End of changes. 8 change blocks. 
6 lines changed or deleted 10 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/