[dart2wasm] Move boxed double and int types to their own libs

This allows injecting internally public members int and double members
to the libraries and it's consistent with how we've been restructuring
the dart2wasm standard libraries.

Tested: existing tests
Change-Id: I5261f3ab78667de93b4d7583d99bb9ae151a6cb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373241
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Ömer Sinan Ağacan
2024-07-05 11:34:34 +00:00
committed by Commit Queue
parent 10e8ee7977
commit cc44c910eb
15 changed files with 158 additions and 98 deletions
+2
View File
@@ -126,6 +126,8 @@ Future<CompilerOutput?> compileToModule(
CoreTypes coreTypes = compilerResult.coreTypes!;
ClassHierarchy classHierarchy = compilerResult.classHierarchy!;
LibraryIndex libraryIndex = LibraryIndex(component, [
"dart:_boxed_double",
"dart:_boxed_int",
"dart:_internal",
"dart:_js_helper",
"dart:_js_types",
+25 -7
View File
@@ -46,12 +46,6 @@ class Intrinsifier {
'<=': (c) => c.b.i64_le_s(),
'>': (c) => c.b.i64_gt_s(),
'>=': (c) => c.b.i64_ge_s(),
'_div_s': (c) => c.b.i64_div_s(),
'_shl': (c) => c.b.i64_shl(),
'_shr_s': (c) => c.b.i64_shr_s(),
'_shr_u': (c) => c.b.i64_shr_u(),
'_le_u': (c) => c.b.i64_le_u(),
'_lt_u': (c) => c.b.i64_lt_u(),
'~/': (c) => c.call(c.translator.truncDiv.reference),
}
},
@@ -65,7 +59,6 @@ class Intrinsifier {
'<=': (c) => c.b.f64_le(),
'>': (c) => c.b.f64_gt(),
'>=': (c) => c.b.f64_ge(),
'_copysign': (c) => c.b.f64_copysign(),
}
},
};
@@ -297,6 +290,26 @@ class Intrinsifier {
codeGen.wrap(node.arguments.positional[0], w.NumType.i64);
b.i64_gt_u();
return boolType;
case "shl":
codeGen.wrap(receiver, w.NumType.i64);
codeGen.wrap(node.arguments.positional[0], w.NumType.i64);
b.i64_shl();
return w.NumType.i64;
case "shrS":
codeGen.wrap(receiver, w.NumType.i64);
codeGen.wrap(node.arguments.positional[0], w.NumType.i64);
b.i64_shr_s();
return w.NumType.i64;
case "shrU":
codeGen.wrap(receiver, w.NumType.i64);
codeGen.wrap(node.arguments.positional[0], w.NumType.i64);
b.i64_shr_u();
return w.NumType.i64;
case "divS":
codeGen.wrap(receiver, w.NumType.i64);
codeGen.wrap(node.arguments.positional[0], w.NumType.i64);
b.i64_div_s();
return w.NumType.i64;
default:
throw 'Unknown WasmI64 member $name';
}
@@ -314,6 +327,11 @@ class Intrinsifier {
codeGen.wrap(receiver, w.NumType.f64);
b.i64_trunc_sat_f64_s();
return w.NumType.i64;
case "copysign":
codeGen.wrap(receiver, w.NumType.f64);
codeGen.wrap(node.arguments.positional[0], w.NumType.f64);
b.f64_copysign();
return w.NumType.f64;
default:
throw 'Unknown WasmF64 member $name';
}
+4 -3
View File
@@ -30,8 +30,9 @@ mixin KernelNodes {
// dart:core various classes
late final Class boxedBoolClass = index.getClass("dart:core", "_BoxedBool");
late final Class boxedDoubleClass =
index.getClass("dart:core", "_BoxedDouble");
late final Class boxedIntClass = index.getClass("dart:core", "_BoxedInt");
index.getClass("dart:_boxed_double", "BoxedDouble");
late final Class boxedIntClass =
index.getClass("dart:_boxed_int", "BoxedInt");
late final Class closureClass = index.getClass("dart:core", "_Closure");
late final Class listBaseClass = index.getClass("dart:_list", "WasmListBase");
late final Class fixedLengthListClass =
@@ -250,7 +251,7 @@ mixin KernelNodes {
late final Procedure stringInterpolate4 =
index.getProcedure("dart:_string", "StringBase", "_interpolate4");
late final Procedure truncDiv =
index.getProcedure("dart:core", "_BoxedInt", "_truncDiv");
index.getProcedure("dart:_boxed_int", "BoxedInt", "_truncDiv");
late final Procedure runtimeTypeEquals =
index.getTopLevelProcedure("dart:core", "_runtimeTypeEquals");
late final Procedure runtimeTypeHashCode =
+7 -2
View File
@@ -142,6 +142,8 @@ class WasmTarget extends Target {
@override
List<String> get extraRequiredLibraries => [
'dart:_boxed_double',
'dart:_boxed_int',
'dart:_http',
'dart:_internal',
'dart:_js_helper',
@@ -163,6 +165,8 @@ class WasmTarget extends Target {
@override
List<String> get extraIndexedLibraries => [
'dart:_boxed_double',
'dart:_boxed_int',
'dart:_js_helper',
'dart:_js_types',
'dart:_list',
@@ -524,11 +528,12 @@ class WasmTarget extends Target {
@override
Class concreteIntLiteralClass(CoreTypes coreTypes, int value) =>
_boxedInt ??= coreTypes.index.getClass("dart:core", "_BoxedInt");
_boxedInt ??= coreTypes.index.getClass("dart:_boxed_int", "BoxedInt");
@override
Class concreteDoubleLiteralClass(CoreTypes coreTypes, double value) =>
_boxedDouble ??= coreTypes.index.getClass("dart:core", "_BoxedDouble");
_boxedDouble ??=
coreTypes.index.getClass("dart:_boxed_double", "BoxedDouble");
@override
DartLibrarySupport get dartLibrarySupport => CustomizedDartLibrarySupport(
@@ -3,26 +3,26 @@ import self as self;
import "dart:core" as core;
[@vm.inferred-type.metadata=dart.core::_BoxedInt]
[@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt]
[@vm.unboxing-info.metadata=(i)->i]
static field core::int x = [@vm.inferred-type.metadata=dart.core::_BoxedInt] core::int::parse("2");
static field core::int x = [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] core::int::parse("2");
[@vm.inferred-type.metadata=dart.core::_BoxedInt]
[@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt]
[@vm.unboxing-info.metadata=(i)->i]
static field core::int y = [@vm.inferred-type.metadata=dart.core::_BoxedInt] core::int::parse("3");
static field core::int y = [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] core::int::parse("3");
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
[@vm.unboxing-info.metadata=(i,i,i)->b]
static method use([@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic a, [@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic b, [@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic c) → void {
static method use([@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic a, [@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic b, [@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic c) → void {
core::print(a);
core::print(b);
core::print(c);
core::print([@vm.direct-call.metadata=dart.core::_BoxedInt.~/] [@vm.inferred-type.metadata=dart.core::_BoxedInt] a{dynamic}.~/(2));
core::print([@vm.direct-call.metadata=dart.core::_BoxedInt.~/] [@vm.inferred-type.metadata=dart.core::_BoxedInt] b{dynamic}.~/(2));
core::print([@vm.direct-call.metadata=dart.core::_BoxedInt.~/] [@vm.inferred-type.metadata=dart.core::_BoxedInt] c{dynamic}.~/(2));
core::print([@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.~/] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] a{dynamic}.~/(2));
core::print([@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.~/] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] b{dynamic}.~/(2));
core::print([@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.~/] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] c{dynamic}.~/(2));
}
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
static method main() → dynamic {
self::use([@vm.direct-call.metadata=dart.core::_BoxedInt.+] [@vm.inferred-type.metadata=dart.core::_BoxedInt (skip check)] [@vm.inferred-type.metadata=dart.core::_BoxedInt] self::x.{core::num::+}([@vm.inferred-type.metadata=dart.core::_BoxedInt] self::y){(core::num) → core::int}, [@vm.direct-call.metadata=dart.core::_BoxedInt.-] [@vm.inferred-type.metadata=dart.core::_BoxedInt (skip check)] [@vm.inferred-type.metadata=dart.core::_BoxedInt] self::x.{core::num::-}([@vm.inferred-type.metadata=dart.core::_BoxedInt] self::y){(core::num) → core::int}, [@vm.direct-call.metadata=dart.core::_BoxedInt.*] [@vm.inferred-type.metadata=dart.core::_BoxedInt (skip check)] [@vm.inferred-type.metadata=dart.core::_BoxedInt] self::x.{core::num::*}([@vm.inferred-type.metadata=dart.core::_BoxedInt] self::y){(core::num) → core::int});
self::use([@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.+] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt (skip check)] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::x.{core::num::+}([@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::y){(core::num) → core::int}, [@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.-] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt (skip check)] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::x.{core::num::-}([@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::y){(core::num) → core::int}, [@vm.direct-call.metadata=library dart:_boxed_int::BoxedInt.*] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt (skip check)] [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::x.{core::num::*}([@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] self::y){(core::num) → core::int});
}
@@ -8,7 +8,7 @@ static field dynamic list = <core::Object>["abc", (42, {foo42: "foo42"})];
[@vm.inferred-return-type.metadata=dart.core::Record_2_bar]
[@vm.unboxing-info.metadata=(i,i,i)->b]
static method recordLiteral([@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic x, [@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic y, [@vm.inferred-arg-type.metadata=dart.core::_BoxedInt] final dynamic z) → dynamic
static method recordLiteral([@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic x, [@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic y, [@vm.inferred-arg-type.metadata=library dart:_boxed_int::BoxedInt] final dynamic z) → dynamic
return (x, y, {bar: z});
static method recordFieldAccess1([@vm.inferred-arg-type.metadata=dart.core::Record_2] final(core::int, core::String) rec) → dynamic
return rec.$1{core::int};
@@ -20,7 +20,7 @@ static method recordDynamicFieldAccess(final dynamic x) → dynamic
[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)]
static method main() → dynamic {
core::print(#C4);
core::print([@vm.inferred-type.metadata=dart.core::Record_2_bar] self::recordLiteral([@vm.inferred-type.metadata=dart.core::_BoxedInt] core::int::parse("1"), [@vm.inferred-type.metadata=dart.core::_BoxedInt] core::int::parse("2"), [@vm.inferred-type.metadata=dart.core::_BoxedInt] core::int::parse("3")));
core::print([@vm.inferred-type.metadata=dart.core::Record_2_bar] self::recordLiteral([@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] core::int::parse("1"), [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] core::int::parse("2"), [@vm.inferred-type.metadata=library dart:_boxed_int::BoxedInt] core::int::parse("3")));
core::print(self::recordFieldAccess1((10, "hi")));
core::print(self::recordFieldAccess2(({a: 20, b: "bye"})));
core::print(self::recordDynamicFieldAccess([@vm.direct-call.metadata=dart._list::WasmListBase.[]??] [@vm.inferred-type.metadata=!? (receiver not int)] [@vm.inferred-type.metadata=dart._list::GrowableList?<dart.core::Object>] self::list{dynamic}.[](1)));
+15 -14
View File
@@ -2,19 +2,20 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:_boxed_int' show intHashCode;
import 'dart:_internal' show doubleToIntBits, intBitsToDouble;
import 'dart:_js_helper' show JS, jsStringToDartString;
import 'dart:_string';
import 'dart:_wasm';
@pragma("wasm:entry-point")
final class _BoxedDouble extends double {
final class BoxedDouble extends double {
// A boxed double contains an unboxed double.
@pragma("wasm:entry-point")
double value = 0.0;
/// Dummy factory to silence error about missing superclass constructor.
external factory _BoxedDouble();
external factory BoxedDouble();
static const int _mantissaBits = 52;
static const int _exponentBits = 11;
@@ -27,9 +28,9 @@ final class _BoxedDouble extends double {
static int _doubleHashCode(double value) {
const int maxInt = 0x7FFFFFFFFFFFFFFF;
int intValue = value._toInt();
int intValue = value.truncSatS();
if (intValue.toDouble() == value && intValue != maxInt) {
return _intHashCode(intValue);
return intHashCode(intValue);
}
int bits = doubleToIntBits(value);
return (bits ^ (bits >>> 32)) & 0x3FFFFFFF;
@@ -97,10 +98,10 @@ final class _BoxedDouble extends double {
return (a * b) / (a * b);
}
if ((aBits << 1)._le_u(bBits << 1)) {
if ((aBits << 1).leU(bBits << 1)) {
if ((aBits << 1) == (bBits << 1)) {
// abs(a) == abs(b), so remainder = +/- 0.0 depending on sign of a
return 0.0._copysign(a);
return 0.0.copysign(a);
}
// abs(a) < abs(b), so b = 0 * a rem. a
@@ -139,7 +140,7 @@ final class _BoxedDouble extends double {
// remainder is positive
if (remainder == 0) {
// a divides into b exactly, so remainder = +/- 0.0 depending on sign of a
return 0.0._copysign(a);
return 0.0.copysign(a);
}
aBits = remainder;
@@ -155,7 +156,7 @@ final class _BoxedDouble extends double {
// remainder is positive
if (remainder == 0) {
// a divides into b exactly, so remainder = +/- 0.0 depending on sign of a
return 0.0._copysign(a);
return 0.0.copysign(a);
}
aBits = remainder;
@@ -205,7 +206,7 @@ final class _BoxedDouble extends double {
bool get isNegative {
// Sign bit set, not NaN
int bits = doubleToIntBits(this);
return (bits ^ _signMask)._le_u(_exponentMask);
return (bits ^ _signMask).leU(_exponentMask);
}
@pragma("wasm:prefer-inline")
@@ -231,7 +232,7 @@ final class _BoxedDouble extends double {
@pragma("wasm:prefer-inline")
double abs() {
return value._copysign(0.0);
return value.copysign(0.0);
}
@pragma("wasm:prefer-inline")
@@ -273,8 +274,8 @@ final class _BoxedDouble extends double {
// Add 0.5 to the absolute value of the number and truncate the result.
final int shift = (_exponentBias + _mantissaBits - 1) - exponent;
final int adjust = 1._shl(shift);
final int mask = (-2)._shl(shift);
final int adjust = 1.shl(shift);
final int mask = (-2).shl(shift);
final int rounded = (bits + adjust) & mask;
return intBitsToDouble(rounded);
}
@@ -298,7 +299,7 @@ final class _BoxedDouble extends double {
if (!isFinite) {
throw UnsupportedError("Infinity or NaN toInt");
}
return value._toInt();
return value.truncSatS();
}
@pragma("wasm:prefer-inline")
@@ -476,7 +477,7 @@ final class _BoxedDouble extends double {
return GREATER;
}
}
return value._toInt().compareTo(other);
return value.truncSatS().compareTo(other);
} else {
return EQUAL;
}
+17 -16
View File
@@ -2,17 +2,18 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:_boxed_double';
import 'dart:_internal';
import 'dart:_wasm';
@pragma("wasm:entry-point")
final class _BoxedInt extends int {
final class BoxedInt extends int {
// A boxed int contains an unboxed int.
@pragma("wasm:entry-point")
int value = 0;
/// Dummy factory to silence error about missing superclass constructor.
external factory _BoxedInt();
external factory BoxedInt();
external num operator +(num other);
external num operator -(num other);
@@ -26,12 +27,12 @@ final class _BoxedInt extends int {
@pragma("wasm:prefer-inline")
int operator ~/(num other) => other is int
? _truncDiv(this.value, other)
: _BoxedDouble.truncDiv(toDouble(), unsafeCast<double>(other));
: BoxedDouble.truncDiv(toDouble(), unsafeCast<double>(other));
@pragma("wasm:prefer-inline")
num operator %(num other) => other is int
? _modulo(this, other)
: _BoxedDouble.modulo(toDouble(), unsafeCast<double>(other));
: BoxedDouble.modulo(toDouble(), unsafeCast<double>(other));
static int _modulo(int a, int b) {
int rem = a - (a ~/ b) * b;
@@ -58,13 +59,13 @@ final class _BoxedInt extends int {
throw IntegerDivisionByZeroException();
}
return a._div_s(b);
return a.divS(b);
}
@pragma("wasm:prefer-inline")
num remainder(num other) => other is int
? this - (this ~/ other) * other
: _BoxedDouble.computeRemainder(toDouble(), unsafeCast<double>(other));
: BoxedDouble.computeRemainder(toDouble(), unsafeCast<double>(other));
external int operator -();
@@ -75,8 +76,8 @@ final class _BoxedInt extends int {
@pragma("wasm:prefer-inline")
int operator >>(int shift) {
// Unsigned comparison to check for large and negative shifts
if (shift._lt_u(64)) {
return value._shr_s(shift);
if (shift.ltU(64)) {
return value.shrS(shift);
}
if (shift < 0) {
@@ -84,14 +85,14 @@ final class _BoxedInt extends int {
}
// shift >= 64, 0 or -1 depending on sign: `this >= 0 ? 0 : -1`
return value._shr_s(63);
return value.shrS(63);
}
@pragma("wasm:prefer-inline")
int operator >>>(int shift) {
// Unsigned comparison to check for large and negative shifts
if (shift._lt_u(64)) {
return value._shr_u(shift);
if (shift.ltU(64)) {
return value.shrU(shift);
}
if (shift < 0) {
@@ -105,8 +106,8 @@ final class _BoxedInt extends int {
@pragma("wasm:prefer-inline")
int operator <<(int shift) {
// Unsigned comparison to check for large and negative shifts
if (shift._lt_u(64)) {
return value._shl(shift);
if (shift.ltU(64)) {
return value.shl(shift);
}
if (shift < 0) {
@@ -195,7 +196,7 @@ final class _BoxedInt extends int {
} else {
// If abs(other) > MAX_EXACT_INT_TO_DOUBLE, then other has an integer
// value (no bits below the decimal point).
other = other._toInt();
other = other.truncSatS();
}
}
if (this < other) {
@@ -411,7 +412,7 @@ final class _BoxedInt extends int {
return _binaryGcd(x, y, false);
}
int get hashCode => _intHashCode(this);
int get hashCode => intHashCode(this);
external int operator ~();
external int get bitLength;
@@ -420,7 +421,7 @@ final class _BoxedInt extends int {
external String toString();
}
int _intHashCode(int value) {
int intHashCode(int value) {
const int magic = 0x2D51;
int lower = (value & 0xFFFFFFFF) * magic;
int upper = (value >>> 32) * magic;
@@ -6,7 +6,7 @@ import 'dart:_internal';
import 'dart:_string';
@patch
class _BoxedInt {
class BoxedInt {
@patch
String toRadixString(int radix) => _intToRadixString(value, radix);
@@ -42,10 +42,4 @@ class double {
}
return result;
}
/// Wasm i64.trunc_sat_f64_s instruction.
external int _toInt();
/// Wasm f64.copysign instruction.
external double _copysign(double other);
}
@@ -9,22 +9,4 @@ class int {
@patch
external const factory int.fromEnvironment(String name,
{int defaultValue = 0});
/// Wasm i64.div_s instruction.
external int _div_s(int divisor);
/// Wasm i64.le_u instruction.
external bool _le_u(int other);
/// Wasm i64.lt_u instruction.
external bool _lt_u(int other);
/// Wasm i64.shr_s instruction.
external int _shr_s(int shift);
/// Wasm i64.shr_u instruction.
external int _shr_u(int shift);
/// Wasm i64.shl instruction.
external int _shl(int shift);
}
@@ -9,7 +9,7 @@ import 'dart:_string';
import 'dart:_wasm';
@patch
class _BoxedInt {
class BoxedInt {
@patch
String toRadixString(int radix) {
// We could also catch the `_JavaScriptError` here and convert it to
+49 -3
View File
@@ -165,6 +165,18 @@ class WasmI64 extends _WasmBase {
/// Wasm `i64.gt_u` instruction.
external bool gtU(WasmI64 other);
/// Wasm `i64.shl` instruction.
external WasmI64 shl(WasmI64 shift);
/// Wasm `i64.shr_s` instruction.
external WasmI64 shrS(WasmI64 shift);
/// Wasm `i64.shr_u` instruction.
external WasmI64 shrU(WasmI64 shift);
/// Wasm `i64.div_s` instruction.
external WasmI64 divS(WasmI64 divisor);
}
/// The Wasm `f32` type.
@@ -193,8 +205,11 @@ class WasmF64 extends _WasmBase {
external double toDouble();
/// `i64.trunc_sat_f64_s`.
/// Wasm `i64.trunc_sat_f64_s` instruction.
external WasmI64 truncSatS();
/// Wasm `f64.copysign` instruction.
external WasmF64 copysign(WasmF64 other);
}
/// A Wasm array.
@@ -302,8 +317,11 @@ class WasmTable<T> extends _WasmBase {
external F callIndirect<F extends Function>(WasmI32 index);
}
extension IntToWasmInt on int {
extension IntWasmInstructions on int {
@pragma("wasm:prefer-inline")
WasmI32 toWasmI32() => WasmI32.fromInt(this);
@pragma("wasm:prefer-inline")
WasmI64 toWasmI64() => WasmI64.fromInt(this);
/// Wasm `i64.le_u` instruction.
@@ -321,11 +339,39 @@ extension IntToWasmInt on int {
/// Wasm `i64.gt_u` instruction.
@pragma("wasm:prefer-inline")
bool gtU(int other) => this.toWasmI64().gtU(other.toWasmI64());
/// Wasm `i64.shl` instruction.
@pragma("wasm:prefer-inline")
int shl(int shift) => this.toWasmI64().shl(shift.toWasmI64()).toInt();
/// Wasm `i64.shr_s` instruction.
@pragma("wasm:prefer-inline")
int shrS(int shift) => this.toWasmI64().shrS(shift.toWasmI64()).toInt();
/// Wasm `i64.shr_u` instruction.
@pragma("wasm:prefer-inline")
int shrU(int shift) => this.toWasmI64().shrU(shift.toWasmI64()).toInt();
/// Wasm `i64.div_s` instruction.
@pragma("wasm:prefer-inline")
int divS(int divisor) => this.toWasmI64().divS(divisor.toWasmI64()).toInt();
}
extension DoubleToWasmFloat on double {
extension DoubleWasmInstructions on double {
@pragma("wasm:prefer-inline")
WasmF32 toWasmF32() => WasmF32.fromDouble(this);
@pragma("wasm:prefer-inline")
WasmF64 toWasmF64() => WasmF64.fromDouble(this);
/// Wasm `i64.trunc_sat_f64_s` instruction.
@pragma("wasm:prefer-inline")
int truncSatS() => this.toWasmF64().truncSatS().toInt();
/// Wasm `f64.copysign` instruction.
@pragma("wasm:prefer-inline")
double copysign(double other) =>
this.toWasmF64().copysign(other.toWasmF64()).toDouble();
}
extension WasmExternRefToJSAny on WasmExternRef {
+14 -8
View File
@@ -132,9 +132,6 @@
"_internal/vm_shared/lib/map_patch.dart",
"_internal/vm_shared/lib/null_patch.dart",
"_internal/wasm/lib/array_patch.dart",
"_internal/wasm/lib/boxed_double.dart",
"_internal/wasm/lib/boxed_int.dart",
"_internal/wasm/lib/boxed_int_to_string.dart",
"_internal/wasm/lib/core_patch.dart",
"_internal/wasm/lib/date_patch_patch.dart",
"_internal/wasm/lib/int_common_patch.dart",
@@ -158,6 +155,10 @@
"_internal/wasm/lib/typed_data_patch.dart"
]
},
"_boxed_int": {
"uri": "_internal/wasm/lib/boxed_int.dart",
"patches": "_internal/wasm/lib/boxed_int_to_string.dart"
},
"_string": {
"uri": "_internal/wasm/lib/js_string.dart",
"patches": "_internal/wasm/lib/string.dart"
@@ -195,14 +196,11 @@
"_internal/vm_shared/lib/map_patch.dart",
"_internal/vm_shared/lib/null_patch.dart",
"_internal/wasm/lib/array_patch.dart",
"_internal/wasm/lib/boxed_double.dart",
"_internal/wasm/lib/boxed_int.dart",
"_internal/wasm/lib/core_patch.dart",
"_internal/wasm/lib/date_patch_patch.dart",
"_internal/wasm/lib/int_common_patch.dart",
"_internal/wasm/lib/sync_star_patch.dart",
"_internal/wasm/lib/weak_patch.dart",
"_internal/wasm_js_compatibility/lib/boxed_int_to_string.dart",
"_internal/wasm_js_compatibility/lib/int_patch.dart",
"_internal/wasm_js_compatibility/lib/string_buffer_patch.dart",
"_internal/wasm_js_compatibility/lib/string_patch.dart"
@@ -215,6 +213,10 @@
"_internal/wasm_js_compatibility/lib/typed_data_patch.dart"
]
},
"_boxed_int": {
"uri": "_internal/wasm/lib/boxed_int.dart",
"patches": "_internal/wasm_js_compatibility/lib/boxed_int_to_string.dart"
},
"_string": {
"uri": "_internal/wasm/lib/js_string.dart"
},
@@ -231,11 +233,15 @@
"core": {
"uri": "core/core.dart",
"patches": [
"_internal/wasm/lib/boxed_double.dart",
"_internal/wasm/lib/boxed_int.dart",
"_internal/wasm/lib/int_common_patch.dart"
]
},
"_boxed_int": {
"uri": "_internal/wasm/lib/boxed_int.dart"
},
"_boxed_double": {
"uri": "_internal/wasm/lib/boxed_double.dart"
},
"_error_utils": {
"uri": "_internal/wasm/lib/error_utils.dart"
},
+12 -8
View File
@@ -123,9 +123,6 @@ wasm:
- _internal/vm_shared/lib/map_patch.dart
- _internal/vm_shared/lib/null_patch.dart
- _internal/wasm/lib/array_patch.dart
- _internal/wasm/lib/boxed_double.dart
- _internal/wasm/lib/boxed_int.dart
- _internal/wasm/lib/boxed_int_to_string.dart
- _internal/wasm/lib/core_patch.dart
- _internal/wasm/lib/date_patch_patch.dart
- _internal/wasm/lib/int_common_patch.dart
@@ -143,6 +140,10 @@ wasm:
patches:
- _internal/wasm/lib/simd_patch.dart
- _internal/wasm/lib/typed_data_patch.dart
_boxed_int:
uri: _internal/wasm/lib/boxed_int.dart
patches:
_internal/wasm/lib/boxed_int_to_string.dart
_string:
uri: _internal/wasm/lib/js_string.dart
patches:
@@ -171,14 +172,11 @@ wasm_js_compatibility:
- _internal/vm_shared/lib/map_patch.dart
- _internal/vm_shared/lib/null_patch.dart
- _internal/wasm/lib/array_patch.dart
- _internal/wasm/lib/boxed_double.dart
- _internal/wasm/lib/boxed_int.dart
- _internal/wasm/lib/core_patch.dart
- _internal/wasm/lib/date_patch_patch.dart
- _internal/wasm/lib/int_common_patch.dart
- _internal/wasm/lib/sync_star_patch.dart
- _internal/wasm/lib/weak_patch.dart
- _internal/wasm_js_compatibility/lib/boxed_int_to_string.dart
- _internal/wasm_js_compatibility/lib/int_patch.dart
- _internal/wasm_js_compatibility/lib/string_buffer_patch.dart
- _internal/wasm_js_compatibility/lib/string_patch.dart
@@ -187,6 +185,10 @@ wasm_js_compatibility:
patches:
- _internal/wasm/lib/simd_patch.dart
- _internal/wasm_js_compatibility/lib/typed_data_patch.dart
_boxed_int:
uri: _internal/wasm/lib/boxed_int.dart
patches:
_internal/wasm_js_compatibility/lib/boxed_int_to_string.dart
_string:
uri: _internal/wasm/lib/js_string.dart
_js_helper:
@@ -199,9 +201,11 @@ wasm_common:
core:
uri: core/core.dart
patches:
- _internal/wasm/lib/boxed_double.dart
- _internal/wasm/lib/boxed_int.dart
- _internal/wasm/lib/int_common_patch.dart
_boxed_int:
uri: _internal/wasm/lib/boxed_int.dart
_boxed_double:
uri: _internal/wasm/lib/boxed_double.dart
_error_utils:
uri: _internal/wasm/lib/error_utils.dart
_http: