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)
This commit is contained in:
0x4261756D 2023-01-04 00:45:34 +01:00
parent 3d2cd64c6d
commit ffdc54947b
1 changed files with 9 additions and 7 deletions

View File

@ -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<Operation>, functions: &Vec<Function>, intrinsics: &HashMap<&str, (Vec<Datatype>, Vec<Datatype>)>, arrays: &Vec<Arr>, debug: bool) -> Result<(), std::io::Error>
{
let mut data = AssemblyData
@ -308,11 +313,6 @@ fn generate_assembly_linux_x64(operations: &Vec<Operation>, functions: &Vec<Func
return fs::write("out.asm", format!("{}{}{}{}", ASSEMBLY_LINUX_X64_HEADER, data.code, data.arrays, data.strings));
}
// r12: head
// r13: tail
// r14: base
// r15: dynamic end
fn generate_assembly_linux_x64_block(operations: &Vec<Operation>, functions: &Vec<Function>, intrinsics: &HashMap<&str, (Vec<Datatype>, Vec<Datatype>)>, arrays: &Vec<Arr>, debug: bool) -> AssemblyData
{
let mut data = AssemblyData
@ -357,8 +357,9 @@ fn generate_assembly_linux_x64_block(operations: &Vec<Operation>, 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<Operation>, 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";