aboutsummaryrefslogtreecommitdiff
path: root/src/vm_x64.dasc
diff options
context:
space:
mode:
authorMike Pall <mike>2023-08-13 02:25:12 +0200
committerMike Pall <mike>2023-08-13 02:25:12 +0200
commit119fd1fab0ebf235669456fbb57ee872fb05fc73 (patch)
tree2445387dda68d8559bf3fc584e4889bc48230116 /src/vm_x64.dasc
parent27af72e66f6a285298d1a9be370779aae945eb14 (diff)
downloadluajit-119fd1fab0ebf235669456fbb57ee872fb05fc73.tar.gz
luajit-119fd1fab0ebf235669456fbb57ee872fb05fc73.tar.bz2
luajit-119fd1fab0ebf235669456fbb57ee872fb05fc73.zip
Ensure forward progress on trace exit to BC_ITERN.
Also use a safer way to force a static dispatch for BC_RET*. Reported by Bartel Eerdekens. Analyzed by Peter Cawley. #1000 #1045
Diffstat (limited to 'src/vm_x64.dasc')
-rw-r--r--src/vm_x64.dasc13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc
index 03d96557..5983eeed 100644
--- a/src/vm_x64.dasc
+++ b/src/vm_x64.dasc
@@ -2453,7 +2453,7 @@ static void build_subroutines(BuildCtx *ctx)
2453 | mov r12, [RA] 2453 | mov r12, [RA]
2454 | mov rsp, RA // Reposition stack to C frame. 2454 | mov rsp, RA // Reposition stack to C frame.
2455 |.endif 2455 |.endif
2456 | test RDd, RDd; js >9 // Check for error from exit. 2456 | cmp RDd, -LUA_ERRERR; jae >9 // Check for error from exit.
2457 | mov L:RB, SAVE_L 2457 | mov L:RB, SAVE_L
2458 | mov MULTRES, RDd 2458 | mov MULTRES, RDd
2459 | mov LFUNC:KBASE, [BASE-16] 2459 | mov LFUNC:KBASE, [BASE-16]
@@ -2469,6 +2469,8 @@ static void build_subroutines(BuildCtx *ctx)
2469 | movzx OP, RCL 2469 | movzx OP, RCL
2470 | add PC, 4 2470 | add PC, 4
2471 | shr RCd, 16 2471 | shr RCd, 16
2472 | cmp MULTRES, -17 // Static dispatch?
2473 | je >5
2472 | cmp OP, BC_FUNCF // Function header? 2474 | cmp OP, BC_FUNCF // Function header?
2473 | jb >3 2475 | jb >3
2474 | cmp OP, BC_FUNCC+2 // Fast function? 2476 | cmp OP, BC_FUNCC+2 // Fast function?
@@ -2491,6 +2493,15 @@ static void build_subroutines(BuildCtx *ctx)
2491 | mov KBASE, [KBASE+PC2PROTO(k)] 2493 | mov KBASE, [KBASE+PC2PROTO(k)]
2492 | jmp <2 2494 | jmp <2
2493 | 2495 |
2496 |5: // Dispatch to static entry of original ins replaced by BC_JLOOP.
2497 | mov RA, [DISPATCH+DISPATCH_J(trace)]
2498 | mov TRACE:RA, [RA+RD*8]
2499 | mov RCd, TRACE:RA->startins
2500 | movzx RAd, RCH
2501 | movzx OP, RCL
2502 | shr RCd, 16
2503 | jmp aword [DISPATCH+OP*8+GG_DISP2STATIC]
2504 |
2494 |9: // Rethrow error from the right C frame. 2505 |9: // Rethrow error from the right C frame.
2495 | mov CARG2d, RDd 2506 | mov CARG2d, RDd
2496 | mov CARG1, L:RB 2507 | mov CARG1, L:RB