Flutter Engine
The Flutter Engine
third_party
dart-lang
sdk
runtime
vm
compiler
ffi
abi.cc
Go to the documentation of this file.
1
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2
// for details. All rights reserved. Use of this source code is governed by a
3
// BSD-style license that can be found in the LICENSE file.
4
5
#include "
vm/compiler/ffi/abi.h
"
6
7
#include "
platform/globals.h
"
8
#include "
vm/constants.h
"
9
10
namespace
dart
{
11
12
namespace
compiler
{
13
14
namespace
ffi {
15
16
// See pkg/vm/lib/transformations/ffi/abi.dart, which makes these assumptions.
17
struct
AbiAlignmentDouble
{
18
int8_t
use_one_byte
;
19
double
d
;
20
};
21
struct
AbiAlignmentUint64
{
22
int8_t
use_one_byte
;
23
uint64_t
i
;
24
};
25
26
#if defined(HOST_ARCH_X64) || defined(HOST_ARCH_ARM64) || \
27
defined(HOST_ARCH_RISCV32) || defined(HOST_ARCH_RISCV64)
28
static_assert
(offsetof(
AbiAlignmentDouble
,
d
) == 8,
29
"FFI transformation alignment"
);
30
static_assert
(offsetof(
AbiAlignmentUint64
,
i
) == 8,
31
"FFI transformation alignment"
);
32
#elif (defined(HOST_ARCH_IA32) &&
/* NOLINT(whitespace/parens) */
\
33
(defined(DART_HOST_OS_LINUX) || defined(DART_HOST_OS_MACOS) || \
34
defined(DART_HOST_OS_ANDROID))) || \
35
(defined(HOST_ARCH_ARM) && defined(DART_HOST_OS_IOS))
36
static_assert
(offsetof(
AbiAlignmentDouble
,
d
) == 4,
37
"FFI transformation alignment"
);
38
static_assert
(offsetof(
AbiAlignmentUint64
,
i
) == 4,
39
"FFI transformation alignment"
);
40
#elif defined(HOST_ARCH_IA32) && defined(DART_HOST_OS_WINDOWS) || \
41
defined(HOST_ARCH_ARM)
42
static_assert
(offsetof(
AbiAlignmentDouble
,
d
) == 8,
43
"FFI transformation alignment"
);
44
static_assert
(offsetof(
AbiAlignmentUint64
,
i
) == 8,
45
"FFI transformation alignment"
);
46
#else
47
#error "Unknown platform. Please add alignment requirements for ABI."
48
#endif
49
50
#if defined(DART_TARGET_OS_ANDROID)
51
#define DART_TARGET_OS_NAME Android
52
#elif defined(DART_TARGET_OS_FUCHSIA)
53
#define DART_TARGET_OS_NAME Fuchsia
54
#elif defined(DART_TARGET_OS_LINUX)
55
#define DART_TARGET_OS_NAME Linux
56
#elif defined(DART_TARGET_OS_MACOS)
57
#if DART_TARGET_OS_MACOS_IOS
58
#define DART_TARGET_OS_NAME IOS
59
#else
60
#define DART_TARGET_OS_NAME MacOS
61
#endif
62
#elif defined(DART_TARGET_OS_WINDOWS)
63
#define DART_TARGET_OS_NAME Windows
64
#else
65
#error Unknown OS
66
#endif
67
68
#if defined(TARGET_ARCH_IA32)
69
#define TARGET_ARCH_NAME IA32
70
#elif defined(TARGET_ARCH_X64)
71
#define TARGET_ARCH_NAME X64
72
#elif defined(TARGET_ARCH_ARM)
73
#define TARGET_ARCH_NAME Arm
74
#elif defined(TARGET_ARCH_ARM64)
75
#define TARGET_ARCH_NAME Arm64
76
#elif defined(TARGET_ARCH_RISCV32)
77
#define TARGET_ARCH_NAME Riscv32
78
#elif defined(TARGET_ARCH_RISCV64)
79
#define TARGET_ARCH_NAME Riscv64
80
#else
81
#error Unknown arch
82
#endif
83
84
#define ABI_ENUM_VALUE1(os, arch) k##os##arch
85
#define ABI_ENUM_VALUE2(os, arch) ABI_ENUM_VALUE1(os, arch)
86
#define ABI_ENUM_VALUE3 ABI_ENUM_VALUE2(DART_TARGET_OS_NAME, TARGET_ARCH_NAME)
87
88
Abi
TargetAbi
() {
89
return
Abi::ABI_ENUM_VALUE3
;
90
}
91
92
const
char
*
target_abi_name
=
93
kTargetOperatingSystemName
"_"
kTargetArchitectureName;
94
95
}
// namespace ffi
96
97
}
// namespace compiler
98
99
}
// namespace dart
ABI_ENUM_VALUE3
#define ABI_ENUM_VALUE3
Definition:
abi.cc:86
abi.h
d
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition:
main.cc:19
i
int i
Definition:
fl_socket_accessible.cc:18
compiler
Definition:
compiler.py:1
dart::compiler::ffi::Abi
Abi
Definition:
abi.h:22
dart::compiler::ffi::target_abi_name
const char * target_abi_name
Definition:
abi.cc:92
dart::compiler::ffi::TargetAbi
Abi TargetAbi()
Definition:
abi.cc:88
dart
Definition:
dart_vm.cc:33
globals.h
dart::compiler::ffi::AbiAlignmentDouble
Definition:
abi.cc:17
dart::compiler::ffi::AbiAlignmentDouble::use_one_byte
int8_t use_one_byte
Definition:
abi.cc:18
dart::compiler::ffi::AbiAlignmentDouble::d
double d
Definition:
abi.cc:19
dart::compiler::ffi::AbiAlignmentUint64
Definition:
abi.cc:21
dart::compiler::ffi::AbiAlignmentUint64::use_one_byte
int8_t use_one_byte
Definition:
abi.cc:22
dart::compiler::ffi::AbiAlignmentUint64::i
uint64_t i
Definition:
abi.cc:23
constants.h
Generated on Sun Jun 23 2024 21:55:36 for Flutter Engine by
1.9.4