Add required PHIs for implicit conversions (via XREF fwd).
[luajit-2.0.git] / src / lj_vm.h
blob2cf0418480d603667b2b19826d1dd27d783618d9
1 /*
2 ** Assembler VM interface definitions.
3 ** Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
4 */
6 #ifndef _LJ_VM_H
7 #define _LJ_VM_H
9 #include "lj_obj.h"
11 /* Entry points for ASM parts of VM. */
12 LJ_ASMF void lj_vm_call(lua_State *L, TValue *base, int nres1);
13 LJ_ASMF int lj_vm_pcall(lua_State *L, TValue *base, int nres1, ptrdiff_t ef);
14 typedef TValue *(*lua_CPFunction)(lua_State *L, lua_CFunction func, void *ud);
15 LJ_ASMF int lj_vm_cpcall(lua_State *L, lua_CFunction func, void *ud,
16 lua_CPFunction cp);
17 LJ_ASMF int lj_vm_resume(lua_State *L, TValue *base, int nres1, ptrdiff_t ef);
18 LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_c(void *cframe, int errcode);
19 LJ_ASMF_NORET void LJ_FASTCALL lj_vm_unwind_ff(void *cframe);
20 LJ_ASMF void lj_vm_unwind_c_eh(void);
21 LJ_ASMF void lj_vm_unwind_ff_eh(void);
22 #if LJ_TARGET_X86ORX64
23 LJ_ASMF void lj_vm_unwind_rethrow(void);
24 #endif
26 /* Miscellaneous functions. */
27 #if LJ_TARGET_X86ORX64
28 LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]);
29 #endif
30 #if LJ_TARGET_PPC
31 void lj_vm_cachesync(void *start, void *end);
32 #endif
33 LJ_ASMF double lj_vm_foldarith(double x, double y, int op);
34 #if LJ_HASJIT
35 LJ_ASMF double lj_vm_foldfpm(double x, int op);
36 #endif
37 #if !LJ_ARCH_HASFPU
38 /* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */
39 #endif
41 /* Dispatch targets for recording and hooks. */
42 LJ_ASMF void lj_vm_record(void);
43 LJ_ASMF void lj_vm_inshook(void);
44 LJ_ASMF void lj_vm_rethook(void);
45 LJ_ASMF void lj_vm_callhook(void);
47 /* Trace exit handling. */
48 LJ_ASMF void lj_vm_exit_handler(void);
49 LJ_ASMF void lj_vm_exit_interp(void);
51 /* Internal math helper functions. */
52 #if LJ_TARGET_X86ORX64
53 #define lj_vm_floor(x) floor(x)
54 #define lj_vm_ceil(x) ceil(x)
55 #else
56 LJ_ASMF double lj_vm_floor(double);
57 LJ_ASMF double lj_vm_ceil(double);
58 #endif
60 #if LJ_HASJIT
61 #if LJ_TARGET_X86ORX64
62 LJ_ASMF void lj_vm_floor_sse(void);
63 LJ_ASMF void lj_vm_ceil_sse(void);
64 LJ_ASMF void lj_vm_trunc_sse(void);
65 LJ_ASMF void lj_vm_exp_x87(void);
66 LJ_ASMF void lj_vm_exp2_x87(void);
67 LJ_ASMF void lj_vm_pow_sse(void);
68 LJ_ASMF void lj_vm_powi_sse(void);
69 #else
70 LJ_ASMF double lj_vm_trunc(double);
71 LJ_ASMF double lj_vm_powi(double, int32_t);
72 #ifdef LUAJIT_NO_LOG2
73 LJ_ASMF double lj_vm_log2(double);
74 #else
75 #define lj_vm_log2 log2
76 #endif
77 #ifdef LUAJIT_NO_EXP2
78 LJ_ASMF double lj_vm_exp2(double);
79 #else
80 #define lj_vm_exp2 exp2
81 #endif
82 #endif
83 LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t);
84 #if LJ_HASFFI
85 LJ_ASMF int lj_vm_errno(void);
86 #endif
87 #endif
89 /* Continuations for metamethods. */
90 LJ_ASMF void lj_cont_cat(void); /* Continue with concatenation. */
91 LJ_ASMF void lj_cont_ra(void); /* Store result in RA from instruction. */
92 LJ_ASMF void lj_cont_nop(void); /* Do nothing, just continue execution. */
93 LJ_ASMF void lj_cont_condt(void); /* Branch if result is true. */
94 LJ_ASMF void lj_cont_condf(void); /* Branch if result is false. */
95 LJ_ASMF void lj_cont_hook(void); /* Continue from hook yield. */
97 enum { LJ_CONT_TAILCALL, LJ_CONT_FFI_CALLBACK }; /* Special continuations. */
99 /* Start of the ASM code. */
100 LJ_ASMF char lj_vm_asm_begin[];
102 /* Bytecode offsets are relative to lj_vm_asm_begin. */
103 #define makeasmfunc(ofs) ((ASMFunction)(lj_vm_asm_begin + (ofs)))
105 #endif