| Index: src/handles-inl.h
|
| diff --git a/src/handles-inl.h b/src/handles-inl.h
|
| index fa7f7b8609cd76c190f6f6baf9bc981c1d4391a4..0088d3a379bef788237c1c6fd74b188e9c3dc97f 100644
|
| --- a/src/handles-inl.h
|
| +++ b/src/handles-inl.h
|
| @@ -43,6 +43,11 @@ Handle<T>::Handle(T* obj) {
|
| location_ = HandleScope::CreateHandle(obj, Isolate::Current());
|
| }
|
|
|
| +template<class T>
|
| +Handle<T>::Handle(HeapObject* obj) {
|
| + location_ = HandleScope::CreateHandle<T>(obj, obj->GetIsolate());
|
| +}
|
| +
|
|
|
| template<class T>
|
| Handle<T>::Handle(T* obj, Isolate* isolate) {
|
| @@ -59,9 +64,36 @@ inline T* Handle<T>::operator*() const {
|
| }
|
|
|
|
|
| +// Helper class to zero out the number of extensions in the handle
|
| +// scope data after it has been saved.
|
| +// This is only necessary for HandleScope constructor to get the right
|
| +// order of effects.
|
| +class HandleScopeDataTransfer {
|
| + public:
|
| + typedef v8::ImplementationUtilities::HandleScopeData Data;
|
| +
|
| + explicit HandleScopeDataTransfer(Data* data) : data_(data) {}
|
| + ~HandleScopeDataTransfer() { data_->extensions = 0; }
|
| +
|
| + // Called before the destructor to get the data to save.
|
| + Data* data() { return data_; }
|
| +
|
| + private:
|
| + Data* data_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(HandleScopeDataTransfer);
|
| +};
|
| +
|
| +
|
| HandleScope::HandleScope()
|
| - : previous_(*Isolate::Current()->handle_scope_data()) {
|
| - Isolate::Current()->handle_scope_data()->extensions = 0;
|
| + : previous_(*HandleScopeDataTransfer(
|
| + Isolate::Current()->handle_scope_data()).data()) {
|
| +}
|
| +
|
| +
|
| +HandleScope::HandleScope(Isolate* isolate)
|
| + : previous_(*HandleScopeDataTransfer(isolate->handle_scope_data()).data()) {
|
| + ASSERT(isolate == Isolate::Current());
|
| }
|
|
|
|
|
|
|