Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions bootstrap/omega/compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ Every arm and the fallback must meet that bound. When a predicate selects
an arm, the checker may use its truth value to bound that arm's result.
A literal-pattern comparison introduces no predicate fact. [Match bounds](../../../tests/fixtures/bootstrap/compiler_cases/match_bounds)

Inside a transition block, `env.depth > 0` can justify
`env.depth = env.depth - 1`. The guard applies while the assignment evaluates
its operands. A write ends a guard over mutable storage, and an effectful
operand ends it before the operand runs. Guards over immutable scalar inputs
survive later writes. [Block guard cases](../../../tests/fixtures/bootstrap/compiler_cases/transition_block_guards)

### Private helper arrivals

A private nested helper with no authored `requires` can infer one unsigned
Expand Down Expand Up @@ -170,10 +176,10 @@ The manifest, not directory enumeration or path order, selects and orders D's
members. `mbx xtask source-closure` validates every
declared length, digest, source byte, path, strictly increasing stable
identity, and exact source inventory before concatenating bytes without separators.
The manifest materializes 1,808,835 bytes with SHA-256
`5b605a6ec9972f2f8fdd6b91221d17dc430d85ab8cd9144a0d9f1f4a3c39faa5`.
The manifest materializes 1,811,233 bytes with SHA-256
`034ea4e45e502bc0b70ef8afdf90354ba4cfec5274bda500bf95e0f5aa1bad1f`.
The manifest itself is 11,099 bytes, SHA-256
`472e371d046661c74ea7e4fbc5ab5e576fd058e3d36d8c0fb60813808d9b117d`;
`cbb4b48d0fe4f42d3169589bce8dd180f73c33c2d740bda21a4a50add1c641ec`;
`tools/bootstrap/omega/compiler_env.sh` checks both identities against every
materialization. The source-closure verifier checks the resulting packed bytes.
A digest binds source custody; it does not prove compiler correctness.
Expand Down
15 changes: 13 additions & 2 deletions bootstrap/omega/compiler/checking/branch_facts.epsilon
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,19 @@ machine OmegaScalarCompiler::check_guarded_transition(
transition default_truth >= 0 { true -> candidate(row, row.subject, default_truth) _ -> plain() }
}
machine candidate(row: OmegaTransitionStatementSyntax, condition: i32, truth: i32) {
transition (condition >= 0) && (self.pure_value(condition) == 1) &&
((self.pure_transition_target(row) == 1) || (self.stable_predicate(state_index, condition) == 1)) {
transition (condition >= 0) && (self.pure_value(condition) == 1) {
true -> target(row, condition, truth)
_ -> plain()
}
}
machine target(row: OmegaTransitionStatementSyntax, condition: i32, truth: i32) {
transition row.target_kind {
OmegaTransitionTargetKind::Block{first, end} -> guarded(condition, truth, self.value_guard)
_ -> operands(row, condition, truth)
}
}
machine operands(row: OmegaTransitionStatementSyntax, condition: i32, truth: i32) {
transition (self.pure_transition_target(row) == 1) || (self.stable_predicate(state_index, condition) == 1) {
true -> guarded(condition, truth, self.value_guard)
_ -> plain()
}
Expand Down
91 changes: 66 additions & 25 deletions bootstrap/omega/compiler/checking/transition_blocks.epsilon
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,83 @@ machine OmegaScalarCompiler::check_arm_value(@mutable self, source: @[u8], owner
machine OmegaScalarCompiler::check_transition_body(@mutable self, source: @[u8], owner: i32,
state: i32, first: i32, end: i32) -> i32 {
let base: i32 = self.parser.machine_states[self.local_state_row(state)].first_statement;
transition true { true -> statement(first, base) }
machine statement(index: i32, base: i32) {
transition index < end { true -> item(index, base, self.parser.statements[index]) _ -> return 1 }
let outer: OmegaBranchFact = self.value_guard;
let ok: i32 = self.check_transition_statements(source, owner, state, base, first, end,
self.stable_predicate(state, outer.condition));
self.value_guard = outer;
return ok;
}

// Operands of an assignment run before the write. A guard over mutable
// storage can justify those operands, then expires before the next statement.
// An effectful operand may already have changed the storage before it is read.
machine OmegaScalarCompiler::check_transition_statements(@mutable self, source: @[u8], owner: i32,
state: i32, base: i32, first: i32, end: i32, stable: i32) -> i32 {
transition true { true -> statement(first) }
machine statement(index: i32) {
transition index < end { true -> item(index, self.parser.statements[index]) _ -> return 1 }
}
machine item(index: i32, base: i32, row: OmegaStatementSyntax) {
machine item(index: i32, row: OmegaStatementSyntax) {
transition row.kind {
OmegaStatementKind::LocalData -> local(index, base, row.item_index)
OmegaStatementKind::Assignment -> store(index, base, self.parser.assignment_statements[row.item_index])
OmegaStatementKind::MatchTest -> advance(index, base,
self.check_value(source, owner, state, index - base, row.item_index, 1))
OmegaStatementKind::MatchOtherwise -> statement(index + 1, base)
OmegaStatementKind::MatchEnd -> statement(index + 1, base)
OmegaStatementKind::ArmJoin -> statement(index + 1, base)
OmegaStatementKind::ArmResult -> advance(index, base, self.check_arm_value(source, owner, state,
index - base, row.item_index, self.arm_returns_result(index),
self.parser.transition_statements[self.parser.statements[first - 1].item_index].target.start))
OmegaStatementKind::LocalData -> local(index, row.item_index, self.parser.local_data_statements[row.item_index])
OmegaStatementKind::Assignment -> store(index, self.parser.assignment_statements[row.item_index])
OmegaStatementKind::MatchTest -> test(index, row.item_index)
OmegaStatementKind::MatchOtherwise -> statement(index + 1)
OmegaStatementKind::MatchEnd -> statement(index + 1)
OmegaStatementKind::ArmJoin -> statement(index + 1)
OmegaStatementKind::ArmResult -> result(index, row.item_index)
_ -> unsupported()
}
}
machine advance(index: i32, base: i32, ok: i32) {
transition ok { 1 -> statement(index + 1, base) _ -> return 0 }
machine advance(index: i32, ok: i32) {
transition ok { 1 -> statement(index + 1) _ -> return 0 }
}
machine local(index: i32, base: i32, item: i32) {
transition self.check_declared_local(source, owner, state, index - base, item) {
1 -> statement(index + 1, base)
_ -> return 0
}
machine test(index: i32, subject: i32) {
self.retain_statement_fact(stable, subject);
transition true { true -> advance(index, self.check_value(source, owner, state, index - base, subject, 1)) }
}
machine store(index: i32, base: i32, row: OmegaAssignmentStatementSyntax) {
transition self.check_store_value(source, owner, state, index - base, row.target, row.value, row.start) {
1 -> statement(index + 1, base)
_ -> return 0
machine result(index: i32, expression: i32) {
self.retain_statement_fact(stable, expression);
transition true { true -> advance(index, self.check_arm_value(source, owner, state,
index - base, expression, self.arm_returns_result(index),
self.parser.transition_statements[self.parser.statements[first - 1].item_index].target.start)) }
}
machine local(index: i32, slot: i32, row: OmegaLocalDataStatementSyntax) {
transition row.has_initial_value {
1 -> initializer(index, slot, row.initial_value)
_ -> declared(index, slot)
}
}
machine initializer(index: i32, slot: i32, value: i32) {
self.retain_statement_fact(stable, value);
transition true { true -> declared(index, slot) }
}
machine declared(index: i32, slot: i32) {
transition true { true -> advance(index, self.check_declared_local(source, owner, state, index - base, slot)) }
}
machine store(index: i32, row: OmegaAssignmentStatementSyntax) {
self.retain_statement_fact(stable, row.target);
self.retain_statement_fact(stable, row.value);
let ok: i32 = self.check_store_value(source, owner, state, index - base, row.target, row.value, row.start);
transition stable { 1 -> advance(index, ok) _ -> wrote(index, ok) }
}
machine wrote(index: i32, ok: i32) {
self.value_guard.condition = -1;
transition true { true -> advance(index, ok) }
}
machine unsupported() {
self.record_incomplete(4, self.parser.transition_statements[self.parser.statements[first - 1].item_index].target.start);
return 0;
}
}

machine OmegaScalarCompiler::retain_statement_fact(@mutable self, stable: i32, expression: i32) {
transition (self.value_guard.condition >= 0) && (stable == 0) && (expression >= 0) {
true -> operand()
_ -> return
}
machine operand() {
transition self.pure_value(expression) { 1 -> return _ -> expires() }
}
machine expires() { self.value_guard.condition = -1; }
}
4 changes: 2 additions & 2 deletions bootstrap/omega/compiler/omega_compiler.epsilon.sources
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ member 000000000000000000000000000000000000000000000000000000000000001e 2188 082
member 000000000000000000000000000000000000000000000000000000000000001f 6960 5b182ad7696fd95c62ff7f80ecfc21f79d8b081106eb1b68fcfe36c72dc56a4b checking/word_bounds.epsilon
member 0000000000000000000000000000000000000000000000000000000000000020 29912 1617a5453c1b80f21a755aa4dff8c50a7692cf37f73d59b57e1c5062f1917541 checking/entry_bounds.epsilon
member 0000000000000000000000000000000000000000000000000000000000000021 10366 ac443ce9b16f4085c8ff768d679ccd01e8a6205e6e8b5d63dfd8c61a78c1b3c3 checking/invocation_cycles.epsilon
member 0000000000000000000000000000000000000000000000000000000000000022 12144 317ded59db6eee26f6379d864ad51db86f4f3307440c8d9cc03909b36f223462 checking/branch_facts.epsilon
member 0000000000000000000000000000000000000000000000000000000000000022 12619 1700700a488d06cb52ebb4b01f0c76ee4ca9701f221887e7f1116e0f945a3988 checking/branch_facts.epsilon
member 0000000000000000000000000000000000000000000000000000000000000023 10894 23bd6fe3954567fa63a81d6f27ade9ac865d06fc7bdef8774f507c648080d747 checking/guard_comparisons.epsilon
member 0000000000000000000000000000000000000000000000000000000000000024 2621 d8b35d25fce0aaa007965dc75f0b5581ad4a9fd1d3c915784aae52407bf1b351 checking/terminal_backing.epsilon
member 0000000000000000000000000000000000000000000000000000000000000025 3977 7ea1b88416f16cc9a32c205ba944387cc26c654211038e0266ad2174291d97aa checking/natural_ranking.epsilon
Expand All @@ -50,7 +50,7 @@ member 0000000000000000000000000000000000000000000000000000000000000030 2996 c18
member 0000000000000000000000000000000000000000000000000000000000000031 5705 c32a861511ea4608ea8e409a436edec01f98ed33237aca448e466432b12b5fb5 alpha/byte_observations.epsilon
member 0000000000000000000000000000000000000000000000000000000000000032 5962 de8d72229ece1034a13e425e87c824fc138dc1adafc37a5addfbacb11a9296b6 resolution/type_aliases.epsilon
member 0000000000000000000000000000000000000000000000000000000000000033 5300 e2762c27ee4c6e0076daf0949462b574ecca8e24bc8d5e1032a9ee38d74b1770 checking/stores.epsilon
member 0000000000000000000000000000000000000000000000000000000000000034 4619 0494302678a2f578a6e8511272379d879b28c0f27a549ac91637d93d6d27b957 checking/transition_blocks.epsilon
member 0000000000000000000000000000000000000000000000000000000000000034 6542 2f2d7eb70a668273ef554c8bab1ce86f271622cf1995aa838f4de6a9ced801e3 checking/transition_blocks.epsilon
member 0000000000000000000000000000000000000000000000000000000000000035 4884 fedb94079ff841b7b7fd90f63ff2e69df4b7ffbfe693be19fe56e944702153c2 alpha/transition_blocks.epsilon
member 0000000000000000000000000000000000000000000000000000000000000036 14106 fd66b0587778e2bd59c6aa22cad1863b994f712cf7daca8aec4ba215e48e40e6 checking/slice_extent.epsilon
member 0000000000000000000000000000000000000000000000000000000000000037 16148 eb1a64ac7ce96878c04390426a50c412f5fadb157dd61f1b0c78e16c9c9b5b6a checking/unsigned_equations.epsilon
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap/interpreted/gate_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def require_rung_identities(directory, adapter):
require_identity("execution adapter", adapter, 2150,
"ab79416b4278d3b132a4fd432485f1b90e868c0549af96e604e2e8da570d1baa")
compiler = (directory / "omega_compiler.epsilon").read_bytes()
require_identity("D", compiler, 1808835,
"5b605a6ec9972f2f8fdd6b91221d17dc430d85ab8cd9144a0d9f1f4a3c39faa5")
require_identity("D", compiler, 1811233,
"034ea4e45e502bc0b70ef8afdf90354ba4cfec5274bda500bf95e0f5aa1bad1f")
return compiler, epsilon


Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap/interpreted/omega-executable/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def main():
require_identity("Delta compiler", delta_compiler, 152411,
"cfa4f2a6f75352d819a83486169bd517ab48ecf90246c561e47a809309ccc25f")
compiler = (directory / "omega_compiler.epsilon").read_bytes()
require_identity("D", compiler, 1808835,
"5b605a6ec9972f2f8fdd6b91221d17dc430d85ab8cd9144a0d9f1f4a3c39faa5")
require_identity("D", compiler, 1811233,
"034ea4e45e502bc0b70ef8afdf90354ba4cfec5274bda500bf95e0f5aa1bad1f")
subject = epsilon + adapter
support = (directory / "support.bin").read_bytes()
request = (b"DCREQ\x01\x00\x00" + struct.pack("<II", 1, len(subject))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> { env.depth = env.depth - 1; },
_ -> {}
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
machine reset(env:@mutable State)->u32 { env.depth=0; 0 }
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> { let ignored:u32=reset(env); env.depth = env.depth - 1; },
_ -> {}
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
before-write exit 42
through-local exit 42
wrong-field refuse 2
write-invalidates refuse 2
call-invalidates refuse 2
other-arm refuse 2
fallback exit 42
stable-argument exit 42
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth <= 0 {
true -> {},
_ -> { env.depth = env.depth - 1; }
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> {},
_ -> { env.depth = env.depth - 1; }
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data State {depth:u32;}
machine step(env:@mutable State, n:u32) {
transition n > 0 {true -> { env.depth=0; env.depth=n-1; }, _ -> {}}
}
machine main()->u8 { let mutable env:State; step(@mutable env,43); match env.depth==42 {true->42,_->1} }
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> { let n:u32=env.depth-1; env.depth=n; },
_ -> {}
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> { env.depth=0; env.depth = env.depth - 1; },
_ -> {}
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
data State { depth: u32; count: u32; }
machine step(env: @mutable State) {
transition env.depth > 0 {
true -> { env.count = env.count - 1; },
_ -> {}
}
}
machine main()->u8 {
let mutable env:State;
env.depth=3;
step(@mutable env);
match env.depth==2 {true->42,_->1}
}
6 changes: 3 additions & 3 deletions tools/bootstrap/omega/compiler_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# implements Omega. Changing a member or the manifest invalidates the
# dependent evidence and must update every record.
OMEGA_COMPILER_MANIFEST_SIZE=11099
OMEGA_COMPILER_MANIFEST_SHA256=472e371d046661c74ea7e4fbc5ab5e576fd058e3d36d8c0fb60813808d9b117d
OMEGA_COMPILER_PACKED_SIZE=1808835
OMEGA_COMPILER_PACKED_SHA256=5b605a6ec9972f2f8fdd6b91221d17dc430d85ab8cd9144a0d9f1f4a3c39faa5
OMEGA_COMPILER_MANIFEST_SHA256=cbb4b48d0fe4f42d3169589bce8dd180f73c33c2d740bda21a4a50add1c641ec
OMEGA_COMPILER_PACKED_SIZE=1811233
OMEGA_COMPILER_PACKED_SHA256=034ea4e45e502bc0b70ef8afdf90354ba4cfec5274bda500bf95e0f5aa1bad1f

# Bound gate-local entries packed on top of the bound member bytes. Each
# omega-* gate appends its own customer entry after the packed D closure —
Expand Down
4 changes: 2 additions & 2 deletions tools/xtask/src/source_closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,8 @@ mod tests {
),
(
"bootstrap/omega/compiler/omega_compiler.epsilon.sources",
1808835,
"5b605a6ec9972f2f8fdd6b91221d17dc430d85ab8cd9144a0d9f1f4a3c39faa5",
1811233,
"034ea4e45e502bc0b70ef8afdf90354ba4cfec5274bda500bf95e0f5aa1bad1f",
None,
),
(
Expand Down
Loading