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/lib_base.c | |
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/lib_base.c')
-rw-r--r-- | src/lib_base.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index 032d5bcc..e85b7264 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
@@ -22,7 +22,9 @@ | |||
22 | #include "lj_tab.h" | 22 | #include "lj_tab.h" |
23 | #include "lj_meta.h" | 23 | #include "lj_meta.h" |
24 | #include "lj_state.h" | 24 | #include "lj_state.h" |
25 | #include "lj_bc.h" | ||
25 | #include "lj_ff.h" | 26 | #include "lj_ff.h" |
27 | #include "lj_dispatch.h" | ||
26 | #include "lj_ctype.h" | 28 | #include "lj_ctype.h" |
27 | #include "lj_lib.h" | 29 | #include "lj_lib.h" |
28 | 30 | ||
@@ -521,19 +523,25 @@ void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) | |||
521 | lj_err_run(L); | 523 | lj_err_run(L); |
522 | } | 524 | } |
523 | 525 | ||
526 | /* Forward declaration. */ | ||
527 | static void setpc_wrap_aux(lua_State *L, GCfunc *fn); | ||
528 | |||
524 | LJLIB_CF(coroutine_wrap) | 529 | LJLIB_CF(coroutine_wrap) |
525 | { | 530 | { |
526 | GCfunc *fn; | ||
527 | lj_cf_coroutine_create(L); | 531 | lj_cf_coroutine_create(L); |
528 | lua_pushcclosure(L, lj_ffh_coroutine_wrap_aux, 1); | 532 | lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); |
529 | fn = funcV(L->top-1); | 533 | setpc_wrap_aux(L, funcV(L->top-1)); |
530 | fn->c.gate = lj_ff_coroutine_wrap_aux; | ||
531 | fn->c.ffid = FF_coroutine_wrap_aux; | ||
532 | return 1; | 534 | return 1; |
533 | } | 535 | } |
534 | 536 | ||
535 | #include "lj_libdef.h" | 537 | #include "lj_libdef.h" |
536 | 538 | ||
539 | /* Fix the PC of wrap_aux. Really ugly workaround. */ | ||
540 | static void setpc_wrap_aux(lua_State *L, GCfunc *fn) | ||
541 | { | ||
542 | setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); | ||
543 | } | ||
544 | |||
537 | /* ------------------------------------------------------------------------ */ | 545 | /* ------------------------------------------------------------------------ */ |
538 | 546 | ||
539 | static void newproxy_weaktable(lua_State *L) | 547 | static void newproxy_weaktable(lua_State *L) |