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
This commit is contained in:
kmillikin@chromium.org 2009-03-25 11:05:36 +00:00
parent 4d8ea7143f
commit 7c35a5d820
4 changed files with 18 additions and 32 deletions

View File

@ -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<Code> stub = ComputeCallInitialize(args->length());
Handle<Code> 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);
}

View File

@ -4454,12 +4454,8 @@ void CodeGenerator::VisitCallRuntime(CallRuntime* node) {
if (function == NULL) {
// Call the JS runtime function.
Handle<Code> 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 {

View File

@ -784,10 +784,6 @@ Result VirtualFrame::CallCodeObject(Handle<Code> 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);

View File

@ -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 };