Don't assume we want the iOS ABI if running simarm on Mac and the EABI otherwise.

Allow controlling the target ABI by defining TARGET_ABI_IOS or TARGET_ABI_EABI.  If neither is defined, default to the previous behavior.

Make Linux, Mac, Android and iOS agree on the value of PreferredCodeAlignment for all architectures.

BUG=http://dartbug.com/26464
R=zra@google.com

Review URL: https://codereview.chromium.org/1982613003 .
This commit is contained in:
Ryan Macnak 2016-05-17 15:03:54 -07:00
parent 66dacc643b
commit 85cdc0eac2
10 changed files with 109 additions and 29 deletions

View file

@ -104,6 +104,11 @@ config("dart_config") {
if (dart_target_arch != "") {
if (dart_target_arch == "arm") {
defines += [ "TARGET_ARCH_ARM" ]
if (target_os == "mac" || target_os == "ios") {
defines += [ "TARGET_ABI_IOS" ]
} else {
defines += [ "TARGET_ABI_EABI" ]
}
} else if (dart_target_arch == "arm64") {
defines += [ "TARGET_ARCH_ARM64" ]
} else if (dart_target_arch == "mips") {

View file

@ -2,8 +2,8 @@
// 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.
#ifndef RUNTIME_PLATFORM_GLOBALS_H_
#define RUNTIME_PLATFORM_GLOBALS_H_
#ifndef PLATFORM_GLOBALS_H_
#define PLATFORM_GLOBALS_H_
// __STDC_FORMAT_MACROS has to be defined before including <inttypes.h> to
// enable platform independent printf format specifiers.
@ -365,6 +365,20 @@ typedef simd128_value_t fpu_register_t;
#define ARCH_IS_MULTI_CORE 1
#endif
#if defined(TARGET_ARCH_ARM)
#if defined(TARGET_ABI_IOS) && defined(TARGET_ABI_EABI)
#error Both TARGET_ABI_IOS and TARGET_ABI_EABI defined.
#elif !defined(TARGET_ABI_IOS) && !defined(TARGET_ABI_EABI)
#if defined(TARGET_OS_MAC)
#define TARGET_ABI_IOS 1
#else
#define TARGET_ABI_EABI 1
#endif
#endif
#endif // TARGET_ARCH_ARM
// Short form printf format specifiers
#define Pd PRIdPTR
#define Pu PRIuPTR
@ -683,4 +697,4 @@ static inline T ReadUnaligned(const T* ptr) {
} // namespace dart
#endif // RUNTIME_PLATFORM_GLOBALS_H_
#endif // PLATFORM_GLOBALS_H_

View file

@ -25,6 +25,41 @@ namespace dart {
#endif
// The Linux/Android ABI and the iOS ABI differ in their choice of frame
// pointer, their treatment of R9, and the interproduceral stack alignment.
// EABI (Linux, Android)
// See "Procedure Call Standard for the ARM Architecture".
// R0-R1: Argument / result / volatile
// R2-R3: Argument / volatile
// R4-R10: Preserved
// R11: Frame pointer
// R12: Volatile
// R13: Stack pointer
// R14: Link register
// R15: Program counter
// Stack alignment: 4 bytes always, 8 bytes at public interfaces
// Linux (Debian armhf) and Android also differ in whether floating point
// arguments are passed in registers. Linux uses hardfp and Android uses
// softfp. See TargetCPUFeatures::hardfp_supported().
// iOS ABI
// See "iOS ABI Function Call Guide"
// R0-R1: Argument / result / volatile
// R2-R3: Argument / volatile
// R4-R6: Preserved
// R7: Frame pointer
// R8-R9: Preserved
// R12: Volatile
// R13: Stack pointer
// R14: Link register
// R15: Program counter
// Stack alignment: 4 bytes always, 4 bytes at public interfaces
// iOS passes floating point arguments in registers (hardfp)
enum Register {
R0 = 0,
R1 = 1,
@ -46,12 +81,14 @@ enum Register {
kNoRegister = -1, // Signals an illegal register.
// Aliases.
#if defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_IOS)
FP = R7,
NOTFP = R11,
#else
#elif defined(TARGET_ABI_EABI)
FP = R11,
NOTFP = R7,
#else
#error Unknown ABI
#endif
IP = R12,
SP = R13,
@ -268,16 +305,18 @@ const RegList kAllCpuRegistersList = 0xFFFF;
// C++ ABI call registers.
const RegList kAbiArgumentCpuRegs =
(1 << R0) | (1 << R1) | (1 << R2) | (1 << R3);
#if defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_IOS)
const RegList kAbiPreservedCpuRegs =
(1 << R4) | (1 << R5) | (1 << R6) | (1 << R8) |
(1 << R10) | (1 << R11);
const int kAbiPreservedCpuRegCount = 6;
#else
#elif defined(TARGET_ABI_EABI)
const RegList kAbiPreservedCpuRegs =
(1 << R4) | (1 << R5) | (1 << R6) | (1 << R7) |
(1 << R8) | (1 << R9) | (1 << R10);
const int kAbiPreservedCpuRegCount = 7;
#else
#error Unknown ABI
#endif
const QRegister kAbiFirstPreservedFpuReg = Q4;
const QRegister kAbiLastPreservedFpuReg = Q7;
@ -296,9 +335,9 @@ const RegList kDartAvailableCpuRegs =
// Registers available to Dart that are not preserved by runtime calls.
const RegList kDartVolatileCpuRegs =
kDartAvailableCpuRegs & ~kAbiPreservedCpuRegs;
#if defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_IOS)
const int kDartVolatileCpuRegCount = 6;
#else
#elif defined(TARGET_ABI_EABI)
const int kDartVolatileCpuRegCount = 5;
#endif
const QRegister kDartFirstVolatileFpuReg = Q0;

View file

@ -617,10 +617,12 @@ const char* Dart::FeaturesString(Snapshot::Kind kind) {
// Generated code must match the host architecture and ABI.
#if defined(TARGET_ARCH_ARM)
#if defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_IOS)
buffer.AddString(" arm-ios");
#else
#elif defined(TARGET_ABI_EABI)
buffer.AddString(" arm-eabi");
#else
#error Unknown ABI
#endif
buffer.AddString(TargetCPUFeatures::hardfp_supported() ? " hardfp"
: " softfp");

View file

@ -114,12 +114,14 @@ void ARMDecoder::PrintCondition(Instr* instr) {
// formatting, except for register alias pp (r5).
// See for example the command "objdump -d <binary file>".
static const char* reg_names[kNumberOfCpuRegisters] = {
#if defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_IOS)
"r0", "r1", "r2", "r3", "r4", "pp", "r6", "fp",
"r8", "r9", "r10", "r11", "ip", "sp", "lr", "pc",
#else
#elif defined(TARGET_ABI_EABI)
"r0", "r1", "r2", "r3", "r4", "pp", "r6", "r7",
"r8", "r9", "r10", "fp", "ip", "sp", "lr", "pc",
#else
#error Unknown ABI
#endif
};

View file

@ -220,12 +220,12 @@ intptr_t OS::ActivationFrameAlignment() {
intptr_t OS::PreferredCodeAlignment() {
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \
defined(TARGET_ARCH_ARM64)
const int kMinimumAlignment = 16;
#elif defined(TARGET_ARCH_ARM)
const int kMinimumAlignment = 16;
#elif defined(TARGET_ARCH_DBC)
#if defined(TARGET_ARCH_IA32) || \
defined(TARGET_ARCH_X64) || \
defined(TARGET_ARCH_ARM64) || \
defined(TARGET_ARCH_DBC)
const int kMinimumAlignment = 32;
#elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS)
const int kMinimumAlignment = 16;
#else
#error Unsupported architecture.

View file

@ -204,8 +204,24 @@ intptr_t OS::ActivationFrameAlignment() {
intptr_t OS::PreferredCodeAlignment() {
ASSERT(32 <= OS::kMaxPreferredCodeAlignment);
return 32;
#if defined(TARGET_ARCH_IA32) || \
defined(TARGET_ARCH_X64) || \
defined(TARGET_ARCH_ARM64) || \
defined(TARGET_ARCH_DBC)
const int kMinimumAlignment = 32;
#elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS)
const int kMinimumAlignment = 16;
#else
#error Unsupported architecture.
#endif
intptr_t alignment = kMinimumAlignment;
// TODO(5411554): Allow overriding default code alignment for
// testing purposes.
// Flags::DebugIsInt("codealign", &alignment);
ASSERT(Utils::IsPowerOfTwo(alignment));
ASSERT(alignment >= kMinimumAlignment);
ASSERT(alignment <= OS::kMaxPreferredCodeAlignment);
return alignment;
}

View file

@ -3759,7 +3759,7 @@ int64_t Simulator::Call(int32_t entry,
int32_t r6_val = get_register(R6);
int32_t r7_val = get_register(R7);
int32_t r8_val = get_register(R8);
#if !defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_EABI)
int32_t r9_val = get_register(R9);
#endif
int32_t r10_val = get_register(R10);
@ -3793,7 +3793,7 @@ int64_t Simulator::Call(int32_t entry,
set_register(R6, callee_saved_value);
set_register(R7, callee_saved_value);
set_register(R8, callee_saved_value);
#if !defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_EABI)
set_register(R9, callee_saved_value);
#endif
set_register(R10, callee_saved_value);
@ -3821,7 +3821,7 @@ int64_t Simulator::Call(int32_t entry,
ASSERT(callee_saved_value == get_register(R6));
ASSERT(callee_saved_value == get_register(R7));
ASSERT(callee_saved_value == get_register(R8));
#if !defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_EABI)
ASSERT(callee_saved_value == get_register(R9));
#endif
ASSERT(callee_saved_value == get_register(R10));
@ -3844,7 +3844,7 @@ int64_t Simulator::Call(int32_t entry,
set_register(R6, r6_val);
set_register(R7, r7_val);
set_register(R8, r8_val);
#if !defined(TARGET_OS_MACOS)
#if defined(TARGET_ABI_EABI)
set_register(R9, r9_val);
#endif
set_register(R10, r10_val);

View file

@ -43,14 +43,16 @@ static const int kParamEndSlotFromFp = 1; // One slot past last parameter.
static const int kCallerSpSlotFromFp = 2;
// Entry and exit frame layout.
#if defined(TARGET_OS_MAC)
#if defined(TARGET_ABI_IOS)
static const int kExitLinkSlotFromEntryFp = -26;
COMPILE_ASSERT(kAbiPreservedCpuRegCount == 6);
COMPILE_ASSERT(kAbiPreservedFpuRegCount == 4);
#else
#elif defined(TARGET_ABI_EABI)
static const int kExitLinkSlotFromEntryFp = -27;
COMPILE_ASSERT(kAbiPreservedCpuRegCount == 7);
COMPILE_ASSERT(kAbiPreservedFpuRegCount == 4);
#else
#error Unknown ABI
#endif
} // namespace dart

View file

@ -772,9 +772,9 @@ void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
// kExitLinkSlotFromEntryFp must be kept in sync with the code below.
__ Push(R4);
#if defined(TARGET_OS_MAC)
#if defined(TARGET_ABI_IOS)
ASSERT(kExitLinkSlotFromEntryFp == -26);
#else
#elif defined(TARGET_ABI_EABI)
ASSERT(kExitLinkSlotFromEntryFp == -27);
#endif
__ Push(R9);