Commit 1016e625 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[d8] Run the message loop in the same RealmScope as the script

In d8 a script is executed in a RealmScope. However, all micro task
which are created by the script are not executed within the RealmScope
at the moment. With this CL I move the execution of the micro task into
the RealmScope.

I thought about creating a new RealmScope for the micro tasks, but
(1) It did not fix the crashing repro;
(2) It seems wrong that the micro tasks are executed in a different
    realm than the script;

Therefore I just moved the execution of the micro tasks into the
RealmScope of the script.

Thereby I moved the execution tasks also into the Context::Scope of the
script. The problem is that the Context::Scope surrounds the RealmScope,
and when I to open the RealmScope before the Context::Scope, not even
the execution of the script works anymore.

R=yangguo@chromium.org

Bug: chromium:797846
Change-Id: If152af282beec8f0b0564dcc9682fee8588e142c
Reviewed-on: https://chromium-review.googlesource.com/856497Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50442}
parent 0e7d4ccd
......@@ -2536,11 +2536,11 @@ void SourceGroup::ExecuteInThread() {
Shell::options.enable_inspector);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
Execute(isolate);
Shell::CompleteMessageLoop(isolate);
}
DisposeModuleEmbedderData(context);
}
Shell::CollectGarbage(isolate);
Shell::CompleteMessageLoop(isolate);
}
done_semaphore_.Signal();
}
......@@ -2943,6 +2943,7 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
InspectorClient inspector_client(context, options.enable_inspector);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
options.isolate_sources[0].Execute(isolate);
CompleteMessageLoop(isolate);
}
if (!use_existing_context) {
DisposeModuleEmbedderData(context);
......@@ -2950,7 +2951,6 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[], bool last_run) {
WriteLcovData(isolate, options.lcov_file);
}
CollectGarbage(isolate);
CompleteMessageLoop(isolate);
for (int i = 1; i < options.num_isolates; ++i) {
if (last_run) {
options.isolate_sources[i].JoinThread();
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
load('test/mjsunit/wasm/wasm-constants.js');
load('test/mjsunit/wasm/wasm-module-builder.js');
// We need a module with one valid function.
const builder = new WasmModuleBuilder();
builder.addFunction('test', kSig_v_v).addBody([]);
const buffer = builder.toBuffer();
assertPromiseResult(
WebAssembly.compile(buffer), _ => Realm.createAllowCrossRealmAccess());
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