From 7c35a5d820ed7dc225fecb5752f1f9d1d4927660 Mon Sep 17 00:00:00 2001 From: "kmillikin@chromium.org" Date: Wed, 25 Mar 2009 11:05:36 +0000 Subject: [PATCH] The code generator doesn't need to put the argument count in eax for call ICs. Refactor CallRuntime on ARM to match the structure of IA32. Update some comments. Review URL: http://codereview.chromium.org/42598 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1607 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/codegen-arm.cc | 30 +++++++++++++----------------- src/codegen-ia32.cc | 8 ++------ src/virtual-frame-ia32.cc | 4 ---- src/virtual-frame.cc | 8 +++----- 4 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/codegen-arm.cc b/src/codegen-arm.cc index 52009d985b..98c0153766 100644 --- a/src/codegen-arm.cc +++ b/src/codegen-arm.cc @@ -3456,18 +3456,7 @@ void CodeGenerator::VisitCallRuntime(CallRuntime* node) { Comment cmnt(masm_, "[ CallRuntime"); Runtime::Function* function = node->function(); - if (function != NULL) { - // Push the arguments ("left-to-right"). - int arg_count = args->length(); - for (int i = 0; i < arg_count; i++) { - LoadAndSpill(args->at(i)); - } - - // Call the C runtime function. - frame_->CallRuntime(function, arg_count); - frame_->EmitPush(r0); - - } else { + if (function == NULL) { // Prepare stack for calling JS runtime function. __ mov(r0, Operand(node->name())); frame_->EmitPush(r0); @@ -3475,18 +3464,25 @@ void CodeGenerator::VisitCallRuntime(CallRuntime* node) { __ ldr(r1, GlobalObject()); __ ldr(r0, FieldMemOperand(r1, GlobalObject::kBuiltinsOffset)); frame_->EmitPush(r0); + } - int arg_count = args->length(); - for (int i = 0; i < arg_count; i++) { - LoadAndSpill(args->at(i)); - } + // Push the arguments ("left-to-right"). + int arg_count = args->length(); + for (int i = 0; i < arg_count; i++) { + LoadAndSpill(args->at(i)); + } + if (function == NULL) { // Call the JS runtime function. - Handle stub = ComputeCallInitialize(args->length()); + Handle stub = ComputeCallInitialize(arg_count); frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); __ ldr(cp, frame_->Context()); frame_->Drop(); frame_->EmitPush(r0); + } else { + // Call the C runtime function. + frame_->CallRuntime(function, arg_count); + frame_->EmitPush(r0); } ASSERT(frame_->height() == original_height + 1); } diff --git a/src/codegen-ia32.cc b/src/codegen-ia32.cc index 82d44e0185..10a00350a5 100644 --- a/src/codegen-ia32.cc +++ b/src/codegen-ia32.cc @@ -4454,12 +4454,8 @@ void CodeGenerator::VisitCallRuntime(CallRuntime* node) { if (function == NULL) { // Call the JS runtime function. Handle stub = ComputeCallInitialize(arg_count); - - Result num_args = allocator()->Allocate(eax); - ASSERT(num_args.is_valid()); - __ Set(num_args.reg(), Immediate(args->length())); - Result answer = frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, - &num_args, arg_count + 1); + Result answer = + frame_->CallCodeObject(stub, RelocInfo::CODE_TARGET, arg_count + 1); frame_->RestoreContextRegister(); frame_->SetElementAt(0, &answer); } else { diff --git a/src/virtual-frame-ia32.cc b/src/virtual-frame-ia32.cc index 2af1aa0946..aca6ba56dc 100644 --- a/src/virtual-frame-ia32.cc +++ b/src/virtual-frame-ia32.cc @@ -784,10 +784,6 @@ Result VirtualFrame::CallCodeObject(Handle code, int dropped_args) { int spilled_args = 0; switch (code->kind()) { - case Code::CALL_IC: - ASSERT(arg->reg().is(eax)); - spilled_args = dropped_args + 1; - break; case Code::LOAD_IC: ASSERT(arg->reg().is(ecx)); ASSERT(dropped_args == 0); diff --git a/src/virtual-frame.cc b/src/virtual-frame.cc index 0038ad6f65..267b50f575 100644 --- a/src/virtual-frame.cc +++ b/src/virtual-frame.cc @@ -179,12 +179,10 @@ void VirtualFrame::Spill(Register target) { } -// Spill any register if possible, making its external reference count zero. +// If there are any registers referenced only by the frame, spill one. Register VirtualFrame::SpillAnyRegister() { - // Find the leftmost (ordered by register code), least - // internally-referenced register whose internal reference count matches - // its external reference count (so that spilling it from the frame frees - // it for use). + // Find the leftmost (ordered by register code) register whose only + // reference is in the frame. for (int i = 0; i < kNumRegisters; i++) { if (is_used(i) && cgen_->allocator()->count(i) == 1) { Register result = { i };