diff options
author | Mike Pall <mike> | 2012-10-07 15:47:11 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-10-07 15:47:11 +0200 |
commit | 0561a5693884d76db5b75f7cc746478b325b311b (patch) | |
tree | beef0d8674adf5b0f24a101e4e92613ee85e996e /src/vm_x86.dasc | |
parent | 0d62e2e1ab450a2d2d2291dc9da43606bd573bf7 (diff) | |
download | luajit-0561a5693884d76db5b75f7cc746478b325b311b.tar.gz luajit-0561a5693884d76db5b75f7cc746478b325b311b.tar.bz2 luajit-0561a5693884d76db5b75f7cc746478b325b311b.zip |
From Lua 5.2: Add math.log(x, base).
Diffstat (limited to '')
-rw-r--r-- | src/vm_x86.dasc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc index 67984c6c..75683225 100644 --- a/src/vm_x86.dasc +++ b/src/vm_x86.dasc | |||
@@ -2045,7 +2045,12 @@ static void build_subroutines(BuildCtx *ctx) | |||
2045 | |.else | 2045 | |.else |
2046 | |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn | 2046 | |.ffunc_n math_sqrt; fsqrt; jmp ->fff_resn |
2047 | |.endif | 2047 | |.endif |
2048 | |.ffunc_n math_log, fldln2; fyl2x; jmp ->fff_resn | 2048 | | |
2049 | |.ffunc math_log | ||
2050 | | cmp NARGS:RD, 1+1; jne ->fff_fallback // Exactly one argument. | ||
2051 | | cmp dword [BASE+4], LJ_TISNUM; jae ->fff_fallback | ||
2052 | | fldln2; fld qword [BASE]; fyl2x; jmp ->fff_resn | ||
2053 | | | ||
2049 | |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn | 2054 | |.ffunc_n math_log10, fldlg2; fyl2x; jmp ->fff_resn |
2050 | |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn | 2055 | |.ffunc_n math_exp; call ->vm_exp_x87; jmp ->fff_resn |
2051 | | | 2056 | | |
@@ -3157,6 +3162,29 @@ static void build_subroutines(BuildCtx *ctx) | |||
3157 | | ret | 3162 | | ret |
3158 | |.endif | 3163 | |.endif |
3159 | | | 3164 | | |
3165 | |// FP log2(x). Called by math.log(x, base). | ||
3166 | |->vm_log2: | ||
3167 | |.if X64WIN | ||
3168 | | movsd qword [rsp+8], xmm0 // Use scratch area. | ||
3169 | | fld1 | ||
3170 | | fld qword [rsp+8] | ||
3171 | | fyl2x | ||
3172 | | fstp qword [rsp+8] | ||
3173 | | movsd xmm0, qword [rsp+8] | ||
3174 | |.elif X64 | ||
3175 | | movsd qword [rsp-8], xmm0 // Use red zone. | ||
3176 | | fld1 | ||
3177 | | fld qword [rsp-8] | ||
3178 | | fyl2x | ||
3179 | | fstp qword [rsp-8] | ||
3180 | | movsd xmm0, qword [rsp-8] | ||
3181 | |.else | ||
3182 | | fld1 | ||
3183 | | fld qword [esp+4] | ||
3184 | | fyl2x | ||
3185 | |.endif | ||
3186 | | ret | ||
3187 | | | ||
3160 | |// FP exponentiation e^x and 2^x. Called by math.exp fast function and | 3188 | |// FP exponentiation e^x and 2^x. Called by math.exp fast function and |
3161 | |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. | 3189 | |// from JIT code. Arg/ret on x87 stack. No int/xmm regs modified. |
3162 | |// Caveat: needs 3 slots on x87 stack! | 3190 | |// Caveat: needs 3 slots on x87 stack! |