Fast forward to sync public repo.

Compile math.sinh(), math.cosh(), math.tanh() and math.random().
Compile various io.*() functions.
Drive the GC forward on string allocations in the parser.
Improve KNUM fuse vs. load heuristics.
Add abstract C call handling to IR.
This commit is contained in:
Mike Pall
2009-12-08 20:35:29 +01:00
parent 5287b93264
commit 3f1f9e11f4
44 changed files with 1218 additions and 766 deletions

View File

@@ -6,16 +6,22 @@
#define lj_ir_c
#define LUA_CORE
/* For pointers to libc/libm functions. */
#include <stdio.h>
#include <math.h>
#include "lj_obj.h"
#if LJ_HASJIT
#include "lj_gc.h"
#include "lj_str.h"
#include "lj_tab.h"
#include "lj_ir.h"
#include "lj_jit.h"
#include "lj_iropt.h"
#include "lj_trace.h"
#include "lj_lib.h"
/* Some local macros to save typing. Undef'd at the end. */
#define IR(ref) (&J->cur.ir[(ref)])
@@ -32,6 +38,17 @@ IRDEF(IRMODE)
0
};
/* C call info for CALL* instructions. */
LJ_DATADEF const CCallInfo lj_ir_callinfo[] = {
#define IRCALLCI(name, nargs, kind, type, flags) \
{ (ASMFunction)name, \
(nargs)|(CCI_CALL_##kind)|(IRT_##type<<CCI_OTSHIFT)|(flags) },
IRCALLDEF(IRCALLCI)
#undef IRCALLCI
{ NULL, 0 }
};
/* -- IR emitter ---------------------------------------------------------- */
/* Grow IR buffer at the top. */
@@ -92,6 +109,25 @@ TRef LJ_FASTCALL lj_ir_emit(jit_State *J)
return TREF(ref, irt_t((ir->t = fins->t)));
}
/* Emit call to a C function. */
TRef lj_ir_call(jit_State *J, IRCallID id, ...)
{
const CCallInfo *ci = &lj_ir_callinfo[id];
uint32_t n = CCI_NARGS(ci);
TRef tr = TREF_NIL;
va_list argp;
va_start(argp, id);
if ((ci->flags & CCI_L)) n--;
if (n > 0)
tr = va_arg(argp, IRRef);
while (n-- > 1)
tr = emitir(IRT(IR_CARG, IRT_NIL), tr, va_arg(argp, IRRef));
va_end(argp);
if (CCI_OP(ci) == IR_CALLS)
J->needsnap = 1; /* Need snapshot after call with side effect. */
return emitir(CCI_OPTYPE(ci), tr, id);
}
/* -- Interning of constants ---------------------------------------------- */
/*