]> 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:36:52 +0000 (14:36 +0200)
committerMike Pall <mike>
Mon, 20 Sep 2021 12:36:52 +0000 (14:36 +0200)
Reported by Yichun Zhang. #743

src/vm_arm.dasc
src/vm_mips.dasc
src/vm_ppc.dasc

index 21d706d8e3e1b4e13da0d0dcd4ca7f1af24b0db9..344147e81692ddc6f6896609816c3a4fde5b4e8d 100644 (file)
@@ -524,13 +524,13 @@ static void build_subroutines(BuildCtx *ctx)
   |    cmp CARG1, #1
   |.endif
   |   ldr PC, [CARG4, #-12]            // Restore PC from [cont|PC].
-  |  ldr CARG3, LFUNC:CARG3->field_pc
   |    mvn INS, #~LJ_TNIL
   |    add CARG2, RA, RC
   |    str INS, [CARG2, #-4]           // Ensure one valid arg.
   |.if FFI
   |    bls >1
   |.endif
+  |  ldr CARG3, LFUNC:CARG3->field_pc
   |  ldr KBASE, [CARG3, #PC2PROTO(k)]
   |  // BASE = base, RA = resultptr, CARG4 = meta base
   |    bx CARG1
index 8cb4bd3daf499b19249c297d79d5a33c8f351c1e..03a8498578aa141e956e8357331f4b8e6381ca4d 100644 (file)
@@ -603,11 +603,11 @@ static void build_subroutines(BuildCtx *ctx)
   |.endif
   |     lw PC, -16+HI(RB)              // Restore PC from [cont|PC].
   |   addu TMP2, RA, RD
-  |    lw TMP1, LFUNC:TMP1->pc
   |.if FFI
   |  bnez AT, >1
   |.endif
   |.  sw TISNIL, -8+HI(TMP2)           // Ensure one valid arg.
+  |    lw TMP1, LFUNC:TMP1->pc
   |  // BASE = base, RA = resultptr, RB = meta base
   |  jr TMP0                           // Jump to continuation.
   |.  lw KBASE, PC2PROTO(k)(TMP1)
index e2d62e0027d23438a90fb30ca37bdb5223260efe..9c1cc36fa431954268a0faf78435c1fd05c0b9d3 100644 (file)
@@ -819,11 +819,11 @@ static void build_subroutines(BuildCtx *ctx)
   |.endif
   |     lwz PC, -16(RB)                        // Restore PC from [cont|PC].
   |   subi TMP2, RD, 8
-  |    lwz TMP1, LFUNC:TMP1->pc
   |   stwx TISNIL, RA, TMP2            // Ensure one valid arg.
   |.if FFI
   |  ble >1
   |.endif
+  |    lwz TMP1, LFUNC:TMP1->pc
   |    lwz KBASE, PC2PROTO(k)(TMP1)
   |  // BASE = base, RA = resultptr, RB = meta base
   |  mtctr TMP0