From ae4fd1e54fb0d599e8f9ed019359f4b886cda84e Mon Sep 17 00:00:00 2001 From: "kasperl@chromium.org" Date: Mon, 1 Feb 2010 13:20:43 +0000 Subject: [PATCH] Avoid using RecordWrite with the context (esi, rsi, cp) as one of the arguments since this may clobber the register. Review URL: http://codereview.chromium.org/556101 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3757 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/full-codegen-arm.cc | 3 ++- src/arm/macro-assembler-arm.cc | 5 +++++ src/ia32/full-codegen-ia32.cc | 3 ++- src/ia32/macro-assembler-ia32.cc | 5 +++++ src/x64/full-codegen-x64.cc | 3 ++- src/x64/macro-assembler-x64.cc | 5 +++++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 733c5f484d..07b0c798b7 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -581,7 +581,8 @@ void FullCodeGenerator::VisitDeclaration(Declaration* decl) { int offset = Context::SlotOffset(slot->index()); __ mov(r2, Operand(offset)); // We know that we have written a function, which is not a smi. - __ RecordWrite(cp, r2, result_register()); + __ mov(r1, Operand(cp)); + __ RecordWrite(r1, r2, result_register()); } break; diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 09aebf07fd..6cbd6a57f3 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -205,6 +205,11 @@ void MacroAssembler::LoadRoot(Register destination, // tag is shifted away. void MacroAssembler::RecordWrite(Register object, Register offset, Register scratch) { + // The compiled code assumes that record write doesn't change the + // context register, so we check that none of the clobbered + // registers are cp. + ASSERT(!object.is(cp) && !offset.is(cp) && !scratch.is(cp)); + // This is how much we shift the remembered set bit offset to get the // offset of the word in the remembered set. We divide by kBitsPerInt (32, // shift right 5) and then multiply by kIntSize (4, shift left 2). diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index 5fd594cbe9..438ad94f8f 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -695,7 +695,8 @@ void FullCodeGenerator::VisitDeclaration(Declaration* decl) { __ mov(CodeGenerator::ContextOperand(esi, slot->index()), result_register()); int offset = Context::SlotOffset(slot->index()); - __ RecordWrite(esi, offset, result_register(), ecx); + __ mov(ebx, esi); + __ RecordWrite(ebx, offset, result_register(), ecx); } break; diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 74525ea5a6..07622bba18 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -147,6 +147,11 @@ void RecordWriteStub::Generate(MacroAssembler* masm) { // All registers are clobbered by the operation. void MacroAssembler::RecordWrite(Register object, int offset, Register value, Register scratch) { + // The compiled code assumes that record write doesn't change the + // context register, so we check that none of the clobbered + // registers are esi. + ASSERT(!object.is(esi) && !value.is(esi) && !scratch.is(esi)); + // First, check if a remembered set write is even needed. The tests below // catch stores of Smis and stores into young gen (which does not have space // for the remembered set bits. diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 7ab95170b6..9804b832a8 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -698,7 +698,8 @@ void FullCodeGenerator::VisitDeclaration(Declaration* decl) { __ movq(CodeGenerator::ContextOperand(rsi, slot->index()), result_register()); int offset = Context::SlotOffset(slot->index()); - __ RecordWrite(rsi, offset, result_register(), rcx); + __ movq(rbx, rsi); + __ RecordWrite(rbx, offset, result_register(), rcx); } break; diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index b3729f194b..0bb8118532 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -178,6 +178,11 @@ void MacroAssembler::RecordWrite(Register object, int offset, Register value, Register smi_index) { + // The compiled code assumes that record write doesn't change the + // context register, so we check that none of the clobbered + // registers are rsi. + ASSERT(!object.is(rsi) && !value.is(rsi) && !smi_index.is(rsi)); + // First, check if a remembered set write is even needed. The tests below // catch stores of Smis and stores into young gen (which does not have space // for the remembered set bits.