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

Unified Diff: src/api.cc

Issue 2152803003: Avoid Context::Enter and Context::Exit if we're reentering the active and last entered context (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | no next file » | 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 cb6658082206e529c84f701a0835ca63122ad3fc..ec538cc6e9f1c434415a5e7e94746369c05ffe7a 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -182,7 +182,17 @@
DCHECK(!isolate_->external_caught_exception());
isolate_->IncrementJsCallsFromApiCounter();
isolate_->handle_scope_implementer()->IncrementCallDepth();
- if (!context_.IsEmpty()) context_->Enter();
+ if (!context.IsEmpty()) {
+ 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)) {
+ context_ = Local<Context>();
+ } else {
+ context_->Enter();
+ }
+ }
if (do_callback_) isolate_->FireBeforeCallEnteredCallback();
}
~CallDepthScope() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698