Files
sdk/runtime/vm/compiler/ffi/native_location_test.cc
T
Daco Harkes b52113314b [vm/ffi] Structs by value compiler frontend (part 2)
Split off https://dart-review.googlesource.com/c/sdk/+/140290 to make
that CL smaller.

This CL adds support for passing struct arguments in the native calling
convention calculation in
`runtime/vm/compiler/ffi/native_calling_convention.cc`.

The code in this CL is unit tested with expect files. The unit tests are
designed to cover the majority of corner cases in the ABIs without
resorting to very many unit tests.

TEST=runtime/vm/compiler/ffi/native_calling_convention_test.cc

The code in this CL has been end-to-end tested in the CL it is split off
from. And will be end-to-end tested when that CL also lands.

Issue: https://github.com/dart-lang/sdk/issues/36730

Change-Id: I5b3c3786122c5f856f33181f898fbd8db782cff3
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-mac-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172763
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2020-11-19 13:28:19 +00:00

41 lines
1.2 KiB
C++

// Copyright (c) 2020, 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.
#include "vm/compiler/ffi/unit_test.h"
#include "vm/compiler/ffi/native_location.h"
namespace dart {
namespace compiler {
namespace ffi {
UNIT_TEST_CASE_WITH_ZONE(NativeStackLocation) {
const auto& native_type = *new (Z) NativePrimitiveType(kInt8);
const int kUnalignedStackLocation = 17;
const auto& native_location = *new (Z) NativeStackLocation(
native_type, native_type, SPREG, kUnalignedStackLocation);
EXPECT_EQ(kUnalignedStackLocation + native_type.SizeInBytes(),
native_location.StackTopInBytes());
}
UNIT_TEST_CASE_WITH_ZONE(NativeStackLocation_Split) {
const auto& native_type = *new (Z) NativePrimitiveType(kInt64);
const auto& native_location =
*new (Z) NativeStackLocation(native_type, native_type, SPREG, 0);
const auto& half_0 = native_location.Split(Z, 2, 0);
const auto& half_1 = native_location.Split(Z, 2, 1);
EXPECT_EQ(0, half_0.offset_in_bytes());
EXPECT_EQ(4, half_1.offset_in_bytes());
}
} // namespace ffi
} // namespace compiler
} // namespace dart