From b13c37726c4dc5cc60d1117c6de629810d2519f0 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Fri, 16 Oct 2020 11:16:02 +0000 Subject: [PATCH] [cfe/ffi] Transformation changes for structs-by-value Changes the kernel representation of structs in two ways. 1. `_addressOf` field of `Struct` gets type `Object` because it will be either `TypedData` or `Pointer` in structs by value CL. 2. Subtypes of `Struct` get a pragma `vm:ffi:struct-fields` which contains a const list of the native types of the fields of the struct which will be read in the VM to do compute the locations of structs in the target ABI. Split off from https://dart-review.googlesource.com/c/sdk/+/140290/23 to make that CL smaller. That CL will no longer have changes to the kernel representation of FFI code after this CL lands separately. These changes are not consumed in the VM in this CL, but they are tested by the expect files. Issue: https://github.com/dart-lang/sdk/issues/36730. Change-Id: I5d3babd5be07f78c6d2bd80bbc1fd492c51bc01f Cq-Include-Trybots: luci.dart.try:front-end-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167280 Commit-Queue: Daco Harkes Reviewed-by: Martin Kustermann --- .../general/ffi_sample.dart.outline.expect | 2 +- .../general/ffi_sample.dart.strong.expect | 2 +- .../ffi_sample.dart.strong.transformed.expect | 40 ++++++++++-------- .../ffi_sample.dart.weak.expect | 2 +- .../ffi_sample.dart.weak.transformed.expect | 40 ++++++++++-------- .../ffi_01.yaml.world.1.expect | 40 ++++++++++-------- .../ffi_01.yaml.world.2.expect | 40 ++++++++++-------- .../ffi_02.yaml.world.1.expect | 40 ++++++++++-------- .../no_outline_change_35.yaml.world.1.expect | 40 ++++++++++-------- .../no_outline_change_35.yaml.world.2.expect | 40 ++++++++++-------- .../no_outline_change_35.yaml.world.3.expect | 40 ++++++++++-------- pkg/vm/lib/transformations/ffi.dart | 2 + .../lib/transformations/ffi_definitions.dart | 41 ++++++++++++++++--- pkg/vm/lib/transformations/ffi_use_sites.dart | 25 ++++++----- sdk/lib/ffi/struct.dart | 2 +- 15 files changed, 239 insertions(+), 157 deletions(-) diff --git a/pkg/front_end/testcases/general/ffi_sample.dart.outline.expect b/pkg/front_end/testcases/general/ffi_sample.dart.outline.expect index 2a3bf2683899..c1e27d7ee1eb 100644 --- a/pkg/front_end/testcases/general/ffi_sample.dart.outline.expect +++ b/pkg/front_end/testcases/general/ffi_sample.dart.outline.expect @@ -14,7 +14,7 @@ class Coordinate extends ffi::Struct { field ffi::Pointer* next; static factory allocate(core::double* x, core::double* y, ffi::Pointer* next) → self::Coordinate* ; - abstract member-signature get _addressOf() → ffi::Pointer*; -> ffi::Struct::_addressOf + abstract member-signature get _addressOf() → core::Object*; -> ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf diff --git a/pkg/front_end/testcases/general/ffi_sample.dart.strong.expect b/pkg/front_end/testcases/general/ffi_sample.dart.strong.expect index 0e669c094a97..a8534216b1ec 100644 --- a/pkg/front_end/testcases/general/ffi_sample.dart.strong.expect +++ b/pkg/front_end/testcases/general/ffi_sample.dart.strong.expect @@ -20,7 +20,7 @@ class Coordinate extends ffi::Struct { #t1.{self::Coordinate::next} = next; } =>#t1; } - abstract member-signature get _addressOf() → ffi::Pointer*; -> ffi::Struct::_addressOf + abstract member-signature get _addressOf() → core::Object*; -> ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf diff --git a/pkg/front_end/testcases/general/ffi_sample.dart.strong.transformed.expect b/pkg/front_end/testcases/general/ffi_sample.dart.strong.transformed.expect index c402dcaca161..324ae5feccac 100644 --- a/pkg/front_end/testcases/general/ffi_sample.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/general/ffi_sample.dart.strong.transformed.expect @@ -8,9 +8,10 @@ import "dart:ffi"; import "package:ffi/ffi.dart"; @#C3 +@#C8 class Coordinate extends ffi::Struct { @#C3 - static final field core::int* #sizeOf = (#C6).{core::List::[]}(ffi::_abi()); + static final field core::int* #sizeOf = (#C11).{core::List::[]}(ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super ffi::Struct::_fromPointer(#pointer) @@ -22,7 +23,7 @@ class Coordinate extends ffi::Struct { #t1.{self::Coordinate::next} = next; } =>#t1; } - abstract member-signature get _addressOf() → ffi::Pointer*; -> ffi::Struct::_addressOf + abstract member-signature get _addressOf() → core::Object*; -> ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -34,17 +35,17 @@ class Coordinate extends ffi::Struct { abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType get x() → core::double* - return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C8).{core::List::[]}(ffi::_abi())); + return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C13).{core::List::[]}(ffi::_abi())); set x(core::double* #v) → void - return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C8).{core::List::[]}(ffi::_abi()), #v); + return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C13).{core::List::[]}(ffi::_abi()), #v); get y() → core::double* - return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C10).{core::List::[]}(ffi::_abi())); + return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C15).{core::List::[]}(ffi::_abi())); set y(core::double* #v) → void - return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C10).{core::List::[]}(ffi::_abi()), #v); + return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C15).{core::List::[]}(ffi::_abi()), #v); get next() → ffi::Pointer* - return ffi::_fromAddress(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C12).{core::List::[]}(ffi::_abi()))); + return ffi::_fromAddress(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C17).{core::List::[]}(ffi::_abi()))); set next(ffi::Pointer* #v) → void - return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C12).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address}); + return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C17).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address}); } static method main() → dynamic {} @@ -52,13 +53,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(ffi::Double) + #C6 = TypeLiteralConstant(ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.expect b/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.expect index 0e669c094a97..a8534216b1ec 100644 --- a/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.expect +++ b/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.expect @@ -20,7 +20,7 @@ class Coordinate extends ffi::Struct { #t1.{self::Coordinate::next} = next; } =>#t1; } - abstract member-signature get _addressOf() → ffi::Pointer*; -> ffi::Struct::_addressOf + abstract member-signature get _addressOf() → core::Object*; -> ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf diff --git a/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.transformed.expect b/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.transformed.expect index c402dcaca161..324ae5feccac 100644 --- a/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general_nnbd_opt_out/ffi_sample.dart.weak.transformed.expect @@ -8,9 +8,10 @@ import "dart:ffi"; import "package:ffi/ffi.dart"; @#C3 +@#C8 class Coordinate extends ffi::Struct { @#C3 - static final field core::int* #sizeOf = (#C6).{core::List::[]}(ffi::_abi()); + static final field core::int* #sizeOf = (#C11).{core::List::[]}(ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super ffi::Struct::_fromPointer(#pointer) @@ -22,7 +23,7 @@ class Coordinate extends ffi::Struct { #t1.{self::Coordinate::next} = next; } =>#t1; } - abstract member-signature get _addressOf() → ffi::Pointer*; -> ffi::Struct::_addressOf + abstract member-signature get _addressOf() → core::Object*; -> ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -34,17 +35,17 @@ class Coordinate extends ffi::Struct { abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType get x() → core::double* - return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C8).{core::List::[]}(ffi::_abi())); + return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C13).{core::List::[]}(ffi::_abi())); set x(core::double* #v) → void - return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C8).{core::List::[]}(ffi::_abi()), #v); + return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C13).{core::List::[]}(ffi::_abi()), #v); get y() → core::double* - return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C10).{core::List::[]}(ffi::_abi())); + return ffi::_loadDouble(this.{ffi::Struct::_addressOf}, (#C15).{core::List::[]}(ffi::_abi())); set y(core::double* #v) → void - return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C10).{core::List::[]}(ffi::_abi()), #v); + return ffi::_storeDouble(this.{ffi::Struct::_addressOf}, (#C15).{core::List::[]}(ffi::_abi()), #v); get next() → ffi::Pointer* - return ffi::_fromAddress(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C12).{core::List::[]}(ffi::_abi()))); + return ffi::_fromAddress(ffi::_loadIntPtr(this.{ffi::Struct::_addressOf}, (#C17).{core::List::[]}(ffi::_abi()))); set next(ffi::Pointer* #v) → void - return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C12).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address}); + return ffi::_storeIntPtr(this.{ffi::Struct::_addressOf}, (#C17).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address}); } static method main() → dynamic {} @@ -52,13 +53,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(ffi::Double) + #C6 = TypeLiteralConstant(ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.1.expect index 07b6c8065ac6..0fc8261aa63c 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.1.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.1.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -14,7 +15,7 @@ library from "org-dartlang-test:///lib.dart" as lib { static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer* next) → lib::Coordinate* { return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -26,17 +27,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -54,13 +55,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.2.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.2.expect index c592dbf78ce7..492675028bfd 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.2.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_01.yaml.world.2.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -14,7 +15,7 @@ library from "org-dartlang-test:///lib.dart" as lib { static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer* next) → lib::Coordinate* { return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -26,17 +27,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -58,13 +59,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_02.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_02.yaml.world.1.expect index fae41df26cf9..afc46dc896a0 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_02.yaml.world.1.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/ffi_02.yaml.world.1.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -14,7 +15,7 @@ library from "org-dartlang-test:///lib.dart" as lib { static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer* next) → lib::Coordinate* { return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -26,17 +27,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -55,13 +56,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.1.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.1.expect index 07b6c8065ac6..0fc8261aa63c 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.1.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.1.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -14,7 +15,7 @@ library from "org-dartlang-test:///lib.dart" as lib { static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer* next) → lib::Coordinate* { return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -26,17 +27,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -54,13 +55,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.2.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.2.expect index 879c49737d34..b4e95441bc7f 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.2.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.2.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -14,7 +15,7 @@ library from "org-dartlang-test:///lib.dart" as lib { static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer* next) → lib::Coordinate* { return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -26,17 +27,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -55,13 +56,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.3.expect b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.3.expect index c31f2701e9f4..3c5ae831ad73 100644 --- a/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.3.expect +++ b/pkg/front_end/testcases/incremental_initialize_from_dill/no_outline_change_35.yaml.world.3.expect @@ -4,9 +4,10 @@ library from "org-dartlang-test:///lib.dart" as lib { import "dart:ffi"; @#C3 + @#C8 class Coordinate extends dart.ffi::Struct { @#C3 - static final field dart.core::int* #sizeOf = (#C6).{dart.core::List::[]}(dart.ffi::_abi()); + static final field dart.core::int* #sizeOf = (#C11).{dart.core::List::[]}(dart.ffi::_abi()); @#C3 constructor #fromPointer(dynamic #pointer) → dynamic : super dart.ffi::Struct::_fromPointer(#pointer) @@ -15,7 +16,7 @@ library from "org-dartlang-test:///lib.dart" as lib { dart.core::print("hello"); return null; } - abstract member-signature get _addressOf() → dart.ffi::Pointer*; -> dart.ffi::Struct::_addressOf + abstract member-signature get _addressOf() → dart.core::Object*; -> dart.ffi::Struct::_addressOf abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf @@ -27,17 +28,17 @@ library from "org-dartlang-test:///lib.dart" as lib { abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType get x() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi())); set x(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C8).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C13).{dart.core::List::[]}(dart.ffi::_abi()), #v); get y() → dart.core::double* - return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi())); + return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi())); set y(dart.core::double* #v) → void - return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C10).{dart.core::List::[]}(dart.ffi::_abi()), #v); + return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_addressOf}, (#C15).{dart.core::List::[]}(dart.ffi::_abi()), #v); get next() → dart.ffi::Pointer* - return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()))); + return dart.ffi::_fromAddress(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()))); set next(dart.ffi::Pointer* #v) → void - return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); + return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_addressOf}, (#C17).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address}); } } library from "org-dartlang-test:///main.dart" as main { @@ -56,13 +57,18 @@ constants { #C1 = "vm:entry-point" #C2 = null #C3 = dart.core::pragma {name:#C1, options:#C2} - #C4 = 24 - #C5 = 20 - #C6 = [#C4, #C5, #C4] - #C7 = 0 - #C8 = [#C7, #C7, #C7] - #C9 = 8 - #C10 = [#C9, #C9, #C9] - #C11 = 16 - #C12 = [#C11, #C11, #C11] + #C4 = "vm:ffi:struct-fields" + #C5 = TypeLiteralConstant(dart.ffi::Double) + #C6 = TypeLiteralConstant(dart.ffi::Pointer) + #C7 = [#C5, #C5, #C6] + #C8 = dart.core::pragma {name:#C4, options:#C7} + #C9 = 24 + #C10 = 20 + #C11 = [#C9, #C10, #C9] + #C12 = 0 + #C13 = [#C12, #C12, #C12] + #C14 = 8 + #C15 = [#C14, #C14, #C14] + #C16 = 16 + #C17 = [#C16, #C16, #C16] } diff --git a/pkg/vm/lib/transformations/ffi.dart b/pkg/vm/lib/transformations/ffi.dart index 716ba06b22a5..2752c237e64b 100644 --- a/pkg/vm/lib/transformations/ffi.dart +++ b/pkg/vm/lib/transformations/ffi.dart @@ -192,6 +192,7 @@ class FfiTransformer extends Transformer { final Class intClass; final Class doubleClass; final Class listClass; + final Class typeClass; final Class pragmaClass; final Field pragmaName; final Field pragmaOptions; @@ -233,6 +234,7 @@ class FfiTransformer extends Transformer { intClass = coreTypes.intClass, doubleClass = coreTypes.doubleClass, listClass = coreTypes.listClass, + typeClass = coreTypes.typeClass, pragmaClass = coreTypes.pragmaClass, pragmaName = coreTypes.pragmaName, pragmaOptions = coreTypes.pragmaOptions, diff --git a/pkg/vm/lib/transformations/ffi_definitions.dart b/pkg/vm/lib/transformations/ffi_definitions.dart index 13498bcc2487..b8a3e62b2510 100644 --- a/pkg/vm/lib/transformations/ffi_definitions.dart +++ b/pkg/vm/lib/transformations/ffi_definitions.dart @@ -227,9 +227,9 @@ class _FfiDefinitionTransformer extends FfiTransformer { f.fileUri); } else { final DartType nativeType = InterfaceType( - nativeTypesClasses[nativeTypeAnnos.first.index], + nativeTypesClasses[_getFieldType(nativeTypeAnnos.first).index], Nullability.legacy); - // TODO(36730): Support structs inside structs. + // TODO(dartbug.com/37271): Support structs inside structs. final DartType shouldBeDartType = convertNativeTypeToDartType( nativeType, /*allowStructs=*/ false, /*allowHandle=*/ false); if (shouldBeDartType == null || @@ -294,6 +294,7 @@ class _FfiDefinitionTransformer extends FfiTransformer { /// /// Returns the total size of the struct (for all ABIs). Map _replaceFields(Class node, IndexedClass indexedClass) { + final classes = []; final types = []; final fields = {}; final getters = {}; @@ -304,18 +305,22 @@ class _FfiDefinitionTransformer extends FfiTransformer { final dartType = _structFieldMemberType(m); NativeType nativeType; + Class clazz; if (_isPointerType(dartType)) { nativeType = NativeType.kPointer; + clazz = pointerClass; } else { final nativeTypeAnnos = _getNativeTypeAnnotations(m).toList(); if (nativeTypeAnnos.length == 1) { - nativeType = nativeTypeAnnos.first; + clazz = nativeTypeAnnos.first; + nativeType = _getFieldType(clazz); } } if ((m is Field || (m is Procedure && m.isGetter)) && nativeType != null) { types.add(nativeType); + classes.add(clazz); if (m is Field) { fields[i] = m; } @@ -332,6 +337,8 @@ class _FfiDefinitionTransformer extends FfiTransformer { } } + _annoteStructWithFields(node, classes); + final sizeAndOffsets = {}; for (final Abi abi in Abi.values) { sizeAndOffsets[abi] = _calculateSizeAndOffsets(types, abi); @@ -377,6 +384,29 @@ class _FfiDefinitionTransformer extends FfiTransformer { return sizeAndOffsets.map((k, v) => MapEntry(k, v.size)); } + void _annoteStructWithFields(Class node, List fieldTypes) { + final types = fieldTypes.map((Class c) { + List typeArg = const []; + if (c == pointerClass) { + typeArg = [ + InterfaceType(pointerClass.superclass, Nullability.nonNullable) + ]; + } + return TypeLiteralConstant( + InterfaceType(c, Nullability.nonNullable, typeArg)); + }).toList(); + + node.addAnnotation(ConstantExpression( + InstanceConstant(pragmaClass.reference, [], { + pragmaName.reference: StringConstant("vm:ffi:struct-fields"), + // TODO(dartbug.com/38158): Wrap list in class to be able to encode + // more information when needed. + pragmaOptions.reference: ListConstant( + InterfaceType(typeClass, Nullability.nonNullable), types) + }), + InterfaceType(pragmaClass, Nullability.nonNullable, []))); + } + /// Expression that queries VM internals at runtime to figure out on which ABI /// we are. Expression _runtimeBranchOnLayout(Map values) { @@ -571,14 +601,13 @@ class _FfiDefinitionTransformer extends FfiTransformer { return fieldType; } - Iterable _getNativeTypeAnnotations(Member node) { + Iterable _getNativeTypeAnnotations(Member node) { return node.annotations .whereType() .map((expr) => expr.constant) .whereType() .map((constant) => constant.classNode) - .map((klass) => _getFieldType(klass)) - .where((type) => type != null); + .where((klass) => _getFieldType(klass) != null); } } diff --git a/pkg/vm/lib/transformations/ffi_use_sites.dart b/pkg/vm/lib/transformations/ffi_use_sites.dart index e198b1012295..b0926a106e1b 100644 --- a/pkg/vm/lib/transformations/ffi_use_sites.dart +++ b/pkg/vm/lib/transformations/ffi_use_sites.dart @@ -171,17 +171,18 @@ class _FfiUseSiteTransformer extends FfiTransformer { nativeFunctionClass, Nullability.legacy, [node.arguments.types[0]]); final DartType dartType = node.arguments.types[1]; - _ensureNativeTypeValid(nativeType, node); - _ensureNativeTypeToDartType(nativeType, dartType, node); - + _ensureNativeTypeValid(nativeType, node, allowStructs: false); + _ensureNativeTypeToDartType(nativeType, dartType, node, + allowStructs: false); return _replaceLookupFunction(node); } else if (target == asFunctionMethod) { final DartType dartType = node.arguments.types[1]; final DartType nativeType = InterfaceType( nativeFunctionClass, Nullability.legacy, [node.arguments.types[0]]); - _ensureNativeTypeValid(nativeType, node); - _ensureNativeTypeToDartType(nativeType, dartType, node); + _ensureNativeTypeValid(nativeType, node, allowStructs: false); + _ensureNativeTypeToDartType(nativeType, dartType, node, + allowStructs: false); final DartType nativeSignature = (nativeType as InterfaceType).typeArguments[0]; @@ -198,20 +199,22 @@ class _FfiUseSiteTransformer extends FfiTransformer { _ensureIsStaticFunction(func); - // TODO(36730): Allow passing/returning structs by value. - _ensureNativeTypeValid(nativeType, node); - _ensureNativeTypeToDartType(nativeType, dartType, node); + _ensureNativeTypeValid(nativeType, node, allowStructs: false); + _ensureNativeTypeToDartType(nativeType, dartType, node, + allowStructs: false); // Check `exceptionalReturn`'s type. final FunctionType funcType = dartType; - final NativeType expectedReturn = getType( + final Class expectedReturnClass = ((node.arguments.types[0] as FunctionType).returnType as InterfaceType) - .classNode); + .classNode; + final NativeType expectedReturn = getType(expectedReturnClass); if (expectedReturn == NativeType.kVoid || expectedReturn == NativeType.kPointer || - expectedReturn == NativeType.kHandle) { + expectedReturn == NativeType.kHandle || + expectedReturnClass.superclass == structClass) { if (node.arguments.positional.length > 1) { diagnosticReporter.report( templateFfiExpectedNoExceptionalReturn.withArguments( diff --git a/sdk/lib/ffi/struct.dart b/sdk/lib/ffi/struct.dart index f4cb315a7a6b..0faf7ca5207c 100644 --- a/sdk/lib/ffi/struct.dart +++ b/sdk/lib/ffi/struct.dart @@ -18,7 +18,7 @@ part of dart.ffi; /// by native memory. The may allocated via allocation or loaded from a /// [Pointer], but not by a generative constructor. abstract class Struct extends NativeType { - final Pointer _addressOf; + final Object _addressOf; /// Construct a reference to the [nullptr]. ///