implements PR-09.7: normalize compiler intrinsic registry loading to canonical artifact

This commit is contained in:
bQUARKz 2026-03-09 16:11:00 +00:00
parent fdef7fbc3e
commit 5c3e776b9f
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8

View File

@ -47,6 +47,7 @@ final class IRVMIntrinsicRegistry {
try (final var reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) { try (final var reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
String rawLine; String rawLine;
int lineNumber = 0; int lineNumber = 0;
Integer previousFinalId = null;
while ((rawLine = reader.readLine()) != null) { while ((rawLine = reader.readLine()) != null) {
lineNumber++; lineNumber++;
final var line = rawLine.trim(); final var line = rawLine.trim();
@ -64,7 +65,18 @@ final class IRVMIntrinsicRegistry {
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
throw new IllegalStateException("invalid intrinsic version at line " + lineNumber + ": " + line, ex); throw new IllegalStateException("invalid intrinsic version at line " + lineNumber + ": " + line, ex);
} }
if (canonicalName.isBlank()) {
throw new IllegalStateException("blank intrinsic name at line " + lineNumber + ": " + line);
}
if (canonicalVersion < 0) {
throw new IllegalStateException("negative intrinsic version at line " + lineNumber + ": " + line);
}
final int finalId = parseFinalId(columns[2].trim(), lineNumber, line); final int finalId = parseFinalId(columns[2].trim(), lineNumber, line);
if (previousFinalId != null && Integer.compareUnsigned(finalId, previousFinalId) <= 0) {
throw new IllegalStateException(
"intrinsic final ids must be strictly increasing for deterministic evolution at line "
+ lineNumber + ": " + line);
}
register(registry, canonicalName, canonicalVersion, finalId); register(registry, canonicalName, canonicalVersion, finalId);
final var identity = canonicalIdentity(canonicalName, canonicalVersion); final var identity = canonicalIdentity(canonicalName, canonicalVersion);
final var previous = identityByFinalId.putIfAbsent(finalId, identity); final var previous = identityByFinalId.putIfAbsent(finalId, identity);
@ -72,6 +84,7 @@ final class IRVMIntrinsicRegistry {
throw new IllegalStateException( throw new IllegalStateException(
"duplicate intrinsic final id 0x%08X for %s and %s".formatted(finalId, previous, identity)); "duplicate intrinsic final id 0x%08X for %s and %s".formatted(finalId, previous, identity));
} }
previousFinalId = finalId;
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new IllegalStateException("failed to read intrinsic registry resource: " + REGISTRY_RESOURCE, ex); throw new IllegalStateException("failed to read intrinsic registry resource: " + REGISTRY_RESOURCE, ex);