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

Unified Diff: src/api.cc

Issue 985873002: api: introduce SealHandleScope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 | « include/v8.h ('k') | src/handles-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 0d0bf3f75a6a8d2e01e1d57ac006ff2b7b5cb1c1..3d112e6b93ba4c7265c9646043bca66c263d7ada 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -686,6 +686,34 @@ i::Object** EscapableHandleScope::Escape(i::Object** escape_value) {
}
+SealHandleScope::SealHandleScope(Isolate* isolate) {
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ // We do not want to check the correct usage of the Locker class all over the
+ // place, so we do it only here: Without a HandleScope, an embedder can do
+ // almost nothing, so it is enough to check in this central place.
+ // We make an exception if the serializer is enabled, which means that the
+ // Isolate is exclusively used to create a snapshot.
+ Utils::ApiCheck(
+ !v8::Locker::IsActive() ||
+ internal_isolate->thread_manager()->IsLockedByCurrentThread() ||
+ internal_isolate->serializer_enabled(),
+ "HandleScope::HandleScope",
Yang 2015/03/10 12:52:32 Please update this line to SealHandleScope.
+ "Entering the V8 API without proper locking in place");
+
+ isolate_ = internal_isolate;
+ i::HandleScopeData* current = internal_isolate->handle_scope_data();
+ level_ = current->level;
+ current->level = 0;
+}
+
+
+SealHandleScope::~SealHandleScope() {
+ i::HandleScopeData* current = isolate_->handle_scope_data();
+ DCHECK_EQ(0, current->level);
+ current->level = level_;
+}
+
+
void Context::Enter() {
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = env->GetIsolate();
« no previous file with comments | « include/v8.h ('k') | src/handles-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698