diff --git a/src/x64/assembler-x64.h b/src/x64/assembler-x64.h index a532729d15..15da6a9e9a 100644 --- a/src/x64/assembler-x64.h +++ b/src/x64/assembler-x64.h @@ -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(reinterpret_cast(value))) { DCHECK(SmiValuesAre31Bits()); // Only available for 31-bit SMI. - value_ = static_cast(reinterpret_cast(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