From ffdc54947b7a9d46923a4653e35b3230d885c5e7 Mon Sep 17 00:00:00 2001 From: 0x4261756D <–38735823+0x4261756D@users.noreply.github.com> Date: Wed, 4 Jan 2023 00:45:34 +0100 Subject: [PATCH] Improve queue runaway problems By changing the order of "pointer" increases it is possible to check and move back the queue if it is empty before function calls and req. With the function call change in particular it is now possible to run conway_diehard.qbl a queue of length 1024 (down from ~16384) --- src/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index f30a8e4..6168e38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -252,6 +252,11 @@ const ASSEMBLY_LINUX_X64_TRY_RESET_QUEUE: &str = "\tcmp r12, r13\n\tcmove r12, r const ASSEMBLY_LINUX_X64_EXIT: &str = "\tmov rax, 60\n\tmov rdi, 0\n\tsyscall\n"; const ASSEMBLY_LINUX_X64_DYNAMIC_DATA_LENGTH: u32 = 16384; +// r12: head +// r13: tail +// r14: base +// r15: dynamic end + fn generate_assembly_linux_x64(operations: &Vec, functions: &Vec, intrinsics: &HashMap<&str, (Vec, Vec)>, arrays: &Vec, debug: bool) -> Result<(), std::io::Error> { let mut data = AssemblyData @@ -308,11 +313,6 @@ fn generate_assembly_linux_x64(operations: &Vec, functions: &Vec, functions: &Vec, intrinsics: &HashMap<&str, (Vec, Vec)>, arrays: &Vec, debug: bool) -> AssemblyData { let mut data = AssemblyData @@ -357,8 +357,9 @@ fn generate_assembly_linux_x64_block(operations: &Vec, functions: &Ve { data.code += format!("\t;;req {}:{}\n", line, col).as_str(); data.code += "\tmov rax, [queue+8*r12]\n"; - data.code += "\tmov [queue+8*r13], rax\n"; data.code += "\tinc r12\n"; + data.code += ASSEMBLY_LINUX_X64_TRY_RESET_QUEUE; + data.code += "\tmov [queue+8*r13], rax\n"; data.code += "\tinc r13\n"; } Operation::Swap(line, col) => @@ -614,8 +615,9 @@ fn generate_assembly_linux_x64_block(operations: &Vec, functions: &Ve for _ in 0..function.ins.len() { data.code += "\tmov rax, [queue+8*r12]\n"; - data.code += "\tmov [queue+8*r13], rax\n"; data.code += "\tinc r12\n"; + data.code += ASSEMBLY_LINUX_X64_TRY_RESET_QUEUE; + data.code += "\tmov [queue+8*r13], rax\n"; data.code += "\tinc r13\n"; } data.code += "\t;; move pointers\n";