aboutsummaryrefslogtreecommitdiff
path: root/src/lj_obj.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_obj.h')
-rw-r--r--src/lj_obj.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h
index fbc1eff9..22b69c60 100644
--- a/src/lj_obj.h
+++ b/src/lj_obj.h
@@ -335,12 +335,6 @@ enum {
335 335
336/* -- Prototype object ---------------------------------------------------- */ 336/* -- Prototype object ---------------------------------------------------- */
337 337
338/* Split constant array. Collectables are below, numbers above pointer. */
339typedef union ProtoK {
340 lua_Number *n; /* Numbers. */
341 GCRef *gc; /* Collectable objects (strings/table/proto). */
342} ProtoK;
343
344#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef)) 338#define SCALE_NUM_GCO ((int32_t)sizeof(lua_Number)/sizeof(GCRef))
345#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1)) 339#define round_nkgc(n) (((n) + SCALE_NUM_GCO-1) & ~(SCALE_NUM_GCO-1))
346 340
@@ -356,8 +350,8 @@ typedef struct GCproto {
356 uint8_t framesize; /* Fixed frame size. */ 350 uint8_t framesize; /* Fixed frame size. */
357 MSize sizebc; /* Number of bytecode instructions. */ 351 MSize sizebc; /* Number of bytecode instructions. */
358 GCRef gclist; 352 GCRef gclist;
359 ProtoK k; /* Split constant array (points to the middle). */ 353 MRef k; /* Split constant array (points to the middle). */
360 BCIns *bc; /* Array of bytecode instructions. */ 354 MRef bc; /* Array of bytecode instructions. */
361 uint16_t *uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */ 355 uint16_t *uv; /* Upvalue list. local slot|0x8000 or parent uv idx. */
362 MSize sizekgc; /* Number of collectable constants. */ 356 MSize sizekgc; /* Number of collectable constants. */
363 MSize sizekn; /* Number of lua_Number constants. */ 357 MSize sizekn; /* Number of lua_Number constants. */
@@ -383,6 +377,18 @@ typedef struct GCproto {
383#define PROTO_NO_JIT 0x10 377#define PROTO_NO_JIT 0x10
384#define PROTO_HAS_ILOOP 0x20 378#define PROTO_HAS_ILOOP 0x20
385 379
380#define proto_kgc(pt, idx) \
381 check_exp((uintptr_t)(intptr_t)(idx) >= (uintptr_t)-(intptr_t)(pt)->sizekgc, \
382 gcref(mref((pt)->k, GCRef)[(idx)]))
383#define proto_knum(pt, idx) \
384 check_exp((uintptr_t)(idx) < (pt)->sizekn, mref((pt)->k, lua_Number)[(idx)])
385#define proto_bc(pt) (mref((pt)->bc, BCIns))
386#define proto_ins(pt, pos) \
387 check_exp((uintptr_t)(pos) < (pt)->sizebc, proto_bc(pt)[(pos)])
388#define proto_insptr(pt, pos) \
389 check_exp((uintptr_t)(pos) < (pt)->sizebc, &proto_bc(pt)[(pos)])
390#define proto_bcpos(pt, pc) ((BCPos)((pc) - proto_bc(pt)))
391
386/* -- Upvalue object ------------------------------------------------------ */ 392/* -- Upvalue object ------------------------------------------------------ */
387 393
388typedef struct GCupval { 394typedef struct GCupval {