From bdb896cc407cea632f8469d0c96ed62c12e592c3 Mon Sep 17 00:00:00 2001 From: "kmillikin@chromium.org" Date: Fri, 7 Nov 2008 08:21:07 +0000 Subject: [PATCH] Emit pushes and pops through the virtual frame on ARM. Merging of frames is not yet handled. The ARM code generator should be back in line with the IA32 one. Review URL: http://codereview.chromium.org/9182 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@706 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/codegen-arm.cc | 559 +++++++++++++++++++++++++++------------------------- src/codegen-arm.h | 19 +- src/codegen-ia32.cc | 46 ++--- 3 files changed, 332 insertions(+), 292 deletions(-) diff --git a/src/codegen-arm.cc b/src/codegen-arm.cc index 69455a7..4d2cf2d 100644 --- a/src/codegen-arm.cc +++ b/src/codegen-arm.cc @@ -49,6 +49,70 @@ VirtualFrame::VirtualFrame(CodeGenerator* cgen) { } +void VirtualFrame::Enter() { + Comment cmnt(masm_, "[ Enter JS frame"); +#ifdef DEBUG + { Label done, fail; + __ tst(r1, Operand(kSmiTagMask)); + __ b(eq, &fail); + __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); + __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); + __ cmp(r2, Operand(JS_FUNCTION_TYPE)); + __ b(eq, &done); + __ bind(&fail); + __ stop("CodeGenerator::EnterJSFrame - r1 not a function"); + __ bind(&done); + } +#endif // DEBUG + + __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); + // Adjust FP to point to saved FP. + __ add(fp, sp, Operand(2 * kPointerSize)); +} + + +void VirtualFrame::Exit() { + 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); + __ ldm(ia_w, sp, fp.bit() | lr.bit()); +} + + +void VirtualFrame::AllocateLocals() { + if (frame_local_count_ > 0) { + Comment cmnt(masm_, "[ Allocate space for locals"); + // Initialize stack slots with 'undefined' value. + __ mov(ip, Operand(Factory::undefined_value())); + for (int i = 0; i < frame_local_count_; i++) { + __ push(ip); + } + } +} + + +void VirtualFrame::Drop(int count) { + ASSERT(count >= 0); + if (count > 0) { + __ add(sp, sp, Operand(count * kPointerSize)); + } +} + + +void VirtualFrame::Pop() { Drop(1); } + + +void VirtualFrame::Pop(Register reg) { + __ pop(reg); +} + + +void VirtualFrame::Push(Register reg) { + __ push(reg); +} + + // ------------------------------------------------------------------------- // CodeGenState implementation. @@ -99,7 +163,6 @@ CodeGenerator::CodeGenerator(int buffer_size, Handle