Commit 6239ec10 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[modules] Fix bug in instantiation failure handling

It's not sufficient to reset only the modules on the current DFS path.

Bug: chromium:1050164
Change-Id: I00e5e12144ad70ac6371eea5e11590b72feaeecc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2049853
Auto-Submit: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66229}
parent 447e2a7c
......@@ -76,9 +76,11 @@ void Module::RecordError(Isolate* isolate, Handle<Object> error) {
}
void Module::ResetGraph(Isolate* isolate, Handle<Module> module) {
DCHECK_NE(module->status(), kInstantiating);
DCHECK_NE(module->status(), kEvaluating);
if (module->status() != kPreInstantiating) return;
if (module->status() != kPreInstantiating &&
module->status() != kInstantiating) {
return;
}
Handle<FixedArray> requested_modules =
module->IsSourceTextModule()
......@@ -180,15 +182,14 @@ bool Module::Instantiate(Isolate* isolate, Handle<Module> module,
if (!PrepareInstantiate(isolate, module, context, callback)) {
ResetGraph(isolate, module);
DCHECK_EQ(module->status(), kUninstantiated);
return false;
}
Zone zone(isolate->allocator(), ZONE_NAME);
ZoneForwardList<Handle<SourceTextModule>> stack(&zone);
unsigned dfs_index = 0;
if (!FinishInstantiate(isolate, module, &stack, &dfs_index, &zone)) {
for (auto& descendant : stack) {
Reset(isolate, descendant);
}
ResetGraph(isolate, module);
DCHECK_EQ(module->status(), kUninstantiated);
return false;
}
......
// Copyright 2020 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.
// Flags: --allow-natives-syntax
import("./modules-skip-reset1.js").then(() => %AbortJS("must throw"));
import("./modules-skip-reset3.js").then(() => %AbortJS("must throw"));
// Copyright 2020 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.
import {a} from "./modules-skip-reset2.js";
import {b} from "./modules-skip-reset3.js";
export let c = 42;
// Copyright 2020 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.
export {a} from "./modules-skip-reset2.js";
// Copyright 2020 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.
import {c} from "./modules-skip-reset1.js";
export let b = 23;
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