[vm/ffi] Add Fuchsia ABI unit tests

Adds the Fuchsia ABI to the ABI unit tests.

Adds an ABI test for the FFI callback on who's return the stack is/gets
corrupted from bug:
https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=105336

TEST=tools/test.py ffi_unit

Change-Id: I3c9bb9941e4883384dfba787bb6dacb4c8cdc141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255122
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
Daco Harkes 2022-08-16 12:17:26 +00:00 committed by Commit Bot
parent 34c11de808
commit 1ae40d5ebf
62 changed files with 691 additions and 0 deletions

View file

@ -389,6 +389,7 @@ class FfiTestSuite extends TestSuite {
static const targetAbis = [
"arm64_android",
"arm64_fuchsia",
"arm64_ios",
"arm64_linux",
"arm64_macos",
@ -398,6 +399,7 @@ class FfiTestSuite extends TestSuite {
"ia32_android",
"ia32_linux",
"ia32_win",
"x64_fuchsia",
"x64_ios",
"x64_linux",
"x64_macos",

View file

@ -61,6 +61,10 @@ config("define_target_os_android") {
defines = [ "DART_TARGET_OS_ANDROID" ]
}
config("define_target_os_fuchsia") {
defines = [ "DART_TARGET_OS_FUCHSIA" ]
}
config("define_target_os_ios") {
defines = [ "DART_TARGET_OS_MACOS_IOS" ]
}
@ -105,6 +109,13 @@ build_run_ffi_unit_tests("run_ffi_unit_tests_arm64_android") {
]
}
build_run_ffi_unit_tests("run_ffi_unit_tests_arm64_fuchsia") {
extra_configs = [
":define_target_arch_arm64",
":define_target_os_fuchsia",
]
}
build_run_ffi_unit_tests("run_ffi_unit_tests_arm64_ios") {
extra_configs = [
":define_target_arch_arm64",
@ -147,6 +158,13 @@ build_run_ffi_unit_tests("run_ffi_unit_tests_ia32_win") {
]
}
build_run_ffi_unit_tests("run_ffi_unit_tests_x64_fuchsia") {
extra_configs = [
":define_target_arch_x64",
":define_target_os_fuchsia",
]
}
build_run_ffi_unit_tests("run_ffi_unit_tests_x64_ios") {
extra_configs = [
":define_target_arch_x64",
@ -192,6 +210,7 @@ build_run_ffi_unit_tests("run_ffi_unit_tests_riscv64_linux") {
group("run_ffi_unit_tests") {
deps = [
":run_ffi_unit_tests_arm64_android",
":run_ffi_unit_tests_arm64_fuchsia",
":run_ffi_unit_tests_arm64_ios", # No other test coverage.
":run_ffi_unit_tests_arm64_linux",
":run_ffi_unit_tests_arm64_macos",
@ -203,6 +222,7 @@ group("run_ffi_unit_tests") {
":run_ffi_unit_tests_ia32_win",
":run_ffi_unit_tests_riscv32_linux",
":run_ffi_unit_tests_riscv64_linux",
":run_ffi_unit_tests_x64_fuchsia",
":run_ffi_unit_tests_x64_ios", # Simulator, no other test coverage.
":run_ffi_unit_tests_x64_linux",
":run_ffi_unit_tests_x64_macos",

View file

@ -697,6 +697,38 @@ UNIT_TEST_CASE_WITH_ZONE(NativeCallingConvention_struct12bytesFloatx6) {
RunSignatureTest(Z, "struct12bytesFloatx6", arguments, int64_type);
}
// typedef void (*YogaDartMeasureFunc)(intptr_t node_id,
// double available_width,
// int32_t width_mode,
// double available_height,
// int32_t height_mode,
// double *measured_width,
// double *measured_height);
// https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=105336
//
// See the *.expect in ./unit_tests for this behavior.
UNIT_TEST_CASE_WITH_ZONE(NativeCallingConvention_regress_fuchsia105336) {
#if defined(TARGET_ARCH_IS_32_BIT)
const auto& intptr_type = *new (Z) NativePrimitiveType(kInt32);
#elif defined(TARGET_ARCH_IS_64_BIT)
const auto& intptr_type = *new (Z) NativePrimitiveType(kInt64);
#endif
const auto& double_type = *new (Z) NativePrimitiveType(kDouble);
const auto& int32_type = *new (Z) NativePrimitiveType(kInt32);
const auto& void_type = *new (Z) NativePrimitiveType(kVoid);
auto& arguments = *new (Z) NativeTypes(Z, 6);
arguments.Add(&intptr_type);
arguments.Add(&double_type);
arguments.Add(&int32_type);
arguments.Add(&double_type);
arguments.Add(&int32_type);
arguments.Add(&intptr_type); // pointer
arguments.Add(&intptr_type); // pointer
RunSignatureTest(Z, "regress_fuchsia105336", arguments, void_type);
}
} // namespace ffi
} // namespace compiler
} // namespace dart

View file

@ -0,0 +1,22 @@
v0 double
v1 double
v2 double
v3 double
v4 double
v5 double
v6 double
v7 double
S+0 double
S+8 double
S+16 double
S+24 double
S+32 double
S+40 double
S+48 double
S+56 double
S+64 double
S+72 double
S+80 double
S+88 double
=>
v0 double

View file

@ -0,0 +1,22 @@
xmm0 double
xmm1 double
xmm2 double
xmm3 double
xmm4 double
xmm5 double
xmm6 double
xmm7 double
S+0 double
S+8 double
S+16 double
S+24 double
S+32 double
S+40 double
S+48 double
S+56 double
S+64 double
S+72 double
S+80 double
S+88 double
=>
xmm0 double

View file

@ -0,0 +1,22 @@
v0 float
v1 float
v2 float
v3 float
v4 float
v5 float
v6 float
v7 float
S+0 float
S+8 float
S+16 float
S+24 float
S+32 float
S+40 float
S+48 float
S+56 float
S+64 float
S+72 float
S+80 float
S+88 float
=>
v0 float

View file

@ -0,0 +1,22 @@
xmm0 float
xmm1 float
xmm2 float
xmm3 float
xmm4 float
xmm5 float
xmm6 float
xmm7 float
S+0 float
S+8 float
S+16 float
S+24 float
S+32 float
S+40 float
S+48 float
S+56 float
S+64 float
S+72 float
S+80 float
S+88 float
=>
xmm0 float

View file

@ -0,0 +1,12 @@
r0 int8
r1 int8
r2 int8
r3 int8
r4 int8
r5 int8
r6 int8
r7 int8
S+0 int8
S+8 int8
=>
r0 int8

View file

@ -0,0 +1,12 @@
rdi int32[int8]
rsi int32[int8]
rdx int32[int8]
rcx int32[int8]
r8 int32[int8]
r9 int32[int8]
S+0 int32[int8]
S+8 int32[int8]
S+16 int32[int8]
S+24 int32[int8]
=>
rax int8

View file

@ -0,0 +1,22 @@
r0 int64
v0 float
r1 int64
v1 double
r2 int64
v2 float
r3 int64
v3 double
r4 int64
v4 float
r5 int64
v5 double
r6 int64
v6 float
r7 int64
v7 double
S+0 int64
S+8 float
S+16 int64
S+24 double
=>
v0 double

View file

@ -0,0 +1,22 @@
rdi int64
xmm0 float
rsi int64
xmm1 double
rdx int64
xmm2 float
rcx int64
xmm3 double
r8 int64
xmm4 float
r9 int64
xmm5 double
S+0 int64
xmm6 float
S+8 int64
xmm7 double
S+16 int64
S+24 float
S+32 int64
S+40 double
=>
xmm0 double

View file

@ -0,0 +1,3 @@
=>
M(r0 int64) Struct(size: 8)

View file

@ -0,0 +1,3 @@
=>
M(rax int64) Struct(size: 8)

View file

@ -0,0 +1,9 @@
r0 int64
v0 double
r1 int32
v1 double
r2 int32
r3 int64
r4 int64
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int64
v0 double
r1 int32
v1 double
r2 int32
r3 int64
r4 int64
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int64
v0 double
r1 int32
v1 double
r2 int32
r3 int64
r4 int64
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int64
v0 double
r1 int32
v1 double
r2 int32
r3 int64
r4 int64
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int64
v0 double
r1 int32
v1 double
r2 int32
r3 int64
r4 int64
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int32
(r2, r3) int64[double]
S+0 int32
S+8 double
S+16 int32
S+20 int32
S+24 int32
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int32
d0 double
r1 int32
d1 double
r2 int32
r3 int32
S+0 int32
=>
r0 void

View file

@ -0,0 +1,9 @@
r0 int32
d0 double
r1 int32
d1 double
r2 int32
r3 int32
S+0 int32
=>
r0 void

View file

@ -0,0 +1,9 @@
S+0 int32
S+4 double
S+12 int32
S+16 double
S+24 int32
S+28 int32
S+32 int32
=>
eax void

View file

@ -0,0 +1,9 @@
S+0 int32
S+4 double
S+12 int32
S+16 double
S+24 int32
S+28 int32
S+32 int32
=>
eax void

View file

@ -0,0 +1,9 @@
S+0 int32
S+4 double
S+12 int32
S+16 double
S+24 int32
S+28 int32
S+32 int32
=>
eax void

View file

@ -0,0 +1,9 @@
a0 int32
fa0 double
a1 int32
fa1 double
a2 int32
a3 int32
a4 int32
=>
a0 void

View file

@ -0,0 +1,9 @@
a0 int64
fa0 double
a1 int32
fa1 double
a2 int32
a3 int64
a4 int64
=>
a0 void

View file

@ -0,0 +1,9 @@
rdi int64
xmm0 double
rsi int32
xmm1 double
rdx int32
rcx int64
r8 int64
=>
rax void

View file

@ -0,0 +1,9 @@
rdi int64
xmm0 double
rsi int32
xmm1 double
rdx int32
rcx int64
r8 int64
=>
rax void

View file

@ -0,0 +1,9 @@
rdi int64
xmm0 double
rsi int32
xmm1 double
rdx int32
rcx int64
r8 int64
=>
rax void

View file

@ -0,0 +1,9 @@
rdi int64
xmm0 double
rsi int32
xmm1 double
rdx int32
rcx int64
r8 int64
=>
rax void

View file

@ -0,0 +1,9 @@
rcx int64
xmm1 double
r8 int32
xmm3 double
S+0 int32
S+8 int64
S+16 int64
=>
rax void

View file

@ -0,0 +1,4 @@
P(r0 int64) Struct(size: 128)
r1 int32
=>
P(r8 int64) Struct(size: 128)

View file

@ -0,0 +1,4 @@
S+0 Struct(size: 128)
rsi int32
=>
P(rdi int64, ret:rax int64) Struct(size: 128)

View file

@ -0,0 +1,8 @@
M(v0 float, v1 float, v2 float) Struct(size: 12)
M(v3 float, v4 float, v5 float) Struct(size: 12)
S+0 Struct(size: 12)
S+16 Struct(size: 12)
S+32 Struct(size: 12)
S+48 Struct(size: 12)
=>
r0 int64

View file

@ -0,0 +1,8 @@
M(xmm0 double, xmm1 double) Struct(size: 12)
M(xmm2 double, xmm3 double) Struct(size: 12)
M(xmm4 double, xmm5 double) Struct(size: 12)
M(xmm6 double, xmm7 double) Struct(size: 12)
S+0 Struct(size: 12)
S+16 Struct(size: 12)
=>
rax int64

View file

@ -0,0 +1,15 @@
M(v0 float, v1 float, v2 float, v3 float) Struct(size: 16)
v4 float
S+0 Struct(size: 16)
S+16 Struct(size: 16)
S+32 Struct(size: 16)
S+48 Struct(size: 16)
S+64 Struct(size: 16)
S+80 Struct(size: 16)
S+96 Struct(size: 16)
S+112 Struct(size: 16)
S+128 float
r0 int8
S+136 Struct(size: 16)
=>
M(v0 float, v1 float, v2 float, v3 float) Struct(size: 16)

View file

@ -0,0 +1,15 @@
M(xmm0 double, xmm1 double) Struct(size: 16)
xmm2 float
M(xmm3 double, xmm4 double) Struct(size: 16)
M(xmm5 double, xmm6 double) Struct(size: 16)
S+0 Struct(size: 16)
S+16 Struct(size: 16)
S+32 Struct(size: 16)
S+48 Struct(size: 16)
S+64 Struct(size: 16)
S+80 Struct(size: 16)
xmm7 float
rdi int32[int8]
S+96 Struct(size: 16)
=>
M(xmm0 double, xmm1 double) Struct(size: 16)

View file

@ -0,0 +1,13 @@
M(xmm0 double, rdi int64) Struct(size: 16)
M(xmm1 double, rsi int64) Struct(size: 16)
M(xmm2 double, rdx int64) Struct(size: 16)
M(xmm3 double, rcx int64) Struct(size: 16)
M(xmm4 double, r8 int64) Struct(size: 16)
M(xmm5 double, r9 int64) Struct(size: 16)
S+0 Struct(size: 16)
S+16 Struct(size: 16)
S+32 Struct(size: 16)
S+48 Struct(size: 16)
xmm6 float
=>
M(xmm0 double, rax int64) Struct(size: 16)

View file

@ -0,0 +1,17 @@
xmm0 float
xmm1 float
xmm2 float
xmm3 float
M(xmm4 double, rdi int64) Struct(size: 16)
M(xmm5 double, rsi int64) Struct(size: 16)
M(xmm6 double, rdx int64) Struct(size: 16)
M(xmm7 double, rcx int64) Struct(size: 16)
S+0 Struct(size: 16)
S+16 Struct(size: 16)
S+32 Struct(size: 16)
S+48 Struct(size: 16)
S+64 Struct(size: 16)
S+80 Struct(size: 16)
r8 int32
=>
M(xmm0 double, rax int64) Struct(size: 16)

View file

@ -0,0 +1,13 @@
M(rdi int64, xmm0 double) Struct(size: 16)
M(rsi int64, xmm1 double) Struct(size: 16)
M(rdx int64, xmm2 double) Struct(size: 16)
M(rcx int64, xmm3 double) Struct(size: 16)
M(r8 int64, xmm4 double) Struct(size: 16)
M(r9 int64, xmm5 double) Struct(size: 16)
S+0 Struct(size: 16)
S+16 Struct(size: 16)
S+32 Struct(size: 16)
S+48 Struct(size: 16)
xmm6 float
=>
M(rax int64, xmm0 double) Struct(size: 16)

View file

@ -0,0 +1,12 @@
M(r0 int64) Struct(size: 3)
M(r1 int64) Struct(size: 3)
M(r2 int64) Struct(size: 3)
M(r3 int64) Struct(size: 3)
M(r4 int64) Struct(size: 3)
M(r5 int64) Struct(size: 3)
M(r6 int64) Struct(size: 3)
M(r7 int64) Struct(size: 3)
M(S+0 int64) Struct(size: 3)
M(S+8 int64) Struct(size: 3)
=>
M(r0 int64) Struct(size: 3)

View file

@ -0,0 +1,12 @@
M(rdi int64) Struct(size: 3)
M(rsi int64) Struct(size: 3)
M(rdx int64) Struct(size: 3)
M(rcx int64) Struct(size: 3)
M(r8 int64) Struct(size: 3)
M(r9 int64) Struct(size: 3)
S+0 Struct(size: 3)
S+8 Struct(size: 3)
S+16 Struct(size: 3)
S+24 Struct(size: 3)
=>
M(rax int64) Struct(size: 3)

View file

@ -0,0 +1,12 @@
M(r0 int64) Struct(size: 8)
M(r1 int64) Struct(size: 8)
M(r2 int64) Struct(size: 8)
M(r3 int64) Struct(size: 8)
M(r4 int64) Struct(size: 8)
M(r5 int64) Struct(size: 8)
M(r6 int64) Struct(size: 8)
M(r7 int64) Struct(size: 8)
S+0 Struct(size: 8)
S+8 Struct(size: 8)
=>
M(r0 int64) Struct(size: 8)

View file

@ -0,0 +1,12 @@
S+0 Struct(size: 8)
S+8 Struct(size: 8)
S+16 Struct(size: 8)
S+24 Struct(size: 8)
S+32 Struct(size: 8)
S+40 Struct(size: 8)
S+48 Struct(size: 8)
S+56 Struct(size: 8)
S+64 Struct(size: 8)
S+72 Struct(size: 8)
=>
P(rdi int64, ret:rax int64) Struct(size: 8)

View file

@ -0,0 +1,3 @@
M(r0 int64) Struct(size: 8)
=>
M(r0 int64) Struct(size: 8)

View file

@ -0,0 +1,3 @@
M(rdi int64) Struct(size: 8)
=>
M(rax int64) Struct(size: 8)

View file

@ -0,0 +1,15 @@
M(r0 int64, r1 int64) Struct(size: 9)
M(r2 int64, r3 int64) Struct(size: 9)
M(r4 int64, r5 int64) Struct(size: 9)
M(r6 int64, r7 int64) Struct(size: 9)
S+0 Struct(size: 9)
S+16 Struct(size: 9)
S+32 Struct(size: 9)
S+48 Struct(size: 9)
S+64 Struct(size: 9)
S+80 Struct(size: 9)
v0 double
S+96 int32
S+104 int32
=>
v0 double

View file

@ -0,0 +1,15 @@
S+0 Struct(size: 9)
S+16 Struct(size: 9)
S+32 Struct(size: 9)
S+48 Struct(size: 9)
S+64 Struct(size: 9)
S+80 Struct(size: 9)
S+96 Struct(size: 9)
S+112 Struct(size: 9)
S+128 Struct(size: 9)
S+144 Struct(size: 9)
xmm0 double
rdi int32
rsi int32
=>
xmm0 double

View file

@ -0,0 +1,17 @@
Struct(size: 88, field alignment: 8, stack alignment: 8, members: {
0: int8,
2: int16,
4: int32,
8: int64,
16: uint8,
18: uint16,
20: uint32,
24: uint64,
32: int64,
40: double,
48: float,
56: int64,
64: int64,
72: int64,
80: int8
})

View file

@ -0,0 +1,17 @@
Struct(size: 88, field alignment: 8, stack alignment: 8, members: {
0: int8,
2: int16,
4: int32,
8: int64,
16: uint8,
18: uint16,
20: uint32,
24: uint64,
32: int64,
40: double,
48: float,
56: int64,
64: int64,
72: int64,
80: int8
})

View file

@ -0,0 +1,3 @@
Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 8, members: {0: Array(element type: float, length: 2)}), length: 2)
})

View file

@ -0,0 +1,3 @@
Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
0: Array(element type: Struct(size: 8, field alignment: 4, stack alignment: 8, members: {0: Array(element type: float, length: 2)}), length: 2)
})

