]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Don't load PC from non-function object in FFI continuation.
authorMike Pall <mike>
Mon, 20 Sep 2021 12:39:26 +0000 (14:39 +0200)
committerMike Pall <mike>
Mon, 20 Sep 2021 12:39:26 +0000 (14:39 +0200)
Reported by Yichun Zhang. #743

src/vm_arm64.dasc
src/vm_mips64.dasc

index 1abc6eccdeb53ba48e77b1fb793388e23268daa9..304e45448bb7829de0c74dd7495743d5822ccff7 100644 (file)
@@ -562,12 +562,12 @@ static void build_subroutines(BuildCtx *ctx)
   |    cmp CARG1, #1
   |.endif
   |   ldr PC, [CARG4, #-24]            // Restore PC from [cont|PC].
-  |  ldr CARG3, LFUNC:CARG3->pc
   |    add TMP0, RA, RC
   |    str TISNIL, [TMP0, #-8]         // Ensure one valid arg.
   |.if FFI
   |    bls >1
   |.endif
+  |  ldr CARG3, LFUNC:CARG3->pc
   |  ldr KBASE, [CARG3, #PC2PROTO(k)]
   |  // BASE = base, RA = resultptr, CARG4 = meta base
   |    br CARG1
index 5c5d761c2c708053f803da690011c6fd8ce00de9..4ddb2f9c075890daf06e9a58a0984317f623abbc 100644 (file)
@@ -728,11 +728,11 @@ static void build_subroutines(BuildCtx *ctx)
   |     ld PC, -24(RB)                 // Restore PC from [cont|PC].
   |    cleartp LFUNC:TMP1
   |   daddu TMP2, RA, RD
-  |    ld TMP1, LFUNC:TMP1->pc
   |.if FFI
   |  bnez AT, >1
   |.endif
   |.  sd TISNIL, -8(TMP2)              // Ensure one valid arg.
+  |    ld TMP1, LFUNC:TMP1->pc
   |  // BASE = base, RA = resultptr, RB = meta base
   |  jr TMP0                           // Jump to continuation.
   |.  ld KBASE, PC2PROTO(k)(TMP1)