From 289b245d2b2e949eae062d03e301c94a104fb430 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Mon, 3 May 2010 09:54:48 +0000 Subject: [PATCH] X64: Use allocation with no scratch registers to avoid push/pop. Minor prettifications. Review URL: http://codereview.chromium.org/1862001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4562 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/codegen-x64.cc | 16 ++++------------ src/x64/macro-assembler-x64.cc | 29 ++++++++++++++++------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 9d17194..a6f856e 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -5969,7 +5969,7 @@ void DeferredInlineBinaryOperation::Generate() { || (op_ ==Token::SUB) || (op_ == Token::MUL) || (op_ == Token::DIV)) { - Label call_runtime, after_alloc_failure; + Label call_runtime; Label left_smi, right_smi, load_right, do_op; __ JumpIfSmi(left_, &left_smi); __ CompareRoot(FieldOperand(left_, HeapObject::kMapOffset), @@ -5987,9 +5987,7 @@ void DeferredInlineBinaryOperation::Generate() { __ Integer32ToSmi(left_, left_); if (mode_ == OVERWRITE_LEFT) { Label alloc_failure; - __ push(left_); - __ AllocateHeapNumber(dst_, left_, &after_alloc_failure); - __ pop(left_); + __ AllocateHeapNumber(dst_, no_reg, &call_runtime); } __ bind(&load_right); @@ -6002,9 +6000,7 @@ void DeferredInlineBinaryOperation::Generate() { __ movq(dst_, right_); } else if (mode_ == NO_OVERWRITE) { Label alloc_failure; - __ push(left_); - __ AllocateHeapNumber(dst_, left_, &after_alloc_failure); - __ pop(left_); + __ AllocateHeapNumber(dst_, no_reg, &call_runtime); } __ jmp(&do_op); @@ -6014,9 +6010,7 @@ void DeferredInlineBinaryOperation::Generate() { __ Integer32ToSmi(right_, right_); if (mode_ == OVERWRITE_RIGHT || mode_ == NO_OVERWRITE) { Label alloc_failure; - __ push(left_); - __ AllocateHeapNumber(dst_, left_, &after_alloc_failure); - __ pop(left_); + __ AllocateHeapNumber(dst_, no_reg, &call_runtime); } __ bind(&do_op); @@ -6030,8 +6024,6 @@ void DeferredInlineBinaryOperation::Generate() { __ movsd(FieldOperand(dst_, HeapNumber::kValueOffset), xmm0); __ jmp(&done); - __ bind(&after_alloc_failure); - __ pop(left_); __ bind(&call_runtime); } GenericBinaryOpStub stub(op_, mode_, NO_SMI_CODE_IN_STUB); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 26202b8..9c60d27 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -2356,18 +2356,17 @@ void MacroAssembler::LoadAllocationTopHelper(Register result, return; } - // Move address of new object to result. Use scratch register if available. - if (!scratch.is_valid()) { - if (result.is(rax)) { - load_rax(new_space_allocation_top); - } else { - movq(kScratchRegister, new_space_allocation_top); - movq(result, Operand(kScratchRegister, 0)); - } - } else { + // Move address of new object to result. Use scratch register if available, + // and keep address in scratch until call to UpdateAllocationTopHelper. + if (scratch.is_valid()) { ASSERT(!scratch.is(result_end)); movq(scratch, new_space_allocation_top); movq(result, Operand(scratch, 0)); + } else if (result.is(rax)) { + load_rax(new_space_allocation_top); + } else { + movq(kScratchRegister, new_space_allocation_top); + movq(result, Operand(kScratchRegister, 0)); } } @@ -2388,11 +2387,11 @@ void MacroAssembler::UpdateAllocationTopHelper(Register result_end, store_rax(new_space_allocation_top); } else { // Register required - use scratch provided if available. - if (!scratch.is_valid()) { + if (scratch.is_valid()) { + movq(Operand(scratch, 0), result_end); + } else { movq(kScratchRegister, new_space_allocation_top); movq(Operand(kScratchRegister, 0), result_end); - } else { - movq(Operand(scratch, 0), result_end); } } } @@ -2415,7 +2414,11 @@ void MacroAssembler::AllocateInNewSpace(int object_size, Register top_reg = result_end.is_valid() ? result_end : result; - lea(top_reg, Operand(result, object_size)); + if (top_reg.is(result)) { + addq(top_reg, Immediate(object_size)); + } else { + lea(top_reg, Operand(result, object_size)); + } movq(kScratchRegister, new_space_allocation_limit); cmpq(top_reg, Operand(kScratchRegister, 0)); j(above, gc_required); -- 2.7.4