aboutsummaryrefslogtreecommitdiff
path: root/src/lj_bcread.c
diff options
context:
space:
mode:
authorMike Pall <mike>2024-01-22 19:06:36 +0100
committerMike Pall <mike>2024-01-22 19:06:36 +0100
commit4b90f6c4d7420139c135435e1580acb52ea18436 (patch)
tree1c3543b6baa4f8b30a33e8a624b60edc6feb0206 /src/lj_bcread.c
parentc525bcb9024510cad9e170e12b6209aedb330f83 (diff)
downloadluajit-4b90f6c4d7420139c135435e1580acb52ea18436.tar.gz
luajit-4b90f6c4d7420139c135435e1580acb52ea18436.tar.bz2
luajit-4b90f6c4d7420139c135435e1580acb52ea18436.zip
Add cross-32/64 bit and deterministic bytecode generation.
Contributed by Peter Cawley. #993 #1008
Diffstat (limited to 'src/lj_bcread.c')
-rw-r--r--src/lj_bcread.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lj_bcread.c b/src/lj_bcread.c
index c98c0d42..637ef067 100644
--- a/src/lj_bcread.c
+++ b/src/lj_bcread.c
@@ -281,8 +281,11 @@ static void bcread_knum(LexState *ls, GCproto *pt, MSize sizekn)
281static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc) 281static void bcread_bytecode(LexState *ls, GCproto *pt, MSize sizebc)
282{ 282{
283 BCIns *bc = proto_bc(pt); 283 BCIns *bc = proto_bc(pt);
284 bc[0] = BCINS_AD((pt->flags & PROTO_VARARG) ? BC_FUNCV : BC_FUNCF, 284 BCIns op;
285 pt->framesize, 0); 285 if (ls->fr2 != LJ_FR2) op = BC_NOT; /* Mark non-native prototype. */
286 else if ((pt->flags & PROTO_VARARG)) op = BC_FUNCV;
287 else op = BC_FUNCF;
288 bc[0] = BCINS_AD(op, pt->framesize, 0);
286 bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns)); 289 bcread_block(ls, bc+1, (sizebc-1)*(MSize)sizeof(BCIns));
287 /* Swap bytecode instructions if the endianess differs. */ 290 /* Swap bytecode instructions if the endianess differs. */
288 if (bcread_swap(ls)) { 291 if (bcread_swap(ls)) {
@@ -395,7 +398,7 @@ static int bcread_header(LexState *ls)
395 bcread_byte(ls) != BCDUMP_VERSION) return 0; 398 bcread_byte(ls) != BCDUMP_VERSION) return 0;
396 bcread_flags(ls) = flags = bcread_uleb128(ls); 399 bcread_flags(ls) = flags = bcread_uleb128(ls);
397 if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0; 400 if ((flags & ~(BCDUMP_F_KNOWN)) != 0) return 0;
398 if ((flags & BCDUMP_F_FR2) != LJ_FR2*BCDUMP_F_FR2) return 0; 401 if ((flags & BCDUMP_F_FR2) != (uint32_t)ls->fr2*BCDUMP_F_FR2) return 0;
399 if ((flags & BCDUMP_F_FFI)) { 402 if ((flags & BCDUMP_F_FFI)) {
400#if LJ_HASFFI 403#if LJ_HASFFI
401 lua_State *L = ls->L; 404 lua_State *L = ls->L;