File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -206,9 +206,9 @@ import {
206206 isPowerOf2 ,
207207 readI32 ,
208208 isIdentifier ,
209- accuratePow64 ,
210209 v128_zero ,
211210 v128_ones ,
211+ accuratePow64 ,
212212} from "./util" ;
213213
214214import {
@@ -5129,7 +5129,8 @@ export class Compiler extends DiagnosticEmitter {
51295129 let leftValue = getConstValueF32 ( leftExpr ) ;
51305130 let rightValue = getConstValueF32 ( rightExpr ) ;
51315131 this . currentType = type ;
5132- return module . f32 ( f32 ( accuratePow64 ( leftValue , rightValue ) ) ) ;
5132+ console . log ( leftValue , rightValue , accuratePow64 ( leftValue , rightValue ) )
5133+ return module . f32 ( f32 ( Math . pow ( leftValue , rightValue ) ) ) ;
51335134 }
51345135 }
51355136 let instance = this . f32PowInstance ;
@@ -5170,6 +5171,7 @@ export class Compiler extends DiagnosticEmitter {
51705171 let leftValue = getConstValueF64 ( leftExpr ) ;
51715172 let rightValue = getConstValueF64 ( rightExpr ) ;
51725173 this . currentType = type ;
5174+ console . log ( leftValue , rightValue , accuratePow64 ( leftValue , rightValue ) )
51735175 return module . f64 ( accuratePow64 ( leftValue , rightValue ) ) ;
51745176 }
51755177 }
Original file line number Diff line number Diff line change @@ -11,15 +11,11 @@ export function isPowerOf2(x: i32): bool {
1111export function accuratePow64 ( x : f64 , y : f64 ) : f64 {
1212 if ( ! ASC_TARGET ) { // ASC_TARGET == JS
1313 // Engines like V8, WebKit and SpiderMonkey uses powi fast path if exponent is integer
14- // This speculative optimization leads to loose precisions like 10 ** 208 != 1e208
15- // or/and 10 ** -5 != 1e-5 anymore. For avoid this behaviour we are forcing exponent
14+ // This speculative optimization leads to loose precisions like 10 ** -5 != 1e-5 anymore.
15+ // For avoid this behaviour we are forcing exponent
1616 // to fractional form and compensate this afterwards.
17- if ( isFinite ( y ) && Math . abs ( y ) >= 2 && Math . trunc ( y ) == y ) {
18- if ( y < 0 ) {
19- return Math . pow ( x , y + 0.5 ) / Math . pow ( x , 0.5 ) ;
20- } else {
21- return Math . pow ( x , y - 0.5 ) * Math . pow ( x , 0.5 ) ;
22- }
17+ if ( isFinite ( y ) && y <= 2 && Math . trunc ( y ) == y ) {
18+ return Math . pow ( x , y + 0.5 ) / Math . pow ( x , 0.5 ) ;
2319 }
2420 }
2521 return Math . pow ( x , y ) ;
You can’t perform that action at this time.
0 commit comments