v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 158 | skipping to change at line 158 | |||
* | * | |||
* 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, | typedef void (*WeakReferenceCallback)(Persistent<Value> object, | |||
void* parameter); | void* parameter); | |||
// TODO(svenpanne) Temporary definition until Chrome is in sync. | ||||
typedef void (*NearDeathCallback)(Isolate* isolate, | ||||
Persistent<Value> object, | ||||
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); \ | |||
} | } | |||
/** | /** | |||
* An object reference managed by the v8 garbage collector. | * An object reference managed by the v8 garbage collector. | |||
* | * | |||
skipping to change at line 387 | skipping to change at line 392 | |||
// 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)); | ||||
/** | /** | |||
* Creates a new persistent handle for an existing local or | * Creates a new persistent handle for an existing local or persistent ha | |||
* persistent handle. | ndle. | |||
*/ | */ | |||
V8_INLINE(static Persistent<T> New(Handle<T> that)); | V8_INLINE(static Persistent<T> New(Isolate* isolate, Handle<T> that)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(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. | |||
*/ | */ | |||
V8_INLINE(void Dispose()); | ||||
V8_INLINE(void Dispose(Isolate* isolate)); | V8_INLINE(void Dispose(Isolate* isolate)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(void MakeWeak(void* parameters, | ||||
WeakReferenceCallback 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::WeakReferenceCallback 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. | |||
*/ | */ | |||
V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback) ); | ||||
V8_INLINE(void MakeWeak(Isolate* isolate, | V8_INLINE(void MakeWeak(Isolate* isolate, | |||
void* parameters, | void* parameters, | |||
WeakReferenceCallback callback)); | NearDeathCallback callback)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(void ClearWeak()); | ||||
/** Clears the weak reference to this object. */ | /** Clears the weak reference to this object. */ | |||
V8_INLINE(void ClearWeak()); | V8_INLINE(void ClearWeak(Isolate* isolate)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(void MarkIndependent()); | ||||
/** | /** | |||
* Marks the reference to this object independent. Garbage collector | * Marks the reference to this object independent. Garbage collector is f | |||
* is free to ignore any object groups containing this object. | ree | |||
* Weak callback for an independent handle should not | * to ignore any object groups containing this object. Weak callback for | |||
* assume that it will be preceded by a global GC prologue callback | an | |||
* or followed by a global GC epilogue callback. | * 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. | ||||
*/ | */ | |||
V8_INLINE(void MarkIndependent()); | ||||
V8_INLINE(void MarkIndependent(Isolate* isolate)); | V8_INLINE(void MarkIndependent(Isolate* isolate)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(void MarkPartiallyDependent()); | ||||
/** | /** | |||
* Marks the reference to this object partially dependent. Partially | * Marks the reference to this object partially dependent. Partially depe | |||
* dependent handles only depend on other partially dependent handles and | ndent | |||
* these dependencies are provided through object groups. It provides a w | * handles only depend on other partially dependent handles and these | |||
ay | * dependencies are provided through object groups. It provides a way to | |||
* to build smaller object groups for young objects that represent only a | build | |||
* subset of all external dependencies. This mark is automatically cleare | * smaller object groups for young objects that represent only a subset o | |||
d | f all | |||
* after each garbage collection. | * external dependencies. This mark is automatically cleared after each | |||
* garbage collection. | ||||
*/ | */ | |||
V8_INLINE(void MarkPartiallyDependent()); | ||||
V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); | V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(bool IsIndependent() const); | ||||
/** Returns true if this handle was previously marked as independent. */ | /** Returns true if this handle was previously marked as independent. */ | |||
V8_INLINE(bool IsIndependent() const); | ||||
V8_INLINE(bool IsIndependent(Isolate* isolate) const); | V8_INLINE(bool IsIndependent(Isolate* isolate) const); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
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. */ | |||
V8_INLINE(bool IsNearDeath() const); | V8_INLINE(bool IsNearDeath(Isolate* isolate) const); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(bool IsWeak() const); | ||||
/** 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(Isolate* isolate) const); | V8_INLINE(bool IsWeak(Isolate* isolate) const); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(void SetWrapperClassId(uint16_t class_id)); | ||||
/** | /** | |||
* Assigns a wrapper class ID to the handle. See RetainedObjectInfo | * Assigns a wrapper class ID to the handle. See RetainedObjectInfo inter | |||
* interface description in v8-profiler.h for details. | face | |||
* description in v8-profiler.h for details. | ||||
*/ | */ | |||
V8_INLINE(void SetWrapperClassId(uint16_t class_id)); | V8_INLINE(void SetWrapperClassId(Isolate* isolate, uint16_t class_id)); | |||
/** Deprecated. Use Isolate version instead. */ | ||||
V8_DEPRECATED(uint16_t WrapperClassId() const); | ||||
/** | /** | |||
* Returns the class ID previously assigned to this handle or 0 if no cla | * Returns the class ID previously assigned to this handle or 0 if no cla | |||
ss | ss ID | |||
* ID was previously assigned. | * was previously assigned. | |||
*/ | */ | |||
V8_INLINE(uint16_t WrapperClassId() const); | V8_INLINE(uint16_t WrapperClassId(Isolate* isolate) const); | |||
private: | private: | |||
friend class ImplementationUtilities; | friend class ImplementationUtilities; | |||
friend class ObjectTemplate; | friend class ObjectTemplate; | |||
}; | }; | |||
/** | /** | |||
* 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 | |||
skipping to change at line 3455 | skipping to change at line 3486 | |||
* Optional notification that a context has been disposed. V8 uses | * Optional notification that a context has been disposed. V8 uses | |||
* these notifications to guide the GC heuristic. Returns the number | * these notifications to guide the GC heuristic. Returns the number | |||
* of context disposals - including this one - since the last time | * of context disposals - including this one - since the last time | |||
* V8 had a chance to clean up. | * V8 had a chance to clean up. | |||
*/ | */ | |||
static int ContextDisposedNotification(); | static int ContextDisposedNotification(); | |||
private: | private: | |||
V8(); | V8(); | |||
static internal::Object** GlobalizeReference(internal::Object** handle); | static internal::Object** GlobalizeReference(internal::Isolate* isolate, | |||
static void DisposeGlobal(internal::Object** global_handle); | internal::Object** handle); | |||
static void DisposeGlobal(internal::Isolate* isolate, | static void DisposeGlobal(internal::Isolate* isolate, | |||
internal::Object** global_handle); | internal::Object** global_handle); | |||
static void MakeWeak(internal::Object** global_handle, | ||||
void* data, | ||||
WeakReferenceCallback); | ||||
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); | WeakReferenceCallback weak_reference_callback, | |||
static void ClearWeak(internal::Object** global_handle); | NearDeathCallback near_death_callback); | |||
static void MarkIndependent(internal::Object** global_handle); | static void ClearWeak(internal::Isolate* isolate, | |||
static void MarkIndependent(internal::Isolate* isolate, | internal::Object** global_handle); | |||
internal::Object** global_handle); | ||||
static void MarkPartiallyDependent(internal::Object** global_handle); | ||||
static void MarkPartiallyDependent(internal::Isolate* isolate, | ||||
internal::Object** global_handle); | ||||
static bool IsGlobalIndependent(internal::Object** global_handle); | ||||
static bool IsGlobalIndependent(internal::Isolate* isolate, | ||||
internal::Object** global_handle); | ||||
static bool IsGlobalNearDeath(internal::Object** global_handle); | ||||
static bool IsGlobalWeak(internal::Object** global_handle); | ||||
static bool IsGlobalWeak(internal::Isolate* isolate, | ||||
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; | |||
}; | }; | |||
/** | /** | |||
* An external exception handler. | * An external exception handler. | |||
*/ | */ | |||
skipping to change at line 3895 | skipping to change at line 3912 | |||
* // V8 Now no longer locked. | * // V8 Now no longer locked. | |||
* \endcode | * \endcode | |||
*/ | */ | |||
class V8EXPORT Unlocker { | class V8EXPORT 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 V8EXPORT Locker { | class V8EXPORT 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 | |||
* that will switch between multiple threads that are in contention | * that will switch between multiple threads that are in contention | |||
* for the V8 lock. | * for the V8 lock. | |||
skipping to change at line 4090 | skipping to change at line 4103 | |||
static const int kContextHeaderSize = 2 * kApiPointerSize; | static const int kContextHeaderSize = 2 * kApiPointerSize; | |||
static const int kContextEmbedderDataIndex = 54; | static const int kContextEmbedderDataIndex = 54; | |||
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 kNodeClassIdOffset = 1 * kApiPointerSize; | ||||
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | ||||
static const int kUndefinedValueRootIndex = 5; | static const int kUndefinedValueRootIndex = 5; | |||
static const int kNullValueRootIndex = 7; | static const int kNullValueRootIndex = 7; | |||
static const int kTrueValueRootIndex = 8; | static const int kTrueValueRootIndex = 8; | |||
static const int kFalseValueRootIndex = 9; | static const int kFalseValueRootIndex = 9; | |||
static const int kEmptySymbolRootIndex = 119; | static const int kEmptySymbolRootIndex = 119; | |||
static const int kNodeClassIdOffset = 1 * kApiPointerSize; | ||||
static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; | ||||
static const int kNodeStateMask = 0xf; | ||||
static const int kNodeStateIsWeakValue = 2; | ||||
static const int kNodeStateIsNearDeathValue = 4; | ||||
static const int kNodeIsIndependentShift = 4; | static const int kNodeIsIndependentShift = 4; | |||
static const int kNodeIsPartiallyDependentShift = 5; | static const int kNodeIsPartiallyDependentShift = 5; | |||
static const int kJSObjectType = 0xab; | static const int kJSObjectType = 0xab; | |||
static const int kFirstNonstringType = 0x80; | static const int kFirstNonstringType = 0x80; | |||
static const int kOddballType = 0x82; | static const int kOddballType = 0x82; | |||
static const int kForeignType = 0x85; | static const int kForeignType = 0x85; | |||
static const int kUndefinedOddballKind = 5; | static const int kUndefinedOddballKind = 5; | |||
static const int kNullOddballKind = 3; | static const int kNullOddballKind = 3; | |||
skipping to change at line 4151 | skipping to change at line 4167 | |||
return *addr & (1 << shift); | return *addr & (1 << 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 = 1 << shift; | uint8_t mask = 1 << shift; | |||
*addr = (*addr & ~mask) | (value << shift); | *addr = (*addr & ~mask) | (value << shift); | |||
} | } | |||
V8_INLINE(static uint8_t GetNodeState(internal::Object** obj)) { | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | ||||
return *addr & kNodeStateMask; | ||||
} | ||||
V8_INLINE(static void UpdateNodeState(internal::Object** obj, | ||||
uint8_t value)) { | ||||
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; | ||||
*addr = (*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); | |||
skipping to change at line 4215 | skipping to change at line 4242 | |||
T* that_ptr = *that; | T* that_ptr = *that; | |||
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>(); | if (that.IsEmpty()) return Local<T>(); | |||
T* that_ptr = *that; | 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); | ||||
} | ||||
template <class T> | ||||
Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) { | ||||
if (that.IsEmpty()) return Persistent<T>(); | if (that.IsEmpty()) return Persistent<T>(); | |||
internal::Object** p = reinterpret_cast<internal::Object**>(*that); | internal::Object** p = reinterpret_cast<internal::Object**>(*that); | |||
return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | return Persistent<T>(reinterpret_cast<T*>( | |||
V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), | ||||
p))); | ||||
} | } | |||
template <class T> | template <class T> | |||
bool Persistent<T>::IsIndependent() const { | bool Persistent<T>::IsIndependent() const { | |||
if (this->IsEmpty()) return false; | return IsIndependent(Isolate::GetCurrent()); | |||
return V8::IsGlobalIndependent(reinterpret_cast<internal::Object**>(**thi | ||||
s)); | ||||
} | } | |||
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), | |||
I::kNodeIsIndependentShift); | I::kNodeIsIndependentShift); | |||
} | } | |||
template <class T> | template <class T> | |||
bool Persistent<T>::IsNearDeath() const { | bool Persistent<T>::IsNearDeath() const { | |||
return IsNearDeath(Isolate::GetCurrent()); | ||||
} | ||||
template <class T> | ||||
bool Persistent<T>::IsNearDeath(Isolate* isolate) const { | ||||
typedef internal::Internals I; | ||||
if (this->IsEmpty()) return false; | if (this->IsEmpty()) return false; | |||
return V8::IsGlobalNearDeath(reinterpret_cast<internal::Object**>(**this) | if (!I::IsInitialized(isolate)) return false; | |||
); | return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) == | |||
I::kNodeStateIsNearDeathValue; | ||||
} | } | |||
template <class T> | template <class T> | |||
bool Persistent<T>::IsWeak() const { | bool Persistent<T>::IsWeak() const { | |||
if (this->IsEmpty()) return false; | return IsWeak(Isolate::GetCurrent()); | |||
return V8::IsGlobalWeak(reinterpret_cast<internal::Object**>(**this)); | ||||
} | } | |||
template <class T> | template <class T> | |||
bool Persistent<T>::IsWeak(Isolate* isolate) const { | bool Persistent<T>::IsWeak(Isolate* isolate) const { | |||
typedef internal::Internals I; | ||||
if (this->IsEmpty()) return false; | if (this->IsEmpty()) return false; | |||
return V8::IsGlobalWeak(reinterpret_cast<internal::Isolate*>(isolate), | if (!I::IsInitialized(isolate)) return false; | |||
reinterpret_cast<internal::Object**>(**this)); | return I::GetNodeState(reinterpret_cast<internal::Object**>(**this)) == | |||
I::kNodeStateIsWeakValue; | ||||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::Dispose() { | void Persistent<T>::Dispose() { | |||
if (this->IsEmpty()) return; | Dispose(Isolate::GetCurrent()); | |||
V8::DisposeGlobal(reinterpret_cast<internal::Object**>(**this)); | ||||
} | } | |||
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)); | |||
} | } | |||
template <class T> | template <class T> | |||
Persistent<T>::Persistent() : Handle<T>() { } | Persistent<T>::Persistent() : Handle<T>() { } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) { | void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) { | |||
V8::MakeWeak(reinterpret_cast<internal::Object**>(**this), | Isolate* isolate = Isolate::GetCurrent(); | |||
V8::MakeWeak(reinterpret_cast<internal::Isolate*>(isolate), | ||||
reinterpret_cast<internal::Object**>(**this), | ||||
parameters, | parameters, | |||
callback); | callback, | |||
NULL); | ||||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MakeWeak(Isolate* isolate, void* parameters, | void Persistent<T>::MakeWeak(Isolate* isolate, | |||
WeakReferenceCallback callback) { | void* parameters, | |||
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), | |||
parameters, | parameters, | |||
NULL, | ||||
callback); | callback); | |||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::ClearWeak() { | void Persistent<T>::ClearWeak() { | |||
V8::ClearWeak(reinterpret_cast<internal::Object**>(**this)); | ClearWeak(Isolate::GetCurrent()); | |||
} | ||||
template <class T> | ||||
void Persistent<T>::ClearWeak(Isolate* isolate) { | ||||
V8::ClearWeak(reinterpret_cast<internal::Isolate*>(isolate), | ||||
reinterpret_cast<internal::Object**>(**this)); | ||||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MarkIndependent() { | void Persistent<T>::MarkIndependent() { | |||
V8::MarkIndependent(reinterpret_cast<internal::Object**>(**this)); | 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), | |||
true, I::kNodeIsIndependentShift); | true, | |||
I::kNodeIsIndependentShift); | ||||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MarkPartiallyDependent() { | void Persistent<T>::MarkPartiallyDependent() { | |||
V8::MarkPartiallyDependent(reinterpret_cast<internal::Object**>(**this)); | 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), | |||
true, I::kNodeIsPartiallyDependentShift); | true, | |||
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); | ||||
} | ||||
template <class T> | ||||
void Persistent<T>::SetWrapperClassId(Isolate* isolate, uint16_t class_id) | ||||
{ | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
if (this->IsEmpty()) return; | ||||
if (!I::IsInitialized(isolate)) return; | ||||
internal::Object** obj = reinterpret_cast<internal::Object**>(**this); | internal::Object** obj = reinterpret_cast<internal::Object**>(**this); | |||
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()); | ||||
} | ||||
template <class T> | ||||
uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { | ||||
typedef internal::Internals I; | typedef internal::Internals I; | |||
if (this->IsEmpty()) return 0; | ||||
if (!I::IsInitialized(isolate)) return 0; | ||||
internal::Object** obj = reinterpret_cast<internal::Object**>(**this); | internal::Object** obj = reinterpret_cast<internal::Object**>(**this); | |||
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), | |||
End of changes. 56 change blocks. | ||||
83 lines changed or deleted | 156 lines changed or added | |||