[vm/ffi] Expand Abis

This CL expands the ABIs in the FFI transform and VM from 3 groups to
18 individual ABIs in preparation of adding ABI-specific integer sizes
and structs.

This increases const lists with offsets in the kernel representation
from 3 to 18 elements. We do not expect significant size increases or
performance regressions from this. The constants are deduplicated in
Dart and the optimizer should optimize indexed lookups in const lists
away. However, landing this separately will enable us to verify that
assumption.

This also moves `Abi` to its own file and makes it an opaque class with
a predefined set of instances so that we do not depend on its internals.
That will enable us to keep `pkg/vm/lib/transformations/ffi/abi.dart`
consistent with the `Abi` abstraction to be introduced in `dart:ffi`
later for specifying ABI-specific integer sizes.

Bug: https://github.com/dart-lang/sdk/issues/42563
Bug: https://github.com/dart-lang/sdk/issues/42816

List of ABIs decided based on what's currently used (as Dart SDK target
platform, or Flutter target platform, or G3 target) and added
windows_arm64 in anticipation of
(https://github.com/flutter/flutter/issues/53120).
Excluded are macos_ia32 (https://github.com/dart-lang/sdk/issues/39810)
because we discontinued support; and windows_arm, fuchsia_arm,
fuchsia_ia32, ios_ia32, and macos_arm because these are
unlikely to be added.

TEST=pkg/front_end/testcases/*.expect
TEST=tests/ffi/*

Change-Id: I437707c18d8667490c063272a5f8a33d846e6061
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-x64-try,vm-ffi-android-debug-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-ffi-android-debug-arm64c-try,vm-kernel-mac-release-arm64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-android-release-arm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217184
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
This commit is contained in:
Daco Harkes 2021-11-03 19:29:03 +00:00 committed by commit-bot@chromium.org
parent 851d821556
commit ed39d3cae9
35 changed files with 389 additions and 223 deletions

View file

@ -59,16 +59,16 @@ constants {
#C7 = core::pragma {name:#C1, options:#C6}
#C8 = ffi::Double {}
#C9 = 0
#C10 = <core::int*>[#C9, #C9, #C9]
#C10 = <core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <core::int*>[#C11, #C11, #C11]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <core::int*>[#C13, #C13, #C13]
#C14 = <core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <core::int*>[#C17, #C18, #C17]
#C19 = <core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -56,11 +56,11 @@ constants {
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = dart.ffi::Uint32 {}
#C8 = 0
#C9 = <dart.core::int*>[#C8, #C8, #C8]
#C9 = <dart.core::int*>[#C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8]
#C10 = "vm:prefer-inline"
#C11 = dart.core::pragma {name:#C10, options:#C4}
#C12 = 4
#C13 = <dart.core::int*>[#C12, #C12, #C12]
#C13 = <dart.core::int*>[#C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12]
#C14 = TypeLiteralConstant(lib::Y)
#C15 = <dart.core::Type>[#C14]
#C16 = dart.ffi::_FfiStructLayout {fieldTypes:#C15, packing:#C4}

View file

@ -56,11 +56,11 @@ constants {
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = dart.ffi::Uint32 {}
#C8 = 0
#C9 = <dart.core::int*>[#C8, #C8, #C8]
#C9 = <dart.core::int*>[#C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8]
#C10 = "vm:prefer-inline"
#C11 = dart.core::pragma {name:#C10, options:#C4}
#C12 = 4
#C13 = <dart.core::int*>[#C12, #C12, #C12]
#C13 = <dart.core::int*>[#C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12, #C12]
#C14 = TypeLiteralConstant(lib::Y)
#C15 = <dart.core::Type>[#C14]
#C16 = dart.ffi::_FfiStructLayout {fieldTypes:#C15, packing:#C4}

View file

@ -62,7 +62,7 @@ constants {
#C5 = dart.ffi::_FfiStructLayout {fieldTypes:#C3, packing:#C4}
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = 0
#C8 = <dart.core::int*>[#C7, #C7, #C7]
#C8 = <dart.core::int*>[#C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7]
#C9 = "vm:prefer-inline"
#C10 = dart.core::pragma {name:#C9, options:#C4}
}

View file

@ -62,7 +62,7 @@ constants {
#C5 = dart.ffi::_FfiStructLayout {fieldTypes:#C3, packing:#C4}
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = 0
#C8 = <dart.core::int*>[#C7, #C7, #C7]
#C8 = <dart.core::int*>[#C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7]
#C9 = "vm:prefer-inline"
#C10 = dart.core::pragma {name:#C9, options:#C4}
}

View file

@ -62,14 +62,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -66,14 +66,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -63,14 +63,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -101,19 +101,19 @@ constants {
#C6 = dart.ffi::_FfiStructLayout {fieldTypes:#C4, packing:#C5}
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = 0
#C9 = <dart.core::int*>[#C8, #C8, #C8]
#C10 = 8
#C11 = 4
#C12 = <dart.core::int*>[#C10, #C11, #C11]
#C9 = <dart.core::int*>[#C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8]
#C10 = 4
#C11 = 8
#C12 = <dart.core::int*>[#C10, #C11, #C10, #C11, #C11, #C11, #C10, #C11, #C11, #C10, #C11, #C10, #C11, #C11, #C11, #C11, #C10, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C10, #C10]
#C15 = 24
#C16 = 12
#C17 = <dart.core::int*>[#C15, #C16, #C16]
#C14 = <dart.core::int*>[#C11, #C13, #C11, #C13, #C13, #C13, #C11, #C13, #C13, #C11, #C13, #C11, #C13, #C13, #C13, #C13, #C11, #C13]
#C15 = 12
#C16 = 24
#C17 = <dart.core::int*>[#C15, #C16, #C15, #C16, #C16, #C16, #C15, #C16, #C16, #C15, #C16, #C15, #C16, #C16, #C16, #C16, #C15, #C16]
#C18 = "vm:prefer-inline"
#C19 = dart.core::pragma {name:#C18, options:#C5}
#C20 = 48
#C21 = <dart.core::int*>[#C20, #C15, #C15]
#C21 = <dart.core::int*>[#C16, #C20, #C16, #C20, #C20, #C20, #C16, #C20, #C20, #C16, #C20, #C16, #C20, #C20, #C20, #C20, #C16, #C20]
#C22 = <dart.core::Type>[#C2, #C2, #C2]
#C23 = dart.ffi::_FfiStructLayout {fieldTypes:#C22, packing:#C5}
#C24 = dart.core::pragma {name:#C1, options:#C23}

View file

@ -101,19 +101,19 @@ constants {
#C6 = dart.ffi::_FfiStructLayout {fieldTypes:#C4, packing:#C5}
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = 0
#C9 = <dart.core::int*>[#C8, #C8, #C8]
#C10 = 8
#C11 = 4
#C12 = <dart.core::int*>[#C10, #C11, #C11]
#C9 = <dart.core::int*>[#C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8, #C8]
#C10 = 4
#C11 = 8
#C12 = <dart.core::int*>[#C10, #C11, #C10, #C11, #C11, #C11, #C10, #C11, #C11, #C10, #C11, #C10, #C11, #C11, #C11, #C11, #C10, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C10, #C10]
#C15 = 24
#C16 = 12
#C17 = <dart.core::int*>[#C15, #C16, #C16]
#C14 = <dart.core::int*>[#C11, #C13, #C11, #C13, #C13, #C13, #C11, #C13, #C13, #C11, #C13, #C11, #C13, #C13, #C13, #C13, #C11, #C13]
#C15 = 12
#C16 = 24
#C17 = <dart.core::int*>[#C15, #C16, #C15, #C16, #C16, #C16, #C15, #C16, #C16, #C15, #C16, #C15, #C16, #C16, #C16, #C16, #C15, #C16]
#C18 = "vm:prefer-inline"
#C19 = dart.core::pragma {name:#C18, options:#C5}
#C20 = 48
#C21 = <dart.core::int*>[#C20, #C15, #C15]
#C21 = <dart.core::int*>[#C16, #C20, #C16, #C20, #C20, #C20, #C16, #C20, #C20, #C16, #C20, #C16, #C20, #C20, #C20, #C20, #C16, #C20]
#C22 = <dart.core::Type>[#C2, #C2, #C2]
#C23 = dart.ffi::_FfiStructLayout {fieldTypes:#C22, packing:#C5}
#C24 = dart.core::pragma {name:#C1, options:#C23}

View file

@ -62,14 +62,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -63,14 +63,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -64,14 +64,14 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Double {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <dart.core::int*>[#C13, #C13, #C13]
#C14 = <dart.core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = dart.core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <dart.core::int*>[#C17, #C18, #C17]
#C19 = <dart.core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -82,26 +82,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 1
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = dart.ffi::Uint64 {}
#C14 = 8
#C15 = 4
#C16 = <dart.core::int*>[#C14, #C15, #C14]
#C16 = <dart.core::int*>[#C14, #C14, #C15, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C14, #C14]
#C17 = "vm:prefer-inline"
#C18 = dart.core::pragma {name:#C17, options:#C5}
#C19 = 16
#C20 = 12
#C21 = <dart.core::int*>[#C19, #C20, #C19]
#C21 = <dart.core::int*>[#C19, #C19, #C20, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C19, #C19]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 32
#C27 = 24
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 40
#C30 = 28
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -82,26 +82,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = dart.ffi::Uint64 {}
#C12 = 8
#C13 = 4
#C14 = <dart.core::int*>[#C12, #C13, #C12]
#C14 = <dart.core::int*>[#C12, #C12, #C13, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C12, #C12]
#C15 = 16
#C16 = 12
#C17 = <dart.core::int*>[#C15, #C16, #C15]
#C17 = <dart.core::int*>[#C15, #C15, #C16, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C15, #C15]
#C18 = "vm:prefer-inline"
#C19 = dart.core::pragma {name:#C18, options:#C5}
#C20 = 24
#C21 = <dart.core::int*>[#C20, #C15, #C20]
#C21 = <dart.core::int*>[#C20, #C20, #C15, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C20, #C20]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 48
#C27 = 32
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 56
#C30 = 36
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -82,26 +82,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 1
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = dart.ffi::Uint64 {}
#C14 = 8
#C15 = 4
#C16 = <dart.core::int*>[#C14, #C15, #C14]
#C16 = <dart.core::int*>[#C14, #C14, #C15, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C14, #C14]
#C17 = "vm:prefer-inline"
#C18 = dart.core::pragma {name:#C17, options:#C5}
#C19 = 16
#C20 = 12
#C21 = <dart.core::int*>[#C19, #C20, #C19]
#C21 = <dart.core::int*>[#C19, #C19, #C20, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C19, #C19]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 32
#C27 = 24
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 40
#C30 = 28
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -82,26 +82,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = dart.ffi::Uint64 {}
#C12 = 8
#C13 = 4
#C14 = <dart.core::int*>[#C12, #C13, #C12]
#C14 = <dart.core::int*>[#C12, #C12, #C13, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C12, #C12]
#C15 = 16
#C16 = 12
#C17 = <dart.core::int*>[#C15, #C16, #C15]
#C17 = <dart.core::int*>[#C15, #C15, #C16, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C15, #C15]
#C18 = "vm:prefer-inline"
#C19 = dart.core::pragma {name:#C18, options:#C5}
#C20 = 24
#C21 = <dart.core::int*>[#C20, #C15, #C20]
#C21 = <dart.core::int*>[#C20, #C20, #C15, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C20, #C20]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 48
#C27 = 32
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 56
#C30 = 36
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -228,26 +228,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 1
#C12 = <dart.core::int*>[#C11, #C11, #C11]
#C12 = <dart.core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = dart.ffi::Uint64 {}
#C14 = 8
#C15 = 4
#C16 = <dart.core::int*>[#C14, #C15, #C14]
#C16 = <dart.core::int*>[#C14, #C14, #C15, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C15, #C14, #C14, #C14, #C14, #C14, #C14]
#C17 = "vm:prefer-inline"
#C18 = dart.core::pragma {name:#C17, options:#C5}
#C19 = 16
#C20 = 12
#C21 = <dart.core::int*>[#C19, #C20, #C19]
#C21 = <dart.core::int*>[#C19, #C19, #C20, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C20, #C19, #C19, #C19, #C19, #C19, #C19]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 32
#C27 = 24
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 40
#C30 = 28
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -228,26 +228,26 @@ constants {
#C7 = dart.core::pragma {name:#C1, options:#C6}
#C8 = dart.ffi::Uint8 {}
#C9 = 0
#C10 = <dart.core::int*>[#C9, #C9, #C9]
#C10 = <dart.core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = dart.ffi::Uint64 {}
#C12 = 8
#C13 = 4
#C14 = <dart.core::int*>[#C12, #C13, #C12]
#C14 = <dart.core::int*>[#C12, #C12, #C13, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C13, #C12, #C12, #C12, #C12, #C12, #C12]
#C15 = 16
#C16 = 12
#C17 = <dart.core::int*>[#C15, #C16, #C15]
#C17 = <dart.core::int*>[#C15, #C15, #C16, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C16, #C15, #C15, #C15, #C15, #C15, #C15]
#C18 = "vm:prefer-inline"
#C19 = dart.core::pragma {name:#C18, options:#C5}
#C20 = 24
#C21 = <dart.core::int*>[#C20, #C15, #C20]
#C21 = <dart.core::int*>[#C20, #C20, #C15, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C15, #C20, #C20, #C20, #C20, #C20, #C20]
#C22 = TypeLiteralConstant(lib::Y)
#C23 = <dart.core::Type>[#C22, #C22, #C2]
#C24 = dart.ffi::_FfiStructLayout {fieldTypes:#C23, packing:#C5}
#C25 = dart.core::pragma {name:#C1, options:#C24}
#C26 = 48
#C27 = 32
#C28 = <dart.core::int*>[#C26, #C27, #C26]
#C28 = <dart.core::int*>[#C26, #C26, #C27, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C27, #C26, #C26, #C26, #C26, #C26, #C26]
#C29 = 56
#C30 = 36
#C31 = <dart.core::int*>[#C29, #C30, #C29]
#C31 = <dart.core::int*>[#C29, #C29, #C30, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C30, #C29, #C29, #C29, #C29, #C29, #C29]
}

View file

@ -55,12 +55,12 @@ constants {
#C5 = dart.ffi::_FfiStructLayout {fieldTypes:#C3, packing:#C4}
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = 0
#C8 = <dart.core::int*>[#C7, #C7, #C7]
#C8 = <dart.core::int*>[#C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7]
#C9 = "vm:prefer-inline"
#C10 = dart.core::pragma {name:#C9, options:#C4}
#C11 = 8
#C12 = 4
#C13 = <dart.core::int*>[#C11, #C12, #C12]
#C11 = 4
#C12 = 8
#C13 = <dart.core::int*>[#C11, #C12, #C11, #C12, #C12, #C12, #C11, #C12, #C12, #C11, #C12, #C11, #C12, #C12, #C12, #C12, #C11, #C12]
#C14 = TypeLiteralConstant(lib::COMObject)
#C15 = <dart.core::Type>[#C14]
#C16 = dart.ffi::_FfiStructLayout {fieldTypes:#C15, packing:#C4}

View file

@ -55,12 +55,12 @@ constants {
#C5 = dart.ffi::_FfiStructLayout {fieldTypes:#C3, packing:#C4}
#C6 = dart.core::pragma {name:#C1, options:#C5}
#C7 = 0
#C8 = <dart.core::int*>[#C7, #C7, #C7]
#C8 = <dart.core::int*>[#C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7, #C7]
#C9 = "vm:prefer-inline"
#C10 = dart.core::pragma {name:#C9, options:#C4}
#C11 = 8
#C12 = 4
#C13 = <dart.core::int*>[#C11, #C12, #C12]
#C11 = 4
#C12 = 8
#C13 = <dart.core::int*>[#C11, #C12, #C11, #C12, #C12, #C12, #C11, #C12, #C12, #C11, #C12, #C11, #C12, #C12, #C12, #C12, #C11, #C12]
#C14 = TypeLiteralConstant(lib::COMObject)
#C15 = <dart.core::Type>[#C14]
#C16 = dart.ffi::_FfiStructLayout {fieldTypes:#C15, packing:#C4}

View file

@ -50,16 +50,16 @@ constants {
#C7 = core::pragma {name:#C1, options:#C6}
#C8 = ffi::Double {}
#C9 = 0
#C10 = <core::int*>[#C9, #C9, #C9]
#C10 = <core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <core::int*>[#C11, #C11, #C11]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <core::int*>[#C13, #C13, #C13]
#C14 = <core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <core::int*>[#C17, #C18, #C17]
#C19 = <core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -50,16 +50,16 @@ constants {
#C7 = core::pragma {name:#C1, options:#C6}
#C8 = ffi::Double {}
#C9 = 0
#C10 = <core::int*>[#C9, #C9, #C9]
#C10 = <core::int*>[#C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9, #C9]
#C11 = 8
#C12 = <core::int*>[#C11, #C11, #C11]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 16
#C14 = <core::int*>[#C13, #C13, #C13]
#C14 = <core::int*>[#C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13, #C13]
#C15 = "vm:prefer-inline"
#C16 = core::pragma {name:#C15, options:#C5}
#C17 = 24
#C18 = 20
#C19 = <core::int*>[#C17, #C18, #C17]
#C19 = <core::int*>[#C17, #C17, #C18, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C18, #C17, #C17, #C17, #C17, #C17, #C17]
}

View file

@ -42,8 +42,8 @@ constants {
#C8 = core::pragma {name:#C1, options:#C7}
#C9 = ffi::_ArraySize<ffi::NativeType> {dimension1:#C3, dimension2:#C6, dimension3:#C6, dimension4:#C6, dimension5:#C6, dimensions:#C6}
#C10 = 0
#C11 = <core::int*>[#C10, #C10, #C10]
#C12 = <core::int*>[#C3, #C3, #C3]
#C11 = <core::int*>[#C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10]
#C12 = <core::int*>[#C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3]
#C13 = <core::int*>[]
#C14 = "vm:prefer-inline"
#C15 = core::pragma {name:#C14, options:#C6}

View file

@ -42,8 +42,8 @@ constants {
#C8 = core::pragma {name:#C1, options:#C7}
#C9 = ffi::_ArraySize<ffi::NativeType*> {dimension1:#C3, dimension2:#C6, dimension3:#C6, dimension4:#C6, dimension5:#C6, dimensions:#C6}
#C10 = 0
#C11 = <core::int*>[#C10, #C10, #C10]
#C12 = <core::int*>[#C3, #C3, #C3]
#C11 = <core::int*>[#C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10, #C10]
#C12 = <core::int*>[#C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3]
#C13 = <core::int*>[]
#C14 = "vm:prefer-inline"
#C15 = core::pragma {name:#C14, options:#C6}

View file

@ -67,8 +67,8 @@ constants {
#C9 = 2
#C10 = ffi::_ArraySize<ffi::NativeType> {dimension1:#C9, dimension2:#C9, dimension3:#C9, dimension4:#C6, dimension5:#C6, dimensions:#C6}
#C11 = 0
#C12 = <core::int*>[#C11, #C11, #C11]
#C13 = <core::int*>[#C3, #C3, #C3]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = <core::int*>[#C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3]
#C14 = <core::int*>[#C9, #C9]
#C15 = "vm:prefer-inline"
#C16 = core::pragma {name:#C15, options:#C6}

View file

@ -67,8 +67,8 @@ constants {
#C9 = 2
#C10 = ffi::_ArraySize<ffi::NativeType*> {dimension1:#C9, dimension2:#C9, dimension3:#C9, dimension4:#C6, dimension5:#C6, dimensions:#C6}
#C11 = 0
#C12 = <core::int*>[#C11, #C11, #C11]
#C13 = <core::int*>[#C3, #C3, #C3]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = <core::int*>[#C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3, #C3]
#C14 = <core::int*>[#C9, #C9]
#C15 = "vm:prefer-inline"
#C16 = core::pragma {name:#C15, options:#C6}

View file

@ -0,0 +1,175 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// 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 'common.dart';
/// The hardware architectures the Dart VM runs on.
enum _Architecture {
arm,
arm64,
ia32,
x64,
}
extension on _Architecture {
/// The size of integer registers and memory addresses in bytes.
int get wordSize {
switch (this) {
case _Architecture.arm:
case _Architecture.ia32:
return 4;
case _Architecture.arm64:
case _Architecture.x64:
return 8;
}
}
}
/// The operating systems the Dart VM runs on.
enum _OS {
android,
fuchsia,
ios,
linux,
macos,
windows,
}
/// Application binary interface.
///
/// The Dart VM can run on a variety of [Abi]s, see [supportedAbis].
class Abi {
/// The operating system of this [Abi].
// ignore: unused_field
final _OS _os;
/// The architecture of this [Abi].
final _Architecture _architecture;
/// The size of integer registers and memory addresses in bytes.
int get wordSize => _architecture.wordSize;
const Abi._(this._architecture, this._os);
}
const androidArm = Abi._(_Architecture.arm, _OS.android);
const androidArm64 = Abi._(_Architecture.arm64, _OS.android);
const androidIA32 = Abi._(_Architecture.ia32, _OS.android);
const androidX64 = Abi._(_Architecture.x64, _OS.android);
const fuchsiaArm64 = Abi._(_Architecture.arm64, _OS.fuchsia);
const fuchsiaX64 = Abi._(_Architecture.x64, _OS.fuchsia);
const iosArm = Abi._(_Architecture.arm, _OS.ios);
const iosArm64 = Abi._(_Architecture.arm64, _OS.ios);
const iosX64 = Abi._(_Architecture.x64, _OS.ios);
const linuxArm = Abi._(_Architecture.arm, _OS.linux);
const linuxArm64 = Abi._(_Architecture.arm64, _OS.linux);
const linuxIA32 = Abi._(_Architecture.ia32, _OS.linux);
const linuxX64 = Abi._(_Architecture.x64, _OS.linux);
const macosArm64 = Abi._(_Architecture.arm64, _OS.macos);
// No macosIA32, not intending to support.
// https://github.com/dart-lang/sdk/issues/39810
const macosX64 = Abi._(_Architecture.x64, _OS.macos);
/// Currently not supported, but feature requested for Flutter.
/// https://github.com/flutter/flutter/issues/53120
const windowsArm64 = Abi._(_Architecture.arm64, _OS.windows);
const windowsIA32 = Abi._(_Architecture.ia32, _OS.windows);
const windowsX64 = Abi._(_Architecture.x64, _OS.windows);
/// All ABIs that the DartVM can run on sorted alphabetically.
///
/// Keep consistent with runtime/vm/compiler/ffi/abi.cc.
const supportedAbisOrdered = [
androidArm,
androidArm64,
androidIA32,
androidX64,
fuchsiaArm64,
fuchsiaX64,
iosArm,
iosArm64,
iosX64,
linuxArm,
linuxArm64,
linuxIA32,
linuxX64,
macosArm64,
macosX64,
windowsArm64,
windowsIA32,
windowsX64,
];
/// The size of integer registers and memory addresses in bytes per [Abi].
// Keep consistent with sdk/lib/_internal/vm/lib/ffi_patch.dart
final Map<Abi, int> wordSize = {
for (final abi in supportedAbisOrdered) abi: abi.wordSize
};
/// Struct and union fields that are not aligned to their size.
///
/// Has an entry for all Abis. Empty entries document that every native
/// type is aligned to it's own size in this ABI.
///
/// See runtime/vm/compiler/ffi/abi.cc for asserts in the VM that verify these
/// alignments.
const nonSizeAlignment = <Abi, Map<NativeType, int>>{
// _wordSize64
androidArm64: _wordSize64,
androidX64: _wordSize64,
fuchsiaArm64: _wordSize64,
fuchsiaX64: _wordSize64,
iosArm64: _wordSize64,
iosX64: _wordSize64,
linuxArm64: _wordSize64,
linuxX64: _wordSize64,
macosArm64: _wordSize64,
macosX64: _wordSize64,
windowsArm64: _wordSize64,
windowsX64: _wordSize64,
// _wordSize32Align32
androidIA32: _wordSize32Align32,
iosArm: _wordSize32Align32,
linuxIA32: _wordSize32Align32,
// _wordSize32Align64
androidArm: _wordSize32Align64,
linuxArm: _wordSize32Align64,
windowsIA32: _wordSize32Align64,
};
// All 64 bit ABIs align struct fields to their size.
const Map<NativeType, int> _wordSize64 = {};
// x86 System V ABI:
// > uint64_t | size 8 | alignment 4
// > double | size 8 | alignment 4
// https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf page 8.
//
// ios 32 bit alignment:
// https://developer.apple.com/documentation/uikit/app_and_environment/updating_your_app_from_32-bit_to_64-bit_architecture/updating_data_structures
const Map<NativeType, int> _wordSize32Align32 = {
NativeType.kDouble: 4,
NativeType.kInt64: 4,
NativeType.kUint64: 4
};
// The default for MSVC x86:
// > The alignment-requirement for all data except structures, unions, and
// > arrays is either the size of the object or the current packing size
// > (specified with either /Zp or the pack pragma, whichever is less).
// https://docs.microsoft.com/en-us/cpp/c-language/padding-and-alignment-of-structure-members?view=vs-2019
//
// GCC _can_ compile on Linux to this alignment with -malign-double, but does
// not do so by default:
// > Warning: if you use the -malign-double switch, structures containing the
// > above types are aligned differently than the published application
// > binary interface specifications for the x86-32 and are not binary
// > compatible with structures in code compiled without that switch.
// https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
//
// ARM always requires 8 byte alignment for 8 byte values:
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf 4.1 Fundamental Data Types
const Map<NativeType, int> _wordSize32Align64 = {};

View file

@ -17,6 +17,8 @@ import 'package:kernel/type_algebra.dart' show Substitution;
import 'package:kernel/type_environment.dart'
show TypeEnvironment, SubtypeCheckMode;
import 'abi.dart';
/// Represents the (instantiated) ffi.NativeType.
enum NativeType {
kNativeType,
@ -107,78 +109,6 @@ const Map<NativeType, int> nativeTypeSizes = <NativeType, int>{
NativeType.kBool: 1,
};
/// The struct layout in various ABIs.
///
/// ABIs differ per architectures and with different compilers.
/// We pick the default struct layout based on the architecture and OS.
///
/// Compilers _can_ deviate from the default layout, but this prevents
/// executables from making system calls. So this seems rather uncommon.
///
/// In the future, we might support custom struct layouts. For more info see
/// https://github.com/dart-lang/sdk/issues/35768.
enum Abi {
/// Layout in all 64bit ABIs (x64 and arm64).
wordSize64,
/// Layout in System V ABI for x386 (ia32 on Linux) and in iOS Arm 32 bit.
wordSize32Align32,
/// Layout in both the Arm 32 bit ABI and the Windows ia32 ABI.
wordSize32Align64,
}
/// WORD_SIZE in bytes.
const wordSize = <Abi, int>{
Abi.wordSize64: 8,
Abi.wordSize32Align32: 4,
Abi.wordSize32Align64: 4,
};
/// Elements that are not aligned to their size.
///
/// Has an entry for all Abis. Empty entries document that every native
/// type is aligned to it's own size in this ABI.
///
/// See runtime/vm/ffi/abi.cc for asserts in the VM that verify these
/// alignments.
///
/// TODO(37470): Add uncommon primitive data types when we want to support them.
const nonSizeAlignment = <Abi, Map<NativeType, int>>{
Abi.wordSize64: {},
// x86 System V ABI:
// > uint64_t | size 8 | alignment 4
// > double | size 8 | alignment 4
// https://github.com/hjl-tools/x86-psABI/wiki/intel386-psABI-1.1.pdf page 8.
//
// iOS 32 bit alignment:
// https://developer.apple.com/documentation/uikit/app_and_environment/updating_your_app_from_32-bit_to_64-bit_architecture/updating_data_structures
Abi.wordSize32Align32: {
NativeType.kDouble: 4,
NativeType.kInt64: 4,
NativeType.kUint64: 4
},
// The default for MSVC x86:
// > The alignment-requirement for all data except structures, unions, and
// > arrays is either the size of the object or the current packing size
// > (specified with either /Zp or the pack pragma, whichever is less).
// https://docs.microsoft.com/en-us/cpp/c-language/padding-and-alignment-of-structure-members?view=vs-2019
//
// GCC _can_ compile on Linux to this alignment with -malign-double, but does
// not do so by default:
// > Warning: if you use the -malign-double switch, structures containing the
// > above types are aligned differently than the published application
// > binary interface specifications for the x86-32 and are not binary
// > compatible with structures in code compiled without that switch.
// https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
//
// Arm always requires 8 byte alignment for 8 byte values:
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf 4.1 Fundamental Data Types
Abi.wordSize32Align64: {},
};
/// Load, store, and elementAt are rewired to their static type for these types.
const List<NativeType> optimizedTypes = [
NativeType.kBool,
@ -617,9 +547,7 @@ class FfiTransformer extends Transformer {
return InstanceInvocation(
InstanceAccessKind.Instance,
intListConstantExpression([
values[Abi.wordSize64]!,
values[Abi.wordSize32Align32]!,
values[Abi.wordSize32Align64]!
for (final abi in supportedAbisOrdered) values[abi]!,
]),
listElementAt.name,
Arguments([StaticInvocation(abiMethod, Arguments([]))]),

View file

@ -31,6 +31,7 @@ import 'package:kernel/target/targets.dart' show DiagnosticReporter;
import 'package:kernel/type_environment.dart' show SubtypeCheckMode;
import 'package:kernel/util/graph.dart';
import 'abi.dart';
import 'common.dart';
/// Checks and elaborates the dart:ffi compounds and their fields.
@ -833,7 +834,8 @@ class _FfiDefinitionTransformer extends FfiTransformer {
void _addSizeOfField(Class compound, IndexedClass? indexedClass,
[Map<Abi, int>? sizes = null]) {
if (sizes == null) {
sizes = Map.fromEntries(Abi.values.map((abi) => MapEntry(abi, 0)));
sizes =
Map.fromEntries(supportedAbisOrdered.map((abi) => MapEntry(abi, 0)));
}
final name = Name("#sizeOf");
final getterReference = indexedClass?.lookupGetterReference(name);
@ -1079,12 +1081,14 @@ class PrimitiveNativeTypeCfe implements NativeTypeCfe {
if (size == WORD_SIZE) {
return wordSize;
}
return Map.fromEntries(Abi.values.map((abi) => MapEntry(abi, size)));
return Map.fromEntries(
supportedAbisOrdered.map((abi) => MapEntry(abi, size)));
}
@override
Map<Abi, int> get alignment => Map.fromEntries(Abi.values.map((abi) =>
MapEntry(abi, nonSizeAlignment[abi]![nativeType] ?? size[abi]!)));
Map<Abi, int> get alignment =>
Map.fromEntries(supportedAbisOrdered.map((abi) =>
MapEntry(abi, nonSizeAlignment[abi]![nativeType] ?? size[abi]!)));
@override
Constant generateConstant(FfiTransformer transformer) =>
@ -1305,7 +1309,7 @@ class StructNativeTypeCfe extends CompoundNativeTypeCfe {
factory StructNativeTypeCfe(Class clazz, List<NativeTypeCfe> members,
{int? packing}) {
final layout = Map.fromEntries(Abi.values
final layout = Map.fromEntries(supportedAbisOrdered
.map((abi) => MapEntry(abi, _calculateLayout(members, packing, abi))));
return StructNativeTypeCfe._(clazz, members, packing, layout);
}
@ -1341,8 +1345,8 @@ class StructNativeTypeCfe extends CompoundNativeTypeCfe {
class UnionNativeTypeCfe extends CompoundNativeTypeCfe {
factory UnionNativeTypeCfe(Class clazz, List<NativeTypeCfe> members) {
final layout = Map.fromEntries(
Abi.values.map((abi) => MapEntry(abi, _calculateLayout(members, abi))));
final layout = Map.fromEntries(supportedAbisOrdered
.map((abi) => MapEntry(abi, _calculateLayout(members, abi))));
return UnionNativeTypeCfe._(clazz, members, layout);
}

View file

@ -26,14 +26,9 @@ import 'package:kernel/target/targets.dart' show DiagnosticReporter;
import 'package:kernel/type_algebra.dart' show Substitution;
import 'package:kernel/type_environment.dart';
import 'abi.dart' show wordSize;
import 'common.dart'
show
NativeType,
FfiTransformer,
nativeTypeSizes,
WORD_SIZE,
UNKNOWN,
wordSize;
show NativeType, FfiTransformer, nativeTypeSizes, WORD_SIZE, UNKNOWN;
/// Checks and replaces calls to dart:ffi compound fields and methods.
void transformLibraries(

View file

@ -128,10 +128,10 @@ constants {
#C9 = ffi::_FfiStructLayout {fieldTypes:#C8, packing:#C4}
#C10 = core::pragma {name:#C1, options:#C9}
#C11 = 0
#C12 = <core::int*>[#C11, #C11, #C11]
#C13 = 8
#C14 = 4
#C15 = <core::int*>[#C13, #C14, #C14]
#C12 = <core::int*>[#C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11, #C11]
#C13 = 4
#C14 = 8
#C15 = <core::int*>[#C13, #C14, #C13, #C14, #C14, #C14, #C13, #C14, #C14, #C13, #C14, #C13, #C14, #C14, #C14, #C14, #C13, #C14]
#C16 = static-tearoff self::useStruct3
#C17 = static-tearoff self::returnStruct7
#C18 = 1

View file

@ -12,7 +12,7 @@ namespace compiler {
namespace ffi {
// See pkg/vm/lib/transformations/ffi.dart, which makes these assumptions.
// See pkg/vm/lib/transformations/ffi/abi.dart, which makes these assumptions.
struct AbiAlignmentDouble {
int8_t use_one_byte;
double d;
@ -45,20 +45,42 @@ static_assert(offsetof(AbiAlignmentUint64, i) == 8,
#error "Unknown platform. Please add alignment requirements for ABI."
#endif
Abi TargetAbi() {
#if defined(TARGET_ARCH_X64) || defined(TARGET_ARCH_ARM64)
return Abi::kWordSize64;
#elif (defined(TARGET_ARCH_IA32) && /* NOLINT(whitespace/parens) */ \
(defined(DART_TARGET_OS_LINUX) || defined(DART_TARGET_OS_MACOS) || \
defined(DART_TARGET_OS_ANDROID))) || \
(defined(TARGET_ARCH_ARM) && defined(DART_TARGET_OS_MACOS_IOS))
return Abi::kWordSize32Align32;
#elif defined(TARGET_ARCH_IA32) && defined(DART_TARGET_OS_WINDOWS) || \
defined(TARGET_ARCH_ARM)
return Abi::kWordSize32Align64;
#if defined(DART_TARGET_OS_ANDROID)
#define DART_TARGET_OS_NAME Android
#elif defined(DART_TARGET_OS_FUCHSIA)
#define DART_TARGET_OS_NAME Fuchsia
#elif defined(DART_TARGET_OS_LINUX)
#define DART_TARGET_OS_NAME Linux
#elif defined(DART_TARGET_OS_MACOS)
#if DART_TARGET_OS_MACOS_IOS
#define DART_TARGET_OS_NAME IOS
#else
#error "Unknown platform. Please add alignment requirements for ABI."
#define DART_TARGET_OS_NAME MacOS
#endif
#elif defined(DART_TARGET_OS_WINDOWS)
#define DART_TARGET_OS_NAME Windows
#else
#error Unknown OS
#endif
#if defined(TARGET_ARCH_IA32)
#define TARGET_ARCH_NAME IA32
#elif defined(TARGET_ARCH_X64)
#define TARGET_ARCH_NAME X64
#elif defined(TARGET_ARCH_ARM)
#define TARGET_ARCH_NAME Arm
#elif defined(TARGET_ARCH_ARM64)
#define TARGET_ARCH_NAME Arm64
#else
#error Unknown arch
#endif
#define ABI_NAME1(os, arch) k##os##arch
#define ABI_NAME2(os, arch) ABI_NAME1(os, arch)
#define ABI_NAME3 ABI_NAME2(DART_TARGET_OS_NAME, TARGET_ARCH_NAME)
Abi TargetAbi() {
return Abi::ABI_NAME3;
}
} // namespace ffi

