diff options
Diffstat (limited to 'src/lj_obj.h')
-rw-r--r-- | src/lj_obj.h | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index 9101f053..cebeda9b 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -315,7 +315,7 @@ typedef struct GCstr { | |||
315 | /* Userdata object. Payload follows. */ | 315 | /* Userdata object. Payload follows. */ |
316 | typedef struct GCudata { | 316 | typedef struct GCudata { |
317 | GCHeader; | 317 | GCHeader; |
318 | uint8_t unused1; | 318 | uint8_t udtype; /* Userdata type. */ |
319 | uint8_t unused2; | 319 | uint8_t unused2; |
320 | GCRef env; /* Should be at same offset in GCfunc. */ | 320 | GCRef env; /* Should be at same offset in GCfunc. */ |
321 | MSize len; /* Size of payload. */ | 321 | MSize len; /* Size of payload. */ |
@@ -323,6 +323,13 @@ typedef struct GCudata { | |||
323 | uint32_t align1; /* To force 8 byte alignment of the payload. */ | 323 | uint32_t align1; /* To force 8 byte alignment of the payload. */ |
324 | } GCudata; | 324 | } GCudata; |
325 | 325 | ||
326 | /* Userdata types. */ | ||
327 | enum { | ||
328 | UDTYPE_USERDATA, /* Regular userdata. */ | ||
329 | UDTYPE_IO_FILE, /* I/O library FILE. */ | ||
330 | UDTYPE__MAX | ||
331 | }; | ||
332 | |||
326 | #define uddata(u) ((void *)((u)+1)) | 333 | #define uddata(u) ((void *)((u)+1)) |
327 | #define sizeudata(u) (sizeof(struct GCudata)+(u)->len) | 334 | #define sizeudata(u) (sizeof(struct GCudata)+(u)->len) |
328 | 335 | ||
@@ -496,7 +503,17 @@ MMDEF(MMENUM) | |||
496 | MM_FAST = MM_eq | 503 | MM_FAST = MM_eq |
497 | } MMS; | 504 | } MMS; |
498 | 505 | ||
499 | #define BASEMT_MAX ((~LJ_TNUMX)+1) | 506 | /* GC root IDs. */ |
507 | typedef enum { | ||
508 | GCROOT_BASEMT, /* Metatables for base types. */ | ||
509 | GCROOT_BASEMT_NUM = ~LJ_TNUMX, /* Last base metatable. */ | ||
510 | GCROOT_IO_INPUT, /* Userdata for default I/O input file. */ | ||
511 | GCROOT_IO_OUTPUT, /* Userdata for default I/O output file. */ | ||
512 | GCROOT__MAX | ||
513 | } GCRootID; | ||
514 | |||
515 | #define basemt_it(g, it) ((g)->gcroot[GCROOT_BASEMT+~(it)]) | ||
516 | #define basemt_obj(g, o) ((g)->gcroot[GCROOT_BASEMT+itypemap(o)]) | ||
500 | 517 | ||
501 | typedef struct GCState { | 518 | typedef struct GCState { |
502 | MSize total; /* Memory currently allocated. */ | 519 | MSize total; /* Memory currently allocated. */ |
@@ -544,7 +561,7 @@ typedef struct global_State { | |||
544 | volatile int32_t vmstate; /* VM state or current JIT code trace number. */ | 561 | volatile int32_t vmstate; /* VM state or current JIT code trace number. */ |
545 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ | 562 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ |
546 | MRef jit_base; /* Current JIT code L->base. */ | 563 | MRef jit_base; /* Current JIT code L->base. */ |
547 | GCRef basemt[BASEMT_MAX]; /* Metatables for base types. */ | 564 | GCRef gcroot[GCROOT__MAX]; /* GC roots. */ |
548 | GCRef mmname[MM_MAX]; /* Array holding metamethod names. */ | 565 | GCRef mmname[MM_MAX]; /* Array holding metamethod names. */ |
549 | } global_State; | 566 | } global_State; |
550 | 567 | ||