mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Replace math.deg/math.rad with builtin Lua function.
This commit is contained in:
parent
e20157c6e6
commit
19d5651455
@ -3,10 +3,13 @@
|
||||
static const int libbc_endian = 0;
|
||||
|
||||
static const uint8_t libbc_code[] = {
|
||||
0
|
||||
0,1,2,0,0,1,2,22,1,0,0,72,1,2,0,241,135,158,166,3,220,203,178,130,4,0,1,2,0,
|
||||
0,1,2,22,1,0,0,72,1,2,0,243,244,148,165,20,198,190,199,252,3,0
|
||||
};
|
||||
|
||||
static const struct { const char *name; int ofs; } libbc_map[] = {
|
||||
{NULL,0}
|
||||
{"math_deg",0},
|
||||
{"math_rad",25},
|
||||
{NULL,50}
|
||||
};
|
||||
|
||||
|
@ -63,11 +63,8 @@ LJLIB_ASM(math_log) LJLIB_REC(math_log)
|
||||
return FFH_RETRY;
|
||||
}
|
||||
|
||||
LJLIB_PUSH(57.29577951308232)
|
||||
LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad)
|
||||
|
||||
LJLIB_PUSH(0.017453292519943295)
|
||||
LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad)
|
||||
LJLIB_LUA(math_deg) /* function(x) return x * 57.29577951308232 end */
|
||||
LJLIB_LUA(math_rad) /* function(x) return x * 0.017453292519943295 end */
|
||||
|
||||
LJLIB_ASM(math_atan2) LJLIB_REC(.)
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ typedef uint16_t HotCount;
|
||||
#define HOTCOUNT_CALL 1
|
||||
|
||||
/* This solves a circular dependency problem -- bump as needed. Sigh. */
|
||||
#define GG_NUM_ASMFF 62
|
||||
#define GG_NUM_ASMFF 60
|
||||
|
||||
#define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF)
|
||||
#define GG_LEN_SDISP BC_FUNCF
|
||||
|
@ -528,14 +528,6 @@ static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd)
|
||||
rd->nres = 2;
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0]));
|
||||
J->base[0] = emitir(IRTN(IR_MUL), tr, trm);
|
||||
UNUSED(rd);
|
||||
}
|
||||
|
||||
static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd)
|
||||
{
|
||||
TRef tr = lj_ir_tonum(J, J->base[0]);
|
||||
|
@ -1501,19 +1501,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| math_extern2 atan2
|
||||
| math_extern2 fmod
|
||||
|
|
||||
|->ff_math_deg:
|
||||
|.if FPU
|
||||
| .ffunc_d math_rad
|
||||
| vldr d1, CFUNC:CARG3->upvalue[0]
|
||||
| vmul.f64 d0, d0, d1
|
||||
| b ->fff_resd
|
||||
|.else
|
||||
| .ffunc_n math_rad
|
||||
| ldrd CARG34, CFUNC:CARG3->upvalue[0]
|
||||
| bl extern __aeabi_dmul
|
||||
| b ->fff_restv
|
||||
|.endif
|
||||
|
|
||||
|.if HFABI
|
||||
| .ffunc math_ldexp
|
||||
| ldr CARG4, [BASE, #4]
|
||||
|
@ -1521,12 +1521,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| b ->fff_resn
|
||||
|. nop
|
||||
|
|
||||
|->ff_math_deg:
|
||||
|.ffunc_n math_rad
|
||||
|. ldc1 FARG2, CFUNC:RB->upvalue[0]
|
||||
| b ->fff_resn
|
||||
|. mul.d FRET1, FARG1, FARG2
|
||||
|
|
||||
|.ffunc_nn math_ldexp
|
||||
| cvt.w.d FARG2, FARG2
|
||||
| load_got ldexp
|
||||
|
@ -1870,12 +1870,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| math_extern2 atan2
|
||||
| math_extern2 fmod
|
||||
|
|
||||
|->ff_math_deg:
|
||||
|.ffunc_n math_rad
|
||||
| lfd FARG2, CFUNC:RB->upvalue[0]
|
||||
| fmul FARG1, FARG1, FARG2
|
||||
| b ->fff_resn
|
||||
|
|
||||
|.if DUALNUM
|
||||
|.ffunc math_ldexp
|
||||
| cmplwi NARGS8:RC, 16
|
||||
|
@ -1456,12 +1456,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| math_extern2 atan2
|
||||
| math_extern2 fmod
|
||||
|
|
||||
|->ff_math_deg:
|
||||
|.ffunc_n math_rad
|
||||
| evldd CARG2, CFUNC:RB->upvalue[0]
|
||||
| efdmul CRET1, CARG1, CARG2
|
||||
| b ->fff_restv
|
||||
|
|
||||
|.ffunc math_ldexp
|
||||
| cmplwi NARGS8:RC, 16
|
||||
| evldd CARG2, 0(BASE)
|
||||
|
@ -2030,12 +2030,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| math_extern cosh
|
||||
| math_extern tanh
|
||||
|
|
||||
|->ff_math_deg:
|
||||
|.ffunc_nsse math_rad
|
||||
| mov CFUNC:RB, [BASE-8]
|
||||
| mulsd xmm0, qword CFUNC:RB->upvalue[0]
|
||||
| jmp ->fff_resxmm0
|
||||
|
|
||||
|.ffunc_nn math_atan2; fpatan; jmp ->fff_resn
|
||||
|.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn
|
||||
|
|
||||
|
Loading…
Reference in New Issue
Block a user