From 1e4f40775f317de7a485992ffeddf6b6af4009ad Mon Sep 17 00:00:00 2001 From: "haitao.feng@intel.com" Date: Wed, 28 Aug 2013 01:07:31 +0000 Subject: [PATCH] Introduce PushInt64AsTwoSmis and PopInt64AsTwoSmis macro instructions for X64 R=danno@chromium.org Review URL: https://codereview.chromium.org/22348005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16376 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/debug-x64.cc | 15 ++------------- src/x64/macro-assembler-x64.cc | 24 ++++++++++++++++++++++++ src/x64/macro-assembler-x64.h | 8 ++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc index e6bc929..c8e1c96 100644 --- a/src/x64/debug-x64.cc +++ b/src/x64/debug-x64.cc @@ -123,14 +123,8 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, if ((object_regs & (1 << r)) != 0) { __ push(reg); } - // Store the 64-bit value as two smis. if ((non_object_regs & (1 << r)) != 0) { - __ movq(kScratchRegister, reg); - __ Integer32ToSmi(reg, reg); - __ push(reg); - __ sar(kScratchRegister, Immediate(32)); - __ Integer32ToSmi(kScratchRegister, kScratchRegister); - __ push(kScratchRegister); + __ PushInt64AsTwoSmis(reg); } } @@ -155,12 +149,7 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, } // Reconstruct the 64-bit value from two smis. if ((non_object_regs & (1 << r)) != 0) { - __ pop(kScratchRegister); - __ SmiToInteger32(kScratchRegister, kScratchRegister); - __ shl(kScratchRegister, Immediate(32)); - __ pop(reg); - __ SmiToInteger32(reg, reg); - __ or_(reg, kScratchRegister); + __ PopInt64AsTwoSmis(reg); } } diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 5651b57..0938007 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -2196,6 +2196,30 @@ void MacroAssembler::AddSmiField(Register dst, const Operand& src) { } +void MacroAssembler::PushInt64AsTwoSmis(Register src, Register scratch) { + movq(scratch, src); + // High bits. + shr(src, Immediate(64 - kSmiShift)); + shl(src, Immediate(kSmiShift)); + push(src); + // Low bits. + shl(scratch, Immediate(kSmiShift)); + push(scratch); +} + + +void MacroAssembler::PopInt64AsTwoSmis(Register dst, Register scratch) { + pop(scratch); + // Low bits. + shr(scratch, Immediate(kSmiShift)); + pop(dst); + shr(dst, Immediate(kSmiShift)); + // High bits. + shl(dst, Immediate(64 - kSmiShift)); + or_(dst, scratch); +} + + void MacroAssembler::JumpIfNotString(Register object, Register object_map, Label* not_string, diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index dcbf6ae..d9fb373 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -720,6 +720,14 @@ class MacroAssembler: public Assembler { } void Push(Smi* smi); + + // Save away a 64-bit integer on the stack as two 32-bit integers + // masquerading as smis so that the garbage collector skips visiting them. + void PushInt64AsTwoSmis(Register src, Register scratch = kScratchRegister); + // Reconstruct a 64-bit integer from two 32-bit integers masquerading as + // smis on the top of stack. + void PopInt64AsTwoSmis(Register dst, Register scratch = kScratchRegister); + void Test(const Operand& dst, Smi* source); -- 2.7.4