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

Unified Diff: src/handles-inl.h

Issue 6614010: [Isolates] Merge 6700:7030 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 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/heap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/handles-inl.h
===================================================================
--- src/handles-inl.h (revision 7006)
+++ src/handles-inl.h (working copy)
@@ -45,21 +45,21 @@
return obj->GetIsolate();
}
-template<class T>
+template<typename T>
Handle<T>::Handle(T* obj) {
ASSERT(!obj->IsFailure());
location_ = HandleScope::CreateHandle(obj, GetIsolateForHandle(obj));
}
-template<class T>
+template<typename T>
Handle<T>::Handle(T* obj, Isolate* isolate) {
ASSERT(!obj->IsFailure());
location_ = HandleScope::CreateHandle(obj, isolate);
}
-template <class T>
+template <typename T>
inline T* Handle<T>::operator*() const {
ASSERT(location_ != NULL);
ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue);
@@ -90,6 +90,10 @@
HandleScope::~HandleScope() {
+ CloseScope();
+}
+
+void HandleScope::CloseScope() {
ASSERT(isolate_ == Isolate::Current());
v8::ImplementationUtilities::HandleScopeData* current =
isolate_->handle_scope_data();
@@ -106,6 +110,25 @@
template <typename T>
+Handle<T> HandleScope::CloseAndEscape(Handle<T> handle_value) {
+ T* value = *handle_value;
+ // Throw away all handles in the current scope.
+ CloseScope();
+ v8::ImplementationUtilities::HandleScopeData* current =
+ isolate_->handle_scope_data();
+ // Allocate one handle in the parent scope.
+ ASSERT(current->level > 0);
+ Handle<T> result(CreateHandle<T>(value, isolate_));
+ // Reinitialize the current scope (so that it's ready
+ // to be used or closed again).
+ prev_next_ = current->next;
+ prev_limit_ = current->limit;
+ current->level++;
+ return result;
+}
+
+
+template <typename T>
T** HandleScope::CreateHandle(T* value, Isolate* isolate) {
ASSERT(isolate == Isolate::Current());
v8::ImplementationUtilities::HandleScopeData* current =
« no previous file with comments | « src/handles.cc ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698