Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UI8 assign on Linux #665

Merged
merged 1 commit into from
Mar 24, 2024
Merged

Conversation

yuxiaomao
Copy link
Collaborator

Fixes #142 , fixes #658 for me without breaking our game on Linux (Ubuntu 22.04).

I'm not very sure what I'm doing, so here is some description:
I found that Linux & Windows have different set of CPU registers (if I use the same cpu set, I have segfault)

hashlink/src/jit.c

Lines 227 to 239 in 8bc5f8f

# ifdef HL_WIN_CALL
# define CALL_NREGS 4
# define RCPU_SCRATCH_COUNT 7
# define RFPU_SCRATCH_COUNT 6
static const int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, R8, R9, R10, R11 };
static const CpuReg CALL_REGS[] = { Ecx, Edx, R8, R9 };
# else
# define CALL_NREGS 6 // TODO : XMM6+XMM7 are FPU reg parameters
# define RCPU_SCRATCH_COUNT 9
# define RFPU_SCRATCH_COUNT 16
static const int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, Esi, Edi, R8, R9, R10, R11 };
static const CpuReg CALL_REGS[] = { Edi, Esi, Edx, Ecx, R8, R9 };
# endif

Esi, Edi are used in Linux, however they are not 8 bit register (remove the id check on RCPU fixes the issues, but will make our game to exit "normally" without actually run and I don't understand why)

hashlink/src/jit.c

Lines 542 to 544 in 8bc5f8f

static bool is_reg8( preg *a ) {
return a->kind == RSTACK || a->kind == RMEM || a->kind == RCONST || (a->kind == RCPU && a->id != Esi && a->id != Edi);
}

The UI8 op failed during a MOV8 (called by copy-copyfrom), with a RCPU id = 1, b RCPU id = 7 (Edi)

hashlink/src/jit.c

Lines 552 to 554 in 8bc5f8f

case MOV8:
if( !is_reg8(a) || !is_reg8(b) )
ASSERT(0);

So I move the !is_reg8(from) also for the case when to.kind = RCPU. I also force the Reg choice to RCPU_8BITS because by the name it make sens, but it seems not necessary for the fix.

@skial skial mentioned this pull request Mar 20, 2024
1 task
@ncannasse ncannasse merged commit 068bb35 into HaxeFoundation:master Mar 24, 2024
9 checks passed
@ncannasse
Copy link
Member

Seems good

@yuxiaomao yuxiaomao deleted the dev-linuxUI8 branch March 25, 2024 07:21
GlassySundew pushed a commit to GlassySundew/hashlink that referenced this pull request May 11, 2024
yuxiaomao added a commit that referenced this pull request Jun 27, 2024
RandomityGuy pushed a commit to RandomityGuy/hashlink that referenced this pull request Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT ERROR 0 mixing hl.UI8 and Float Std.int(hl.UI8) causes jit error on linux
2 participants