Skip to content
Open
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
4 changes: 2 additions & 2 deletions crates/ordo-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tracing.workspace = true
# Signature support (optional, requires getrandom which needs special config for wasm)
ed25519-dalek = { workspace = true, optional = true }
rand = { workspace = true, optional = true }
base64 = { workspace = true, optional = true }
base64 = { workspace = true }
getrandom = { version = "0.2", features = ["js"], optional = true }

# JIT compilation (optional, not available on wasm32)
Expand All @@ -41,7 +41,7 @@ ordo-derive = { workspace = true, optional = true }
default = ["derive", "jit", "signature"]
derive = ["ordo-derive"]
jit = ["cranelift", "cranelift-jit", "cranelift-module", "cranelift-native", "cranelift-codegen"]
signature = ["ed25519-dalek", "rand", "base64", "getrandom"]
signature = ["ed25519-dalek", "rand", "getrandom"]

[dev-dependencies]
criterion = { version = "0.7.0", features = ["html_reports"] }
Expand Down
21 changes: 20 additions & 1 deletion crates/ordo-core/src/expr/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ impl ExprCompiler {
#[inline]
fn alloc_reg(&mut self) -> u8 {
let reg = self.next_reg;
self.next_reg += 1;
self.next_reg = self
.next_reg
.checked_add(1)
.expect("register limit exceeded: expression requires more than 256 registers");
reg
}

Expand Down Expand Up @@ -77,6 +80,10 @@ impl ExprCompiler {
return idx as u8;
}
let idx = self.compiled.constants.len();
assert!(
idx < 256,
"constant pool limit exceeded: expression has more than 256 unique constants"
);
self.compiled.constants.push(value);
idx as u8
}
Expand All @@ -87,6 +94,10 @@ impl ExprCompiler {
return idx as u8;
}
let idx = self.compiled.fields.len();
assert!(
idx < 256,
"field pool limit exceeded: expression references more than 256 unique fields"
);
self.compiled.fields.push(name.to_string());
idx as u8
}
Expand All @@ -97,6 +108,10 @@ impl ExprCompiler {
return idx as u8;
}
let idx = self.compiled.functions.len();
assert!(
idx < 256,
"function pool limit exceeded: expression references more than 256 unique functions"
);
self.compiled.functions.push(name.to_string());
idx as u8
}
Expand Down Expand Up @@ -166,6 +181,10 @@ impl ExprCompiler {
}

let func_idx = self.add_function(name);
assert!(
args.len() < 256,
"argument count limit exceeded: function call has more than 255 arguments"
);
// For Call: a=result, b=func_idx, c=arg_count
// Arguments are expected in registers [result_reg+1, result_reg+1+arg_count)
self.emit(Instruction::new(
Expand Down
Loading