Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a3b3e5a
[JSC] Module graph instances: instantiate a linked module graph more …
dylan-conway Aug 27, 2026
0cda1e0
[JSC] Module graph instances: review fixes (1)
dylan-conway Aug 27, 2026
aab59bd
[JSC] Module graph instances: review fixes (2)
dylan-conway Aug 27, 2026
217c231
[JSC] Module graph instances: ModuleRegistryEntry::error(IncludeEvalu…
dylan-conway Aug 27, 2026
87c6201
[JSC] Module graph instances: review fixes (3)
dylan-conway Aug 27, 2026
1e71dd2
[JSC] Module graph instances: drop the plain-data heuristic for synth…
dylan-conway Aug 27, 2026
2b82fdf
[JSC] Module graph instances: review fixes (4)
dylan-conway Aug 27, 2026
2c9a549
[JSC] Module graph instances: resume an instance's TLA module body in…
dylan-conway Aug 27, 2026
e868804
[JSC] Module graph instances: skip export entries without a symbol ta…
dylan-conway Aug 27, 2026
1b7be2f
[JSC] Module graph instances: review fixes (5)
dylan-conway Aug 27, 2026
8e22183
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Aug 27, 2026
caa81f4
[JSC] Module graph instances: one ModuleVar slow path for LLInt, base…
dylan-conway Aug 27, 2026
7cdc0d4
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Aug 27, 2026
356d6f4
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Aug 28, 2026
4ea63b9
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Aug 31, 2026
35df9d7
[JSC] Module graph instances: review fixes (6)
dylan-conway Aug 31, 2026
d21196e
[JSC] graphInstanceForScope: initialize *overlayOut on every path
dylan-conway Aug 31, 2026
54732f1
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Sep 1, 2026
037935f
[JSC] Module graph instances: instance-aware import-promise TLA gatin…
dylan-conway Sep 1, 2026
eaee8d0
[JSC] Module graph instances: review fixes (7)
dylan-conway Sep 1, 2026
8efef1e
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Sep 1, 2026
ef69056
Resolve the origin/main merge (8efef1eb2d12 was committed with confli…
dylan-conway Sep 1, 2026
d39cbe1
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Sep 1, 2026
4edf55a
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Sep 4, 2026
1c32f3d
Merge remote-tracking branch 'origin/main' into module-instances-v4
dylan-conway Sep 9, 2026
00739ff
[JSC] Module graph instances: don't hold the loader's cell lock aroun…
dylan-conway Sep 10, 2026
38d8a18
[JSC] Module graph instances: rework as fresh module records that sha…
dylan-conway Sep 10, 2026
d2d9b75
[JSC] Module graph instances: instances no longer share executables (…
dylan-conway Sep 10, 2026
a112ce3
[JSC] Module graph instances: replace with additional module loaders …
dylan-conway Sep 10, 2026
ea1e725
[JSC] Additional module loaders: leave CyclicModuleRecord / JSModuleR…
dylan-conway Sep 10, 2026
15f05c6
[JSC] Additional module loaders: remove what is not load-bearing (cre…
dylan-conway Sep 10, 2026
7450a3a
[JSC] Additional module loaders: drop explanatory comments and an assert
dylan-conway Sep 10, 2026
156d0a5
[JSC] Additional module loaders: a module record and a registry entry…
dylan-conway Sep 10, 2026
d663d7b
[JSC] Additional module loaders: import() receives its referencing mo…
dylan-conway Sep 10, 2026
bbec6ac
[JSC] Additional module loaders: the module environment binds @module…
dylan-conway Sep 10, 2026
4b1ad76
[JSC] Additional module loaders: code knows statically whether it is …
dylan-conway Sep 10, 2026
142f68b
[JSC] Additional module loaders: the module loader is a lexically sco…
dylan-conway Sep 10, 2026
f5b9864
[JSC] Additional module loaders: every module environment declares @m…
dylan-conway Sep 10, 2026
cf19d58
[JSC] Additional module loaders: no global @moduleLoader binding; imp…
dylan-conway Sep 11, 2026
843b82c
[JSC] Module records for the same source share their ModuleProgramExe…
dylan-conway Sep 11, 2026
0d5ec4a
[JSC] Fill module import slots lazily and share executables by depend…
dylan-conway Sep 11, 2026
61fdeb7
[JSC] Module loaders: fill import slots at evaluation, source-canonic…
dylan-conway Sep 11, 2026
50c6255
[JSC] Module loaders can create their modules' environments in a scop…
dylan-conway Sep 11, 2026
d020164
[JSC] Module loaders: key shared executables by module key; ModulePro…
dylan-conway Sep 11, 2026
10a9fa8
[JSC] Module loader tests: no shared on-disk fixture mutation, testLo…
dylan-conway Sep 11, 2026
0f47197
[JSC] Module loaders: review fixes
dylan-conway Sep 11, 2026
d02fd12
[JSC] Module loaders: key shared executables by (module key, module s…
dylan-conway Sep 11, 2026
1191c4a
[JSC] Module loaders: the global object binds @moduleLoader to its mo…
dylan-conway Sep 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions JSTests/modules/module-loaders-changed-dependency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { shouldBe } from "./resources/assert.js";

// A module whose text is unchanged but whose dependency changed shape between two
// loaders fetching it links its own code in the second loader instead of running
// the first loader's; a third loader then shares the second's. The modules are
// written by the test under names of its own, so concurrent runs do not interfere.
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
const importer = `./module-loaders-changed-dependency/${id}-importer.js`;
const dep = `./module-loaders-changed-dependency/${id}-dep.js`;
const version1 = `export let x = "x1";\nexport const shape = 1;\n`;
const version2 = `export let w = "w";\nexport let x = "x2";\nexport const shape = 2;\n`;
writeFile(importer, `import { x, shape } from "./${id}-dep.js"\nexport function read(n) { let result; for (let i = 0; i < n; ++i) result = x; return [result, shape]; }\n`);
const load = () => $vm.moduleLoaderImport($vm.createModuleLoader(), importer);

writeFile(dep, version1);
const a = await load();
const readA = a.read(testLoopCount);
writeFile(dep, version2);
const b = await load();
const readB = b.read(testLoopCount);
const c = await load();
shouldBe(typeof $vm.codeBlockFor(c.read), "string"); // never called, and already has b's code
shouldBe(JSON.stringify([readA, a.read(1), readB, c.read(testLoopCount)]), `[["x1",1],["x1",1],["x2",2],["x2",2]]`);
shouldBe($vm.codeBlockFor(a.read) === $vm.codeBlockFor(b.read), false);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
16 changes: 16 additions & 0 deletions JSTests/modules/module-loaders-delete-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { shouldBe } from "./resources/assert.js";

// After all code is deleted, a new loader links the module afresh rather than
// adopting the executable earlier loaders used; later loaders share the new one.
const load = () => $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders/main.js");

const a = await load();
shouldBe(a.run(1000), 1000);
$vm.deleteAllCodeWhenIdle();
await new Promise((resolve) => setTimeout(resolve, 0));
const b = await load();
shouldBe(JSON.stringify([b.run(10), a.run(1)]), `[10,1001]`);
shouldBe($vm.codeBlockFor(a.run) === $vm.codeBlockFor(b.run), false);
const c = await load();
shouldBe(typeof $vm.codeBlockFor(c.run), "string"); // never called, and already has b's code
shouldBe(c.run(20), 20);
29 changes: 29 additions & 0 deletions JSTests/modules/module-loaders-scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { shouldBe, shouldThrow } from "./resources/assert.js";

globalThis.realGlobal = globalThis;
globalThis.marker = "global";

// A loader can give its modules a scope between them and the global scope; free
// identifiers of every module it loads resolve there first.
const loaderA = $vm.createModuleLoader({ who: "a", marker: 1 });
const a = await $vm.moduleLoaderImport(loaderA, "./module-loaders-scope/main.js");
const describeA = a.describe(testLoopCount);
const b = await $vm.moduleLoaderImport($vm.createModuleLoader({ who: "b", marker: 2 }, loaderA), "./module-loaders-scope/main.js");
// Loaders whose scopes have the same symbol table run the same code: b.describe was
// never called and already has a's.
shouldBe(typeof $vm.codeBlockFor(b.describe), "string");
shouldBe(JSON.stringify([describeA, b.describe(testLoopCount)]), `["a,dep:a,number,true","b,dep:b,number,true"]`);

// The scope's bindings are variables: assignable from the loader's modules, invisible elsewhere.
(await a.lazy()).setWho("a2");
shouldBe(JSON.stringify([a.describe(1), b.describe(1)]), `["a2,dep:a,number,true","b,dep:b,number,true"]`);
shouldThrow(() => who, `ReferenceError: who is not defined`);
shouldBe(a.evaluated(), "undefined");

// A loader without the scope, or with a scope of its own symbol table, links its own code.
globalThis.who = "global";
const plain = await $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders-scope/main.js");
const other = await $vm.moduleLoaderImport($vm.createModuleLoader({ marker: 3, extra: 0, who: "c" }), "./module-loaders-scope/main.js");
shouldBe(JSON.stringify([plain.describe(testLoopCount), other.describe(testLoopCount), a.describe(3)]), `["global,dep:global,string,true","c,dep:c,number,true","a2,dep:a,number,true"]`);
shouldBe($vm.codeBlockFor(plain.describe) === $vm.codeBlockFor(a.describe), false);
shouldBe($vm.codeBlockFor(other.describe) === $vm.codeBlockFor(a.describe), false);
2 changes: 2 additions & 0 deletions JSTests/modules/module-loaders-scope/dep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const tag = "dep:" + who;
export function setWho(value) { who = value; }
12 changes: 12 additions & 0 deletions JSTests/modules/module-loaders-scope/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { tag } from "./dep.js"

export function describe(n)
{
let result;
for (let i = 0; i < n; ++i)
result = [who, tag, typeof marker, globalThis === realGlobal].join();
return result;
}

export function evaluated() { return new Function("return typeof who")(); }
export const lazy = () => import("./dep.js");
32 changes: 32 additions & 0 deletions JSTests/modules/module-loaders-shared-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { shouldBe } from "./resources/assert.js";

// Records for the same module in different loaders run the same linked code
// (CodeBlocks, JIT code) against their own environments.
const n = testLoopCount;
const loaders = [];
for (let i = 0; i < 6; ++i)
loaders.push($vm.createModuleLoader());
const instance = (i) => $vm.moduleLoaderImport(loaders[i], "./module-loaders/main.js");

const a = await instance(0);
a.run(n);
const b = await instance(1);
shouldBe(typeof $vm.codeBlockFor(b.run), "string"); // never called, and already has a's code
b.run(n);
a.run(n);
shouldBe(JSON.stringify([a.read(), b.read()]), `[[${2 * n},${2 * n},true],[${n},${n},true]]`);

// Once a second instance exists the shared optimized code is instance-generic:
// further instances neither recompile it nor read another instance's bindings.
// (Compile counts are only deterministic without concurrent compilation.)
const compiles = numberOfDFGCompiles(a.run);
const reads = [];
for (let i = 2; i < 6; ++i) {
const m = await instance(i);
m.run(n + i);
reads.push(m.read()[0]);
}
shouldBe(JSON.stringify(reads), `[${n + 2},${n + 3},${n + 4},${n + 5}]`);
if (!jscOptions().useConcurrentJIT)
shouldBe(numberOfDFGCompiles(a.run), compiles);
shouldBe(JSON.stringify([a.read()[0], b.read()[0]]), `[${2 * n},${n}]`);
26 changes: 26 additions & 0 deletions JSTests/modules/module-loaders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { shouldBe } from "./resources/assert.js";
import * as own from "./module-loaders/main.js"

// A module loader created with $vm has its own registry: importing the same
// files through it links and evaluates them again, with their own state.
const a = await $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders/main.js");
const b = await $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders/main.js");

shouldBe(a === own || b === own || a === b, false);
shouldBe(JSON.stringify([own.run(1), a.run(2), b.run(3)]), `[1,2,3]`);
shouldBe(JSON.stringify([own.read(), a.read(), b.read()]), `[[1,1,true],[2,2,true],[3,3,true]]`);
shouldBe(a.counter === b.counter, false);

// import() inside a loader's module resolves in that loader.
shouldBe((await a.loadCounter()) === a.counter, true);
shouldBe((await b.loadCounter()) === b.counter, true);
shouldBe((await own.loadCounter()) === own.counter, true);
const [lazyA, lazyB] = [await a.loadLazy(), await b.loadLazy()];
shouldBe(lazyA === lazyB, false);
shouldBe(JSON.stringify([lazyA.hit(), lazyA.hit(), lazyB.hit()]), `[1,2,1]`);

// Import cycles link and evaluate per loader, including module code that runs
// before its own module is evaluated.
const cycleA = await $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders/cycle-a.js");
const cycleB = await $vm.moduleLoaderImport($vm.createModuleLoader(), "./module-loaders/cycle-a.js");
shouldBe(JSON.stringify([cycleA.fromB, cycleA.early, cycleB.fromB, cycleB.early]), `["bac","ac","bac","ac"]`);
1 change: 1 addition & 0 deletions JSTests/modules/module-loaders/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const c = "c";
3 changes: 3 additions & 0 deletions JSTests/modules/module-loaders/counter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export let count = 0;
export function increment() { return ++count; }
export const object = { tag: "object" };
6 changes: 6 additions & 0 deletions JSTests/modules/module-loaders/cycle-a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { c } from "./c.js"
import { b, early } from "./cycle-b.js"

export function a() { return "a" + c; }
export const fromB = b();
export { early };
4 changes: 4 additions & 0 deletions JSTests/modules/module-loaders/cycle-b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { a } from "./cycle-a.js"

export function b() { return "b" + a(); }
export const early = a();
2 changes: 2 additions & 0 deletions JSTests/modules/module-loaders/lazy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export let hits = 0;
export function hit() { return ++hits; }
18 changes: 18 additions & 0 deletions JSTests/modules/module-loaders/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { count, increment, object } from "./counter.js"
import * as counter from "./counter.js"

export function run(n)
{
for (let i = 0; i < n; ++i)
increment();
return count;
}

export function read()
{
return [count, counter.count, object === counter.object];
}

export const loadLazy = () => import("./lazy.js");
export const loadCounter = () => import("./counter.js");
export { counter };
1 change: 1 addition & 0 deletions Source/JavaScriptCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
runtime/JSStringIteratorInlines.h
runtime/JSStringJoiner.h
runtime/JSSymbolTableObject.h
runtime/JSSymbolTableObjectInlines.h
runtime/JSTemplateObjectDescriptor.h
runtime/JSTemplateObjectDescriptorInlines.h
runtime/JSType.h
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/builtins/BuiltinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ namespace JSC {
macro(copyDataProperties) \
macro(cloneObject) \
macro(meta) \
macro(moduleLoader) \
macro(instanceFieldInitializer) \
macro(privateBrand) \
macro(privateClassBrand) \
Expand Down
4 changes: 2 additions & 2 deletions Source/JavaScriptCore/bytecode/BytecodeList.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@
},
_1: { # offset 6
# written during linking
lexicalEnvironment: WriteBarrierBase[JSCell], # lexicalEnvironment && type == ModuleVar
symbolTable: WriteBarrierBase[SymbolTable], # lexicalEnvironment && type != ModuleVar
symbolTable: WriteBarrierBase[SymbolTable], # lexicalEnvironment (ClosureVar)
moduleImportSlot: unsigned, # ModuleVar: the import slot, as a variable index in the importing module environment

constantScope: WriteBarrierBase[JSScope],

Expand Down
45 changes: 12 additions & 33 deletions Source/JavaScriptCore/bytecode/CodeBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,20 +406,6 @@ CodeBlock::CodeBlock(VM& vm, Structure* structure, ScriptExecutable* ownerExecut
checker().set(CrashChecker::Metadata, checker().hash(this, m_metadata.get()));
}

static FunctionExecutable* instantiatedModuleFunctionExecutable(JSModuleEnvironment* moduleEnvironment, ScriptExecutable* topLevelExecutable, UnlinkedFunctionExecutable* unlinkedExecutable)
{
SymbolTableEntry::Fast entry = moduleEnvironment->symbolTable()->get(unlinkedExecutable->name().impl());
if (entry.isNull())
return nullptr;
auto* function = dynamicDowncast<JSFunction>(moduleEnvironment->variableAt(entry.scopeOffset()).get());
if (!function)
return nullptr;
auto* executable = dynamicDowncast<FunctionExecutable>(function->executable());
if (!executable || executable->unlinkedExecutable() != unlinkedExecutable || executable->topLevelExecutable() != topLevelExecutable)
return nullptr;
return executable;
}

// The main purpose of this function is to generate linked bytecode from unlinked bytecode. The process
// of linking is taking an abstract representation of bytecode and tying it to a GlobalObject and scope
// chain. For example, this process allows us to cache the depth of lexical environment reads that reach
Expand Down Expand Up @@ -449,10 +435,10 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink

// We already have the cloned symbol table for the module environment since we need to instantiate
// the module environments before linking the code block. We replace the stored symbol table with the already cloned one.
JSModuleEnvironment* moduleEnvironment = nullptr;
ModuleProgramExecutable* moduleProgramExecutable = nullptr;
if (UnlinkedModuleProgramCodeBlock* unlinkedModuleProgramCodeBlock = dynamicDowncast<UnlinkedModuleProgramCodeBlock>(unlinkedCodeBlock)) {
moduleEnvironment = uncheckedDowncast<JSModuleEnvironment>(scope);
SymbolTable* clonedSymbolTable = uncheckedDowncast<ModuleProgramExecutable>(ownerExecutable)->moduleEnvironmentSymbolTable();
moduleProgramExecutable = uncheckedDowncast<ModuleProgramExecutable>(ownerExecutable);
SymbolTable* clonedSymbolTable = moduleProgramExecutable->moduleEnvironmentSymbolTable();
if (m_unlinkedCode->wasCompiledWithTypeProfilerOpcodes()) {
ConcurrentJSLocker locker(clonedSymbolTable->m_lock);
clonedSymbolTable->prepareForTypeProfiling(locker);
Expand All @@ -472,9 +458,7 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink
UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock->functionDecl(i);
if (shouldUpdateFunctionHasExecutedCache)
vm.functionHasExecutedCache()->insertUnexecutedRange(ownerExecutable->sourceID(), unlinkedExecutable->unlinkedFunctionStart(), unlinkedExecutable->unlinkedFunctionEnd());
FunctionExecutable* executable = moduleEnvironment ? instantiatedModuleFunctionExecutable(moduleEnvironment, topLevelExecutable, unlinkedExecutable) : nullptr;
if (!executable)
executable = unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source(), std::nullopt, NoIntrinsic, ownerExecutable->isInsideOrdinaryFunction());
FunctionExecutable* executable = moduleProgramExecutable ? moduleProgramExecutable->functionDeclaration(vm, i) : unlinkedExecutable->link(vm, topLevelExecutable, ownerExecutable->source(), std::nullopt, NoIntrinsic, ownerExecutable->isInsideOrdinaryFunction());
m_functionDecls[i].set(vm, this, executable);
}

Expand Down Expand Up @@ -503,9 +487,6 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink
}
}

// Bookkeep the strongly referenced module environments.
UncheckedKeyHashSet<JSModuleEnvironment*> stronglyReferencedModuleEnvironments;

auto link_objectAllocationProfile = [&](const auto& /*instruction*/, auto bytecode, auto& metadata) {
metadata.m_objectAllocationProfile.initializeProfile(vm, m_globalObject.get(), this, m_globalObject->objectPrototype(), bytecode.m_inlineCapacity);
};
Expand Down Expand Up @@ -642,15 +623,11 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink

metadata.m_resolveType = op.type;
metadata.m_localScopeDepth = op.depth;
if (op.lexicalEnvironment) {
if (op.type == ModuleVar) {
// Keep the linked module environment strongly referenced.
if (stronglyReferencedModuleEnvironments.add(uncheckedDowncast<JSModuleEnvironment>(op.lexicalEnvironment)).isNewEntry)
addConstant(ConcurrentJSLocker(m_lock), op.lexicalEnvironment);
metadata.m_lexicalEnvironment.set(vm, this, op.lexicalEnvironment);
} else
metadata.m_symbolTable.set(vm, this, op.lexicalEnvironment->symbolTable());
} else if (JSScope* constantScope = JSScope::constantScopeForCodeBlock(op.type, this)) {
if (op.type == ModuleVar)
metadata.m_moduleImportSlot = op.moduleImportSlot;
else if (op.lexicalEnvironment)
metadata.m_symbolTable.set(vm, this, op.lexicalEnvironment->symbolTable());
else if (JSScope* constantScope = JSScope::constantScopeForCodeBlock(op.type, this)) {
metadata.m_constantScope.set(vm, this, constantScope);
if (op.type == GlobalProperty || op.type == GlobalPropertyWithVarInjectionChecks)
metadata.m_globalLexicalBindingEpoch = m_globalObject->globalLexicalBindingEpoch();
Expand Down Expand Up @@ -853,7 +830,7 @@ bool CodeBlock::finishCreation(VM& vm, ScriptExecutable* ownerExecutable, Unlink

// A module's heap-allocated function declarations got their FunctionExecutable when the module environment was created
// (moduleDeclarationInstantiation) and no new_func names them, so their entries stay null for good (the eager path
// looks the existing one up instead, instantiatedModuleFunctionExecutable()).
// takes them from the ModuleProgramExecutable, which owns them).
unsigned CodeBlock::firstLazilyMaterializedFunctionDecl() const
{
if (auto* unlinkedModuleProgramCodeBlock = dynamicDowncast<UnlinkedModuleProgramCodeBlock>(m_unlinkedCode.get()))
Expand Down Expand Up @@ -1906,6 +1883,8 @@ void CodeBlock::reconcileLLIntInlineCachesAtGCEnd()
// Right now this isn't strictly necessary. Any symbol tables that this will refer to
// are for outer functions, and we refer to those functions strongly, and they refer
// to the symbol table strongly. But it's nice to be on the safe side.
if (metadata.m_resolveType == ModuleVar)
return; // m_moduleImportSlot, not a cell.
WriteBarrierBase<SymbolTable>& symbolTable = metadata.m_symbolTable;
if (!symbolTable || vm.heap.isMarked(symbolTable.get()))
return;
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ BytecodeGenerator::BytecodeGenerator(VM& vm, ModuleProgramNode* moduleProgramNod
// Now declare all variables.

createVariable(m_vm.propertyNames->starNamespacePrivateName, VarKind::Scope, moduleEnvironmentSymbolTable, VerifyExisting);
createVariable(m_vm.propertyNames->builtinNames().moduleLoaderPrivateName(), VarKind::Scope, moduleEnvironmentSymbolTable, VerifyExisting);
if (moduleProgramNode->features() & ImportMetaFeature)
createVariable(m_vm.propertyNames->builtinNames().metaPrivateName(), VarKind::Scope, moduleEnvironmentSymbolTable, VerifyExisting);

Expand Down
11 changes: 6 additions & 5 deletions Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,17 @@ RegisterID* SuperNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds
RegisterID* ImportNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
{
RefPtr<RegisterID> importModule = generator.moveLinkTimeConstant(nullptr, LinkTimeConstant::importModule);
unsigned argumentCount = m_deferred ? 3 : (m_option ? 2 : 1);
CallArguments arguments(generator, nullptr, argumentCount);
CallArguments arguments(generator, nullptr, 4);
generator.emitLoad(arguments.thisRegister(), jsUndefined());
generator.emitNode(arguments.argumentRegister(0), m_expr);
if (m_option)
generator.emitNode(arguments.argumentRegister(1), m_option);
else if (m_deferred)
else
generator.emitLoad(arguments.argumentRegister(1), jsUndefined());
if (m_deferred)
generator.emitLoad(arguments.argumentRegister(2), jsBoolean(true));
generator.emitLoad(arguments.argumentRegister(2), jsBoolean(m_deferred));
Variable moduleLoader = generator.variable(generator.propertyNames().builtinNames().moduleLoaderPrivateName());
RefPtr<RegisterID> scope = generator.emitResolveScope(generator.newTemporary(), moduleLoader);
generator.emitGetFromScope(arguments.argumentRegister(3), scope.get(), moduleLoader, ThrowIfNotFound);
return generator.emitCall(generator.finalDestination(dst, importModule.get()), importModule.get(), NoExpectedFunction, arguments, divot(), divotStart(), divotEnd(), DebuggableCall::No);
}

Expand Down
Loading
Loading