Commit 78f26103 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[d8] Seal HandleScope and reset Context before running a v8::Task

V8 does not require the embedder to open a HandleScope before executing
a v8::Task. However, d8 does open such a HandleScope. Because of that
HandleScope we repeatedly found missing HandleScopes only in Chrome
tests and not in d8 tests. The same is true for the context, which is
not set when Chrome calls a v8::Task.

With this CL we create a SealHandleScope around the execution of a
v8::Task, and we set the context to nullptr, so that d8 matches Chrome
better.

Ideally d8 would not open a HandleScope in the first place, and would
not set a context. Both make d8 behave different than Chrome and thereby
may hide bugs from our testing infrastructure. However, the
implementation of the InspectorClient requires them. I think the
SealHandleScope and resetting the context is a good workaround at the
moment. Yang, do you know if we can get rid of the context there in the
long run?

R=yangguo@chromium.org

Change-Id: I8df0fabde7dfdcdc630d20af4c68f141ac3a454c
Reviewed-on: https://chromium-review.googlesource.com/1177742Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55644}
parent beb7778d
......@@ -3005,6 +3005,10 @@ bool ProcessMessages(Isolate* isolate,
std::function<platform::MessageLoopBehavior()> behavior) {
Platform* platform = GetDefaultPlatform();
while (true) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::SaveContext saved_context(i_isolate);
i_isolate->set_context(nullptr);
SealHandleScope shs(isolate);
while (v8::platform::PumpMessageLoop(platform, isolate, behavior())) {
isolate->RunMicrotasks();
}
......
......@@ -1895,7 +1895,7 @@ class PromiseOnStack {
// If the GCC version is 4.1.x or 4.2.x an additional field is added to the
// class as a work around for a bug in the generated code found with these
// versions of GCC. See V8 issue 122 for details.
class SaveContext BASE_EMBEDDED {
class V8_EXPORT_PRIVATE SaveContext BASE_EMBEDDED {
public:
explicit SaveContext(Isolate* isolate);
~SaveContext();
......
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