From 6f2e90b1cb8013d8900276d37a8bfc8803b690cc Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Mon, 14 Feb 2011 18:34:05 +0000 Subject: [PATCH] X64 Crankshaft: Fix bug in pushed registers at safepoints. Fixes issue 1153 completely. BUG=1153 TEST=mjsunit/mul-exhaustive TBR=kmillikin@chromium.org Review URL: http://codereview.chromium.org/6475012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6779 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/macro-assembler-x64.cc | 8 ++++++-- src/x64/macro-assembler-x64.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index f66883a91c..1053664e11 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -1442,11 +1442,15 @@ void MacroAssembler::Pushad() { // r13 is kRootRegister. push(r14); // r15 is kSmiConstantRegister - STATIC_ASSERT(11 == kRegistersPushedByPushad); + STATIC_ASSERT(11 == kNumSafepointSavedRegisters); + subq(rsp, Immediate( + (kNumSafepointRegisters-kNumSafepointSavedRegisters) * kPointerSize)); } void MacroAssembler::Popad() { + addq(rsp, Immediate( + (kNumSafepointRegisters-kNumSafepointSavedRegisters) * kPointerSize)); pop(r14); pop(r12); pop(r11); @@ -1462,7 +1466,7 @@ void MacroAssembler::Popad() { void MacroAssembler::Dropad() { - addq(rsp, Immediate(kRegistersPushedByPushad * kPointerSize)); + addq(rsp, Immediate(kNumSafepointRegisters * kPointerSize)); } diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index d24fb1e721..8254f2fac0 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -171,7 +171,7 @@ class MacroAssembler: public Assembler { void PushSafepointRegisters() { Pushad(); } void PopSafepointRegisters() { Popad(); } static int SafepointRegisterStackIndex(int reg_code) { - return kRegistersPushedByPushad - 1 - + return kNumSafepointRegisters - 1 - kSafepointPushRegisterIndices[reg_code]; } @@ -967,7 +967,7 @@ class MacroAssembler: public Assembler { // Order general registers are pushed by Pushad. // rax, rcx, rdx, rbx, rsi, rdi, r8, r9, r11, r12, r14. static int kSafepointPushRegisterIndices[Register::kNumRegisters]; - static const int kRegistersPushedByPushad = 11; + static const int kNumSafepointSavedRegisters = 11; bool generating_stub_; bool allow_stub_calls_;