Skip to content

Commit

Permalink
[vm/ffi] Introduce _Compound NativeType
Browse files Browse the repository at this point in the history
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 <askesc@google.com>
  • Loading branch information
dcharkes authored and commit-bot@chromium.org committed Apr 13, 2021
1 parent 0cb6607 commit bde9578
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Coordinate extends ffi::Struct {
#t1.{self::Coordinate::next} = next;
} =>#t1;
}
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Coordinate extends ffi::Struct {
field ffi::Pointer<self::Coordinate*>* next;
static factory allocate(ffi::Allocator* allocator, core::double* x, core::double* y, ffi::Pointer<self::Coordinate*>* next) → self::Coordinate*
;
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Coordinate extends ffi::Struct {
#t1.{self::Coordinate::next} = next;
} =>#t1;
}
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → core::Object*; -> ffi::_Compound::_typedDataBase
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
Expand All @@ -31,17 +31,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::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()));
return ffi::_loadDouble(this.{ffi::_Compound::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()));
set x(core::double* #v) → void
return ffi::_storeDouble(this.{ffi::Struct::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()), #v);
return ffi::_storeDouble(this.{ffi::_Compound::_typedDataBase}, (#C12).{core::List::[]}(ffi::_abi()), #v);
get y() → core::double*
return ffi::_loadDouble(this.{ffi::Struct::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()));
return ffi::_loadDouble(this.{ffi::_Compound::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()));
set y(core::double* #v) → void
return ffi::_storeDouble(this.{ffi::Struct::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()), #v);
return ffi::_storeDouble(this.{ffi::_Compound::_typedDataBase}, (#C14).{core::List::[]}(ffi::_abi()), #v);
get next() → ffi::Pointer<self::Coordinate*>*
return ffi::_fromAddress<self::Coordinate*>(ffi::_loadIntPtr(this.{ffi::Struct::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi())));
return ffi::_fromAddress<self::Coordinate*>(ffi::_loadIntPtr(this.{ffi::_Compound::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi())));
set next(ffi::Pointer<self::Coordinate*>* #v) → void
return ffi::_storeIntPtr(this.{ffi::Struct::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address});
return ffi::_storeIntPtr(this.{ffi::_Compound::_typedDataBase}, (#C16).{core::List::[]}(ffi::_abi()), #v.{ffi::Pointer::address});
}
static method main() → dynamic {}

Expand Down
14 changes: 7 additions & 7 deletions pkg/front_end/testcases/incremental/ffi_01.yaml.world.1.expect
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
return null;
}
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
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
Expand All @@ -24,17 +24,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::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
set x(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get y() → dart.core::double*
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
set y(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get next() → dart.ffi::Pointer<lib::Coordinate*>*
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
}
}
library from "org-dartlang-test:///main.dart" as main {
Expand Down
14 changes: 7 additions & 7 deletions pkg/front_end/testcases/incremental/ffi_01.yaml.world.2.expect
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
return null;
}
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
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
Expand All @@ -24,17 +24,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::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
set x(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get y() → dart.core::double*
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
set y(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get next() → dart.ffi::Pointer<lib::Coordinate*>*
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
}
}
library from "org-dartlang-test:///main.dart" as main {
Expand Down
14 changes: 7 additions & 7 deletions pkg/front_end/testcases/incremental/ffi_02.yaml.world.1.expect
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
return null;
}
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
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
Expand All @@ -24,17 +24,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::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
set x(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get y() → dart.core::double*
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
set y(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get next() → dart.ffi::Pointer<lib::Coordinate*>*
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
}
}
library from "org-dartlang-test:///main.dart" as main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ library from "org-dartlang-test:///lib.dart" as lib {
static factory allocate(dart.core::double* x, dart.core::double* y, dart.ffi::Pointer<lib::Coordinate*>* next) → lib::Coordinate* {
return null;
}
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::Struct::_typedDataBase
abstract member-signature get _typedDataBase() → dart.core::Object*; -> dart.ffi::_Compound::_typedDataBase
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
Expand All @@ -24,17 +24,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::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()));
set x(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C12).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get y() → dart.core::double*
return dart.ffi::_loadDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
return dart.ffi::_loadDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()));
set y(dart.core::double* #v) → void
return dart.ffi::_storeDouble(this.{dart.ffi::Struct::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
return dart.ffi::_storeDouble(this.{dart.ffi::_Compound::_typedDataBase}, (#C14).{dart.core::List::[]}(dart.ffi::_abi()), #v);
get next() → dart.ffi::Pointer<lib::Coordinate*>*
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
return dart.ffi::_fromAddress<lib::Coordinate*>(dart.ffi::_loadIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi())));
set next(dart.ffi::Pointer<lib::Coordinate*>* #v) → void
return dart.ffi::_storeIntPtr(this.{dart.ffi::Struct::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
return dart.ffi::_storeIntPtr(this.{dart.ffi::_Compound::_typedDataBase}, (#C16).{dart.core::List::[]}(dart.ffi::_abi()), #v.{dart.ffi::Pointer::address});
}
}
library from "org-dartlang-test:///main.dart" as main {
Expand Down
Loading

0 comments on commit bde9578

Please sign in to comment.