root/lj_vm.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2 ** Assembler VM interface definitions.
   3 ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
   4 */
   5 
   6 #ifndef _LJ_VM_H
   7 #define _LJ_VM_H
   8 
   9 #include "lj_obj.h"
  10 
  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 #if LJ_ABI_WIN && LJ_TARGET_X86
  21 LJ_ASMF_NORET void LJ_FASTCALL lj_vm_rtlunwind(void *cframe, void *excptrec,
  22                                                void *unwinder, int errcode);
  23 #endif
  24 LJ_ASMF void lj_vm_unwind_c_eh(void);
  25 LJ_ASMF void lj_vm_unwind_ff_eh(void);
  26 #if LJ_TARGET_X86ORX64
  27 LJ_ASMF void lj_vm_unwind_rethrow(void);
  28 #endif
  29 
  30 /* Miscellaneous functions. */
  31 #if LJ_TARGET_X86ORX64
  32 LJ_ASMF int lj_vm_cpuid(uint32_t f, uint32_t res[4]);
  33 #endif
  34 #if LJ_TARGET_PPC
  35 void lj_vm_cachesync(void *start, void *end);
  36 #endif
  37 LJ_ASMF double lj_vm_foldarith(double x, double y, int op);
  38 #if LJ_HASJIT
  39 LJ_ASMF double lj_vm_foldfpm(double x, int op);
  40 #endif
  41 #if !LJ_ARCH_HASFPU
  42 /* Declared in lj_obj.h: LJ_ASMF int32_t lj_vm_tobit(double x); */
  43 #endif
  44 
  45 /* Dispatch targets for recording and hooks. */
  46 LJ_ASMF void lj_vm_record(void);
  47 LJ_ASMF void lj_vm_inshook(void);
  48 LJ_ASMF void lj_vm_rethook(void);
  49 LJ_ASMF void lj_vm_callhook(void);
  50 LJ_ASMF void lj_vm_profhook(void);
  51 
  52 /* Trace exit handling. */
  53 LJ_ASMF void lj_vm_exit_handler(void);
  54 LJ_ASMF void lj_vm_exit_interp(void);
  55 
  56 /* Internal math helper functions. */
  57 #if LJ_TARGET_PPC || LJ_TARGET_ARM64 || (LJ_TARGET_MIPS && LJ_ABI_SOFTFP)
  58 #define lj_vm_floor     floor
  59 #define lj_vm_ceil      ceil
  60 #else
  61 LJ_ASMF double lj_vm_floor(double);
  62 LJ_ASMF double lj_vm_ceil(double);
  63 #if LJ_TARGET_ARM
  64 LJ_ASMF double lj_vm_floor_sf(double);
  65 LJ_ASMF double lj_vm_ceil_sf(double);
  66 #endif
  67 #endif
  68 #ifdef LUAJIT_NO_LOG2
  69 LJ_ASMF double lj_vm_log2(double);
  70 #else
  71 #define lj_vm_log2      log2
  72 #endif
  73 #if !(defined(_LJ_DISPATCH_H) && LJ_TARGET_MIPS)
  74 LJ_ASMF int32_t LJ_FASTCALL lj_vm_modi(int32_t, int32_t);
  75 #endif
  76 
  77 #if LJ_HASJIT
  78 #if LJ_TARGET_X86ORX64
  79 LJ_ASMF void lj_vm_floor_sse(void);
  80 LJ_ASMF void lj_vm_ceil_sse(void);
  81 LJ_ASMF void lj_vm_trunc_sse(void);
  82 LJ_ASMF void lj_vm_powi_sse(void);
  83 #define lj_vm_powi      NULL
  84 #else
  85 LJ_ASMF double lj_vm_powi(double, int32_t);
  86 #endif
  87 #if LJ_TARGET_PPC || LJ_TARGET_ARM64
  88 #define lj_vm_trunc     trunc
  89 #else
  90 LJ_ASMF double lj_vm_trunc(double);
  91 #if LJ_TARGET_ARM
  92 LJ_ASMF double lj_vm_trunc_sf(double);
  93 #endif
  94 #endif
  95 #ifdef LUAJIT_NO_EXP2
  96 LJ_ASMF double lj_vm_exp2(double);
  97 #else
  98 #define lj_vm_exp2      exp2
  99 #endif
 100 #if LJ_HASFFI
 101 LJ_ASMF int lj_vm_errno(void);
 102 #endif
 103 #endif
 104 
 105 /* Continuations for metamethods. */
 106 LJ_ASMF void lj_cont_cat(void);  /* Continue with concatenation. */
 107 LJ_ASMF void lj_cont_ra(void);  /* Store result in RA from instruction. */
 108 LJ_ASMF void lj_cont_nop(void);  /* Do nothing, just continue execution. */
 109 LJ_ASMF void lj_cont_condt(void);  /* Branch if result is true. */
 110 LJ_ASMF void lj_cont_condf(void);  /* Branch if result is false. */
 111 LJ_ASMF void lj_cont_hook(void);  /* Continue from hook yield. */
 112 LJ_ASMF void lj_cont_stitch(void);  /* Trace stitching. */
 113 
 114 /* Start of the ASM code. */
 115 LJ_ASMF char lj_vm_asm_begin[];
 116 
 117 /* Bytecode offsets are relative to lj_vm_asm_begin. */
 118 #define makeasmfunc(ofs)        ((ASMFunction)(lj_vm_asm_begin + (ofs)))
 119 
 120 #endif

/* [<][>][^][v][top][bottom][index][help] */