Real Render Worker Establishment
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-06-20 17:05:25 +01:00
parent aa917cf44e
commit 21b5d59a7d
44 changed files with 350 additions and 3092 deletions
+20 -20
View File
@@ -548,17 +548,17 @@ mod tests {
// replace with arrays containing cross-references. Since our simple
// heap doesn't support in-place element edits via API, simulate by
// directly editing stored objects.
if let Some(slot) = heap.objects.get_mut(a.0 as usize) {
if let Some(obj) = slot.as_mut() {
obj.array_elems = Some(vec![Value::HeapRef(b)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(a.0 as usize)
&& let Some(obj) = slot.as_mut()
{
obj.array_elems = Some(vec![Value::HeapRef(b)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(b.0 as usize) {
if let Some(obj) = slot.as_mut() {
obj.array_elems = Some(vec![Value::HeapRef(a)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(b.0 as usize)
&& let Some(obj) = slot.as_mut()
{
obj.array_elems = Some(vec![Value::HeapRef(a)]);
obj.header.payload_len = 1;
}
// Mark from A; should terminate and mark both.
@@ -720,17 +720,17 @@ mod tests {
let b = heap.allocate_array(vec![]);
// Make A point to B and B point to A.
if let Some(slot) = heap.objects.get_mut(a.0 as usize) {
if let Some(obj) = slot.as_mut() {
obj.array_elems = Some(vec![Value::HeapRef(b)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(a.0 as usize)
&& let Some(obj) = slot.as_mut()
{
obj.array_elems = Some(vec![Value::HeapRef(b)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(b.0 as usize) {
if let Some(obj) = slot.as_mut() {
obj.array_elems = Some(vec![Value::HeapRef(a)]);
obj.header.payload_len = 1;
}
if let Some(slot) = heap.objects.get_mut(b.0 as usize)
&& let Some(obj) = slot.as_mut()
{
obj.array_elems = Some(vec![Value::HeapRef(a)]);
obj.header.payload_len = 1;
}
// No roots: perform sweep directly; both should be reclaimed.
+10 -15
View File
@@ -1052,12 +1052,13 @@ mod tests {
// 21: Jmp 27
// 27: Nop
let mut code = Vec::new();
code.push(OpCode::PushBool as u8);
code.push(0x00);
code.push(1); // 0: PushBool (3 bytes)
code.push(OpCode::JmpIfTrue as u8);
code.push(0x00);
let mut code = vec![
OpCode::PushBool as u8,
0x00,
1, // 0: PushBool (3 bytes)
OpCode::JmpIfTrue as u8,
0x00,
];
code.extend_from_slice(&15u32.to_le_bytes()); // 3: JmpIfTrue (6 bytes)
code.push(OpCode::Jmp as u8);
code.push(0x00);
@@ -1247,9 +1248,7 @@ mod tests {
#[test]
fn test_function_without_terminator_is_rejected() {
// Single NOP with no RET/JMP/TRAP/HALT at the end → fallthrough to end
let mut code = Vec::new();
code.push(OpCode::Nop as u8);
code.push(0x00);
let code = vec![OpCode::Nop as u8, 0x00];
let functions = vec![FunctionMeta { code_offset: 0, code_len: 2, ..Default::default() }];
let res = Verifier::verify(&code, &functions);
@@ -1259,9 +1258,7 @@ mod tests {
#[test]
fn test_function_with_proper_terminator_passes() {
// Minimal function that returns immediately
let mut code = Vec::new();
code.push(OpCode::Ret as u8);
code.push(0x00);
let code = vec![OpCode::Ret as u8, 0x00];
let functions = vec![FunctionMeta {
code_offset: 0,
@@ -1277,9 +1274,7 @@ mod tests {
fn test_verifier_ret_too_few_slots() {
// Function declares 1 return slot but returns nothing
// 0: Ret
let mut code = Vec::new();
code.push(OpCode::Ret as u8);
code.push(0x00);
let code = vec![OpCode::Ret as u8, 0x00];
let functions = vec![FunctionMeta {
code_offset: 0,
@@ -1596,9 +1596,10 @@ mod tests {
#[test]
fn test_push_f64_immediate() {
let value = 3.125f64;
let mut rom = Vec::new();
rom.extend_from_slice(&(OpCode::PushF64 as u16).to_le_bytes());
rom.extend_from_slice(&3.14f64.to_le_bytes());
rom.extend_from_slice(&value.to_le_bytes());
rom.extend_from_slice(&(OpCode::Halt as u16).to_le_bytes());
let mut vm = new_test_vm(rom.clone(), vec![]);
@@ -1606,7 +1607,7 @@ mod tests {
let mut ctx = HostContext::new(None);
vm.step(&mut native, &mut ctx).unwrap();
assert_eq!(vm.peek().unwrap(), &Value::Float(3.14));
assert_eq!(vm.peek().unwrap(), &Value::Float(value));
}
#[test]
@@ -2537,9 +2538,8 @@ mod tests {
let report = vm.run_budget(100, &mut native, &mut ctx).unwrap();
// Any non-trap outcome is considered success here
match report.reason {
LogicalFrameEndingReason::Trap(trap) => panic!("Unexpected trap: {:?}", trap),
_ => {}
if let LogicalFrameEndingReason::Trap(trap) = report.reason {
panic!("Unexpected trap: {:?}", trap);
}
}
@@ -2672,8 +2672,7 @@ mod tests {
#[test]
fn test_loader_hardening_successful_init() {
let mut vm = VirtualMachine::default();
vm.pc = 123; // Pollution
let mut vm = VirtualMachine { pc: 123, ..Default::default() };
let code = assemble("HALT").expect("assemble");
let header = prometeu_bytecode::model::BytecodeModule {
@@ -3978,26 +3977,26 @@ mod tests {
let mut a_href = None;
let mut b_href = None;
// Consider currently running coroutine
if let Some(cur) = vm.current_coro {
if let Some(f) = vm.call_stack.last() {
if f.func_idx == 1 {
a_href = Some(cur);
}
if f.func_idx == 2 {
b_href = Some(cur);
}
if let Some(cur) = vm.current_coro
&& let Some(f) = vm.call_stack.last()
{
if f.func_idx == 1 {
a_href = Some(cur);
}
if f.func_idx == 2 {
b_href = Some(cur);
}
}
// And also consider suspended (Ready/Sleeping) coroutines
for h in vm.heap.suspended_coroutine_handles() {
if let Some(co) = vm.heap.coroutine_data(h) {
if let Some(f) = co.frames.last() {
if f.func_idx == 1 {
a_href = Some(h);
}
if f.func_idx == 2 {
b_href = Some(h);
}
if let Some(co) = vm.heap.coroutine_data(h)
&& let Some(f) = co.frames.last()
{
if f.func_idx == 1 {
a_href = Some(h);
}
if f.func_idx == 2 {
b_href = Some(h);
}
}
}
@@ -4108,25 +4107,25 @@ mod tests {
// Identify A and B coroutine handles (consider both running and suspended)
let mut a_href = None;
let mut b_href = None;
if let Some(cur) = vm.current_coro {
if let Some(f) = vm.call_stack.last() {
if f.func_idx == 1 {
a_href = Some(cur);
}
if f.func_idx == 2 {
b_href = Some(cur);
}
if let Some(cur) = vm.current_coro
&& let Some(f) = vm.call_stack.last()
{
if f.func_idx == 1 {
a_href = Some(cur);
}
if f.func_idx == 2 {
b_href = Some(cur);
}
}
for h in vm.heap.suspended_coroutine_handles() {
if let Some(co) = vm.heap.coroutine_data(h) {
if let Some(f) = co.frames.last() {
if f.func_idx == 1 {
a_href = Some(h);
}
if f.func_idx == 2 {
b_href = Some(h);
}
if let Some(co) = vm.heap.coroutine_data(h)
&& let Some(f) = co.frames.last()
{
if f.func_idx == 1 {
a_href = Some(h);
}
if f.func_idx == 2 {
b_href = Some(h);
}
}
}
@@ -4253,26 +4252,26 @@ mod tests {
let mut a = None;
let mut b = None;
// running
if let Some(cur) = vm.current_coro {
if let Some(f) = vm.call_stack.last() {
if f.func_idx == 1 {
a = Some(cur);
}
if f.func_idx == 2 {
b = Some(cur);
}
if let Some(cur) = vm.current_coro
&& let Some(f) = vm.call_stack.last()
{
if f.func_idx == 1 {
a = Some(cur);
}
if f.func_idx == 2 {
b = Some(cur);
}
}
// suspended
for h in vm.heap.suspended_coroutine_handles() {
if let Some(co) = vm.heap.coroutine_data(h) {
if let Some(f) = co.frames.last() {
if f.func_idx == 1 {
a = Some(h);
}
if f.func_idx == 2 {
b = Some(h);
}
if let Some(co) = vm.heap.coroutine_data(h)
&& let Some(f) = co.frames.last()
{
if f.func_idx == 1 {
a = Some(h);
}
if f.func_idx == 2 {
b = Some(h);
}
}
}