v8.h   v8.h 
skipping to change at line 126 skipping to change at line 126
class Date; class Date;
class DeclaredAccessorDescriptor; class DeclaredAccessorDescriptor;
class External; class External;
class Function; class Function;
class FunctionTemplate; class FunctionTemplate;
class HeapProfiler; class HeapProfiler;
class ImplementationUtilities; class ImplementationUtilities;
class Int32; class Int32;
class Integer; class Integer;
class Isolate; class Isolate;
class LocalContext;
class Number; class Number;
class NumberObject; class NumberObject;
class Object; class Object;
class ObjectOperationDescriptor; class ObjectOperationDescriptor;
class ObjectTemplate; class ObjectTemplate;
class Primitive; class Primitive;
class RawOperationDescriptor; class RawOperationDescriptor;
class Signature; class Signature;
class StackFrame; class StackFrame;
class StackTrace; class StackTrace;
skipping to change at line 190 skipping to change at line 191
/** /**
* A weak reference callback function. * A weak reference callback function.
* *
* This callback should either explicitly invoke Dispose on |object| if * This callback should either explicitly invoke Dispose on |object| if
* V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWe ak. * V8 wrapper is not needed anymore, or 'revive' it by invocation of MakeWe ak.
* *
* \param object the weak global object to be reclaimed by the garbage coll ector * \param object the weak global object to be reclaimed by the garbage coll ector
* \param parameter the value passed in when making the weak global object * \param parameter the value passed in when making the weak global object
*/ */
typedef void (*WeakReferenceCallback)(Persistent<Value> object, template<typename T, typename P>
void* parameter); class WeakReferenceCallbacks {
public:
typedef void (*Revivable)(Isolate* isolate,
Persistent<T>* object,
P* parameter);
};
// TODO(svenpanne) Temporary definition until Chrome is in sync. // TODO(svenpanne) Temporary definition until Chrome is in sync.
typedef void (*NearDeathCallback)(Isolate* isolate, typedef void (*NearDeathCallback)(Isolate* isolate,
Persistent<Value> object, Persistent<Value> object,
void* parameter); void* parameter);
// --- Handles --- // --- Handles ---
#define TYPE_CHECK(T, S) \ #define TYPE_CHECK(T, S) \
while (false) { \ while (false) { \
*(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \
} }
#define V8_USE_UNSAFE_HANDLES
/** /**
* An object reference managed by the v8 garbage collector. * An object reference managed by the v8 garbage collector.
* *
* All objects returned from v8 have to be tracked by the garbage * All objects returned from v8 have to be tracked by the garbage
* collector so that it knows that the objects are still alive. Also, * collector so that it knows that the objects are still alive. Also,
* because the garbage collector may move objects, it is unsafe to * because the garbage collector may move objects, it is unsafe to
* point directly to an object. Instead, all objects are stored in * point directly to an object. Instead, all objects are stored in
* handles which are known by the garbage collector and updated * handles which are known by the garbage collector and updated
* whenever an object moves. Handles should always be passed by value * whenever an object moves. Handles should always be passed by value
* (except in cases like out-parameters) and they should never be * (except in cases like out-parameters) and they should never be
skipping to change at line 237 skipping to change at line 245
* 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) {}
#ifdef V8_USE_UNSAFE_HANDLES
/** /**
* 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) {}
#endif
/** /**
* 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.
skipping to change at line 282 skipping to change at line 292
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==(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** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
#ifndef V8_USE_UNSAFE_HANDLES
template <class S> V8_INLINE(
bool operator==(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;
} }
#endif
/** /**
* 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!=(Handle<S> that) const) { template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) {
return !operator==(that); return !operator==(that);
} }
skipping to change at line 313 skipping to change at line 334
// 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);
} }
#ifndef V8_USE_UNSAFE_HANDLES
V8_INLINE(static Handle<T> New(Isolate* isolate, Handle<T> that)) {
return New(isolate, that.val_);
}
// TODO(dcarney): remove before cutover
V8_INLINE(static Handle<T> New(Isolate* isolate, const Persistent<T>& tha
t)) {
return New(isolate, that.val_);
}
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private:
#endif
/**
* Creates a new handle for the specified value.
*/
V8_INLINE(explicit Handle(T* val)) : val_(val) {}
#endif
private: private:
template<class F>
friend class Persistent;
template<class F>
friend class Local;
friend class Arguments;
friend class String;
friend class Object;
friend class AccessorInfo;
friend Handle<Primitive> Undefined(Isolate* isolate);
friend Handle<Primitive> Null(Isolate* isolate);
friend Handle<Boolean> True(Isolate* isolate);
friend Handle<Boolean> False(Isolate* isolate);
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
#ifndef V8_USE_UNSAFE_HANDLES
V8_INLINE(static Handle<T> New(Isolate* isolate, T* that));
#endif
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.
*/ */
// TODO(dcarney): deprecate entire class
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);
} }
#ifdef V8_USE_UNSAFE_HANDLES
template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { }
#endif
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));
} }
#ifndef V8_USE_UNSAFE_HANDLES
template <class S> V8_INLINE(Local(Handle<S> that))
: Handle<T>(reinterpret_cast<T*>(*that)) {
TYPE_CHECK(T, S);
}
#endif
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));
#ifndef V8_USE_UNSAFE_HANDLES
// TODO(dcarney): remove before cutover
V8_INLINE(static Local<T> New(Isolate* isolate, const Persistent<T>& that
));
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private:
#endif
template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { }
#endif
private:
template<class F>
friend class Persistent;
template<class F>
friend class Handle;
friend class Arguments;
friend class String;
friend class Object;
friend class AccessorInfo;
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
V8_INLINE(static Local<T> New(Isolate* isolate, T* that));
}; };
/** /**
* 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.
* *
* A persistent handle contains a reference to a storage cell within * A persistent handle contains a reference to a storage cell within
* the v8 engine which holds an object value and which is updated by * the v8 engine which holds an object value and which is updated by
* the garbage collector whenever the object is moved. A new storage * the garbage collector whenever the object is moved. A new storage
* cell can be created using Persistent::New and existing handles can * cell can be created using Persistent::New and existing handles can
* be disposed using Persistent::Dispose. Since persistent handles * be disposed using Persistent::Dispose. Since persistent handles
* are passed by value you may have many persistent handle objects * are passed by value you may have many persistent handle objects
* that point to the same storage cell. For instance, if you pass a * that point to the same storage cell. For instance, if you pass a
* persistent handle as an argument to a function you will not get two * persistent handle as an argument to a function you will not get two
* different storage cells but rather two references to the same * different storage cells but rather two references to the same
* storage cell. * storage cell.
*/ */
template <class T> class Persistent : public Handle<T> { template <class T> class Persistent // NOLINT
#ifdef V8_USE_UNSAFE_HANDLES
: public Handle<T> {
#else
{ // NOLINT
#endif
public: public:
#ifndef V8_USE_UNSAFE_HANDLES
V8_INLINE(Persistent()) : val_(0) { }
V8_INLINE(~Persistent()) {
// TODO(dcarney): add this back before cutover.
// Dispose();
}
V8_INLINE(bool IsEmpty() const) { return val_ == 0; }
// TODO(dcarney): remove somehow before cutover
// The handle should either be 0, or a pointer to a live cell.
V8_INLINE(void Clear()) { val_ = 0; }
/**
* A constructor that creates a new global cell pointing to that. In cont
rast
* to the copy constructor, this creates a new persistent handle which ne
eds
* to be separately disposed.
*/
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that)
)
: val_(*New(isolate, that)) { }
#else
/** /**
* Creates an empty persistent handle that doesn't point to any * Creates an empty persistent handle that doesn't point to any
* storage cell. * storage cell.
*/ */
V8_INLINE(Persistent()); V8_INLINE(Persistent()) : Handle<T>() { }
/** /**
* Creates a persistent handle for the same storage cell as the * Creates a persistent handle for the same storage cell as the
* specified handle. This constructor allows you to pass persistent * specified handle. This constructor allows you to pass persistent
* handles as arguments by value and to assign between persistent * handles as arguments by value and to assign between persistent
* handles. However, attempting to assign between incompatible * handles. However, attempting to assign between incompatible
* persistent handles, for instance from a Persistent<String> to a * persistent handles, for instance from a Persistent<String> to a
* Persistent<Number> will cause a compile-time error. Assigning * Persistent<Number> will cause a compile-time error. Assigning
* between compatible persistent handles, for instance assigning a * between compatible persistent handles, for instance assigning a
* Persistent<String> to a variable declared as Persistent<Value>, * Persistent<String> to a variable declared as Persistent<Value>,
skipping to change at line 422 skipping to change at line 543
template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that) ) template <class S> V8_INLINE(Persistent(Isolate* isolate, Handle<S> that) )
: Handle<T>(New(isolate, that)) { } : Handle<T>(New(isolate, that)) { }
/** /**
* "Casts" a plain handle which is known to be a persistent handle * "Casts" a plain handle which is known to be a persistent handle
* to a persistent handle. * to a persistent handle.
*/ */
template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) template <class S> explicit V8_INLINE(Persistent(Handle<S> that))
: Handle<T>(*that) { } : Handle<T>(*that) { }
#endif
template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that )) { template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<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 Persistent<T>(); if (that.IsEmpty()) return Persistent<T>();
#endif #endif
return Persistent<T>(T::Cast(*that)); return Persistent<T>(T::Cast(*that));
} }
template <class S> V8_INLINE(Persistent<S> As()) { template <class S> V8_INLINE(Persistent<S> As()) {
return Persistent<S>::Cast(*this); return Persistent<S>::Cast(*this);
} }
/** Deprecated. Use Isolate version instead. */
V8_DEPRECATED(static Persistent<T> New(Handle<T> that)); V8_DEPRECATED(static Persistent<T> New(Handle<T> that));
/** /**
* Creates a new persistent handle for an existing local or persistent ha ndle. * Creates a new persistent handle for an existing local or persistent ha ndle.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that)); V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that));
#ifndef V8_USE_UNSAFE_HANDLES
// TODO(dcarney): remove before cutover
V8_INLINE(static Persistent<T> New(Isolate* isolate, Persistent<T> that))
;
#endif
/** Deprecated. Use Isolate version instead. */ #ifndef V8_USE_UNSAFE_HANDLES
V8_DEPRECATED(void Dispose()); template <class S> V8_INLINE(
bool operator==(const Persistent<S>& that) const) {
internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
template <class S> V8_INLINE(bool operator==(const Handle<S> that) const)
{
internal::Object** a = reinterpret_cast<internal::Object**>(**this);
internal::Object** b = reinterpret_cast<internal::Object**>(*that);
if (a == 0) return b == 0;
if (b == 0) return false;
return *a == *b;
}
#endif
V8_INLINE(void Dispose());
/** /**
* Releases the storage cell referenced by this persistent handle. * Releases the storage cell referenced by this persistent handle.
* Does not remove the reference to the cell from any handles. * Does not remove the reference to the cell from any handles.
* This handle's reference, and any other references to the storage * This handle's reference, and any other references to the storage
* cell remain and IsEmpty will still return false. * cell remain and IsEmpty will still return false.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(void Dispose(Isolate* isolate)); V8_INLINE(void Dispose(Isolate* isolate));
/** Deprecated. Use Isolate version instead. */ template<typename S, typename P>
V8_DEPRECATED(void MakeWeak(void* parameters, V8_INLINE(void MakeWeak(
WeakReferenceCallback callback)); Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<S, P>::Revivable callback));
template<typename P>
V8_INLINE(void MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback));
/** /**
* Make the reference to this object weak. When only weak handles * Make the reference to this object weak. When only weak handles
* refer to the object, the garbage collector will perform a * refer to the object, the garbage collector will perform a
* callback to the given V8::NearDeathCallback function, passing * callback to the given V8::NearDeathCallback function, passing
* it the object reference and the given parameters. * it the object reference and the given parameters.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(void MakeWeak(Isolate* isolate, V8_INLINE(void MakeWeak(Isolate* isolate,
void* parameters, void* parameters,
NearDeathCallback callback)); NearDeathCallback callback));
/** Deprecated. Use Isolate version instead. */ V8_INLINE(void ClearWeak());
V8_DEPRECATED(void ClearWeak());
/** Clears the weak reference to this object. */ // TODO(dcarney): remove before cutover
V8_INLINE(void ClearWeak(Isolate* isolate)); V8_INLINE(void ClearWeak(Isolate* isolate));
/** Deprecated. Use Isolate version instead. */ V8_INLINE(void MarkIndependent());
V8_DEPRECATED(void MarkIndependent());
/** /**
* 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.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(void MarkIndependent(Isolate* isolate)); V8_INLINE(void MarkIndependent(Isolate* isolate));
/** Deprecated. Use Isolate version instead. */ V8_INLINE(void MarkPartiallyDependent());
V8_DEPRECATED(void MarkPartiallyDependent());
/** /**
* 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.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); V8_INLINE(void MarkPartiallyDependent(Isolate* isolate));
/** Deprecated. Use Isolate version instead. */ V8_INLINE(bool IsIndependent() const);
V8_DEPRECATED(bool IsIndependent() const);
/** Returns true if this handle was previously marked as independent. */ // TODO(dcarney): remove before cutover
V8_INLINE(bool IsIndependent(Isolate* isolate) const); V8_INLINE(bool IsIndependent(Isolate* isolate) const);
/** Deprecated. Use Isolate version instead. */ V8_INLINE(bool IsNearDeath() const);
V8_DEPRECATED(bool IsNearDeath() const);
/** Checks if the handle holds the only reference to an object. */ /** Checks if the handle holds the only reference to an object. */
// TODO(dcarney): remove before cutover
V8_INLINE(bool IsNearDeath(Isolate* isolate) const); V8_INLINE(bool IsNearDeath(Isolate* isolate) const);
/** Deprecated. Use Isolate version instead. */ V8_INLINE(bool IsWeak() const);
V8_DEPRECATED(bool IsWeak() const);
/** Returns true if the handle's reference is weak. */ /** Returns true if the handle's reference is weak. */
// TODO(dcarney): remove before cutover
V8_INLINE(bool IsWeak(Isolate* isolate) const); V8_INLINE(bool IsWeak(Isolate* isolate) const);
/** Deprecated. Use Isolate version instead. */ V8_INLINE(void SetWrapperClassId(uint16_t class_id));
V8_DEPRECATED(void SetWrapperClassId(uint16_t class_id));
/** /**
* 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.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)); V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id));
/** Deprecated. Use Isolate version instead. */ V8_INLINE(uint16_t WrapperClassId() const);
V8_DEPRECATED(uint16_t WrapperClassId() const);
/** /**
* 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.
*/ */
// TODO(dcarney): remove before cutover
V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const);
/**
* Disposes the current contents of the handle and replaces it.
*/
V8_INLINE(void Reset(Isolate* isolate, const Handle<T>& other));
#ifndef V8_USE_UNSAFE_HANDLES
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT
private: private:
#endif
// TODO(dcarney): make unlinkable before cutover
V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {}
// TODO(dcarney): make unlinkable before cutover
V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT
this->val_ = that.val_;
return *this;
}
public:
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
private:
#endif
// TODO(dcarney): remove before cutover
template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { }
// TODO(dcarney): remove before cutover
template <class S> V8_INLINE(Persistent(Persistent<S> that))
: val_(*that) {
TYPE_CHECK(T, S);
}
// TODO(dcarney): remove before cutover
V8_INLINE(T* operator*() const) { return val_; }
public:
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW
private:
#endif
// TODO(dcarney): remove before cutover
V8_INLINE(T* operator->() const) { return val_; }
public:
#endif
private:
template<class F>
friend class Handle;
template<class F>
friend class Local;
friend class ImplementationUtilities; friend class ImplementationUtilities;
friend class ObjectTemplate; friend class ObjectTemplate;
friend class Context;
friend class InternalHandleHelper;
friend class LocalContext;
V8_INLINE(static Persistent<T> New(Isolate* isolate, T* that));
#ifndef V8_USE_UNSAFE_HANDLES
T* val_;
#endif
}; };
/** /**
* 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
* place in the new handle scope until it is deleted. After that, * place in the new handle scope until it is deleted. After that,
* new handles will again be allocated in the original handle scope. * new handles will again be allocated in the original handle scope.
skipping to change at line 1095 skipping to change at line 1304
/** /**
* Returns true if this value is a NativeError. * Returns true if this value is a NativeError.
*/ */
bool IsNativeError() const; bool IsNativeError() const;
/** /**
* Returns true if this value is a RegExp. * Returns true if this value is a RegExp.
*/ */
bool IsRegExp() const; bool IsRegExp() const;
/**
* Returns true if this value is an ArrayBuffer.
* This is an experimental feature.
*/
bool IsArrayBuffer() const;
/**
* Returns true if this value is one of TypedArrays.
* This is an experimental feature.
*/
bool IsTypedArray() const;
/**
* Returns true if this value is an Uint8Array.
* This is an experimental feature.
*/
bool IsUint8Array() const;
/**
* Returns true if this value is an Uint8ClampedArray.
* This is an experimental feature.
*/
bool IsUint8ClampedArray() const;
/**
* Returns true if this value is an Int8Array.
* This is an experimental feature.
*/
bool IsInt8Array() const;
/**
* Returns true if this value is an Uint16Array.
* This is an experimental feature.
*/
bool IsUint16Array() const;
/**
* Returns true if this value is an Int16Array.
* This is an experimental feature.
*/
bool IsInt16Array() const;
/**
* Returns true if this value is an Uint32Array.
* This is an experimental feature.
*/
bool IsUint32Array() const;
/**
* Returns true if this value is an Int32Array.
* This is an experimental feature.
*/
bool IsInt32Array() const;
/**
* Returns true if this value is a Float32Array.
* This is an experimental feature.
*/
bool IsFloat32Array() const;
/**
* Returns true if this value is a Float64Array.
* This is an experimental feature.
*/
bool IsFloat64Array() const;
Local<Boolean> ToBoolean() const; Local<Boolean> ToBoolean() const;
Local<Number> ToNumber() const; Local<Number> ToNumber() const;
Local<String> ToString() const; Local<String> ToString() const;
Local<String> ToDetailString() const; Local<String> ToDetailString() const;
Local<Object> ToObject() const; Local<Object> ToObject() const;
Local<Integer> ToInteger() const; Local<Integer> ToInteger() const;
Local<Uint32> ToUint32() const; Local<Uint32> ToUint32() const;
Local<Int32> ToInt32() const; Local<Int32> ToInt32() const;
/** /**
skipping to change at line 1169 skipping to change at line 1444
/** /**
* 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.
*/ */
// TODO(dcarney): deprecate V8_DEPRECATED(V8_INLINE(bool MayContainNonAscii()) const) { return true;
V8_INLINE(bool MayContainNonAscii()) const { return true; } }
/** /**
* Returns whether this string contains only one byte data. * Returns whether this string contains only one byte data.
*/ */
bool IsOneByte() const; bool IsOneByte() const;
/** /**
* Write the contents of the string to an external buffer. * Write the contents of the string to an external buffer.
* If no arguments are given, expects the buffer to be large * If no arguments are given, expects the buffer to be large
* enough to hold the entire string and NULL terminator. Copies * enough to hold the entire string and NULL terminator. Copies
skipping to change at line 1215 skipping to change at line 1489
NO_NULL_TERMINATION = 2, NO_NULL_TERMINATION = 2,
PRESERVE_ASCII_NULL = 4 PRESERVE_ASCII_NULL = 4
}; };
// 16-bit character codes. // 16-bit character codes.
int Write(uint16_t* buffer, int Write(uint16_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// ASCII characters. // ASCII characters.
int WriteAscii(char* buffer, V8_DEPRECATED(int WriteAscii(char* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const);
// One byte characters. // One byte characters.
int WriteOneByte(uint8_t* buffer, int WriteOneByte(uint8_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// 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;
skipping to change at line 2068 skipping to change at line 2342
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).
* This API is experimental and may change significantly.
*/
class V8EXPORT Uint8ClampedArray : public TypedArray {
public:
static Local<Uint8ClampedArray> New(Handle<ArrayBuffer> array_buffer,
size_t byte_offset, size_t length);
V8_INLINE(static Uint8ClampedArray* Cast(Value* obj));
private:
Uint8ClampedArray();
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 V8EXPORT Int8Array : public TypedArray { class V8EXPORT 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:
skipping to change at line 3514 skipping to change at line 3803
* Interface for iterating through all the persistent handles in the heap. * Interface for iterating through all the persistent handles in the heap.
*/ */
class V8EXPORT PersistentHandleVisitor { // NOLINT class V8EXPORT PersistentHandleVisitor { // NOLINT
public: public:
virtual ~PersistentHandleVisitor() {} virtual ~PersistentHandleVisitor() {}
virtual void VisitPersistentHandle(Persistent<Value> value, virtual void VisitPersistentHandle(Persistent<Value> value,
uint16_t class_id) {} uint16_t class_id) {}
}; };
/** /**
* Asserts that no action is performed that could cause a handle's value
* to be modified. Useful when otherwise unsafe handle operations need to
* be performed.
*/
class V8EXPORT AssertNoGCScope {
#ifndef DEBUG
V8_INLINE(AssertNoGCScope(Isolate* isolate)) {}
#else
AssertNoGCScope(Isolate* isolate);
~AssertNoGCScope();
private:
Isolate* isolate_;
bool last_state_;
#endif
};
/**
* Container class for static utility functions. * Container class for static utility functions.
*/ */
class V8EXPORT V8 { class V8EXPORT V8 {
public: public:
/** Set the callback to invoke in case of fatal errors. */ /** Set the callback to invoke in case of fatal errors. */
static void SetFatalErrorHandler(FatalErrorCallback that); static void SetFatalErrorHandler(FatalErrorCallback that);
/** /**
* Set the callback to invoke to check if code generation from * Set the callback to invoke to check if code generation from
* strings should be allowed. * strings should be allowed.
skipping to change at line 3983 skipping to change at line 4289
*/ */
static int ContextDisposedNotification(); static int ContextDisposedNotification();
private: private:
V8(); V8();
static internal::Object** GlobalizeReference(internal::Isolate* isolate, static internal::Object** GlobalizeReference(internal::Isolate* isolate,
internal::Object** handle); internal::Object** handle);
static void DisposeGlobal(internal::Isolate* isolate, static void DisposeGlobal(internal::Isolate* isolate,
internal::Object** global_handle); internal::Object** global_handle);
typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
static void MakeWeak(internal::Isolate* isolate, static void MakeWeak(internal::Isolate* isolate,
internal::Object** global_handle, internal::Object** global_handle,
void* data, void* data,
WeakReferenceCallback weak_reference_callback, RevivableCallback weak_reference_callback,
NearDeathCallback near_death_callback); NearDeathCallback near_death_callback);
static void ClearWeak(internal::Isolate* isolate, static void ClearWeak(internal::Isolate* isolate,
internal::Object** global_handle); internal::Object** global_handle);
template <class T> friend class Handle; template <class T> friend class Handle;
template <class T> friend class Local; template <class T> friend class Local;
template <class T> friend class Persistent; template <class T> friend class Persistent;
friend class Context; friend class Context;
}; };
skipping to change at line 4326 skipping to change at line 4633
/** /**
* 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();
} }
V8_INLINE(Scope(Isolate* isolate, Persistent<Context>& context)) // NOL
INT
#ifndef V8_USE_UNSAFE_HANDLES
: context_(Handle<Context>::New(isolate, context)) {
#else
: context_(Local<Context>::New(isolate, context)) {
#endif
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 4606 skipping to change at line 4922
// the implementation of v8. // the implementation of v8.
static const int kHeapObjectMapOffset = 0; static const int kHeapObjectMapOffset = 0;
static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze; static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSi ze;
static const int kStringResourceOffset = 3 * kApiPointerSize; static const int kStringResourceOffset = 3 * kApiPointerSize;
static const int kOddballKindOffset = 3 * kApiPointerSize; static const int kOddballKindOffset = 3 * kApiPointerSize;
static const int kForeignAddressOffset = kApiPointerSize; static const int kForeignAddressOffset = kApiPointerSize;
static const int kJSObjectHeaderSize = 3 * kApiPointerSize; static const int kJSObjectHeaderSize = 3 * kApiPointerSize;
static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; static const int kFixedArrayHeaderSize = 2 * kApiPointerSize;
static const int kContextHeaderSize = 2 * kApiPointerSize; static const int kContextHeaderSize = 2 * kApiPointerSize;
static const int kContextEmbedderDataIndex = 64; static const int kContextEmbedderDataIndex = 65;
static const int kFullStringRepresentationMask = 0x07; static const int kFullStringRepresentationMask = 0x07;
static const int kStringEncodingMask = 0x4; static const int kStringEncodingMask = 0x4;
static const int kExternalTwoByteRepresentationTag = 0x02; static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalAsciiRepresentationTag = 0x06; static const int kExternalAsciiRepresentationTag = 0x06;
static const int kIsolateStateOffset = 0; static const int kIsolateStateOffset = 0;
static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize; static const int kIsolateEmbedderDataOffset = 1 * kApiPointerSize;
static const int kIsolateRootsOffset = 3 * kApiPointerSize; static const int kIsolateRootsOffset = 3 * kApiPointerSize;
static const int kUndefinedValueRootIndex = 5; static const int kUndefinedValueRootIndex = 5;
static const int kNullValueRootIndex = 7; static const int kNullValueRootIndex = 7;
skipping to change at line 4755 skipping to change at line 5071
internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
if (internal::Internals::CanCastToHeapObject(that_ptr)) { if (internal::Internals::CanCastToHeapObject(that_ptr)) {
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::HeapObject*>(*p)))); reinterpret_cast<internal::HeapObject*>(*p))));
} }
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
} }
template <class T> template <class T>
Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
if (that.IsEmpty()) return Local<T>(); return New(isolate, that.val_);
T* that_ptr = *that; }
#ifndef V8_USE_UNSAFE_HANDLES
template <class T>
Local<T> Local<T>::New(Isolate* isolate, const Persistent<T>& that) {
return New(isolate, that.val_);
}
template <class T>
Handle<T> Handle<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Handle<T>();
T* that_ptr = that;
internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
return Handle<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::Isolate*>(isolate), *p)));
}
#endif
template <class T>
Local<T> Local<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Local<T>();
T* that_ptr = that;
internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
reinterpret_cast<internal::Isolate*>(isolate), *p))); reinterpret_cast<internal::Isolate*>(isolate), *p)));
} }
template <class T> template <class T>
Persistent<T> Persistent<T>::New(Handle<T> that) { Persistent<T> Persistent<T>::New(Handle<T> that) {
return New(Isolate::GetCurrent(), that); return New(Isolate::GetCurrent(), that.val_);
} }
template <class T> template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) { Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
if (that.IsEmpty()) return Persistent<T>(); return New(Isolate::GetCurrent(), that.val_);
internal::Object** p = reinterpret_cast<internal::Object**>(*that); }
#ifndef V8_USE_UNSAFE_HANDLES
template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, Persistent<T> that) {
return New(Isolate::GetCurrent(), that.val_);
}
#endif
template <class T>
Persistent<T> Persistent<T>::New(Isolate* isolate, T* that) {
if (that == NULL) return Persistent<T>();
internal::Object** p = reinterpret_cast<internal::Object**>(that);
return Persistent<T>(reinterpret_cast<T*>( return Persistent<T>(reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
p))); p)));
} }
template <class T> template <class T>
bool Persistent<T>::IsIndependent() const { bool Persistent<T>::IsIndependent() const {
return IsIndependent(Isolate::GetCurrent()); return IsIndependent(Isolate::GetCurrent());
} }
template <class T> template <class T>
bool Persistent<T>::IsIndependent(Isolate* isolate) const { bool Persistent<T>::IsIndependent(Isolate* isolate) const {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
if (!I::IsInitialized(isolate)) return false; if (!I::IsInitialized(isolate)) return false;
return I::GetNodeFlag(reinterpret_cast<internal::Object**>(**this), return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
I::kNodeIsIndependentShift); I::kNodeIsIndependentShift);
} }
template <class T> template <class T>
bool Persistent<T>::IsNearDeath() const { bool Persistent<T>::IsNearDeath() const {
return IsNearDeath(Isolate::GetCurrent()); return IsNearDeath(Isolate::GetCurrent());
} }
template <class T> template <class T>
bool Persistent<T>::IsNearDeath(Isolate* isolate) const { bool Persistent<T>::IsNearDeath(Isolate* isolate) const {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
if (!I::IsInitialized(isolate)) return false; if (!I::IsInitialized(isolate)) return false;
return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) == return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
I::kNodeStateIsNearDeathValue; I::kNodeStateIsNearDeathValue;
} }
template <class T> template <class T>
bool Persistent<T>::IsWeak() const { bool Persistent<T>::IsWeak() const {
return IsWeak(Isolate::GetCurrent()); return IsWeak(Isolate::GetCurrent());
} }
template <class T> template <class T>
bool Persistent<T>::IsWeak(Isolate* isolate) const { bool Persistent<T>::IsWeak(Isolate* isolate) const {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
if (!I::IsInitialized(isolate)) return false; if (!I::IsInitialized(isolate)) return false;
return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) == return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) ==
I::kNodeStateIsWeakValue; I::kNodeStateIsWeakValue;
} }
template <class T> template <class T>
void Persistent<T>::Dispose() { void Persistent<T>::Dispose() {
Dispose(Isolate::GetCurrent()); Dispose(Isolate::GetCurrent());
} }
template <class T> template <class T>
void Persistent<T>::Dispose(Isolate* isolate) { void Persistent<T>::Dispose(Isolate* isolate) {
if (this->IsEmpty()) return; if (this->IsEmpty()) return;
V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate), V8::DisposeGlobal(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this)); reinterpret_cast<internal::Object**>(this->val_));
#ifndef V8_USE_UNSAFE_HANDLES
val_ = 0;
#endif
} }
template <class T> template <class T>
Persistent<T>::Persistent() : Handle<T>() { } template <typename S, typename P>
void Persistent<T>::MakeWeak(
template <class T> Isolate* isolate,
void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba P* parameters,
ck) { typename WeakReferenceCallbacks<S, P>::Revivable callback) {
Isolate* isolate = Isolate::GetCurrent(); TYPE_CHECK(S, T);
typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable
;
V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this), reinterpret_cast<internal::Object**>(this->val_),
parameters, parameters,
callback, reinterpret_cast<Revivable>(callback),
NULL); NULL);
} }
template <class T> template <class T>
template <typename P>
void Persistent<T>::MakeWeak(
Isolate* isolate,
P* parameters,
typename WeakReferenceCallbacks<T, P>::Revivable callback) {
MakeWeak<T, P>(isolate, parameters, callback);
}
template <class T>
void Persistent<T>::MakeWeak(Isolate* isolate, void Persistent<T>::MakeWeak(Isolate* isolate,
void* parameters, void* parameters,
NearDeathCallback callback) { NearDeathCallback callback) {
V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this), reinterpret_cast<internal::Object**>(this->val_),
parameters, parameters,
NULL, NULL,
callback); callback);
} }
template <class T> template <class T>
void Persistent<T>::ClearWeak() { void Persistent<T>::ClearWeak() {
ClearWeak(Isolate::GetCurrent()); ClearWeak(Isolate::GetCurrent());
} }
template <class T> template <class T>
void Persistent<T>::ClearWeak(Isolate* isolate) { void Persistent<T>::ClearWeak(Isolate* isolate) {
V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate), V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate),
reinterpret_cast<internal::Object**>(**this)); reinterpret_cast<internal::Object**>(this->val_));
} }
template <class T> template <class T>
void Persistent<T>::MarkIndependent() { void Persistent<T>::MarkIndependent() {
MarkIndependent(Isolate::GetCurrent()); MarkIndependent(Isolate::GetCurrent());
} }
template <class T> template <class T>
void Persistent<T>::MarkIndependent(Isolate* isolate) { void Persistent<T>::MarkIndependent(Isolate* isolate) {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return; if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return; if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true, true,
I::kNodeIsIndependentShift); I::kNodeIsIndependentShift);
} }
template <class T> template <class T>
void Persistent<T>::MarkPartiallyDependent() { void Persistent<T>::MarkPartiallyDependent() {
MarkPartiallyDependent(Isolate::GetCurrent()); MarkPartiallyDependent(Isolate::GetCurrent());
} }
template <class T> template <class T>
void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) { void Persistent<T>::MarkPartiallyDependent(Isolate* isolate) {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return; if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return; if (!I::IsInitialized(isolate)) return;
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(**this), I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_),
true, true,
I::kNodeIsPartiallyDependentShift); I::kNodeIsPartiallyDependentShift);
} }
template <class T> template <class T>
void Persistent<T>::SetWrapperClassId(uint16_t class_id) { void Persistent<T>::SetWrapperClassId(uint16_t class_id) {
SetWrapperClassId(Isolate::GetCurrent(), class_id); SetWrapperClassId(Isolate::GetCurrent(), class_id);
} }
template <class T> template <class T>
void Persistent<T>::Reset(Isolate* isolate, const Handle<T>& other) {
Dispose(isolate);
#ifdef V8_USE_UNSAFE_HANDLES
*this = *New(isolate, other);
#else
if (other.IsEmpty()) {
this->val_ = NULL;
return;
}
internal::Object** p = reinterpret_cast<internal::Object**>(other.val_);
this->val_ = reinterpret_cast<T*>(
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate),
p));
#endif
}
template <class T>
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) { void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return; if (this->IsEmpty()) return;
if (!I::IsInitialized(isolate)) return; if (!I::IsInitialized(isolate)) return;
internal::Object** obj = reinterpret_cast<internal::Object**>(**this); internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ;
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
*reinterpret_cast<uint16_t*>(addr) = class_id; *reinterpret_cast<uint16_t*>(addr) = class_id;
} }
template <class T> template <class T>
uint16_t Persistent<T>::WrapperClassId() const { uint16_t Persistent<T>::WrapperClassId() const {
return WrapperClassId(Isolate::GetCurrent()); return WrapperClassId(Isolate::GetCurrent());
} }
template <class T> template <class T>
uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return 0; if (this->IsEmpty()) return 0;
if (!I::IsInitialized(isolate)) return 0; if (!I::IsInitialized(isolate)) return 0;
internal::Object** obj = reinterpret_cast<internal::Object**>(**this); internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ;
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr); return *reinterpret_cast<uint16_t*>(addr);
} }
Arguments::Arguments(internal::Object** implicit_args, Arguments::Arguments(internal::Object** implicit_args,
internal::Object** values, int length, internal::Object** values, int length,
bool is_construct_call) bool is_construct_call)
: implicit_args_(implicit_args), : implicit_args_(implicit_args),
values_(values), values_(values),
length_(length), length_(length),
 End of changes. 72 change blocks. 
60 lines changed or deleted 450 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/