Chromium Code Reviews| Index: src/handles.h |
| diff --git a/src/handles.h b/src/handles.h |
| index 8e9404cb9d105024578fa92b18e140a2a15d0dc0..e5a6c2796ec7c91204b7f688d49abbdd0ec88772 100644 |
| --- a/src/handles.h |
| +++ b/src/handles.h |
| @@ -73,8 +73,8 @@ class Handle { |
| INLINE(T** location() const); |
| template <class S> static Handle<T> cast(Handle<S> that) { |
| - T::cast(*that); |
| - return Handle<T>(reinterpret_cast<T**>(that.location())); |
| + T::cast(*reinterpret_cast<T**>(that.location_)); |
| + return Handle<T>(reinterpret_cast<T**>(that.location_)); |
| } |
| static Handle<T> null() { return Handle<T>(); } |
| @@ -84,6 +84,10 @@ class Handle { |
| // implementation in api.h. |
| inline Handle<T> EscapeFrom(v8::HandleScope* scope); |
| +#ifdef DEBUG |
| + bool IsDereferenceAllowed(bool allow_deferred) const; |
| +#endif // DEBUG |
| + |
| private: |
| T** location_; |
| @@ -341,7 +345,7 @@ class NoHandleAllocation BASE_EMBEDDED { |
| class HandleDereferenceGuard BASE_EMBEDDED { |
| public: |
| - enum State { ALLOW, DISALLOW }; |
| + enum State { ALLOW, DISALLOW, DISALLOW_DEFERRED }; |
| #ifndef DEBUG |
| HandleDereferenceGuard(Isolate* isolate, State state) { } |
| ~HandleDereferenceGuard() { } |
| @@ -350,10 +354,18 @@ class HandleDereferenceGuard BASE_EMBEDDED { |
| inline ~HandleDereferenceGuard(); |
| private: |
| Isolate* isolate_; |
| - bool old_state_; |
| + State old_state_; |
| #endif |
| }; |
| +#ifdef DEBUG |
| +#define ALLOW_HANDLE_DEREF(why_this_is_safe) \ |
| + HandleDereferenceGuard allow(Isolate::Current(), \ |
|
Sven Panne
2013/04/23 06:42:13
Please do *not* introduce any new Isolate::Current
|
| + HandleDereferenceGuard::ALLOW); |
| +#else |
| +#define ALLOW_HANDLE_DEREF(why_this_is_safe) |
| +#endif // DEBUG |
| + |
| } } // namespace v8::internal |
| #endif // V8_HANDLES_H_ |