diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h index 2d224df3951..cef1ff62697 100644 --- a/runtime/vm/compiler/assembler/assembler_arm.h +++ b/runtime/vm/compiler/assembler/assembler_arm.h @@ -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" diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h index f542eeaf20e..de5143689b0 100644 --- a/runtime/vm/compiler/assembler/assembler_arm64.h +++ b/runtime/vm/compiler/assembler/assembler_arm64.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" diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h index e3e78c24e00..1ec424872ce 100644 --- a/runtime/vm/compiler/assembler/assembler_ia32.h +++ b/runtime/vm/compiler/assembler/assembler_ia32.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" @@ -466,7 +466,7 @@ class Assembler : public AssemblerBase { F(sub, 0x2b, 0x29, 5) \ F(sbb, 0x1b, 0x19, 3) \ F(cmp, 0x3b, 0x39, 7) -// clang-format on + // clang-format on #define DECLARE_ALU(op, opcode, opcode2, modrm_opcode) \ void op##l(Register dst, Register src) { Alu(4, opcode, dst, src); } \ diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h index 4e073d5529e..2df4c314d4e 100644 --- a/runtime/vm/compiler/assembler/assembler_x64.h +++ b/runtime/vm/compiler/assembler/assembler_x64.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" diff --git a/runtime/vm/compiler/stub_code_compiler_arm.cc b/runtime/vm/compiler/stub_code_compiler_arm.cc index d8f41bdbf06..ce9321be78d 100644 --- a/runtime/vm/compiler/stub_code_compiler_arm.cc +++ b/runtime/vm/compiler/stub_code_compiler_arm.cc @@ -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" diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc index 6ff109ca607..6b0d49067e4 100644 --- a/runtime/vm/compiler/stub_code_compiler_arm64.cc +++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc @@ -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" diff --git a/runtime/vm/compiler/stub_code_compiler_ia32.cc b/runtime/vm/compiler/stub_code_compiler_ia32.cc index 5b366b36bc1..86f75d6bbf0 100644 --- a/runtime/vm/compiler/stub_code_compiler_ia32.cc +++ b/runtime/vm/compiler/stub_code_compiler_ia32.cc @@ -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" diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc index c7eee2a76c5..2c5dd0acc60 100644 --- a/runtime/vm/compiler/stub_code_compiler_x64.cc +++ b/runtime/vm/compiler/stub_code_compiler_x64.cc @@ -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" diff --git a/runtime/vm/constants.h b/runtime/vm/constants.h index c6412d23e2d..90137d3722a 100644 --- a/runtime/vm/constants.h +++ b/runtime/vm/constants.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_ diff --git a/runtime/vm/constants_arm.h b/runtime/vm/constants_arm.h index 4e272c55afe..fe2ffcc2f0a 100644 --- a/runtime/vm/constants_arm.h +++ b/runtime/vm/constants_arm.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(imm32); + return ::dart::bit_cast(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(imm64); + return ::dart::bit_cast(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(pc); } + static Instr* At(::dart::uword pc) { return reinterpret_cast(pc); } private: DISALLOW_ALLOCATION(); DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); }; -} // namespace dart +} // namespace arch_arm #endif // RUNTIME_VM_CONSTANTS_ARM_H_ diff --git a/runtime/vm/constants_arm64.cc b/runtime/vm/constants_arm64.cc index 0714ae3f282..9938d7c8369 100644 --- a/runtime/vm/constants_arm64.cc +++ b/runtime/vm/constants_arm64.cc @@ -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 diff --git a/runtime/vm/constants_arm64.h b/runtime/vm/constants_arm64.h index fa592e17b2f..8dfabc84177 100644 --- a/runtime/vm/constants_arm64.h +++ b/runtime/vm/constants_arm64.h @@ -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, @@ -107,7 +111,7 @@ const FpuRegister kNoFpuRegister = kNoVRegister; // Register aliases. const Register TMP = R16; // Used as scratch register by assembler. const Register TMP2 = R17; -const Register PP = R27; // Caches object pool pointer in generated code. +const Register PP = R27; // Caches object pool pointer in generated code. const Register CODE_REG = R24; const Register FPREG = FP; // Frame pointer register. const Register SPREG = R15; // Stack pointer register. @@ -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(pc); } + static Instr* At(::dart::uword pc) { return reinterpret_cast(pc); } private: DISALLOW_ALLOCATION(); DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); }; -} // namespace dart +} // namespace arch_arm64 #endif // RUNTIME_VM_CONSTANTS_ARM64_H_ diff --git a/runtime/vm/constants_ia32.cc b/runtime/vm/constants_ia32.cc index 62c3f6a9329..a12af8216a9 100644 --- a/runtime/vm/constants_ia32.cc +++ b/runtime/vm/constants_ia32.cc @@ -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(0)}; -} // namespace dart - -#endif +} // namespace arch_ia32 diff --git a/runtime/vm/constants_ia32.h b/runtime/vm/constants_ia32.h index 24e3783b31e..16eeb4e2562 100644 --- a/runtime/vm/constants_ia32.h +++ b/runtime/vm/constants_ia32.h @@ -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(pc); } + static Instr* At(::dart::uword pc) { return reinterpret_cast(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_ diff --git a/runtime/vm/constants_x64.cc b/runtime/vm/constants_x64.cc index 3f38d9d6035..8d80a334f85 100644 --- a/runtime/vm/constants_x64.cc +++ b/runtime/vm/constants_x64.cc @@ -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 diff --git a/runtime/vm/constants_x64.h b/runtime/vm/constants_x64.h index 3e8d007035b..3d376458719 100644 --- a/runtime/vm/constants_x64.h +++ b/runtime/vm/constants_x64.h @@ -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(pc); } + static Instr* At(::dart::uword pc) { return reinterpret_cast(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_ diff --git a/runtime/vm/cpu_ia32.cc b/runtime/vm/cpu_ia32.cc index 08cfc5e2358..82ab263d4ee 100644 --- a/runtime/vm/cpu_ia32.cc +++ b/runtime/vm/cpu_ia32.cc @@ -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" diff --git a/runtime/vm/cpu_x64.cc b/runtime/vm/cpu_x64.cc index 553e9cd7587..a4a17f10295 100644 --- a/runtime/vm/cpu_x64.cc +++ b/runtime/vm/cpu_x64.cc @@ -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" diff --git a/runtime/vm/instructions_arm.cc b/runtime/vm/instructions_arm.cc index 785f8fb486e..c8e8af96a65 100644 --- a/runtime/vm/instructions_arm.cc +++ b/runtime/vm/instructions_arm.cc @@ -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" diff --git a/runtime/vm/instructions_arm.h b/runtime/vm/instructions_arm.h index 37b7cef86a1..d3e1cdb39ce 100644 --- a/runtime/vm/instructions_arm.h +++ b/runtime/vm/instructions_arm.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 { diff --git a/runtime/vm/instructions_arm64.cc b/runtime/vm/instructions_arm64.cc index ea9a118bdfb..d34d7a76fd7 100644 --- a/runtime/vm/instructions_arm64.cc +++ b/runtime/vm/instructions_arm64.cc @@ -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" diff --git a/runtime/vm/instructions_arm64.h b/runtime/vm/instructions_arm64.h index c78cee337ca..85506434bed 100644 --- a/runtime/vm/instructions_arm64.h +++ b/runtime/vm/instructions_arm64.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 { diff --git a/runtime/vm/instructions_x64.cc b/runtime/vm/instructions_x64.cc index 70ed2552bbb..7c0e336e683 100644 --- a/runtime/vm/instructions_x64.cc +++ b/runtime/vm/instructions_x64.cc @@ -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" diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index ec829b9ea57..2cd0745f1dc 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -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" diff --git a/runtime/vm/simulator_arm.h b/runtime/vm/simulator_arm.h index 406f7ce67da..8f269b2705c 100644 --- a/runtime/vm/simulator_arm.h +++ b/runtime/vm/simulator_arm.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 { diff --git a/runtime/vm/simulator_arm64.cc b/runtime/vm/simulator_arm64.cc index 0d9f446d83b..c83579339ca 100644 --- a/runtime/vm/simulator_arm64.cc +++ b/runtime/vm/simulator_arm64.cc @@ -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" diff --git a/runtime/vm/simulator_arm64.h b/runtime/vm/simulator_arm64.h index 43ae2eac2aa..8a484511c60 100644 --- a/runtime/vm/simulator_arm64.h +++ b/runtime/vm/simulator_arm64.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 { diff --git a/runtime/vm/vm_sources.gni b/runtime/vm/vm_sources.gni index eadae4d8fb6..f4aa3ef0a80 100644 --- a/runtime/vm/vm_sources.gni +++ b/runtime/vm/vm_sources.gni @@ -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",