Commit 1829eb66 authored by verwaest's avatar verwaest Committed by Commit bot

Avoid Context::Enter and Context::Exit if we're reentering the active and last entered context

A bit of browsing around indicates that the new fast-path is taken most of the time:
   3496 Entering new
 152295 Reentering same

BUG=

Review-Url: https://codereview.chromium.org/2131483002
Cr-Commit-Position: refs/heads/master@{#37570}
parent 4a4f7175
......@@ -183,7 +183,17 @@ class CallDepthScope {
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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment