Index: src/x64/macro-assembler-x64.h |
diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h |
index 882ee652960e2c4dac8b1c9af6c47ef6c20e70e3..a256ab82bd4a57a413c5f5176bfe9bb251bcc2a2 100644 |
--- a/src/x64/macro-assembler-x64.h |
+++ b/src/x64/macro-assembler-x64.h |
@@ -47,8 +47,11 @@ enum AllocationFlags { |
// Default scratch register used by MacroAssembler (and other code that needs |
// a spare register). The register isn't callee save, and not used by the |
// function calling convention. |
-static const Register kScratchRegister = { 10 }; // r10. |
-static const Register kRootRegister = { 13 }; // r13 |
+static const Register kScratchRegister = { 10 }; // r10. |
+static const Register kSmiConstantRegister = { 15 }; // r15 (callee save). |
+static const Register kRootRegister = { 13 }; // r13 (callee save). |
+// Value of smi in kSmiConstantRegister. |
+static const int kSmiConstantRegisterValue = 1; |
// Convenience for platform-independent signatures. |
typedef Operand MemOperand; |
@@ -202,6 +205,12 @@ class MacroAssembler: public Assembler { |
// --------------------------------------------------------------------------- |
// Smi tagging, untagging and operations on tagged smis. |
+ void InitializeSmiConstantRegister() { |
+ movq(kSmiConstantRegister, |
+ reinterpret_cast<uint64_t>(Smi::FromInt(kSmiConstantRegisterValue)), |
+ RelocInfo::NONE); |
+ } |
+ |
// Conversions between tagged smi values and non-tagged integer values. |
// Tag an integer value. The result must be known to be a valid smi value. |
@@ -469,11 +478,12 @@ class MacroAssembler: public Assembler { |
// Basic Smi operations. |
void Move(Register dst, Smi* source) { |
- Set(dst, reinterpret_cast<int64_t>(source)); |
+ LoadSmiConstant(dst, source); |
} |
void Move(const Operand& dst, Smi* source) { |
- Set(dst, reinterpret_cast<int64_t>(source)); |
+ Register constant = GetSmiConstant(source); |
+ movq(dst, constant); |
} |
void Push(Smi* smi); |
@@ -820,6 +830,14 @@ class MacroAssembler: public Assembler { |
private: |
bool generating_stub_; |
bool allow_stub_calls_; |
+ |
+ // Returns a register holding the smi value. The register MUST NOT be |
+ // modified. It may be the "smi 1 constant" register. |
+ Register GetSmiConstant(Smi* value); |
+ |
+ // Moves the smi value to the destination register. |
+ void LoadSmiConstant(Register dst, Smi* value); |
+ |
// This handle will be patched with the code object on installation. |
Handle<Object> code_object_; |