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 2862483003: Do not enter contexts implicitly (Closed)
Patch Set: Use correct NewInstance() overload Created 3 years, 8 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 | « no previous file | test/cctest/test-api.cc » ('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 94750842f6a41c10d79a61d86b2914b7aeef0bb8..1921985da5d57d8df10ca280725788eee1b52f02 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -232,17 +232,20 @@ class CallDepthScope {
i::Handle<i::Context> env = Utils::OpenHandle(*context);
i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
if (isolate->context() != nullptr &&
- isolate->context()->native_context() == env->native_context() &&
- impl->LastEnteredContextWas(env)) {
+ isolate->context()->native_context() == env->native_context()) {
context_ = Local<Context>();
} else {
- context_->Enter();
+ impl->SaveContext(isolate->context());
+ isolate->set_context(*env);
}
}
if (do_callback) isolate_->FireBeforeCallEnteredCallback();
}
~CallDepthScope() {
- if (!context_.IsEmpty()) context_->Exit();
+ if (!context_.IsEmpty()) {
+ i::HandleScopeImplementer* impl = isolate_->handle_scope_implementer();
+ isolate_->set_context(impl->RestoreContext());
+ }
if (!escaped_) isolate_->handle_scope_implementer()->DecrementCallDepth();
if (do_callback) isolate_->FireCallCompletedCallback();
#ifdef DEBUG
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698