Selaa lähdekoodia

fixed jit bug

Nicolas Cannasse 10 vuotta sitten
vanhempi
commit
3942f8501d
2 muutettua tiedostoa jossa 6 lisäystä ja 3 poistoa
  1. 5 2
      src/jit.c
  2. 1 1
      src/main.c

+ 5 - 2
src/jit.c

@@ -908,7 +908,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 		}
 		ctx->maxRegs = f->nregs;
 	}
-	if( f->nops >= ctx->maxOps ) {
+	if( f->nops > ctx->maxOps ) {
 		free(ctx->opsPos);
 		ctx->opsPos = (int*)malloc(sizeof(int) * (f->nops + 1));
 		if( ctx->opsPos == NULL ) {
@@ -917,7 +917,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 		}
 		ctx->maxOps = f->nops;
 	}
-	memset(ctx->opsPos,0,f->nops*sizeof(int));
+	memset(ctx->opsPos,0,(f->nops+1)*sizeof(int));
 	size = 0;
 	for(i=0;i<f->nregs;i++) {
 		vreg *r = R(i);
@@ -1026,6 +1026,9 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 	// add nops padding
 	while( BUF_POS() & 15 )
 		op32(ctx, NOP, UNUSED, UNUSED);
+	// clear regs
+	for(i=0;i<REG_COUNT;i++)
+		REG_AT(i)->holds = NULL;
 	// reset tmp allocator
 	hl_free(&ctx->falloc);
 	return codePos;

+ 1 - 1
src/main.c

@@ -28,7 +28,7 @@
 #endif
 
 int main( int argc, char *argv[] ) {
-	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );
 	if( argc == 1 ) {
 		printf("HLVM %d.%d.%d (c)2015 Haxe Foundation\n  Usage : hl <file>\n",HL_VERSION/100,(HL_VERSION/10)%10,HL_VERSION%10);
 		return 1;