mirror of
https://github.com/dart-lang/sdk
synced 2024-09-21 03:13:14 +00:00
[dart2wasm] Specify concrete int and double literal classes for TFA
Tested: existing tests Change-Id: I0f800ca3a375525dcd8ca9f9f0e25144bdce80f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333004 Commit-Queue: Ömer Ağacan <omersa@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
parent
b5c31d0806
commit
ab2c2ae8a2
|
@ -888,25 +888,29 @@ class Intrinsifier {
|
|||
|
||||
// dart:_wasm static functions
|
||||
if (node.target.enclosingLibrary.name == "dart._wasm") {
|
||||
Expression value = node.arguments.positional.single;
|
||||
switch (name) {
|
||||
case "_externalizeNonNullable":
|
||||
final value = node.arguments.positional.single;
|
||||
codeGen.wrap(value, w.RefType.any(nullable: false));
|
||||
b.extern_externalize();
|
||||
return w.RefType.extern(nullable: false);
|
||||
case "_externalizeNullable":
|
||||
final value = node.arguments.positional.single;
|
||||
codeGen.wrap(value, w.RefType.any(nullable: true));
|
||||
b.extern_externalize();
|
||||
return w.RefType.extern(nullable: true);
|
||||
case "_internalizeNonNullable":
|
||||
final value = node.arguments.positional.single;
|
||||
codeGen.wrap(value, w.RefType.extern(nullable: false));
|
||||
b.extern_internalize();
|
||||
return w.RefType.any(nullable: false);
|
||||
case "_internalizeNullable":
|
||||
final value = node.arguments.positional.single;
|
||||
codeGen.wrap(value, w.RefType.extern(nullable: true));
|
||||
b.extern_internalize();
|
||||
return w.RefType.any(nullable: true);
|
||||
case "_wasmExternRefIsNull":
|
||||
final value = node.arguments.positional.single;
|
||||
codeGen.wrap(value, w.RefType.extern(nullable: true));
|
||||
b.ref_is_null();
|
||||
return w.NumType.i32;
|
||||
|
|
|
@ -104,6 +104,8 @@ class WasmTarget extends Target {
|
|||
Class? _twoByteString;
|
||||
Class? _jsString;
|
||||
Class? _closure;
|
||||
Class? _boxedInt;
|
||||
Class? _boxedDouble;
|
||||
Map<String, Class>? _nativeClasses;
|
||||
|
||||
@override
|
||||
|
@ -493,6 +495,14 @@ class WasmTarget extends Target {
|
|||
Class getRecordImplementationClass(CoreTypes coreTypes,
|
||||
int numPositionalFields, List<String> namedFields) =>
|
||||
recordClasses[RecordShape(numPositionalFields, namedFields)]!;
|
||||
|
||||
@override
|
||||
Class concreteIntLiteralClass(CoreTypes coreTypes, int value) =>
|
||||
_boxedInt ??= coreTypes.index.getClass("dart:core", "_BoxedInt");
|
||||
|
||||
@override
|
||||
Class concreteDoubleLiteralClass(CoreTypes coreTypes, double value) =>
|
||||
_boxedDouble ??= coreTypes.index.getClass("dart:core", "_BoxedDouble");
|
||||
}
|
||||
|
||||
class WasmVerification extends Verification {
|
||||
|
|
|
@ -16,7 +16,7 @@ recordDynamicFieldAccess(dynamic x) => x.foo42;
|
|||
|
||||
main() {
|
||||
print(recordConstant);
|
||||
print(recordLiteral(1, 2, 3));
|
||||
print(recordLiteral(int.parse('1'), int.parse('2'), int.parse('3')));
|
||||
print(recordFieldAccess1((10, 'hi')));
|
||||
print(recordFieldAccess2((a: 20, b: 'bye')));
|
||||
print(recordDynamicFieldAccess(list[1]));
|
||||
|
|
|
@ -13,7 +13,7 @@ static method recordDynamicFieldAccess(dynamic x) → dynamic
|
|||
return x{dynamic}.foo42;
|
||||
static method main() → dynamic {
|
||||
core::print(#C4);
|
||||
core::print([@vm.inferred-type.metadata=dart.core::Record_2_bar] self::recordLiteral(1, 2, 3));
|
||||
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(self::recordFieldAccess1((10, "hi")));
|
||||
core::print(self::recordFieldAccess2(({a: 20, b: "bye"})));
|
||||
core::print(self::recordDynamicFieldAccess([@vm.direct-call.metadata=dart.core::_ListBase.[]??] [@vm.inferred-type.metadata=!? (receiver not int)] [@vm.inferred-type.metadata=dart.core::_GrowableList?<dart.core::Object>] self::list{dynamic}.[](1)));
|
||||
|
|
Loading…
Reference in a new issue