Przeglądaj źródła

fixed missing rethrow implementation

Nicolas Cannasse 8 lat temu
rodzic
commit
a59bbe40ba
1 zmienionych plików z 15 dodań i 10 usunięć
  1. 15 10
      src/jit.c

+ 15 - 10
src/jit.c

@@ -332,7 +332,7 @@ static void restore_regs( jit_ctx *ctx ) {
 		preg *p = ctx->pregs + i;
 		preg *p = ctx->pregs + i;
 		p->holds = r;
 		p->holds = r;
 		p->lock = ctx->savedLocks[i];
 		p->lock = ctx->savedLocks[i];
-		if( r ) r->current = p;	
+		if( r ) r->current = p;
 	}
 	}
 }
 }
 
 
@@ -1089,7 +1089,7 @@ static void store_result( jit_ctx *ctx, vreg *r ) {
 
 
 static void op_mov( jit_ctx *ctx, vreg *to, vreg *from ) {
 static void op_mov( jit_ctx *ctx, vreg *to, vreg *from ) {
 	preg *r = fetch(from);
 	preg *r = fetch(from);
-	if( from->t->kind == HF32 && r->kind != RFPU ) 
+	if( from->t->kind == HF32 && r->kind != RFPU )
 		r = alloc_fpu(ctx,from,true);
 		r = alloc_fpu(ctx,from,true);
 	store(ctx, to, r, true);
 	store(ctx, to, r, true);
 }
 }
@@ -1385,7 +1385,7 @@ static preg *op_binop( jit_ctx *ctx, vreg *dst, vreg *a, vreg *b, hl_opcode *op
 				int args[] = { a->stack.id, b->stack.id };
 				int args[] = { a->stack.id, b->stack.id };
 				int size = prepare_call_args(ctx,2,args,ctx->vregs,true,0);
 				int size = prepare_call_args(ctx,2,args,ctx->vregs,true,0);
 				void *mod_fun;
 				void *mod_fun;
-				if( isf32 ) mod_fun = fmodf; else mod_fun = fmod; 
+				if( isf32 ) mod_fun = fmodf; else mod_fun = fmod;
 				call_native(ctx,mod_fun,size);
 				call_native(ctx,mod_fun,size);
 				store_result(ctx,dst);
 				store_result(ctx,dst);
 				return fetch(dst);
 				return fetch(dst);
@@ -1704,7 +1704,7 @@ static void dyn_value_compare( jit_ctx *ctx, preg *a, preg *b, hl_type *t ) {
 		op64(ctx,MOV,a,pmem(&p,a->id,HDYN_VALUE));
 		op64(ctx,MOV,a,pmem(&p,a->id,HDYN_VALUE));
 		op64(ctx,MOV,b,pmem(&p,b->id,HDYN_VALUE));
 		op64(ctx,MOV,b,pmem(&p,b->id,HDYN_VALUE));
 		op64(ctx,CMP,a,b);
 		op64(ctx,CMP,a,b);
-		break;	
+		break;
 	}
 	}
 }
 }
 
 
@@ -1770,7 +1770,7 @@ static void op_jump( jit_ctx *ctx, vreg *a, vreg *b, hl_opcode *op, int targetPo
 				register_jump(ctx,do_jump(ctx,OJNotEq,false),targetPos);
 				register_jump(ctx,do_jump(ctx,OJNotEq,false),targetPos);
 				patch_jump(ctx,jcmp);
 				patch_jump(ctx,jcmp);
 				patch_jump(ctx,jeq);
 				patch_jump(ctx,jeq);
-			} else 
+			} else
 				jit_error("TODO");
 				jit_error("TODO");
 			return;
 			return;
 		}
 		}
@@ -1926,7 +1926,7 @@ static void op_jump( jit_ctx *ctx, vreg *a, vreg *b, hl_opcode *op, int targetPo
 			}
 			}
 			return;
 			return;
 		}
 		}
-		// fallthrough		
+		// fallthrough
 	default:
 	default:
 		op_binop(ctx,NULL,a,b,op);
 		op_binop(ctx,NULL,a,b,op);
 		break;
 		break;
@@ -2859,14 +2859,19 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 					op64(ctx,ADD,PESP,pconst(&p,size));
 					op64(ctx,ADD,PESP,pconst(&p,size));
 					store_result(ctx, dst);
 					store_result(ctx, dst);
 					patch_jump(ctx,jend);
 					patch_jump(ctx,jend);
-				}				
+				}
 				break;
 				break;
 			default:
 			default:
 				ASSERT(0);
 				ASSERT(0);
 				break;
 				break;
 			}
 			}
 			break;
 			break;
-		case ORethrow: // TODO
+		case ORethrow:
+			{
+				int size = prepare_call_args(ctx,1,&o->p1,ctx->vregs,true,0);
+				call_native(ctx,hl_rethrow,size);
+			}
+			break;
 		case OThrow:
 		case OThrow:
 			{
 			{
 				int size = prepare_call_args(ctx,1,&o->p1,ctx->vregs,true,0);
 				int size = prepare_call_args(ctx,1,&o->p1,ctx->vregs,true,0);
@@ -2911,7 +2916,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 				op32(ctx,MOV16,pmem2(&p,base->id,offset->id,1,0),value);
 				op32(ctx,MOV16,pmem2(&p,base->id,offset->id,1,0),value);
 			}
 			}
 			break;
 			break;
-		case OSetMem: 
+		case OSetMem:
 			{
 			{
 				preg *base = alloc_cpu(ctx, dst, true);
 				preg *base = alloc_cpu(ctx, dst, true);
 				preg *offset = alloc_cpu(ctx, ra, true);
 				preg *offset = alloc_cpu(ctx, ra, true);
@@ -3192,7 +3197,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 				op32(ctx, CMP, r, pconst(&p,o->p2));
 				op32(ctx, CMP, r, pconst(&p,o->p2));
 				XJump(JUGte,jdefault);
 				XJump(JUGte,jdefault);
 				// r2 = r * 5 + eip
 				// r2 = r * 5 + eip
-				op32(ctx, MOV, r2, r); 
+				op32(ctx, MOV, r2, r);
 				op32(ctx, SHL, r2, pconst(&p,2));
 				op32(ctx, SHL, r2, pconst(&p,2));
 				op32(ctx, ADD, r2, r);
 				op32(ctx, ADD, r2, r);
 				op64(ctx, ADD, r2, pconst64(&p,0));
 				op64(ctx, ADD, r2, pconst64(&p,0));