File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -420,6 +420,10 @@ class Intrinsifier {
420420 codeGen.translateExpression (receiver, w.NumType .f64);
421421 b.i64_trunc_sat_f64_s ();
422422 return w.NumType .i64;
423+ case "sqrt" :
424+ codeGen.translateExpression (receiver, w.NumType .f64);
425+ b.f64_sqrt ();
426+ return w.NumType .f64;
423427 case "copysign" :
424428 codeGen.translateExpression (receiver, w.NumType .f64);
425429 codeGen.translateExpression (
Original file line number Diff line number Diff line change 55import "dart:_internal" show mix64, patch;
66import "dart:_js_types" show JSUint8ArrayImpl;
77import "dart:js_interop" ;
8+ import "dart:_wasm" ;
89
910/// There are no parts of this patch library.
1011
@@ -113,7 +114,7 @@ double asin(num x) => _asin(x.toDouble());
113114@patch
114115double atan (num x) => _atan (x.toDouble ());
115116@patch
116- double sqrt (num x) => _sqrt ( x.toDouble ());
117+ double sqrt (num x) => x.toDouble (). sqrt ( );
117118@patch
118119double exp (num x) => _exp (x.toDouble ());
119120@patch
@@ -133,8 +134,6 @@ external double _acos(double x);
133134external double _asin (double x);
134135@pragma ("wasm:import" , "Math.atan" )
135136external double _atan (double x);
136- @pragma ("wasm:import" , "Math.sqrt" )
137- external double _sqrt (double x);
138137@pragma ("wasm:import" , "Math.exp" )
139138external double _exp (double x);
140139@pragma ("wasm:import" , "Math.log" )
Original file line number Diff line number Diff line change @@ -221,6 +221,9 @@ class WasmF64 extends _WasmBase {
221221 /// Wasm `i64.trunc_sat_f64_s` instruction.
222222 external WasmI64 truncSatS ();
223223
224+ /// Wasm `f64.sqrt` instruction.
225+ external WasmF64 sqrt ();
226+
224227 /// Wasm `f64.copysign` instruction.
225228 external WasmF64 copysign (WasmF64 other);
226229}
@@ -437,6 +440,10 @@ extension DoubleWasmInstructions on double {
437440 @pragma ("wasm:prefer-inline" )
438441 double copysign (double other) =>
439442 this .toWasmF64 ().copysign (other.toWasmF64 ()).toDouble ();
443+
444+ /// Wasm `f64.sqrt` instruction.
445+ @pragma ("wasm:prefer-inline" )
446+ double sqrt () => this .toWasmF64 ().sqrt ().toDouble ();
440447}
441448
442449extension WasmExternRefToJSAny on WasmExternRef {
You can’t perform that action at this time.
0 commit comments