[Assembler][x64] Make immediates immutable

On x64, we already pass immediates by value. This CL ensures that this
is indeed cheap, and it makes immediates immutable.

R=mstarzinger@chromium.org

Bug: v8:7310
Change-Id: I53a0666d53b9de69d390621298798c03b5190497
Reviewed-on: https://chromium-review.googlesource.com/934341
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51613}
This commit is contained in:
Clemens Hammacher 2018-02-23 12:00:42 +01:00 committed by Commit Bot
parent bdf669be07
commit 01db326cc2

View File

@ -301,23 +301,26 @@ enum RoundingMode {
// -----------------------------------------------------------------------------
// Machine instruction Immediates
class Immediate BASE_EMBEDDED {
class Immediate {
public:
explicit Immediate(int32_t value) : value_(value) {}
explicit Immediate(int32_t value, RelocInfo::Mode rmode)
explicit constexpr Immediate(int32_t value) : value_(value) {}
explicit constexpr Immediate(int32_t value, RelocInfo::Mode rmode)
: value_(value), rmode_(rmode) {}
explicit Immediate(Smi* value) {
explicit Immediate(Smi* value)
: value_(static_cast<int32_t>(reinterpret_cast<intptr_t>(value))) {
DCHECK(SmiValuesAre31Bits()); // Only available for 31-bit SMI.
value_ = static_cast<int32_t>(reinterpret_cast<intptr_t>(value));
}
private:
int32_t value_;
RelocInfo::Mode rmode_ = RelocInfo::NONE;
const int32_t value_;
const RelocInfo::Mode rmode_ = RelocInfo::NONE;
friend class Assembler;
};
static_assert(sizeof(Immediate) <= kPointerSize,
"Immediate must be small enough to pass it by value");
static_assert(IS_TRIVIALLY_COPYABLE(Immediate),
"Immediate must be trivially copyable to pass it by value");
// -----------------------------------------------------------------------------
// Machine instruction Operands