Index: src/mips/code-stubs-mips.cc |
diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc |
index 438837f49587d8581ba4dd739f2c79aa002f7f1d..f4d35bb5bf11713aa73fe167b4d9c6c339bc6bfb 100644 |
--- a/src/mips/code-stubs-mips.cc |
+++ b/src/mips/code-stubs-mips.cc |
@@ -3328,32 +3328,48 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { |
// a2 : cache cell for call target |
Label slow, non_function; |
+ // Check that the function is really a JavaScript function. |
+ // a1: pushed function (to be verified) |
+ __ JumpIfSmi(a1, &non_function); |
+ |
// The receiver might implicitly be the global object. This is |
// indicated by passing the hole as the receiver to the call |
// function stub. |
- if (ReceiverMightBeImplicit()) { |
- Label call; |
- // Get the receiver from the stack. |
- // function, receiver [, arguments] |
- __ lw(t0, MemOperand(sp, argc_ * kPointerSize)); |
- // Call as function is indicated with the hole. |
- __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
- __ Branch(&call, ne, t0, Operand(at)); |
+ if (ReceiverMightBeImplicit() || ReceiverIsImplicit()) { |
+ Label try_call, call, patch_current_context; |
+ if (ReceiverMightBeImplicit()) { |
+ // Get the receiver from the stack. |
+ // function, receiver [, arguments] |
+ __ lw(t0, MemOperand(sp, argc_ * kPointerSize)); |
+ // Call as function is indicated with the hole. |
+ __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
+ __ Branch(&try_call, ne, t0, Operand(at)); |
+ } |
// Patch the receiver on the stack with the global receiver object. |
- __ lw(a3, |
- MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
- __ lw(a3, FieldMemOperand(a3, GlobalObject::kGlobalReceiverOffset)); |
+ // Goto slow case if we do not have a function. |
+ __ GetObjectType(a1, a3, a3); |
+ __ Branch(&patch_current_context, ne, a3, Operand(JS_FUNCTION_TYPE)); |
+ CallStubCompiler::FetchGlobalProxy(masm, a3, a1); |
__ sw(a3, MemOperand(sp, argc_ * kPointerSize)); |
+ __ Branch(&call); |
+ |
+ __ bind(&patch_current_context); |
+ __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); |
+ __ sw(t0, MemOperand(sp, argc_ * kPointerSize)); |
+ __ Branch(&slow); |
+ |
+ __ bind(&try_call); |
+ // Get the map of the function object. |
+ __ GetObjectType(a1, a3, a3); |
+ __ Branch(&slow, ne, a3, Operand(JS_FUNCTION_TYPE)); |
+ |
__ bind(&call); |
+ } else { |
+ // Get the map of the function object. |
+ __ GetObjectType(a1, a3, a3); |
+ __ Branch(&slow, ne, a3, Operand(JS_FUNCTION_TYPE)); |
} |
- // Check that the function is really a JavaScript function. |
- // a1: pushed function (to be verified) |
- __ JumpIfSmi(a1, &non_function); |
- // Get the map of the function object. |
- __ GetObjectType(a1, a3, a3); |
- __ Branch(&slow, ne, a3, Operand(JS_FUNCTION_TYPE)); |
- |
if (RecordCallTarget()) { |
GenerateRecordCallTarget(masm); |
} |
@@ -3396,7 +3412,7 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { |
__ li(a0, Operand(argc_ + 1, RelocInfo::NONE32)); |
__ li(a2, Operand(0, RelocInfo::NONE32)); |
__ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY); |
- __ SetCallKind(t1, CALL_AS_METHOD); |
+ __ SetCallKind(t1, CALL_AS_FUNCTION); |
{ |
Handle<Code> adaptor = |
masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(); |