Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: src/handles-inl.h

Issue 3473024: [Isolates] More handle improvements: (Closed)
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « src/handles.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698