Skip to content

Commit

Permalink
[vm] Clean up constants namespacing
Browse files Browse the repository at this point in the history
This commit undoes https://dart-review.googlesource.com/c/sdk/+/97325 because we removed DBC.

Fixes: #40457
Change-Id: I873a8c6daa2ef79f7b0a5dff00d52f12d5770476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134298
Reviewed-by: Martin Kustermann <kustermann@google.com>
  • Loading branch information
dcharkes authored and commit-bot@chromium.org committed Feb 5, 2020
1 parent 43fe0b3 commit 3284ef8
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 66 deletions.
40 changes: 0 additions & 40 deletions runtime/vm/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,8 @@
#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
#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

class RegisterNames {
public:
static const char* RegisterName(Register reg) {
Expand Down
8 changes: 6 additions & 2 deletions runtime/vm/constants_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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_ARM)

#define RUNTIME_VM_CONSTANTS_H_ // To work around include guard.
#include "vm/constants_arm.h"

namespace arch_arm {
namespace dart {

using dart::bit_cast;

Expand Down Expand Up @@ -139,4 +141,6 @@ float ReciprocalSqrtStep(float op1, float op2) {
return (3.0f - p) / 2.0f;
}

} // namespace arch_arm
} // namespace dart

#endif // defined(TARGET_ARCH_ARM)
10 changes: 5 additions & 5 deletions runtime/vm/constants_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "platform/assert.h"
#include "platform/globals.h"

namespace arch_arm {
namespace dart {

// We support both VFPv3-D16 and VFPv3-D32 profiles, but currently only one at
// a time.
Expand Down Expand Up @@ -663,14 +663,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 ::dart::bit_cast<float, uint32_t>(imm32);
return 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 ::dart::bit_cast<double, uint64_t>(imm64);
return bit_cast<double, uint64_t>(imm64);
}

inline Register DivRdField() const {
Expand Down Expand Up @@ -818,7 +818,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(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }

private:
DISALLOW_ALLOCATION();
Expand All @@ -835,6 +835,6 @@ float ReciprocalStep(float op1, float op2);
float ReciprocalSqrtEstimate(float op);
float ReciprocalSqrtStep(float op1, float op2);

} // namespace arch_arm
} // namespace dart

#endif // RUNTIME_VM_CONSTANTS_ARM_H_
8 changes: 6 additions & 2 deletions runtime/vm/constants_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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 arch_arm64 {
namespace dart {

const char* cpu_reg_names[kNumberOfCpuRegisters] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
Expand All @@ -27,4 +29,6 @@ const FpuRegister CallingConventions::FpuArgumentRegisters[] = {
V0, V1, V2, V3, V4, V5, V6, V7,
};

} // namespace arch_arm64
} // namespace dart

#endif // defined(TARGET_ARCH_ARM64)
6 changes: 3 additions & 3 deletions runtime/vm/constants_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "platform/assert.h"

namespace arch_arm64 {
namespace dart {

enum Register {
R0 = 0,
Expand Down Expand Up @@ -1215,13 +1215,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(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }

private:
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
};

} // namespace arch_arm64
} // namespace dart

#endif // RUNTIME_VM_CONSTANTS_ARM64_H_
8 changes: 6 additions & 2 deletions runtime/vm/constants_ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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 arch_ia32 {
namespace dart {

const char* cpu_reg_names[kNumberOfCpuRegisters] = {"eax", "ecx", "edx", "ebx",
"esp", "ebp", "esi", "edi"};
Expand All @@ -21,4 +23,6 @@ const Register CallingConventions::ArgumentRegisters[] = {
const FpuRegister CallingConventions::FpuArgumentRegisters[] = {
static_cast<FpuRegister>(0)};

} // namespace arch_ia32
} // namespace dart

#endif // defined(TARGET_ARCH_IA32)
8 changes: 4 additions & 4 deletions runtime/vm/constants_ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "platform/assert.h"

namespace arch_ia32 {
namespace dart {

enum Register {
EAX = 0,
Expand Down Expand Up @@ -98,7 +98,7 @@ enum ScaleFactor {
TIMES_4 = 2,
TIMES_8 = 3,
TIMES_16 = 4,
TIMES_HALF_WORD_SIZE = ::dart::kWordSizeLog2 - 1
TIMES_HALF_WORD_SIZE = kWordSizeLog2 - 1
};

class Instr {
Expand All @@ -117,7 +117,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(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }

private:
DISALLOW_ALLOCATION();
Expand Down Expand Up @@ -166,6 +166,6 @@ class CallingConventions {
static constexpr bool kAlignArguments = false;
};

} // namespace arch_ia32
} // namespace dart

#endif // RUNTIME_VM_CONSTANTS_IA32_H_
8 changes: 6 additions & 2 deletions runtime/vm/constants_x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
// 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 arch_x64 {
namespace dart {

const char* cpu_reg_names[kNumberOfCpuRegisters] = {
"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
Expand Down Expand Up @@ -33,4 +35,6 @@ const XmmRegister CallingConventions::FpuArgumentRegisters[] = {
XmmRegister::XMM4, XmmRegister::XMM5, XmmRegister::XMM6, XmmRegister::XMM7};
#endif

} // namespace arch_x64
} // namespace dart

#endif // defined(TARGET_ARCH_X64)
10 changes: 5 additions & 5 deletions runtime/vm/constants_x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "platform/assert.h"
#include "platform/globals.h"

namespace arch_x64 {
namespace dart {

enum Register {
RAX = 0,
Expand Down Expand Up @@ -150,7 +150,7 @@ enum ScaleFactor {
TIMES_4 = 2,
TIMES_8 = 3,
TIMES_16 = 4,
TIMES_HALF_WORD_SIZE = ::dart::kWordSizeLog2 - 1
TIMES_HALF_WORD_SIZE = kWordSizeLog2 - 1
};

#define R(reg) (1 << (reg))
Expand All @@ -176,7 +176,7 @@ class CallingConventions {
// same time? (Windows no, rest yes)
static const bool kArgumentIntRegXorFpuReg = true;

static const intptr_t kShadowSpaceBytes = 4 * ::dart::kWordSize;
static const intptr_t kShadowSpaceBytes = 4 * kWordSize;

static const intptr_t kVolatileCpuRegisters =
R(RAX) | R(RCX) | R(RDX) | R(R8) | R(R9) | R(R10) | R(R11);
Expand Down Expand Up @@ -295,7 +295,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(::dart::uword pc) { return reinterpret_cast<Instr*>(pc); }
static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); }

private:
DISALLOW_ALLOCATION();
Expand All @@ -307,6 +307,6 @@ class Instr {
// becomes important to us.
const int MAX_NOP_SIZE = 8;

} // namespace arch_x64
} // namespace dart

#endif // RUNTIME_VM_CONSTANTS_X64_H_
2 changes: 1 addition & 1 deletion runtime/vm/stack_frame_x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#error Do not include stack_frame_x64.h directly; use stack_frame.h instead.
#endif

#include "vm/constants_x64.h"
#include "vm/constants.h"

namespace dart {

Expand Down

0 comments on commit 3284ef8

Please sign in to comment.