Index: src/handles-inl.h |
diff --git a/src/handles-inl.h b/src/handles-inl.h |
index 130798647ba2d6be2c68a1c810fd57a3bf39d1e0..c084fb901417108f0c78bda099a794e987a358b7 100644 |
--- a/src/handles-inl.h |
+++ b/src/handles-inl.h |
@@ -63,9 +63,18 @@ template <typename T> |
inline T* Handle<T>::operator*() const { |
ASSERT(location_ != NULL); |
ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); |
+ SLOW_ASSERT(ISOLATE->allow_handle_deref()); |
return *BitCast<T**>(location_); |
} |
+template <typename T> |
+inline T** Handle<T>::location() const { |
+ ASSERT(location_ == NULL || |
+ reinterpret_cast<Address>(*location_) != kZapValue); |
+ SLOW_ASSERT(ISOLATE->allow_handle_deref()); |
+ return location_; |
+} |
+ |
HandleScope::HandleScope() { |
Isolate* isolate = Isolate::Current(); |
@@ -175,6 +184,38 @@ inline NoHandleAllocation::~NoHandleAllocation() { |
data->level = level_; |
} |
} |
+ |
+ |
+NoHandleDereference::NoHandleDereference() { |
+ // The guard is set on a per-isolate basis, so it affects all threads. |
+ // That's why we can only use it when running without parallel recompilation. |
+ if (FLAG_parallel_recompilation) return; |
+ Isolate* isolate = Isolate::Current(); |
+ old_state_ = isolate->allow_handle_deref(); |
+ isolate->set_allow_handle_deref(false); |
+} |
+ |
+ |
+NoHandleDereference::~NoHandleDereference() { |
+ if (FLAG_parallel_recompilation) return; |
+ Isolate::Current()->set_allow_handle_deref(old_state_); |
+} |
+ |
+ |
+AllowHandleDereference::AllowHandleDereference() { |
+ // The guard is set on a per-isolate basis, so it affects all threads. |
+ // That's why we can only use it when running without parallel recompilation. |
+ if (FLAG_parallel_recompilation) return; |
+ Isolate* isolate = Isolate::Current(); |
+ old_state_ = isolate->allow_handle_deref(); |
+ isolate->set_allow_handle_deref(true); |
+} |
+ |
+ |
+AllowHandleDereference::~AllowHandleDereference() { |
+ if (FLAG_parallel_recompilation) return; |
+ Isolate::Current()->set_allow_handle_deref(old_state_); |
+} |
#endif |