View file

@ -17,12 +17,34 @@ namespace compiler {
namespace ffi {
// These ABIs should be kept in sync with pkg/vm/lib/transformations/ffi.dart.
// These ABIs should be kept in sync with
// pkg/vm/lib/transformations/ffi/abi.dart.
enum class Abi {
kWordSize64 = 0,
kWordSize32Align32 = 1,
kWordSize32Align64 = 2
kAndroidArm,
kAndroidArm64,
kAndroidIA32,
kAndroidX64,
kFuchsiaArm64,
kFuchsiaX64,
kIOSArm,
kIOSArm64,
kIOSX64,
kLinuxArm,
kLinuxArm64,
kLinuxIA32,
kLinuxX64,
kMacOSArm64,
kMacOSX64,
kWindowsArm64,
kWindowsIA32,
kWindowsX64,
};
// We use the integer values of this enum in
// runtime/vm/compiler/frontend/kernel_to_il.cc
static_assert(static_cast<int64_t>(Abi::kAndroidArm) == 0,
"Enum value unexpected.");
static_assert(static_cast<int64_t>(Abi::kWindowsX64) == 17,
"Enum value unexpected.");
// The target ABI. Defines sizes and alignment of native types.
Abi TargetAbi();

View file

@ -21,8 +21,28 @@ const Map<Type, int> _knownSizes = {
Double: 8,
};
// Keep consistent with pkg/vm/lib/transformations/ffi/abi.dart.
@pragma("vm:prefer-inline")
int get _intPtrSize => (const [8, 4, 4])[_abi()];
int get _intPtrSize => (const [
4, // androidArm,
8, // androidArm64,
4, // androidIA32,
8, // androidX64,
8, // fuchsiaArm64,
8, // fuchsiaX64,
4, // iosArm,
8, // iosArm64,
8, // iosX64,
4, // linuxArm,
8, // linuxArm64,
4, // linuxIA32,
8, // linuxX64,
8, // macosArm64,
8, // macosX64,
8, // windowsArm64,
4, // windowsIA32,
8, // windowsX64,
])[_abi()];
@patch
int sizeOf<T extends NativeType>() {