diff options
author | Mike Pall <mike> | 2010-02-13 04:51:56 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-13 04:51:56 +0100 |
commit | c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b (patch) | |
tree | 8c0ffe2086ab0b032ed8e9f92ae6fb9d4d040d66 /src/lj_obj.h | |
parent | 4f8d7be8ea8a103f4d9046188d6005740b74f3d4 (diff) | |
download | luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.tar.gz luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.tar.bz2 luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.zip |
Major redesign of function call handling.
Drop call gates. Use function headers, dispatched like bytecodes.
Emit BC_FUNCF/BC_FUNCV bytecode at PC 0 for all Lua functions.
C functions and ASM fast functions get extra bytecodes.
Modify internal calling convention: new base in BASE (formerly in RA).
Can now use better C function wrapper semantics (dynamic on/off).
Prerequisite for call hooks with zero-overhead if disabled.
Prerequisite for compiling recursive calls.
Prerequisite for efficient 32/64 bit prototype guards.
Diffstat (limited to 'src/lj_obj.h')
-rw-r--r-- | src/lj_obj.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lj_obj.h b/src/lj_obj.h index a6637954..d463cb2c 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -360,7 +360,6 @@ typedef struct GCproto { | |||
360 | uint16_t trace; /* Anchor for chain of root traces. */ | 360 | uint16_t trace; /* Anchor for chain of root traces. */ |
361 | /* ------ The following fields are for debugging/tracebacks only ------ */ | 361 | /* ------ The following fields are for debugging/tracebacks only ------ */ |
362 | GCRef chunkname; /* Name of the chunk this function was defined in. */ | 362 | GCRef chunkname; /* Name of the chunk this function was defined in. */ |
363 | BCLine linedefined; /* First line of the function definition. */ | ||
364 | BCLine lastlinedefined; /* Last line of the function definition. */ | 363 | BCLine lastlinedefined; /* Last line of the function definition. */ |
365 | MSize sizevarinfo; /* Size of local var info array. */ | 364 | MSize sizevarinfo; /* Size of local var info array. */ |
366 | MRef varinfo; /* Names and extents of local variables. */ | 365 | MRef varinfo; /* Names and extents of local variables. */ |
@@ -419,7 +418,7 @@ typedef struct GCupval { | |||
419 | /* Common header for functions. env should be at same offset in GCudata. */ | 418 | /* Common header for functions. env should be at same offset in GCudata. */ |
420 | #define GCfuncHeader \ | 419 | #define GCfuncHeader \ |
421 | GCHeader; uint8_t ffid; uint8_t nupvalues; \ | 420 | GCHeader; uint8_t ffid; uint8_t nupvalues; \ |
422 | GCRef env; GCRef gclist; ASMFunction gate | 421 | GCRef env; GCRef gclist; MRef pc |
423 | 422 | ||
424 | typedef struct GCfuncC { | 423 | typedef struct GCfuncC { |
425 | GCfuncHeader; | 424 | GCfuncHeader; |
@@ -429,7 +428,6 @@ typedef struct GCfuncC { | |||
429 | 428 | ||
430 | typedef struct GCfuncL { | 429 | typedef struct GCfuncL { |
431 | GCfuncHeader; | 430 | GCfuncHeader; |
432 | MRef pc; /* Start PC (and GCproto reference). */ | ||
433 | GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ | 431 | GCRef uvptr[1]; /* Array of _pointers_ to upvalue objects (GCupval). */ |
434 | } GCfuncL; | 432 | } GCfuncL; |
435 | 433 | ||
@@ -558,7 +556,7 @@ typedef struct global_State { | |||
558 | uint8_t hookmask; /* Hook mask. */ | 556 | uint8_t hookmask; /* Hook mask. */ |
559 | uint8_t dispatchmode; /* Dispatch mode. */ | 557 | uint8_t dispatchmode; /* Dispatch mode. */ |
560 | uint8_t vmevmask; /* VM event mask. */ | 558 | uint8_t vmevmask; /* VM event mask. */ |
561 | uint8_t wrapmode; /* Wrap mode. */ | 559 | uint8_t unused1; |
562 | GCRef mainthref; /* Link to main thread. */ | 560 | GCRef mainthref; /* Link to main thread. */ |
563 | TValue registrytv; /* Anchor for registry. */ | 561 | TValue registrytv; /* Anchor for registry. */ |
564 | TValue tmptv; /* Temporary TValue. */ | 562 | TValue tmptv; /* Temporary TValue. */ |
@@ -569,6 +567,8 @@ typedef struct global_State { | |||
569 | lua_CFunction wrapf; /* Wrapper for C function calls. */ | 567 | lua_CFunction wrapf; /* Wrapper for C function calls. */ |
570 | lua_CFunction panic; /* Called as a last resort for errors. */ | 568 | lua_CFunction panic; /* Called as a last resort for errors. */ |
571 | volatile int32_t vmstate; /* VM state or current JIT code trace number. */ | 569 | volatile int32_t vmstate; /* VM state or current JIT code trace number. */ |
570 | BCIns bc_cfunc_int; /* Bytecode for internal C function calls. */ | ||
571 | BCIns bc_cfunc_ext; /* Bytecode for external C function calls. */ | ||
572 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ | 572 | GCRef jit_L; /* Current JIT code lua_State or NULL. */ |
573 | MRef jit_base; /* Current JIT code L->base. */ | 573 | MRef jit_base; /* Current JIT code L->base. */ |
574 | GCRef gcroot[GCROOT__MAX]; /* GC roots. */ | 574 | GCRef gcroot[GCROOT__MAX]; /* GC roots. */ |
@@ -584,6 +584,7 @@ typedef struct global_State { | |||
584 | /* Hook management. Hook event masks are defined in lua.h. */ | 584 | /* Hook management. Hook event masks are defined in lua.h. */ |
585 | #define HOOK_EVENTMASK 0x0f | 585 | #define HOOK_EVENTMASK 0x0f |
586 | #define HOOK_ACTIVE 0x10 | 586 | #define HOOK_ACTIVE 0x10 |
587 | #define HOOK_ACTIVE_SHIFT 4 | ||
587 | #define HOOK_VMEVENT 0x20 | 588 | #define HOOK_VMEVENT 0x20 |
588 | #define HOOK_GC 0x40 | 589 | #define HOOK_GC 0x40 |
589 | #define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) | 590 | #define hook_active(g) ((g)->hookmask & HOOK_ACTIVE) |