View file

@ -0,0 +1,6 @@
Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
0: float,
4: float,
8: float,
12: float
})

View file

@ -0,0 +1,6 @@
Struct(size: 16, field alignment: 4, stack alignment: 8, members: {
0: float,
4: float,
8: float,
12: float
})

View file

@ -0,0 +1,3 @@
Struct(size: 8, field alignment: 1, stack alignment: 8, members: {
0: Array(element type: int8, length: 8)
})

View file

@ -0,0 +1,3 @@
Struct(size: 8, field alignment: 1, stack alignment: 8, members: {
0: Array(element type: int8, length: 8)
})

View file

@ -0,0 +1,12 @@
Struct(size: 10, field alignment: 1, stack alignment: 8, members: {
0: int8,
1: int8,
2: int8,
3: int8,
4: int8,
5: int8,
6: int8,
7: int8,
8: int8,
9: int8
})

View file

@ -0,0 +1,12 @@
Struct(size: 10, field alignment: 1, stack alignment: 8, members: {
0: int8,
1: int8,
2: int8,
3: int8,
4: int8,
5: int8,
6: int8,
7: int8,
8: int8,
9: int8
})

View file

@ -0,0 +1,13 @@
M(v0 float, v1 float, v2 float, v3 float) Union(size: 16)
M(v4 float, v5 float, v6 float, v7 float) Union(size: 16)
S+0 Union(size: 16)
S+16 Union(size: 16)
S+32 Union(size: 16)
S+48 Union(size: 16)
S+64 Union(size: 16)
S+80 Union(size: 16)
S+96 Union(size: 16)
r0 int8
S+112 Union(size: 16)
=>
M(v0 float, v1 float, v2 float, v3 float) Union(size: 16)

View file

@ -0,0 +1,13 @@
M(xmm0 double, xmm1 double) Union(size: 16)
M(xmm2 double, xmm3 double) Union(size: 16)
M(xmm4 double, xmm5 double) Union(size: 16)
M(xmm6 double, xmm7 double) Union(size: 16)
S+0 Union(size: 16)
S+16 Union(size: 16)
S+32 Union(size: 16)
S+48 Union(size: 16)
S+64 Union(size: 16)
rdi int32[int8]
S+80 Union(size: 16)
=>
M(xmm0 double, xmm1 double) Union(size: 16)

View file

@ -0,0 +1,12 @@
M(r0 int64) Union(size: 5)
M(r1 int64) Union(size: 5)
M(r2 int64) Union(size: 5)
M(r3 int64) Union(size: 5)
M(r4 int64) Union(size: 5)
M(r5 int64) Union(size: 5)
M(r6 int64) Union(size: 5)
M(r7 int64) Union(size: 5)
M(S+0 int64) Union(size: 5)
M(S+8 int64) Union(size: 5)
=>
M(r0 int64) Union(size: 5)

View file

@ -0,0 +1,12 @@
S+0 Union(size: 5)
S+8 Union(size: 5)
S+16 Union(size: 5)
S+24 Union(size: 5)
S+32 Union(size: 5)
S+40 Union(size: 5)
S+48 Union(size: 5)
S+56 Union(size: 5)
S+64 Union(size: 5)
S+72 Union(size: 5)
=>
P(rdi int64, ret:rax int64) Union(size: 5)