diff options
Diffstat (limited to 'deps/v8/src/arm/virtual-frame-arm.cc')
-rw-r--r-- | deps/v8/src/arm/virtual-frame-arm.cc | 77 |
1 files changed, 34 insertions, 43 deletions
diff --git a/deps/v8/src/arm/virtual-frame-arm.cc b/deps/v8/src/arm/virtual-frame-arm.cc index 43100f1ec7..952738329b 100644 --- a/deps/v8/src/arm/virtual-frame-arm.cc +++ b/deps/v8/src/arm/virtual-frame-arm.cc @@ -31,31 +31,25 @@ #include "register-allocator-inl.h" #include "scopes.h" -namespace v8 { namespace internal { +namespace v8 { +namespace internal { // ------------------------------------------------------------------------- // VirtualFrame implementation. -#define __ ACCESS_MASM(masm_) +#define __ ACCESS_MASM(masm()) // On entry to a function, the virtual frame already contains the // receiver and the parameters. All initial frame elements are in // memory. -VirtualFrame::VirtualFrame(CodeGenerator* cgen) - : cgen_(cgen), - masm_(cgen->masm()), - elements_(cgen->scope()->num_parameters() - + cgen->scope()->num_stack_slots() - + kPreallocatedElements), - parameter_count_(cgen->scope()->num_parameters()), - local_count_(0), - stack_pointer_(parameter_count_), // 0-based index of TOS. - frame_pointer_(kIllegalIndex) { - for (int i = 0; i < parameter_count_ + 1; i++) { +VirtualFrame::VirtualFrame() + : elements_(parameter_count() + local_count() + kPreallocatedElements), + stack_pointer_(parameter_count()) { // 0-based index of TOS. + for (int i = 0; i <= stack_pointer_; i++) { elements_.Add(FrameElement::MemoryElement()); } - for (int i = 0; i < kNumRegisters; i++) { + for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) { register_locations_[i] = kIllegalIndex; } } @@ -82,10 +76,10 @@ void VirtualFrame::SyncRange(int begin, int end) { void VirtualFrame::MergeTo(VirtualFrame* expected) { - Comment cmnt(masm_, "[ Merge frame"); + Comment cmnt(masm(), "[ Merge frame"); // We should always be merging the code generator's current frame to an // expected frame. - ASSERT(cgen_->frame() == this); + ASSERT(cgen()->frame() == this); // Adjust the stack pointer upward (toward the top of the virtual // frame) if necessary. @@ -102,7 +96,7 @@ void VirtualFrame::MergeTo(VirtualFrame* expected) { // Fix any sync bit problems from the bottom-up, stopping when we // hit the stack pointer or the top of the frame if the stack // pointer is floating above the frame. - int limit = Min(stack_pointer_, elements_.length() - 1); + int limit = Min(static_cast<int>(stack_pointer_), element_count() - 1); for (int i = 0; i <= limit; i++) { FrameElement source = elements_[i]; FrameElement target = expected->elements_[i]; @@ -134,7 +128,7 @@ void VirtualFrame::MergeMoveRegistersToMemory(VirtualFrame* expected) { // On ARM, all elements are in memory. #ifdef DEBUG - int start = Min(stack_pointer_, elements_.length() - 1); + int start = Min(static_cast<int>(stack_pointer_), element_count() - 1); for (int i = start; i >= 0; i--) { ASSERT(elements_[i].is_memory()); ASSERT(expected->elements_[i].is_memory()); @@ -147,12 +141,12 @@ void VirtualFrame::MergeMoveRegistersToRegisters(VirtualFrame* expected) { } -void VirtualFrame::MergeMoveMemoryToRegisters(VirtualFrame *expected) { +void VirtualFrame::MergeMoveMemoryToRegisters(VirtualFrame* expected) { } void VirtualFrame::Enter() { - Comment cmnt(masm_, "[ Enter JS frame"); + Comment cmnt(masm(), "[ Enter JS frame"); #ifdef DEBUG // Verify that r1 contains a JS function. The following code relies @@ -175,15 +169,14 @@ void VirtualFrame::Enter() { Adjust(4); __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); // Adjust FP to point to saved FP. - frame_pointer_ = elements_.length() - 2; __ add(fp, sp, Operand(2 * kPointerSize)); - cgen_->allocator()->Unuse(r1); - cgen_->allocator()->Unuse(lr); + cgen()->allocator()->Unuse(r1); + cgen()->allocator()->Unuse(lr); } void VirtualFrame::Exit() { - Comment cmnt(masm_, "[ Exit JS frame"); + Comment cmnt(masm(), "[ Exit JS frame"); // Drop the execution stack down to the frame pointer and restore the caller // frame pointer and return address. __ mov(sp, fp); @@ -191,12 +184,11 @@ void VirtualFrame::Exit() { } -void VirtualFrame::AllocateStackSlots(int count) { - ASSERT(height() == 0); - local_count_ = count; - Adjust(count); +void VirtualFrame::AllocateStackSlots() { + int count = local_count(); if (count > 0) { - Comment cmnt(masm_, "[ Allocate space for locals"); + Comment cmnt(masm(), "[ Allocate space for locals"); + Adjust(count); // Initialize stack slots with 'undefined' value. __ mov(ip, Operand(Factory::undefined_value())); for (int i = 0; i < count; i++) { @@ -246,9 +238,9 @@ void VirtualFrame::PushTryHandler(HandlerType type) { Result VirtualFrame::RawCallStub(CodeStub* stub) { - ASSERT(cgen_->HasValidEntryRegisters()); + ASSERT(cgen()->HasValidEntryRegisters()); __ CallStub(stub); - Result result = cgen_->allocator()->Allocate(r0); + Result result = cgen()->allocator()->Allocate(r0); ASSERT(result.is_valid()); return result; } @@ -271,9 +263,9 @@ Result VirtualFrame::CallStub(CodeStub* stub, Result* arg0, Result* arg1) { Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { PrepareForCall(arg_count, arg_count); - ASSERT(cgen_->HasValidEntryRegisters()); + ASSERT(cgen()->HasValidEntryRegisters()); __ CallRuntime(f, arg_count); - Result result = cgen_->allocator()->Allocate(r0); + Result result = cgen()->allocator()->Allocate(r0); ASSERT(result.is_valid()); return result; } @@ -281,9 +273,9 @@ Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { PrepareForCall(arg_count, arg_count); - ASSERT(cgen_->HasValidEntryRegisters()); + ASSERT(cgen()->HasValidEntryRegisters()); __ CallRuntime(id, arg_count); - Result result = cgen_->allocator()->Allocate(r0); + Result result = cgen()->allocator()->Allocate(r0); ASSERT(result.is_valid()); return result; } @@ -297,16 +289,16 @@ Result VirtualFrame::InvokeBuiltin(Builtins::JavaScript id, PrepareForCall(arg_count, arg_count); arg_count_register->Unuse(); __ InvokeBuiltin(id, flags); - Result result = cgen_->allocator()->Allocate(r0); + Result result = cgen()->allocator()->Allocate(r0); return result; } Result VirtualFrame::RawCallCodeObject(Handle<Code> code, RelocInfo::Mode rmode) { - ASSERT(cgen_->HasValidEntryRegisters()); + ASSERT(cgen()->HasValidEntryRegisters()); __ Call(code, rmode); - Result result = cgen_->allocator()->Allocate(r0); + Result result = cgen()->allocator()->Allocate(r0); ASSERT(result.is_valid()); return result; } @@ -401,7 +393,7 @@ Result VirtualFrame::CallCodeObject(Handle<Code> code, void VirtualFrame::Drop(int count) { ASSERT(height() >= count); - int num_virtual_elements = (elements_.length() - 1) - stack_pointer_; + int num_virtual_elements = (element_count() - 1) - stack_pointer_; // Emit code to lower the stack pointer if necessary. if (num_virtual_elements < count) { @@ -422,13 +414,12 @@ void VirtualFrame::Drop(int count) { Result VirtualFrame::Pop() { UNIMPLEMENTED(); - Result invalid(cgen_); - return invalid; + return Result(); } void VirtualFrame::EmitPop(Register reg) { - ASSERT(stack_pointer_ == elements_.length() - 1); + ASSERT(stack_pointer_ == element_count() - 1); stack_pointer_--; elements_.RemoveLast(); __ pop(reg); @@ -436,7 +427,7 @@ void VirtualFrame::EmitPop(Register reg) { void VirtualFrame::EmitPush(Register reg) { - ASSERT(stack_pointer_ == elements_.length() - 1); + ASSERT(stack_pointer_ == element_count() - 1); elements_.Add(FrameElement::MemoryElement()); stack_pointer_++; __ push(reg); |