From 5118c5f353c1862055eabcda3b461dc7f805c599 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Tue, 25 Feb 2020 01:39:13 +0100 Subject: [PATCH] :art: Honor stack offset in usr gack --- src/lib/gack.c | 4 +++- src/vm/vm.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/gack.c b/src/lib/gack.c index 7148ff96..a72059ae 100644 --- a/src/lib/gack.c +++ b/src/lib/gack.c @@ -68,7 +68,9 @@ ANN void gack(const VM_Shred shred, const Instr instr) { ((f_gack)code->native_func)(t, (shred->reg - t->size), shred); POP_REG(shred, t->size); } else { - prepare_call(shred, instr->m_val2); + const m_uint offset = ((m_uint)shred->mem - SIZEOF_REG) != ((m_uint)shred + sizeof(struct VM_Shred_)) ? + instr->m_val2 : 0; + prepare_call(shred, offset); shred->code = code; POP_REG(shred, SZ_INT*2); } diff --git a/src/vm/vm.c b/src/vm/vm.c index 404fa3ce..66378e44 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -682,7 +682,7 @@ PRAGMA_POP() sporkmemberfptr: for(m_uint i = 0; i < VAL; i+= SZ_INT) *(m_uint*)(child->reg + i) = *(m_uint*)(reg - VAL + i); - *(m_uint*)(child->reg + VAL) = a.obj; + *(M_Object*)(child->reg + VAL) = a.obj; *(m_uint*)(child->reg + VAL + SZ_INT) = *(m_uint*)(reg + VAL - SZ_INT*2); child->reg += VAL + SZ_INT*2; DISPATCH() -- 2.43.0