diff options
author | Mike Pall <mike> | 2013-02-22 01:44:17 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2013-02-22 01:44:17 +0100 |
commit | 19d565145592b45713adfd474224a1e46a533a99 (patch) | |
tree | bc0d9571abe59cfe2b977d2d3a13809526fb6181 | |
parent | e20157c6e68472e7c4d82d9ed4c0bb5be029c388 (diff) | |
download | luajit-19d565145592b45713adfd474224a1e46a533a99.tar.gz luajit-19d565145592b45713adfd474224a1e46a533a99.tar.bz2 luajit-19d565145592b45713adfd474224a1e46a533a99.zip |
Replace math.deg/math.rad with builtin Lua function.
-rw-r--r-- | src/host/buildvm_libbc.h | 7 | ||||
-rw-r--r-- | src/lib_math.c | 7 | ||||
-rw-r--r-- | src/lj_dispatch.h | 2 | ||||
-rw-r--r-- | src/lj_ffrecord.c | 8 | ||||
-rw-r--r-- | src/vm_arm.dasc | 13 | ||||
-rw-r--r-- | src/vm_mips.dasc | 6 | ||||
-rw-r--r-- | src/vm_ppc.dasc | 6 | ||||
-rw-r--r-- | src/vm_ppcspe.dasc | 6 | ||||
-rw-r--r-- | src/vm_x86.dasc | 6 |
9 files changed, 8 insertions, 53 deletions
diff --git a/src/host/buildvm_libbc.h b/src/host/buildvm_libbc.h index d2d83ea6..ee97836a 100644 --- a/src/host/buildvm_libbc.h +++ b/src/host/buildvm_libbc.h | |||
@@ -3,10 +3,13 @@ | |||
3 | static const int libbc_endian = 0; | 3 | static const int libbc_endian = 0; |
4 | 4 | ||
5 | static const uint8_t libbc_code[] = { | 5 | static const uint8_t libbc_code[] = { |
6 | 0 | 6 | 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, |
7 | 0,1,2,22,1,0,0,72,1,2,0,243,244,148,165,20,198,190,199,252,3,0 | ||
7 | }; | 8 | }; |
8 | 9 | ||
9 | static const struct { const char *name; int ofs; } libbc_map[] = { | 10 | static const struct { const char *name; int ofs; } libbc_map[] = { |
10 | {NULL,0} | 11 | {"math_deg",0}, |
12 | {"math_rad",25}, | ||
13 | {NULL,50} | ||
11 | }; | 14 | }; |
12 | 15 | ||
diff --git a/src/lib_math.c b/src/lib_math.c index b23d9a2d..e474f980 100644 --- a/src/lib_math.c +++ b/src/lib_math.c | |||
@@ -63,11 +63,8 @@ LJLIB_ASM(math_log) LJLIB_REC(math_log) | |||
63 | return FFH_RETRY; | 63 | return FFH_RETRY; |
64 | } | 64 | } |
65 | 65 | ||
66 | LJLIB_PUSH(57.29577951308232) | 66 | LJLIB_LUA(math_deg) /* function(x) return x * 57.29577951308232 end */ |
67 | LJLIB_ASM_(math_deg) LJLIB_REC(math_degrad) | 67 | LJLIB_LUA(math_rad) /* function(x) return x * 0.017453292519943295 end */ |
68 | |||
69 | LJLIB_PUSH(0.017453292519943295) | ||
70 | LJLIB_ASM_(math_rad) LJLIB_REC(math_degrad) | ||
71 | 68 | ||
72 | LJLIB_ASM(math_atan2) LJLIB_REC(.) | 69 | LJLIB_ASM(math_atan2) LJLIB_REC(.) |
73 | { | 70 | { |
diff --git a/src/lj_dispatch.h b/src/lj_dispatch.h index a56b6260..57614d99 100644 --- a/src/lj_dispatch.h +++ b/src/lj_dispatch.h | |||
@@ -60,7 +60,7 @@ typedef uint16_t HotCount; | |||
60 | #define HOTCOUNT_CALL 1 | 60 | #define HOTCOUNT_CALL 1 |
61 | 61 | ||
62 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ | 62 | /* This solves a circular dependency problem -- bump as needed. Sigh. */ |
63 | #define GG_NUM_ASMFF 62 | 63 | #define GG_NUM_ASMFF 60 |
64 | 64 | ||
65 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) | 65 | #define GG_LEN_DDISP (BC__MAX + GG_NUM_ASMFF) |
66 | #define GG_LEN_SDISP BC_FUNCF | 66 | #define GG_LEN_SDISP BC_FUNCF |
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c index 4aa4f064..30d5c44e 100644 --- a/src/lj_ffrecord.c +++ b/src/lj_ffrecord.c | |||
@@ -528,14 +528,6 @@ static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd) | |||
528 | rd->nres = 2; | 528 | rd->nres = 2; |
529 | } | 529 | } |
530 | 530 | ||
531 | static void LJ_FASTCALL recff_math_degrad(jit_State *J, RecordFFData *rd) | ||
532 | { | ||
533 | TRef tr = lj_ir_tonum(J, J->base[0]); | ||
534 | TRef trm = lj_ir_knum(J, numV(&J->fn->c.upvalue[0])); | ||
535 | J->base[0] = emitir(IRTN(IR_MUL), tr, trm); | ||
536 | UNUSED(rd); | ||
537 | } | ||
538 | |||
539 | static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) | 531 | static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd) |
540 | { | 532 | { |
541 | TRef tr = lj_ir_tonum(J, J->base[0]); | 533 | TRef tr = lj_ir_tonum(J, J->base[0]); |
diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc index 114416a4..c46d9243 100644 --- a/src/vm_arm.dasc +++ b/src/vm_arm.dasc | |||
@@ -1501,19 +1501,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1501 | | math_extern2 atan2 | 1501 | | math_extern2 atan2 |
1502 | | math_extern2 fmod | 1502 | | math_extern2 fmod |
1503 | | | 1503 | | |
1504 | |->ff_math_deg: | ||
1505 | |.if FPU | ||
1506 | | .ffunc_d math_rad | ||
1507 | | vldr d1, CFUNC:CARG3->upvalue[0] | ||
1508 | | vmul.f64 d0, d0, d1 | ||
1509 | | b ->fff_resd | ||
1510 | |.else | ||
1511 | | .ffunc_n math_rad | ||
1512 | | ldrd CARG34, CFUNC:CARG3->upvalue[0] | ||
1513 | | bl extern __aeabi_dmul | ||
1514 | | b ->fff_restv | ||
1515 | |.endif | ||
1516 | | | ||
1517 | |.if HFABI | 1504 | |.if HFABI |
1518 | | .ffunc math_ldexp | 1505 | | .ffunc math_ldexp |
1519 | | ldr CARG4, [BASE, #4] | 1506 | | ldr CARG4, [BASE, #4] |
diff --git a/src/vm_mips.dasc b/src/vm_mips.dasc index a81dbeeb..e7c89267 100644 --- a/src/vm_mips.dasc +++ b/src/vm_mips.dasc | |||
@@ -1521,12 +1521,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1521 | | b ->fff_resn | 1521 | | b ->fff_resn |
1522 | |. nop | 1522 | |. nop |
1523 | | | 1523 | | |
1524 | |->ff_math_deg: | ||
1525 | |.ffunc_n math_rad | ||
1526 | |. ldc1 FARG2, CFUNC:RB->upvalue[0] | ||
1527 | | b ->fff_resn | ||
1528 | |. mul.d FRET1, FARG1, FARG2 | ||
1529 | | | ||
1530 | |.ffunc_nn math_ldexp | 1524 | |.ffunc_nn math_ldexp |
1531 | | cvt.w.d FARG2, FARG2 | 1525 | | cvt.w.d FARG2, FARG2 |
1532 | | load_got ldexp | 1526 | | load_got ldexp |
diff --git a/src/vm_ppc.dasc b/src/vm_ppc.dasc index 685ea518..e6fd977b 100644 --- a/src/vm_ppc.dasc +++ b/src/vm_ppc.dasc | |||
@@ -1870,12 +1870,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1870 | | math_extern2 atan2 | 1870 | | math_extern2 atan2 |
1871 | | math_extern2 fmod | 1871 | | math_extern2 fmod |
1872 | | | 1872 | | |
1873 | |->ff_math_deg: | ||
1874 | |.ffunc_n math_rad | ||
1875 | | lfd FARG2, CFUNC:RB->upvalue[0] | ||
1876 | | fmul FARG1, FARG1, FARG2 | ||
1877 | | b ->fff_resn | ||
1878 | | | ||
1879 | |.if DUALNUM | 1873 | |.if DUALNUM |
1880 | |.ffunc math_ldexp | 1874 | |.ffunc math_ldexp |
1881 | | cmplwi NARGS8:RC, 16 | 1875 | | cmplwi NARGS8:RC, 16 |
diff --git a/src/vm_ppcspe.dasc b/src/vm_ppcspe.dasc index 4fabc02f..b443f1b3 100644 --- a/src/vm_ppcspe.dasc +++ b/src/vm_ppcspe.dasc | |||
@@ -1456,12 +1456,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
1456 | | math_extern2 atan2 | 1456 | | math_extern2 atan2 |
1457 | | math_extern2 fmod | 1457 | | math_extern2 fmod |
1458 | | | 1458 | | |
1459 | |->ff_math_deg: | ||
1460 | |.ffunc_n math_rad | ||
1461 | | evldd CARG2, CFUNC:RB->upvalue[0] | ||
1462 | | efdmul CRET1, CARG1, CARG2 | ||
1463 | | b ->fff_restv | ||
1464 | | | ||
1465 | |.ffunc math_ldexp | 1459 | |.ffunc math_ldexp |
1466 | | cmplwi NARGS8:RC, 16 | 1460 | | cmplwi NARGS8:RC, 16 |
1467 | | evldd CARG2, 0(BASE) | 1461 | | evldd CARG2, 0(BASE) |
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc index 7020eb27..bf42f5d2 100644 --- a/src/vm_x86.dasc +++ b/src/vm_x86.dasc | |||
@@ -2030,12 +2030,6 @@ static void build_subroutines(BuildCtx *ctx) | |||
2030 | | math_extern cosh | 2030 | | math_extern cosh |
2031 | | math_extern tanh | 2031 | | math_extern tanh |
2032 | | | 2032 | | |
2033 | |->ff_math_deg: | ||
2034 | |.ffunc_nsse math_rad | ||
2035 | | mov CFUNC:RB, [BASE-8] | ||
2036 | | mulsd xmm0, qword CFUNC:RB->upvalue[0] | ||
2037 | | jmp ->fff_resxmm0 | ||
2038 | | | ||
2039 | |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn | 2033 | |.ffunc_nn math_atan2; fpatan; jmp ->fff_resn |
2040 | |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn | 2034 | |.ffunc_nnr math_ldexp; fscale; fpop1; jmp ->fff_resn |
2041 | | | 2035 | | |