Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index af1c3b24c4ddb555a40e14c528aec8e2b8ceb859..0e050fea1d589da2e17769d37b4028447f51cb8d 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -2828,7 +2828,7 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
this, pointers, Safepoint::kLazyDeopt); |
// The number of arguments is stored in receiver which is r0, as expected |
// by InvokeFunction. |
- v8::internal::ParameterCount actual(receiver); |
+ ParameterCount actual(receiver); |
__ InvokeFunction(function, actual, CALL_FUNCTION, |
safepoint_generator, CALL_AS_METHOD); |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2883,31 +2883,41 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
int arity, |
LInstruction* instr, |
CallKind call_kind) { |
- // Change context if needed. |
- bool change_context = |
- (info()->closure()->context() != function->context()) || |
- scope()->contains_with() || |
- (scope()->num_heap_slots() > 0); |
- if (change_context) { |
- __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
- } |
- |
- // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
- // is available to write to at this point. |
- if (!function->NeedsArgumentsAdaption()) { |
- __ mov(r0, Operand(arity)); |
- } |
+ bool can_invoke_directly = !function->NeedsArgumentsAdaption() || |
+ function->shared()->formal_parameter_count() == arity; |
LPointerMap* pointers = instr->pointer_map(); |
RecordPosition(pointers->position()); |
- // Invoke function. |
- __ SetCallKind(r5, call_kind); |
- __ ldr(ip, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
- __ Call(ip); |
+ if (can_invoke_directly) { |
+ __ LoadHeapObject(r1, function); |
+ // Change context if needed. |
+ bool change_context = |
+ (info()->closure()->context() != function->context()) || |
+ scope()->contains_with() || |
+ (scope()->num_heap_slots() > 0); |
+ if (change_context) { |
+ __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
+ } |
- // Set up deoptimization. |
- RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
+ // Set r0 to arguments count if adaption is not needed. Assumes that r0 |
+ // is available to write to at this point. |
+ if (!function->NeedsArgumentsAdaption()) { |
+ __ mov(r0, Operand(arity)); |
+ } |
+ |
+ // Invoke function. |
+ __ SetCallKind(r5, call_kind); |
+ __ ldr(ip, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
+ __ Call(ip); |
+ |
+ // Set up deoptimization. |
+ RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
+ } else { |
+ SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
+ ParameterCount count(arity); |
+ __ InvokeFunction(function, count, CALL_FUNCTION, generator, call_kind); |
+ } |
// Restore context. |
__ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2916,7 +2926,6 @@ void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
ASSERT(ToRegister(instr->result()).is(r0)); |
- __ LoadHeapObject(r1, instr->function()); |
CallKnownFunction(instr->function(), |
instr->arity(), |
instr, |
@@ -3351,7 +3360,6 @@ void LCodeGen::DoCallGlobal(LCallGlobal* instr) { |
void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { |
ASSERT(ToRegister(instr->result()).is(r0)); |
- __ LoadHeapObject(r1, instr->target()); |
CallKnownFunction(instr->target(), instr->arity(), instr, CALL_AS_FUNCTION); |
} |