Skip to content

Commit bde9578

Browse files
dcharkescommit-bot@chromium.org
authored andcommitted
[vm/ffi] Introduce _Compound NativeType
Introduces the class `_Compound extends NativeType`, for sharing between `Struct` and `Union`. Does minimal changes to CFE and IL construction. Follow up refactor CLs rename everything. Bug: #38491 tools/test.py ffi ffi_2 TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart Change-Id: I276ceb9249c20bd331c2f8b6ef64e35acb525e9c Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194765 Reviewed-by: Aske Simon Christensen <[email protected]>
1 parent 0cb6607 commit bde9578

22 files changed

+127
-115
lines changed

pkg/front_end/testcases/general/ffi_sample.dart.weak.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Coordinate extends ffi::Struct {
1919
#t1.{self::Coordinate::next} = next;
2020
} =>#t1;
2121
}
22-
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
22+
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
2323
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
2424
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
2525
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf

pkg/front_end/testcases/general/ffi_sample.dart.weak.outline.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Coordinate extends ffi::Struct {
1414
field ffi::Pointer<self::Coordinate*>* next;
1515
static factory allocate(ffi::Allocator* allocator, core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate*
1616
;
17-
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
17+
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
1818
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
1919
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
2020
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf

pkg/front_end/testcases/general/ffi_sample.dart.weak.transformed.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Coordinate extends ffi::Struct {
1919
#t1.{self::Coordinate::next} = next;
2020
} =>#t1;
2121
}
22-
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
22+
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
2323
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
2424
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
2525
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
@@ -31,17 +31,17 @@ class Coordinate extends ffi::Struct {
3131
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
3232
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
3333
get x() → core::double*
34-
return ffi::_loadDouble(this.{ffi::Struct::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()));
34+
return ffi::_loadDouble(this.{ffi::_Compound::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()));
3535
set x(core::double* #v) → void
36-
return ffi::_storeDouble(this.{ffi::Struct::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()), #v);
36+
return ffi::_storeDouble(this.{ffi::_Compound::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()), #v);
3737
get y() → core::double*
38-
return ffi::_loadDouble(this.{ffi::Struct::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()));
38+
return ffi::_loadDouble(this.{ffi::_Compound::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()));
3939
set y(core::double* #v) → void
40-
return ffi::_storeDouble(this.{ffi::Struct::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()), #v);
40+
return ffi::_storeDouble(this.{ffi::_Compound::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()), #v);
4141
get next() → ffi::Pointer<self::Coordinate*>*
42-
return ffi::_fromAddress<self::Coordinate*>(ffi::_loadIntPtr(this.{ffi::Struct::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi())));
42+
return ffi::_fromAddress<self::Coordinate*>(ffi::_loadIntPtr(this.{ffi::_Compound::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi())));
4343
set next(ffi::Pointer<self::Coordinate*>* #v) → void
44-
return ffi::_storeIntPtr(this.{ffi::Struct::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address});
44+
return ffi::_storeIntPtr(this.{ffi::_Compound::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address});
4545
}
4646
static method main() → dynamic {}
4747

pkg/front_end/testcases/incremental/ffi_01.yaml.world.1.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
1212
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
1313
return null;
1414
}
15-
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
15+
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
1616
abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode
1717
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf
1818
abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf
@@ -24,17 +24,17 @@ library from "org-dartlang-test:///lib.dart" as lib {
2424
abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod
2525
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
2626
get x() → dart.core::double*
27-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
27+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
2828
set x(dart.core::double* #v) → void
29-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
29+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3030
get y() → dart.core::double*
31-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
31+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
3232
set y(dart.core::double* #v) → void
33-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
33+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3434
get next() → dart.ffi::Pointer<lib::Coordinate*>*
35-
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
35+
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
3636
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
37-
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
37+
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
3838
}
3939
}
4040
library from "org-dartlang-test:///main.dart" as main {

pkg/front_end/testcases/incremental/ffi_01.yaml.world.2.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
1212
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
1313
return null;
1414
}
15-
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
15+
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
1616
abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode
1717
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf
1818
abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf
@@ -24,17 +24,17 @@ library from "org-dartlang-test:///lib.dart" as lib {
2424
abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod
2525
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
2626
get x() → dart.core::double*
27-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
27+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
2828
set x(dart.core::double* #v) → void
29-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
29+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3030
get y() → dart.core::double*
31-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
31+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
3232
set y(dart.core::double* #v) → void
33-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
33+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3434
get next() → dart.ffi::Pointer<lib::Coordinate*>*
35-
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
35+
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
3636
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
37-
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
37+
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
3838
}
3939
}
4040
library from "org-dartlang-test:///main.dart" as main {

pkg/front_end/testcases/incremental/ffi_02.yaml.world.1.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
1212
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
1313
return null;
1414
}
15-
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
15+
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
1616
abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode
1717
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf
1818
abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf
@@ -24,17 +24,17 @@ library from "org-dartlang-test:///lib.dart" as lib {
2424
abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod
2525
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
2626
get x() → dart.core::double*
27-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
27+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
2828
set x(dart.core::double* #v) → void
29-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
29+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3030
get y() → dart.core::double*
31-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
31+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
3232
set y(dart.core::double* #v) → void
33-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
33+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3434
get next() → dart.ffi::Pointer<lib::Coordinate*>*
35-
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
35+
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
3636
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
37-
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
37+
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
3838
}
3939
}
4040
library from "org-dartlang-test:///main.dart" as main {

pkg/front_end/testcases/incremental/no_outline_change_35.yaml.world.1.expect

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
1212
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
1313
return null;
1414
}
15-
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
15+
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
1616
abstract member-signature get _identityHashCode() → dart.core::int*; -> dart.core::Object::_identityHashCode
1717
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → dart.core::bool*; -> dart.core::Object::_instanceOf
1818
abstract member-signature method _simpleInstanceOf(dynamic type) → dart.core::bool*; -> dart.core::Object::_simpleInstanceOf
@@ -24,17 +24,17 @@ library from "org-dartlang-test:///lib.dart" as lib {
2424
abstract member-signature method noSuchMethod(dart.core::Invocation* invocation) → dynamic; -> dart.core::Object::noSuchMethod
2525
abstract member-signature get runtimeType() → dart.core::Type*; -> dart.core::Object::runtimeType
2626
get x() → dart.core::double*
27-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
27+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
2828
set x(dart.core::double* #v) → void
29-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
29+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3030
get y() → dart.core::double*
31-
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
31+
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
3232
set y(dart.core::double* #v) → void
33-
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
33+
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
3434
get next() → dart.ffi::Pointer<lib::Coordinate*>*
35-
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
35+
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
3636
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
37-
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
37+
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
3838
}
3939
}
4040
library from "org-dartlang-test:///main.dart" as main {

0 commit comments

Comments
 (0)