v8.h | v8.h | |||
---|---|---|---|---|
skipping to change at line 214 | skipping to change at line 214 | |||
* \param parameter the value passed in when making the weak global object | * \param parameter the value passed in when making the weak global object | |||
*/ | */ | |||
template<typename T, typename P> | template<typename T, typename P> | |||
class WeakReferenceCallbacks { | class WeakReferenceCallbacks { | |||
public: | public: | |||
typedef void (*Revivable)(Isolate* isolate, | typedef void (*Revivable)(Isolate* isolate, | |||
Persistent<T>* object, | Persistent<T>* object, | |||
P* parameter); | P* 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); \ | |||
} | } | |||
#define V8_USE_UNSAFE_HANDLES | #define V8_USE_UNSAFE_HANDLES | |||
#define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS | #define V8_USE_OLD_STYLE_PERSISTENT_HANDLE_VISITORS | |||
skipping to change at line 673 | skipping to change at line 668 | |||
// TODO(dcarney): deprecate | // TODO(dcarney): deprecate | |||
template<typename P> | template<typename P> | |||
V8_INLINE(void MakeWeak( | V8_INLINE(void MakeWeak( | |||
Isolate* isolate, | Isolate* isolate, | |||
P* parameters, | P* parameters, | |||
typename WeakReferenceCallbacks<T, P>::Revivable callback)) { | typename WeakReferenceCallbacks<T, P>::Revivable callback)) { | |||
MakeWeak<P>(parameters, callback); | MakeWeak<P>(parameters, callback); | |||
} | } | |||
// TODO(dcarney): remove before cutover | ||||
V8_INLINE(void MakeWeak(Isolate* isolate, | ||||
void* parameters, | ||||
NearDeathCallback callback)); | ||||
V8_INLINE(void ClearWeak()); | V8_INLINE(void ClearWeak()); | |||
// TODO(dcarney): deprecate | // TODO(dcarney): deprecate | |||
V8_INLINE(void ClearWeak(Isolate* isolate)) { ClearWeak(); } | 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. | |||
skipping to change at line 771 | skipping to change at line 761 | |||
* responsible of eventually destroying the underlying object (by creatin g a | * responsible of eventually destroying the underlying object (by creatin g a | |||
* Persistent handle which points to it and Disposing it). In the future, | * Persistent handle which points to it and Disposing it). In the future, | |||
* destructing a Persistent will also Dispose it. With this function, the | * destructing a Persistent will also Dispose it. With this function, the | |||
* embedder can let the Persistent go out of scope without it getting | * embedder can let the Persistent go out of scope without it getting | |||
* disposed. | * disposed. | |||
*/ | */ | |||
V8_INLINE(T* ClearAndLeak()); | V8_INLINE(T* ClearAndLeak()); | |||
#ifndef V8_USE_UNSAFE_HANDLES | #ifndef V8_USE_UNSAFE_HANDLES | |||
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_IMPLICIT | ||||
private: | private: | |||
#endif | ||||
// TODO(dcarney): make unlinkable before cutover | // TODO(dcarney): make unlinkable before cutover | |||
V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} | V8_INLINE(Persistent(const Persistent& that)) : val_(that.val_) {} | |||
// TODO(dcarney): make unlinkable before cutover | // TODO(dcarney): make unlinkable before cutover | |||
V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | V8_INLINE(Persistent& operator=(const Persistent& that)) { // NOLINT | |||
this->val_ = that.val_; | this->val_ = that.val_; | |||
return *this; | return *this; | |||
} | } | |||
public: | public: | |||
#ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | |||
skipping to change at line 797 | skipping to change at line 784 | |||
#endif | #endif | |||
// TODO(dcarney): remove before cutover | // TODO(dcarney): remove before cutover | |||
template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } | template <class S> V8_INLINE(Persistent(S* that)) : val_(that) { } | |||
// TODO(dcarney): remove before cutover | // TODO(dcarney): remove before cutover | |||
template <class S> V8_INLINE(Persistent(Persistent<S> that)) | template <class S> V8_INLINE(Persistent(Persistent<S> that)) | |||
: val_(*that) { | : val_(*that) { | |||
TYPE_CHECK(T, S); | TYPE_CHECK(T, S); | |||
} | } | |||
// TODO(dcarney): remove before cutover | // TODO(dcarney): remove before cutover | |||
V8_INLINE(T* operator*() const) { return val_; } | V8_INLINE(T* operator*() const) { return val_; } | |||
public: | ||||
#ifndef V8_ALLOW_ACCESS_TO_PERSISTENT_ARROW | ||||
private: | private: | |||
#endif | ||||
// TODO(dcarney): remove before cutover | // TODO(dcarney): remove before cutover | |||
V8_INLINE(T* operator->() const) { return val_; } | V8_INLINE(T* operator->() const) { return val_; } | |||
public: | public: | |||
#endif | #endif | |||
private: | private: | |||
template<class F> friend class Handle; | template<class F> friend class Handle; | |||
template<class F> friend class Local; | template<class F> friend class Local; | |||
friend class ImplementationUtilities; | friend class ImplementationUtilities; | |||
friend class ObjectTemplate; | friend class ObjectTemplate; | |||
skipping to change at line 4060 | skipping to change at line 4044 | |||
#endif | #endif | |||
}; | }; | |||
/** | /** | |||
* 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 V8EXPORT AssertNoGCScope { | class V8EXPORT AssertNoGCScope { | |||
#ifndef DEBUG | #ifndef DEBUG | |||
V8_INLINE(AssertNoGCScope(Isolate* isolate)) {} | // TODO(yangguo): remove isolate argument. | |||
V8_INLINE(AssertNoGCScope(Isolate* isolate)) { } | ||||
#else | #else | |||
AssertNoGCScope(Isolate* isolate); | AssertNoGCScope(Isolate* isolate); | |||
~AssertNoGCScope(); | ~AssertNoGCScope(); | |||
private: | private: | |||
Isolate* isolate_; | void* disallow_heap_allocation_; | |||
bool last_state_; | ||||
#endif | #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); | |||
skipping to change at line 4507 | skipping to change at line 4491 | |||
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::Object** global_handle); | static void DisposeGlobal(internal::Object** global_handle); | |||
typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; | |||
static void MakeWeak(internal::Object** global_handle, | static void MakeWeak(internal::Object** global_handle, | |||
void* data, | void* data, | |||
RevivableCallback weak_reference_callback, | RevivableCallback weak_reference_callback); | |||
NearDeathCallback near_death_callback); | ||||
static void ClearWeak(internal::Object** global_handle); | static void ClearWeak(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 5420 | skipping to change at line 5403 | |||
template <class T> | template <class T> | |||
template <typename S, typename P> | template <typename S, typename P> | |||
void Persistent<T>::MakeWeak( | void Persistent<T>::MakeWeak( | |||
P* parameters, | P* parameters, | |||
typename WeakReferenceCallbacks<S, P>::Revivable callback) { | typename WeakReferenceCallbacks<S, P>::Revivable callback) { | |||
TYPE_CHECK(S, T); | TYPE_CHECK(S, T); | |||
typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable ; | typedef typename WeakReferenceCallbacks<Value, void>::Revivable Revivable ; | |||
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | |||
parameters, | parameters, | |||
reinterpret_cast<Revivable>(callback), | reinterpret_cast<Revivable>(callback)); | |||
NULL); | ||||
} | } | |||
template <class T> | template <class T> | |||
template <typename P> | template <typename P> | |||
void Persistent<T>::MakeWeak( | void Persistent<T>::MakeWeak( | |||
P* parameters, | P* parameters, | |||
typename WeakReferenceCallbacks<T, P>::Revivable callback) { | typename WeakReferenceCallbacks<T, P>::Revivable callback) { | |||
MakeWeak<T, P>(parameters, callback); | MakeWeak<T, P>(parameters, callback); | |||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MakeWeak(Isolate* isolate, | ||||
void* parameters, | ||||
NearDeathCallback callback) { | ||||
V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), | ||||
parameters, | ||||
NULL, | ||||
callback); | ||||
} | ||||
template <class T> | ||||
void Persistent<T>::ClearWeak() { | void Persistent<T>::ClearWeak() { | |||
V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); | V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_)); | |||
} | } | |||
template <class T> | template <class T> | |||
void Persistent<T>::MarkIndependent() { | void Persistent<T>::MarkIndependent() { | |||
typedef internal::Internals I; | typedef internal::Internals I; | |||
if (this->IsEmpty()) return; | if (this->IsEmpty()) return; | |||
I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), | |||
true, | true, | |||
End of changes. 11 change blocks. | ||||
33 lines changed or deleted | 5 lines changed or added | |||