From 9d5f6d0b46a7a817b9d1deb664b40c417ab105ec Mon Sep 17 00:00:00 2001 From: "erik.corry@gmail.com" Date: Mon, 3 May 2010 10:22:25 +0000 Subject: [PATCH] Partial and small update to the codegen to use the new register allocator framework. See http://codereview.chromium.org/1732024. Committed for Rodolph Perfetta. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4564 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/codegen-arm.cc | 38 +++++++++++++++++--------------------- src/arm/virtual-frame-arm.cc | 26 ++++++++++++++++++++++++++ src/arm/virtual-frame-arm.h | 2 ++ 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index 90428a7..9394836 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -1563,12 +1563,11 @@ void CodeGenerator::VisitBlock(Block* node) { void CodeGenerator::DeclareGlobals(Handle pairs) { - VirtualFrame::SpilledScope spilled_scope(frame_); frame_->EmitPush(cp); - __ mov(r0, Operand(pairs)); - frame_->EmitPush(r0); - __ mov(r0, Operand(Smi::FromInt(is_eval() ? 1 : 0))); - frame_->EmitPush(r0); + frame_->EmitPush(Operand(pairs)); + frame_->EmitPush(Operand(Smi::FromInt(is_eval() ? 1 : 0))); + + VirtualFrame::SpilledScope spilled_scope(frame_); frame_->CallRuntime(Runtime::kDeclareGlobals, 3); // The result is discarded. } @@ -1578,7 +1577,6 @@ void CodeGenerator::VisitDeclaration(Declaration* node) { #ifdef DEBUG int original_height = frame_->height(); #endif - VirtualFrame::SpilledScope spilled_scope(frame_); Comment cmnt(masm_, "[ Declaration"); Variable* var = node->proxy()->var(); ASSERT(var != NULL); // must have been resolved @@ -1593,28 +1591,27 @@ void CodeGenerator::VisitDeclaration(Declaration* node) { ASSERT(var->is_dynamic()); // For now, just do a runtime call. frame_->EmitPush(cp); - __ mov(r0, Operand(var->name())); - frame_->EmitPush(r0); + frame_->EmitPush(Operand(var->name())); // Declaration nodes are always declared in only two modes. ASSERT(node->mode() == Variable::VAR || node->mode() == Variable::CONST); PropertyAttributes attr = node->mode() == Variable::VAR ? NONE : READ_ONLY; - __ mov(r0, Operand(Smi::FromInt(attr))); - frame_->EmitPush(r0); + frame_->EmitPush(Operand(Smi::FromInt(attr))); // Push initial value, if any. // Note: For variables we must not push an initial value (such as // 'undefined') because we may have a (legal) redeclaration and we // must not destroy the current value. if (node->mode() == Variable::CONST) { - __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); - frame_->EmitPush(r0); + frame_->EmitPushRoot(Heap::kTheHoleValueRootIndex); } else if (node->fun() != NULL) { - LoadAndSpill(node->fun()); + Load(node->fun()); } else { - __ mov(r0, Operand(0)); // no initial value! - frame_->EmitPush(r0); + frame_->EmitPush(Operand(0)); } + + VirtualFrame::SpilledScope spilled_scope(frame_); frame_->CallRuntime(Runtime::kDeclareContextSlot, 4); // Ignore the return value (declarations are statements). + ASSERT(frame_->height() == original_height); return; } @@ -1630,12 +1627,11 @@ void CodeGenerator::VisitDeclaration(Declaration* node) { } if (val != NULL) { - { - // Set initial value. - Reference target(this, node->proxy()); - LoadAndSpill(val); - target.SetValue(NOT_CONST_INIT); - } + // Set initial value. + Reference target(this, node->proxy()); + Load(val); + target.SetValue(NOT_CONST_INIT); + // Get rid of the assigned value (declarations are statements). frame_->Drop(); } diff --git a/src/arm/virtual-frame-arm.cc b/src/arm/virtual-frame-arm.cc index ed26c41..9959ea7 100644 --- a/src/arm/virtual-frame-arm.cc +++ b/src/arm/virtual-frame-arm.cc @@ -541,6 +541,19 @@ Register VirtualFrame::GetTOSRegister() { } +void VirtualFrame::EmitPush(Operand operand) { + element_count_++; + if (SpilledScope::is_spilled()) { + __ mov(r0, operand); + __ push(r0); + return; + } + EnsureOneFreeTOSRegister(); + top_of_stack_state_ = kStateAfterPush[top_of_stack_state_]; + __ mov(kTopRegister[top_of_stack_state_], operand); +} + + void VirtualFrame::EmitPush(MemOperand operand) { element_count_++; if (SpilledScope::is_spilled()) { @@ -554,6 +567,19 @@ void VirtualFrame::EmitPush(MemOperand operand) { } +void VirtualFrame::EmitPushRoot(Heap::RootListIndex index) { + element_count_++; + if (SpilledScope::is_spilled()) { + __ LoadRoot(r0, index); + __ push(r0); + return; + } + EnsureOneFreeTOSRegister(); + top_of_stack_state_ = kStateAfterPush[top_of_stack_state_]; + __ LoadRoot(kTopRegister[top_of_stack_state_], index); +} + + void VirtualFrame::EmitPushMultiple(int count, int src_regs) { ASSERT(SpilledScope::is_spilled()); Adjust(count); diff --git a/src/arm/virtual-frame-arm.h b/src/arm/virtual-frame-arm.h index 7b56bc2..c2e5e8a 100644 --- a/src/arm/virtual-frame-arm.h +++ b/src/arm/virtual-frame-arm.h @@ -372,7 +372,9 @@ class VirtualFrame : public ZoneObject { // Push an element on top of the expression stack and emit a // corresponding push instruction. void EmitPush(Register reg); + void EmitPush(Operand operand); void EmitPush(MemOperand operand); + void EmitPushRoot(Heap::RootListIndex index); // Get a register which is free and which must be immediately used to // push on the top of the stack. -- 2.7.4