Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
34c7c01
AOT test runs: code from source asks for a preload's mock whose entry…
Jarred-Sumner Nov 16, 2026
eff6a66
AOT: a check of proofs follows a value through the head of a loop and…
Jarred-Sumner Nov 16, 2026
742a03a
AOT test runs: whether what a file imports threw in an earlier test file
Jarred-Sumner Nov 16, 2026
1989ffc
A store of code made at run time to a constant of a script throws
Jarred-Sumner Nov 16, 2026
76d6a7c
AOT: under proof checks a front asks again where what is narrowed hol…
Jarred-Sumner Nov 16, 2026
ad04c53
AOT test runs: an import whose load has passed a factory waits for it…
Jarred-Sumner Nov 16, 2026
bab053b
The module loader asks whether a process has compiled code in front o…
Jarred-Sumner Nov 16, 2026
7c11c65
AOT test runs: a require() under a second patch that waits is told of
Jarred-Sumner Nov 16, 2026
e3a6f90
AOT: the name 4294967295 is no name that a class says is absent
Jarred-Sumner Nov 16, 2026
d60e2c5
AOT test runs: what a test file's statements import runs in order in …
Jarred-Sumner Nov 16, 2026
4c26e98
AOT test runs: an original that ran in front of its factory leaves wi…
Jarred-Sumner Nov 16, 2026
7cdda59
AOT: a watched operation declares its user's accesses again only wher…
Jarred-Sumner Nov 16, 2026
25051fb
AOT: for-of calls the return() and next() that code lays on an iterat…
Jarred-Sumner Nov 16, 2026
56ec39e
AOT test runs: what a preload has run under its own mock keeps that m…
Jarred-Sumner Nov 16, 2026
c731074
AOT test runs: a package that a preload has run takes the mock that a…
Jarred-Sumner Nov 16, 2026
e58827b
Revert "AOT test runs: an original that ran in front of its factory l…
Jarred-Sumner Nov 17, 2026
376b38e
Revert "AOT test runs: what a test file's statements import runs in o…
Jarred-Sumner Nov 17, 2026
61bfe89
Revert "AOT test runs: a package that a preload has run takes the moc…
Jarred-Sumner Nov 17, 2026
e7fa8cb
Revert "AOT test runs: what a preload has run under its own mock keep…
Jarred-Sumner Nov 17, 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
3 changes: 2 additions & 1 deletion Source/JavaScriptCore/aot/codegen/AOTCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3304,6 +3304,7 @@ NEVER_INLINE void CodeGenerator::endScheduledLifetimes(const ValueContext& conte
NEVER_INLINE void CodeGenerator::generateWatched(const ValueContext& context)
{
const OperationContext* user = std::exchange(m_operation, &context);
const bool userDeclaresAccesses = user && m_out.hasDeclaredAccesses();
Machine::Origin originOfUser = m_out.origin();
m_out.setOrigin(machineOriginOf(context.id()));
bool userOwesFenceBehindStores = std::exchange(m_owesFenceBehindStores, false);
Expand All @@ -3323,7 +3324,7 @@ NEVER_INLINE void CodeGenerator::generateWatched(const ValueContext& context)
if (m_looksBehindEachOperation) [[unlikely]] {
if (barrierIsCountedOn(context.id()) && !m_storesBehindWhichOwnerIsRemembered.get(context.id().index()) && !m_hasFailed)
fail(context, InternalErrorKind::OpcodeNotInForm, "the barrier of an earlier store is left to this one, and the code of this one does not remember its owner"_s);
if (m_checksAllocation && user)
if (m_checksAllocation && userDeclaresAccesses)
declareAccessesSlow(*user);
else if (m_checksAllocation)
m_out.clearDeclaredAccesses();
Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/aot/machine/AOTMachineBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Builder {

JS_EXPORT_PRIVATE void setDeclaredAccesses(const HeapSet& reads, const HeapSet& writes);
JS_EXPORT_PRIVATE void clearDeclaredAccesses();
bool hasDeclaredAccesses() const { return m_suspensionsOfDeclaredAccesses ? m_hadDeclaredAccessesWhenSuspended : m_hasDeclaredAccesses; }
void suspendDeclaredAccesses()
{
if (!m_suspensionsOfDeclaredAccesses++) {
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/aot/runtime/AOTModuleEvaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5285,7 +5285,7 @@ JSValue Modules::answerRequire(ModuleID target, ModuleID referrer, RequiredBy re
tellOfFilesThatStayedLoadedBelow(target);
if (m_modulesReleasedByLoader.get(target.index()) && !hasInstances(target)) [[unlikely]]
bringBackWhatLoaderLetGoBelow(target);
if (isEvaluatedUnderPendingPatch(target)) [[unlikely]]
if (isEvaluatedUnderPendingPatch(target, referrer)) [[unlikely]]
tellThatFileDidNotRunAgain(fileOf(target));
if (!m_modulesWithRunningFactory.isEmpty()) [[unlikely]]
tellIfFactoryIsRunning(target, LoadKind::Require);
Expand Down
2 changes: 2 additions & 0 deletions Source/JavaScriptCore/aot/runtime/AOTModuleHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ JS_EXPORT_PRIVATE bool wasDisplacedDuringEvaluation(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool wasRegisteredByFailedLoad(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool wasLinkedBeforeTestFile(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool wasLinkedByFailedGraph(JSGlobalObject*, ModuleID, bool byEarlierTestFile = false);
JS_EXPORT_PRIVATE bool failedWithImportInEarlierTestFile(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool wasLinkedBeforeLinkFailure(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool hasImporterLinkedBeforeFailure(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool isLinkedForPendingImporter(JSGlobalObject*, ModuleID, std::optional<ModuleID> asking);
Expand Down Expand Up @@ -441,6 +442,7 @@ JS_EXPORT_PRIVATE bool fulfillDeferredFetches(VM&, uint64_t completedDiskReads =
JS_EXPORT_PRIVATE void didDrainDeferredFetchJobs(VM&);
JS_EXPORT_PRIVATE std::optional<uint32_t> firstDeferredBatchNumber(VM&);
JS_EXPORT_PRIVATE bool shouldDeferFetchFulfillment(JSGlobalObject*, ModuleID);
JS_EXPORT_PRIVATE bool isImportedByLoad(JSGlobalObject*, ModuleID root, ModuleID file);
JS_EXPORT_PRIVATE void deferFetchFulfillment(JSGlobalObject*, ModuleID, JSPromise* fetched, AbstractModuleRecord*);
JS_EXPORT_PRIVATE void didFetch(JSGlobalObject*, AbstractModuleRecord*);
JS_EXPORT_PRIVATE void noteHostImportInFlight(JSGlobalObject*, ModuleID, JSPromise*, bool isFromOwnFactory);
Expand Down
5 changes: 3 additions & 2 deletions Source/JavaScriptCore/aot/runtime/AOTModuleInstances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3469,14 +3469,15 @@ void Modules::reportImportersWithoutInstances(ModuleID module)
}
}

bool Modules::isEvaluatedUnderPendingPatch(ModuleID module)
bool Modules::isEvaluatedUnderPendingPatch(ModuleID module, ModuleID requirer)
{
ModuleID file = fileOf(module);
if (!host().isPatchPending || status(file) != ModuleStatus::Evaluated || !m_table.hasFilePath(file)) [[likely]]
return false;
if (!isPatchPending(file)) [[likely]]
return false;
if (activeMock(file) || hasIntactOriginal(file) || isPatchedByMock(file) || m_originalsEvaluatedUnderMock.get(file.index()) || hasRunBesideMockAlone(file))
bool isPatchedForRequirer = isPatchedByMock(file) && !(requirer && data(requirer).isEntryPoint());
if (activeMock(file) || hasIntactOriginal(file) || isPatchedForRequirer || m_originalsEvaluatedUnderMock.get(file.index()) || hasRunBesideMockAlone(file))
return false;
return data(file).kind == ModuleKind::CommonJs ? wasLoadedByImport(file) : !!currentInstance(file);
}
Expand Down
7 changes: 7 additions & 0 deletions Source/JavaScriptCore/aot/runtime/AOTModuleRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "AOTRecordTypes.h"
#include "AOTVector.h"
#include "CyclicModuleRecord.h"
#include "VM.h"
#include <wtf/BitVector.h>
#include <wtf/HashSet.h>
#include <wtf/OrderedHashSet.h>
Expand Down Expand Up @@ -224,6 +225,12 @@ class ModuleRecord final : public CyclicModuleRecord {
WriteBarrier<JSCell> m_moduleInstance;
};

template<typename T>
ALWAYS_INLINE ModuleRecord* compiledModule(const VM& vm, T module)
{
return vm.hasCompiledCode() ? dynamicDowncast<ModuleRecord>(module) : nullptr;
}

void tryBindOriginal(JSGlobalObject*, JSModuleRecord*);
void noteOriginalsRequestedBySource(JSGlobalObject*, JSModuleRecord* importer);
void linkOriginal(JSGlobalObject*, JSModuleRecord*);
Expand Down
10 changes: 10 additions & 0 deletions Source/JavaScriptCore/aot/runtime/AOTModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5602,6 +5602,10 @@ JSPromise* Modules::startImport(ModuleID module, std::optional<int64_t> referrer
factories = pendingFactoryInGraph(module, askedBy, importWaitState);
RETURN_IF_EXCEPTION(scope, rejectedPromiseWithPendingException(realm, scope));
}
if (!factories && text != ImportSourceState::MayArriveLater && askedBy == PendingFactoryRequester::ImportCall) [[unlikely]] {
factories = pendingFactoryInGraph(module, PendingFactoryRequester::ImportCallAfterSource, importWaitState);
RETURN_IF_EXCEPTION(scope, rejectedPromiseWithPendingException(realm, scope));
}
if (!factories && needsOriginal) [[unlikely]] {
factories = ensureActualKeyLoad(fileOf(module));
RETURN_IF_EXCEPTION(scope, rejectedPromiseWithPendingException(realm, scope));
Expand Down Expand Up @@ -9340,6 +9344,12 @@ bool wasLinkedByFailedGraph(JSGlobalObject* realm, ModuleID module, bool byEarli
return modules && modules->wasLinkedByFailedGraph(module, byEarlierTestFile);
}

bool failedWithImportInEarlierTestFile(JSGlobalObject* realm, ModuleID module)
{
Modules* modules = modulesOf(realm);
return modules && modules->failedWithImportInEarlierTestFile(module);
}

bool hasImporterLinkedBeforeFailure(JSGlobalObject* realm, ModuleID module)
{
Modules* modules = modulesOf(realm);
Expand Down
4 changes: 3 additions & 1 deletion Source/JavaScriptCore/aot/runtime/AOTModules.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ class Modules {
void forgetLoadsRefusedByCheckOfNames(ModuleID mocked);
bool wasRegisteredByFailedLoad(ModuleID) const;
bool wasLinkedByFailedGraph(ModuleID, bool byEarlierTestFile);
bool failedWithImportInEarlierTestFile(ModuleID);
bool isImportedByFailedRoot(ModuleID, bool ofEarlierTestFile = false) const;
bool wasReachedByFailedGraph(ModuleID) const;
bool isFailedLoadRoot(ModuleID module) const { return m_loadRoots.get(module.index()) && status(module) == ModuleStatus::Failed; }
Expand Down Expand Up @@ -1491,7 +1492,7 @@ class Modules {
bool isRequiredModulePatchPending(ModuleID);
std::optional<JSPromise*> importOriginalUnderPatch(ModuleID, ModuleID referrer, const RefPtr<ScriptFetchParameters>&);
bool isPatchPending(ModuleID file) const;
bool isEvaluatedUnderPendingPatch(ModuleID);
bool isEvaluatedUnderPendingPatch(ModuleID, ModuleID requirer);
void tellIfFactoryIsRunning(ModuleID requested, LoadKind);
void tellIfPatchIsPending(ModuleID required);
bool isRequireUnderPendingMock(ModuleID required, ModuleID requirer);
Expand Down Expand Up @@ -1928,6 +1929,7 @@ class Modules {
void fulfillQueuedFetch(JSPromise*);
void fulfillQueuedFetchAfterJobs(JSPromise*);
bool isOriginalLoaded(ModuleID);
bool isImportedByLoad(ModuleID root, ModuleID file) const;
enum class AskedBy : bool { Loader, Import };
bool textOfImportComesInLaterTurn(ModuleID, AskedBy);
bool hasTextAtHand() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ static bool isFunctionOwnName(VM& vm, UniquedStringImpl* uid)

bool isNeverCachedName(VM& vm, UniquedStringImpl* uid)
{
if (uid->length() == 10 && equal(uid, "4294967295"_s)) [[unlikely]]
return true;
return parseIndex(PropertyName(uid)) || uid == vm.propertyNames->underscoreProto.impl() || (PropertyName(uid).isPrivateName() && !PropertyName(uid).passesThroughProxies());
}

Expand Down
26 changes: 23 additions & 3 deletions Source/JavaScriptCore/aot/runtime/AOTTestRunFactories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,17 @@ bool Modules::wasLinkedByFailedGraph(ModuleID module, bool byEarlierTestFile)
return data(module).isESModuleOfProgram() && !data(module).isFacade() && status(module) <= ModuleStatus::Linked && !hasRun(module) && !didCaptureExports(module) && (!byEarlierTestFile || !wasLoadedByTestFile(module)) && isImportedByFailedRoot(module, byEarlierTestFile);
}

bool Modules::failedWithImportInEarlierTestFile(ModuleID module)
{
if (!isFailedESModule(module) || isMocked(module) || activeMock(module) || m_loadedInPreload.get(module.index()) || wasLoadedByTestFile(module))
return false;
for (size_t index : staticImportClosure(module, MockTraversal::Continue)) {
if (ModuleID imported(index); imported != module && isFailedESModule(imported) && !isMocked(imported))
return true;
}
return false;
}

bool Modules::wasReachedByFailedGraph(ModuleID module) const
{
for (uint32_t index = 0; index < m_table.size(); ++index) {
Expand Down Expand Up @@ -1347,17 +1358,26 @@ bool Modules::runMocksInFetchedGraphSlow(ModuleID module)
return false;
evaluateModulesOwedBelow(module);
RETURN_IF_EXCEPTION(scope, false);
scope.release();
if (m_modulesWithPendingMock.isEmpty()) [[likely]]
auto noteRequest = [&] {
if (data(module).isESModuleOfProgram() && wasActiveMockEntryRemoved(module))
noteImportUnderMockInPlace(module);
};
if (m_modulesWithPendingMock.isEmpty()) [[likely]] {
noteRequest();
return false;
}
bool isAskedForByImportCall = m_instance.vm->aotState().importFrameInLoader;
if (isAskedForByImportCall)
clearCachedMockError(module);
m_mocksWhoseFactoriesRanInsideTheirFetch.set(module.index(), m_modulesWithPendingMock.get(module.index()));
SetForScope moduleBeingFetched(m_moduleBeingFetched, loadOfFetch(module));
bool wasFetchedForStatement = m_statementFetchesDelayedByTick.get(module.index());
m_statementFetchesDelayedByTick.clear(module.index());
return runMocksInGraph(module, wasFetchedForStatement || (!isAskedForByImportCall && isFetchedForImportStatement(module)) ? LoadRootKind::ImportStatement : LoadRootKind::StartsLoad);
bool hasCalledWaitingFactory = runMocksInGraph(module, wasFetchedForStatement || (!isAskedForByImportCall && isFetchedForImportStatement(module)) ? LoadRootKind::ImportStatement : LoadRootKind::StartsLoad);
RETURN_IF_EXCEPTION(scope, false);
if (!hasCalledWaitingFactory)
noteRequest();
return hasCalledWaitingFactory;
}

void Modules::willFetchAfterTick(ModuleID module)
Expand Down
20 changes: 20 additions & 0 deletions Source/JavaScriptCore/aot/runtime/AOTTestRunImportTurns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ bool Modules::isFetchedBesideFactory(ModuleID module)
return false;
}

bool Modules::isImportedByLoad(ModuleID root, ModuleID file) const
{
for (size_t index : modulesInLoadGraph(root)) {
ModuleID importer(index);
if (isCommonJSModuleOrFacade(importer) || status(importer) >= ModuleStatus::Evaluating)
continue;
for (const ModuleRequestData& request : m_table.imports(importer)) {
if (fileOf(moduleLoadedBy(request)) == file)
return true;
}
}
return false;
}

bool Modules::textOfImportComesInLaterTurn(ModuleID module, AskedBy askedBy)
{
ModuleID file = fileOf(module);
Expand Down Expand Up @@ -923,6 +937,12 @@ bool wasOriginalRequiredFirst(JSGlobalObject* realm, ModuleID file)
return modules && modules->wasOriginalRequiredFirst(file);
}

bool isImportedByLoad(JSGlobalObject* realm, ModuleID root, ModuleID file)
{
Modules* modules = modulesOf(realm);
return modules && modules->isImportedByLoad(root, file);
}

bool isMockUnseen(JSGlobalObject* realm, ModuleID mocked)
{
Modules* modules = modulesOf(realm);
Expand Down
79 changes: 62 additions & 17 deletions Source/JavaScriptCore/aot/walk/AOTCodeVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class CodeVerifier {
void verifyUsersOfReadNumbers();
bool treatsUndefinedAsNaN(ValueID, const Operation& user, uint32_t operandIndex) const;
bool isOperatorSpecializationCheck(ValueID test) const;
bool failingEdgeLeavesScope(ValueID test) const;
void verifyTestsPassed();
void verifyLengthsHeldAgainst();
void verifyDataViewAccesses();
Expand Down Expand Up @@ -1487,6 +1488,10 @@ bool CodeVerifier::isOperatorSpecializationCheck(ValueID test) const
BitVector names(m_code.numberOfValues());
bool isUsedOnPass = false;
bool isUsedOnFailure = false;
bool isUsedByOtherOperator = false;
const bool isAtInlinedCall = std::ranges::any_of(m_code.inlineFrames().subspan(1), [&](const InlineFrame& copied) {
return copied.parent == asked.inlineFrame && copied.callPosition == asked.position;
});
for (bool someNameIsNew = true; std::exchange(someNameIsNew, false);) {
for (BlockID block : m_reachedBlocks) {
for (ValueID id : operationsOf(block)) {
Expand All @@ -1502,32 +1507,52 @@ bool CodeVerifier::isOperatorSpecializationCheck(ValueID test) const
name = m_code.at(name).operand(0);
return m_code.at(name).isOnTakenEdge();
};
BitVector isBehindFailingEdge(m_code.numberOfBlocks());
const BlockID blockOfTest = m_code.blockOf(test);
if (EdgeID fails = findAnswerEdge(test, false, blockOfTest)) {
Vector<BlockID, 16> waiting { m_code.at(fails).to };
while (!waiting.isEmpty()) {
BlockID block = waiting.takeLast();
if (!isReached(block) || dominates(headOf(block), headOf(blockOfTest)) || isBehindFailingEdge.set(block.index()))
continue;
m_code.forEachEdgeOf(block, [&](EdgeID, const Edge& edge) {
waiting.append(edge.to);
});
auto arrivesIn = [](const BitVector& found, ValueID value) { return value && found.get(value.index()); };
auto followThroughParameters = [&](BitVector& found, const auto& isFirst) {
for (bool someArrivesFurther = true; std::exchange(someArrivesFurther, false);) {
for (BlockID block : m_reachedBlocks) {
for (ValueID id : operationsOf(block)) {
const Operation& record = m_code.at(id);
if (valuePreservingOpcodes.contains(record.opcode) && !names.get(id.index()) && arrivesIn(found, record.operand(0)) && !found.set(id.index()))
someArrivesFurther = true;
}
m_code.forEachEdgeOf(block, [&](EdgeID, const Edge& edge) {
std::span<const ValueID> parameters = m_code.at(edge.to).parameters();
std::span<const ValueID> arguments = edge.arguments();
for (size_t place = 0; place < std::min(arguments.size(), parameters.size()); ++place) {
if (arguments[place] && (arrivesIn(found, arguments[place]) || isFirst(arguments[place])) && !found.set(parameters[place].index()))
someArrivesFurther = true;
}
});
}
}
}
};
BitVector arrivals(m_code.numberOfValues());
followThroughParameters(arrivals, [&](ValueID argument) { return names.get(argument.index()) && isOnPassingEdge(argument); });
BitVector arrivalsOfValue(m_code.numberOfValues());
arrivalsOfValue.set(asked.valueOperand().index());
followThroughParameters(arrivalsOfValue, [&](ValueID argument) { return names.get(argument.index()) && !isOnPassingEdge(argument); });
for (BlockID block : m_reachedBlocks) {
for (ValueID id : operationsOf(block)) {
const Operation& user = m_code.at(id);
for (uint32_t operandIndex = 0; operandIndex < user.numberOfOperands(); ++operandIndex) {
const bool isOperator = (allRelations | arithmeticOnTwoNumbersInCodeVerifier).contains(user.opcode) && user.position == asked.position && user.inlineFrame == asked.inlineFrame;
isUsedOnPass |= isOperator && arrivesIn(arrivals, user.operand(operandIndex));
isUsedOnFailure |= isOperator && arrivesIn(arrivalsOfValue, user.operand(operandIndex));
if (user.operand(operandIndex) == test && (user.opcode != Opcode::Narrowed || user.valueOperand() == test))
return false;
if (user.operand(operandIndex) == asked.valueOperand() && (allRelations | arithmeticOnTwoNumbersInCodeVerifier).contains(user.opcode) && user.position == asked.position && user.inlineFrame == asked.inlineFrame && isBehindFailingEdge.get(block.index()))
if (user.operand(operandIndex) == asked.valueOperand() && (allRelations | arithmeticOnTwoNumbersInCodeVerifier).contains(user.opcode) && user.position == asked.position && user.inlineFrame == asked.inlineFrame)
isUsedOnFailure = true;
if (!user.operand(operandIndex) || !names.get(user.operand(operandIndex).index()) || names.get(id.index()))
continue;
if (user.position != asked.position || user.inlineFrame != asked.inlineFrame)
return false;
(isOnPassingEdge(user.operand(operandIndex)) ? isUsedOnPass : isUsedOnFailure) = true;
bool isOnPass = isOnPassingEdge(user.operand(operandIndex));
if (user.position != asked.position || user.inlineFrame != asked.inlineFrame) {
bool isArithmetic = user.opcode != Opcode::TypeTest && treatsUndefinedAsNaN(id, user, operandIndex);
if (!isArithmetic || !isOnPass || !isAtInlinedCall)
return false;
isUsedByOtherOperator = true;
}
(isOnPass ? isUsedOnPass : isUsedOnFailure) = true;
}
}
const Terminator& end = m_code.at(block).terminator;
Expand All @@ -1542,7 +1567,27 @@ bool CodeVerifier::isOperatorSpecializationCheck(ValueID test) const
if (isEdgeArgument)
return false;
}
return isUsedOnPass && isUsedOnFailure;
return isUsedOnPass && ((isUsedOnFailure && !isUsedByOtherOperator) || failingEdgeLeavesScope(test));
}

bool CodeVerifier::failingEdgeLeavesScope(ValueID test) const
{
ValueID value = m_code.at(test).valueOperand();
bool leavesScope = false;
for (BlockID block : m_reachedBlocks) {
EdgeID edge = findAnswerEdge(test, false, block);
if (!edge)
continue;
BlockID to = m_code.at(edge).to;
for (uint32_t step = 0; isDefinedWhereBlockMayThrow(value, to); ++step) {
const Terminator& end = m_code.at(to).terminator;
if (step == m_code.numberOfBlocks() || end.kind != TerminatorKind::Jump || !std::ranges::all_of(operationsOf(to), [&](ValueID id) { return m_code.at(id).traits().isPure(); }))
return false;
to = m_code.at(end.next()).to;
}
leavesScope = true;
}
return leavesScope;
}

bool CodeVerifier::treatsUndefinedAsNaN(ValueID id, const Operation& user, uint32_t operandIndex) const
Expand Down
Loading
Loading