HaxeFoundation / hashlink

A virtual machine for Haxe
https://hashlink.haxe.org/
MIT License
811 stars 158 forks source link

32 bit JIT error with nightly haxe #708

Open tobil4sk opened 2 months ago

tobil4sk commented 2 months ago

As mentioned in https://github.com/HaxeFoundation/haxe/pull/11734#issuecomment-2262487022, 32 bit builds of hashlink fail to run any program and exit with the error:

JIT ERROR 0 (jit.c line 1242)

Here is the line where the error is coming from: https://github.com/HaxeFoundation/hashlink/blob/9888913ed2e1eef9fc03085100c92bd44985c781/src/jit.c#L1242

This only came up on the CMake build (which has since been disabled), but it also affects the vs2019 build, it's just that those builds don't run any tests.

tobil4sk commented 2 months ago

This patch seems to avoid the error, but I'm not sure if it's correct:

diff --git a/src/jit.c b/src/jit.c
index 7571090..b971f85 100644
--- a/src/jit.c
+++ b/src/jit.c
@@ -1238,7 +1238,7 @@ static void store( jit_ctx *ctx, vreg *r, preg *v, bool bind ) {
                r->current = NULL;
        }
        v = copy(ctx,&r->stack,v,r->size);
-       if( IS_FLOAT(r) != (v->kind == RFPU) )
+       if( (IS_FLOAT(r) || (!IS_64 && r->t->kind == HI64)) != (v->kind == RFPU) )^M
                ASSERT(0);
        if( bind && r->current != v && (v->kind == RCPU || v->kind == RFPU) ) {
                scratch(v);