Fix KBASE for Lua functions below stitched fast functions.

This commit is contained in:
Mike Pall
2014-01-16 22:53:27 +01:00
parent ba9dde2ce6
commit ce9e8ed675
4 changed files with 79 additions and 10 deletions

View File

@@ -2697,6 +2697,8 @@ static void build_subroutines(BuildCtx *ctx)
| mov RB, TMP1 // Get previous trace number.
| mov RA, [DISPATCH+DISPATCH_J(trace)]
| mov TRACE:RD, [RA+RB*4]
| test TRACE:RD, TRACE:RD
| jz ->cont_nop
| movzx RD, word TRACE:RD->link
| cmp RD, RB
| je ->cont_nop // Blacklisted.
@@ -2844,7 +2846,7 @@ static void build_subroutines(BuildCtx *ctx)
| mov r13, TMPa
| mov r12, TMPQ
|.endif
| test RD, RD; js >3 // Check for error from exit.
| test RD, RD; js >9 // Check for error from exit.
| mov L:RB, SAVE_L
| mov MULTRES, RD
| mov LFUNC:KBASE, [BASE-8]
@@ -2860,16 +2862,31 @@ static void build_subroutines(BuildCtx *ctx)
| add PC, 4
| shr RC, 16
| cmp OP, BC_FUNCF // Function header?
| jb >2
| mov RC, MULTRES // RC/RD holds nres+1.
| jb >3
| cmp OP, BC_FUNCC+2 // Fast function?
| jae >4
|2:
| mov RC, MULTRES // RC/RD holds nres+1.
|3:
|.if X64
| jmp aword [DISPATCH+OP*8]
|.else
| jmp aword [DISPATCH+OP*4]
|.endif
|
|3: // Rethrow error from the right C frame.
|4: // Check frame below fast function.
| mov RC, [BASE-4]
| test RC, FRAME_TYPE
| jnz <2 // Trace stitching continuation?
| // Otherwise set KBASE for Lua function below fast function.
| movzx RC, byte [RC-3]
| not RCa
| mov LFUNC:KBASE, [BASE+RC*8-8]
| mov KBASE, LFUNC:KBASE->pc
| mov KBASE, [KBASE+PC2PROTO(k)]
| jmp <2
|
|9: // Rethrow error from the right C frame.
| neg RD
| mov FCARG1, L:RB
| mov FCARG2, RD