mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:29:47 +00:00
[vm] Refactor constants to be available in namespaces dart and dart::host
Refactoring motivation: go/dart-simulated-ffi Change-Id: I219aba2793cfb7d7ea5ecc0a2ab93276c6cbf1e0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97325 Reviewed-by: Samir Jindel <sjindel@google.com>
This commit is contained in:
parent
7f5ed18ffc
commit
544371c7f2
|
@ -15,7 +15,7 @@
|
|||
#include "platform/utils.h"
|
||||
#include "vm/code_entry_kind.h"
|
||||
#include "vm/compiler/runtime_api.h"
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpu.h"
|
||||
#include "vm/hash_map.h"
|
||||
#include "vm/simulator.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "platform/assert.h"
|
||||
#include "platform/utils.h"
|
||||
#include "vm/class_id.h"
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/hash_map.h"
|
||||
#include "vm/simulator.h"
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "platform/assert.h"
|
||||
#include "platform/utils.h"
|
||||
#include "vm/constants_ia32.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/constants_x86.h"
|
||||
#include "vm/pointer_tagging.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "platform/assert.h"
|
||||
#include "platform/utils.h"
|
||||
#include "vm/constants_x64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/constants_x86.h"
|
||||
#include "vm/hash_map.h"
|
||||
#include "vm/pointer_tagging.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "vm/code_entry_kind.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/compiler/backend/locations.h"
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/instructions.h"
|
||||
#include "vm/static_type_exactness_state.h"
|
||||
#include "vm/tags.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "vm/code_entry_kind.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/compiler/backend/locations.h"
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/instructions.h"
|
||||
#include "vm/static_type_exactness_state.h"
|
||||
#include "vm/tags.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "vm/code_entry_kind.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/compiler/backend/locations.h"
|
||||
#include "vm/constants_ia32.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/instructions.h"
|
||||
#include "vm/static_type_exactness_state.h"
|
||||
#include "vm/tags.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "vm/class_id.h"
|
||||
#include "vm/code_entry_kind.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_x64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/instructions.h"
|
||||
#include "vm/static_type_exactness_state.h"
|
||||
#include "vm/tags.h"
|
||||
|
|
|
@ -19,4 +19,50 @@
|
|||
#error Unknown architecture.
|
||||
#endif
|
||||
|
||||
#if defined(HOST_ARCH_IA32)
|
||||
#include "vm/constants_ia32.h"
|
||||
#elif defined(HOST_ARCH_X64)
|
||||
#include "vm/constants_x64.h"
|
||||
#elif defined(HOST_ARCH_ARM)
|
||||
#include "vm/constants_arm.h"
|
||||
#elif defined(HOST_ARCH_ARM64)
|
||||
#include "vm/constants_arm64.h"
|
||||
#else
|
||||
#error Unknown host architecture.
|
||||
#endif
|
||||
|
||||
namespace dart {
|
||||
|
||||
#if defined(TARGET_ARCH_IA32)
|
||||
using namespace arch_ia32; // NOLINT
|
||||
#elif defined(TARGET_ARCH_X64)
|
||||
using namespace arch_x64; // NOLINT
|
||||
#elif defined(TARGET_ARCH_ARM)
|
||||
using namespace arch_arm; // NOLINT
|
||||
#elif defined(TARGET_ARCH_ARM64)
|
||||
using namespace arch_arm64; // NOLINT
|
||||
#elif defined(TARGET_ARCH_DBC)
|
||||
// DBC is defined in namespace dart already.
|
||||
#else
|
||||
#error Unknown architecture.
|
||||
#endif
|
||||
|
||||
namespace host {
|
||||
|
||||
#if defined(HOST_ARCH_IA32)
|
||||
using namespace arch_ia32; // NOLINT
|
||||
#elif defined(HOST_ARCH_X64)
|
||||
using namespace arch_x64; // NOLINT
|
||||
#elif defined(HOST_ARCH_ARM)
|
||||
using namespace arch_arm; // NOLINT
|
||||
#elif defined(HOST_ARCH_ARM64)
|
||||
using namespace arch_arm64; // NOLINT
|
||||
#else
|
||||
#error Unknown host architecture.
|
||||
#endif
|
||||
|
||||
} // namespace host
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif // RUNTIME_VM_CONSTANTS_H_
|
||||
|
|
|
@ -5,10 +5,14 @@
|
|||
#ifndef RUNTIME_VM_CONSTANTS_ARM_H_
|
||||
#define RUNTIME_VM_CONSTANTS_ARM_H_
|
||||
|
||||
#ifndef RUNTIME_VM_CONSTANTS_H_
|
||||
#error Do not include constants_arm.h directly; use constants.h instead.
|
||||
#endif
|
||||
|
||||
#include "platform/assert.h"
|
||||
#include "platform/globals.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_arm {
|
||||
|
||||
// We support both VFPv3-D16 and VFPv3-D32 profiles, but currently only one at
|
||||
// a time.
|
||||
|
@ -609,14 +613,14 @@ class Instr {
|
|||
inline float ImmFloatField() const {
|
||||
uint32_t imm32 = (Bit(19) << 31) | (((1 << 5) - Bit(18)) << 25) |
|
||||
(Bits(16, 2) << 23) | (Bits(0, 4) << 19);
|
||||
return bit_cast<float, uint32_t>(imm32);
|
||||
return ::dart::bit_cast<float, uint32_t>(imm32);
|
||||
}
|
||||
|
||||
// Field used in VFP double immediate move instruction
|
||||
inline double ImmDoubleField() const {
|
||||
uint64_t imm64 = (Bit(19) * (1LL << 63)) | (((1LL << 8) - Bit(18)) << 54) |
|
||||
(Bits(16, 2) * (1LL << 52)) | (Bits(0, 4) * (1LL << 48));
|
||||
return bit_cast<double, uint64_t>(imm64);
|
||||
return ::dart::bit_cast<double, uint64_t>(imm64);
|
||||
}
|
||||
|
||||
inline Register DivRdField() const {
|
||||
|
@ -757,13 +761,13 @@ class Instr {
|
|||
// reference to an instruction is to convert a pointer. There is no way
|
||||
// to allocate or create instances of class Instr.
|
||||
// Use the At(pc) function to create references to Instr.
|
||||
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
static Instr* At(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
|
||||
private:
|
||||
DISALLOW_ALLOCATION();
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
} // namespace arch_arm
|
||||
|
||||
#endif // RUNTIME_VM_CONSTANTS_ARM_H_
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// 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.
|
||||
|
||||
#if defined(TARGET_ARCH_ARM64)
|
||||
|
||||
#define RUNTIME_VM_CONSTANTS_H_ // To work around include guard.
|
||||
#include "vm/constants_arm64.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_arm64 {
|
||||
|
||||
const Register CallingConventions::ArgumentRegisters[] = {
|
||||
R0, R1, R2, R3, R4, R5, R6, R7,
|
||||
|
@ -16,6 +15,4 @@ const FpuRegister CallingConventions::FpuArgumentRegisters[] = {
|
|||
V0, V1, V2, V3, V4, V5, V6, V7,
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif
|
||||
} // namespace arch_arm64
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
#ifndef RUNTIME_VM_CONSTANTS_ARM64_H_
|
||||
#define RUNTIME_VM_CONSTANTS_ARM64_H_
|
||||
|
||||
#ifndef RUNTIME_VM_CONSTANTS_H_
|
||||
#error Do not include constants_arm64.h directly; use constants.h instead.
|
||||
#endif
|
||||
|
||||
#include "platform/assert.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_arm64 {
|
||||
|
||||
enum Register {
|
||||
R0 = 0,
|
||||
|
@ -397,10 +401,7 @@ enum SystemOp {
|
|||
SystemFixed = CompareBranchFixed | B31 | B30 | B24,
|
||||
HINT = SystemFixed | B17 | B16 | B13 | B4 | B3 | B2 | B1 | B0,
|
||||
CLREX = SystemFixed | B17 | B16 | B13 | B12 | B11 | B10 | B9 | B8 | B6 | B4 |
|
||||
B3 |
|
||||
B2 |
|
||||
B1 |
|
||||
B0,
|
||||
B3 | B2 | B1 | B0,
|
||||
};
|
||||
|
||||
// C3.2.5
|
||||
|
@ -1186,13 +1187,13 @@ class Instr {
|
|||
// reference to an instruction is to convert a pointer. There is no way
|
||||
// to allocate or create instances of class Instr.
|
||||
// Use the At(pc) function to create references to Instr.
|
||||
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
static Instr* At(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
|
||||
private:
|
||||
DISALLOW_ALLOCATION();
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
} // namespace arch_arm64
|
||||
|
||||
#endif // RUNTIME_VM_CONSTANTS_ARM64_H_
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// 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.
|
||||
|
||||
#if defined(TARGET_ARCH_IA32)
|
||||
|
||||
#define RUNTIME_VM_CONSTANTS_H_ // To work around include guard.
|
||||
#include "vm/constants_ia32.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_ia32 {
|
||||
|
||||
// Although 'kArgumentRegisters' and 'kFpuArgumentRegisters' are both 0, we have
|
||||
// to give these arrays at least one element to appease MSVC.
|
||||
|
@ -16,6 +15,4 @@ const Register CallingConventions::ArgumentRegisters[] = {
|
|||
const FpuRegister CallingConventions::FpuArgumentRegisters[] = {
|
||||
static_cast<FpuRegister>(0)};
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif
|
||||
} // namespace arch_ia32
|
||||
|
|
|
@ -5,9 +5,13 @@
|
|||
#ifndef RUNTIME_VM_CONSTANTS_IA32_H_
|
||||
#define RUNTIME_VM_CONSTANTS_IA32_H_
|
||||
|
||||
#ifndef RUNTIME_VM_CONSTANTS_H_
|
||||
#error Do not include constants_ia32.h directly; use constants.h instead.
|
||||
#endif
|
||||
|
||||
#include "platform/assert.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_ia32 {
|
||||
|
||||
enum Register {
|
||||
EAX = 0,
|
||||
|
@ -88,7 +92,7 @@ enum ScaleFactor {
|
|||
TIMES_4 = 2,
|
||||
TIMES_8 = 3,
|
||||
TIMES_16 = 4,
|
||||
TIMES_HALF_WORD_SIZE = kWordSizeLog2 - 1
|
||||
TIMES_HALF_WORD_SIZE = ::dart::kWordSizeLog2 - 1
|
||||
};
|
||||
|
||||
class Instr {
|
||||
|
@ -107,7 +111,7 @@ class Instr {
|
|||
// reference to an instruction is to convert a pointer. There is no way
|
||||
// to allocate or create instances of class Instr.
|
||||
// Use the At(pc) function to create references to Instr.
|
||||
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
static Instr* At(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
|
||||
private:
|
||||
DISALLOW_ALLOCATION();
|
||||
|
@ -142,6 +146,6 @@ class CallingConventions {
|
|||
static constexpr Register kSecondNonArgumentRegister = ECX;
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
} // namespace arch_ia32
|
||||
|
||||
#endif // RUNTIME_VM_CONSTANTS_IA32_H_
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
// 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.
|
||||
|
||||
#if defined(TARGET_ARCH_X64)
|
||||
|
||||
#define RUNTIME_VM_CONSTANTS_H_ // To work around include guard.
|
||||
#include "vm/constants_x64.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_x64 {
|
||||
|
||||
#if defined(_WIN64)
|
||||
const Register CallingConventions::ArgumentRegisters[] = {
|
||||
|
@ -26,6 +25,4 @@ const XmmRegister CallingConventions::FpuArgumentRegisters[] = {
|
|||
XmmRegister::XMM4, XmmRegister::XMM5, XmmRegister::XMM6, XmmRegister::XMM7};
|
||||
#endif
|
||||
|
||||
} // namespace dart
|
||||
|
||||
#endif
|
||||
} // namespace arch_x64
|
||||
|
|
|
@ -5,10 +5,14 @@
|
|||
#ifndef RUNTIME_VM_CONSTANTS_X64_H_
|
||||
#define RUNTIME_VM_CONSTANTS_X64_H_
|
||||
|
||||
#ifndef RUNTIME_VM_CONSTANTS_H_
|
||||
#error Do not include constants_x64.h directly; use constants.h instead.
|
||||
#endif
|
||||
|
||||
#include "platform/assert.h"
|
||||
#include "platform/globals.h"
|
||||
|
||||
namespace dart {
|
||||
namespace arch_x64 {
|
||||
|
||||
enum Register {
|
||||
RAX = 0,
|
||||
|
@ -140,7 +144,7 @@ enum ScaleFactor {
|
|||
TIMES_4 = 2,
|
||||
TIMES_8 = 3,
|
||||
TIMES_16 = 4,
|
||||
TIMES_HALF_WORD_SIZE = kWordSizeLog2 - 1
|
||||
TIMES_HALF_WORD_SIZE = ::dart::kWordSizeLog2 - 1
|
||||
};
|
||||
|
||||
#define R(reg) (1 << (reg))
|
||||
|
@ -166,7 +170,7 @@ class CallingConventions {
|
|||
// same time? (Windows no, rest yes)
|
||||
static const bool kArgumentIntRegXorFpuReg = true;
|
||||
|
||||
static const intptr_t kShadowSpaceBytes = 4 * kWordSize;
|
||||
static const intptr_t kShadowSpaceBytes = 4 * ::dart::kWordSize;
|
||||
|
||||
static const intptr_t kVolatileCpuRegisters =
|
||||
R(RAX) | R(RCX) | R(RDX) | R(R8) | R(R9) | R(R10) | R(R11);
|
||||
|
@ -268,7 +272,7 @@ class Instr {
|
|||
// reference to an instruction is to convert a pointer. There is no way
|
||||
// to allocate or create instances of class Instr.
|
||||
// Use the At(pc) function to create references to Instr.
|
||||
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
static Instr* At(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
|
||||
|
||||
private:
|
||||
DISALLOW_ALLOCATION();
|
||||
|
@ -280,6 +284,6 @@ class Instr {
|
|||
// becomes important to us.
|
||||
const int MAX_NOP_SIZE = 8;
|
||||
|
||||
} // namespace dart
|
||||
} // namespace arch_x64
|
||||
|
||||
#endif // RUNTIME_VM_CONSTANTS_X64_H_
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "vm/cpu_ia32.h"
|
||||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_ia32.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpuinfo.h"
|
||||
#include "vm/heap/heap.h"
|
||||
#include "vm/isolate.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "vm/cpu_x64.h"
|
||||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_x64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpuinfo.h"
|
||||
#include "vm/heap/heap.h"
|
||||
#include "vm/isolate.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "vm/instructions_arm.h"
|
||||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpu.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/reverse_pc_lookup_cache.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "vm/allocation.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/native_function.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "vm/instructions_arm64.h"
|
||||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpu.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/reverse_pc_lookup_cache.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "vm/allocation.h"
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/native_function.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "vm/instructions.h"
|
||||
#include "vm/instructions_x64.h"
|
||||
|
||||
#include "vm/constants_x64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpu.h"
|
||||
#include "vm/object.h"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/compiler/assembler/disassembler.h"
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/cpu.h"
|
||||
#include "vm/native_arguments.h"
|
||||
#include "vm/os_thread.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#error Do not include simulator_arm.h directly; use simulator.h.
|
||||
#endif
|
||||
|
||||
#include "vm/constants_arm.h"
|
||||
#include "vm/constants.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "vm/compiler/assembler/assembler.h"
|
||||
#include "vm/compiler/assembler/disassembler.h"
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
#include "vm/native_arguments.h"
|
||||
#include "vm/os_thread.h"
|
||||
#include "vm/stack_frame.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#error Do not include simulator_arm64.h directly; use simulator.h.
|
||||
#endif
|
||||
|
||||
#include "vm/constants_arm64.h"
|
||||
#include "vm/constants.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ vm_sources = [
|
|||
"constants_arm64.cc",
|
||||
"constants_arm64.h",
|
||||
"constants_dbc.h",
|
||||
"constants_ia32.h",
|
||||
"constants_ia32.cc",
|
||||
"constants_ia32.h",
|
||||
"constants_kbc.h",
|
||||
"constants_x64.cc",
|
||||
"constants_x64.h",
|
||||
|
|
Loading…
Reference in a new issue