Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index 7d5d6d3d0b10defc04d30d21a3c103bab7e53413..cda7549df5e24bc2b8ef53478101b2cb85ef1522 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -892,6 +892,38 @@ void MacroAssembler::Set(const Operand& dst, int64_t x) { |
} |
} |
+ |
+bool MacroAssembler::IsUnsafeInt(const int x) { |
+ static const int kMaxBits = 17; |
+ return !is_intn(x, kMaxBits); |
+} |
+ |
+ |
+void MacroAssembler::SafeMove(Register dst, Smi* src) { |
+ ASSERT(!dst.is(kScratchRegister)); |
+ ASSERT(kSmiValueSize == 32); // JIT cookie can be converted to Smi. |
+ if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { |
+ Move(dst, Smi::FromInt(src->value() ^ jit_cookie())); |
+ Move(kScratchRegister, Smi::FromInt(jit_cookie())); |
+ xor_(dst, kScratchRegister); |
+ } else { |
+ Move(dst, src); |
+ } |
+} |
+ |
+ |
+void MacroAssembler::SafePush(Smi* src) { |
+ ASSERT(kSmiValueSize == 32); // JIT cookie can be converted to Smi. |
+ if (IsUnsafeInt(src->value()) && jit_cookie() != 0) { |
+ Push(Smi::FromInt(src->value() ^ jit_cookie())); |
+ Move(kScratchRegister, Smi::FromInt(jit_cookie())); |
+ xor_(Operand(rsp, 0), kScratchRegister); |
+ } else { |
+ Push(src); |
+ } |
+} |
+ |
+ |
// ---------------------------------------------------------------------------- |
// Smi tagging, untagging and tag detection. |