OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3943 | 3943 |
3944 | 3944 |
3945 void StackCheckStub::Generate(MacroAssembler* masm) { | 3945 void StackCheckStub::Generate(MacroAssembler* masm) { |
3946 __ TailCallRuntime(Runtime::kStackGuard, 0, 1); | 3946 __ TailCallRuntime(Runtime::kStackGuard, 0, 1); |
3947 } | 3947 } |
3948 | 3948 |
3949 | 3949 |
3950 void CallFunctionStub::Generate(MacroAssembler* masm) { | 3950 void CallFunctionStub::Generate(MacroAssembler* masm) { |
3951 Label slow; | 3951 Label slow; |
3952 | 3952 |
3953 // If the receiver might be a value (string, number or boolean) check for this | 3953 // If the receiver might be a value (string, number or boolean) check for this |
Mads Ager (chromium)
2011/05/24 07:14:14
I will update this comment.
| |
3954 // and box it if it is. | 3954 // and box it if it is. |
3955 if (ReceiverMightBeValue()) { | 3955 if (ReceiverMightBeImplicit()) { |
3956 Label call; | |
3956 // Get the receiver from the stack. | 3957 // Get the receiver from the stack. |
3957 // +1 ~ return address | 3958 // +1 ~ return address |
3958 Label receiver_is_value, receiver_is_js_object; | |
3959 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); | 3959 __ mov(eax, Operand(esp, (argc_ + 1) * kPointerSize)); |
3960 | 3960 // Call as function is indicated with the hole. |
3961 // Check if receiver is a smi (which is a number value). | 3961 __ cmp(eax, masm->isolate()->factory()->the_hole_value()); |
3962 __ test(eax, Immediate(kSmiTagMask)); | 3962 __ j(not_equal, &call, Label::kNear); |
3963 __ j(zero, &receiver_is_value); | 3963 // Patch the receiver on the stack with the global receiver object. |
3964 | 3964 __ mov(ebx, GlobalObjectOperand()); |
3965 // Check if the receiver is a valid JS object. | 3965 __ mov(ebx, FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); |
3966 __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, edi); | 3966 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), ebx); |
3967 __ j(above_equal, &receiver_is_js_object); | 3967 __ bind(&call); |
3968 | |
3969 // Call the runtime to box the value. | |
3970 __ bind(&receiver_is_value); | |
3971 __ EnterInternalFrame(); | |
3972 __ push(eax); | |
3973 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | |
3974 __ LeaveInternalFrame(); | |
3975 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), eax); | |
3976 | |
3977 __ bind(&receiver_is_js_object); | |
3978 } | 3968 } |
3979 | 3969 |
3980 // Get the function to call from the stack. | 3970 // Get the function to call from the stack. |
3981 // +2 ~ receiver, return address | 3971 // +2 ~ receiver, return address |
3982 __ mov(edi, Operand(esp, (argc_ + 2) * kPointerSize)); | 3972 __ mov(edi, Operand(esp, (argc_ + 2) * kPointerSize)); |
3983 | 3973 |
3984 // Check that the function really is a JavaScript function. | 3974 // Check that the function really is a JavaScript function. |
3985 __ test(edi, Immediate(kSmiTagMask)); | 3975 __ test(edi, Immediate(kSmiTagMask)); |
3986 __ j(zero, &slow); | 3976 __ j(zero, &slow); |
3987 // Goto slow case if we do not have a function. | 3977 // Goto slow case if we do not have a function. |
3988 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 3978 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); |
3989 __ j(not_equal, &slow); | 3979 __ j(not_equal, &slow); |
3990 | 3980 |
3991 // Fast-case: Just invoke the function. | 3981 // Fast-case: Just invoke the function. |
3992 ParameterCount actual(argc_); | 3982 ParameterCount actual(argc_); |
3993 __ InvokeFunction(edi, actual, JUMP_FUNCTION); | 3983 |
3984 if (ReceiverMightBeImplicit()) { | |
3985 Label call_as_function; | |
3986 __ cmp(eax, masm->isolate()->factory()->the_hole_value()); | |
3987 __ j(equal, &call_as_function); | |
3988 __ InvokeFunction(edi, actual, JUMP_FUNCTION); | |
3989 __ bind(&call_as_function); | |
3990 } | |
3991 __ InvokeFunction(edi, | |
3992 actual, | |
3993 JUMP_FUNCTION, | |
3994 NullCallWrapper(), | |
3995 CALL_AS_FUNCTION); | |
3994 | 3996 |
3995 // Slow-case: Non-function called. | 3997 // Slow-case: Non-function called. |
3996 __ bind(&slow); | 3998 __ bind(&slow); |
3997 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead | 3999 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead |
3998 // of the original receiver from the call site). | 4000 // of the original receiver from the call site). |
3999 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); | 4001 __ mov(Operand(esp, (argc_ + 1) * kPointerSize), edi); |
4000 __ Set(eax, Immediate(argc_)); | 4002 __ Set(eax, Immediate(argc_)); |
4001 __ Set(ebx, Immediate(0)); | 4003 __ Set(ebx, Immediate(0)); |
4002 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); | 4004 __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); |
4003 Handle<Code> adaptor = | 4005 Handle<Code> adaptor = |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4277 Builtins::kJSConstructEntryTrampoline, | 4279 Builtins::kJSConstructEntryTrampoline, |
4278 masm->isolate()); | 4280 masm->isolate()); |
4279 __ mov(edx, Immediate(construct_entry)); | 4281 __ mov(edx, Immediate(construct_entry)); |
4280 } else { | 4282 } else { |
4281 ExternalReference entry(Builtins::kJSEntryTrampoline, | 4283 ExternalReference entry(Builtins::kJSEntryTrampoline, |
4282 masm->isolate()); | 4284 masm->isolate()); |
4283 __ mov(edx, Immediate(entry)); | 4285 __ mov(edx, Immediate(entry)); |
4284 } | 4286 } |
4285 __ mov(edx, Operand(edx, 0)); // deref address | 4287 __ mov(edx, Operand(edx, 0)); // deref address |
4286 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); | 4288 __ lea(edx, FieldOperand(edx, Code::kHeaderSize)); |
4289 __ SetCallKind(ecx, CALL_AS_METHOD); | |
4287 __ call(Operand(edx)); | 4290 __ call(Operand(edx)); |
4288 | 4291 |
4289 // Unlink this frame from the handler chain. | 4292 // Unlink this frame from the handler chain. |
4290 __ PopTryHandler(); | 4293 __ PopTryHandler(); |
4291 | 4294 |
4292 __ bind(&exit); | 4295 __ bind(&exit); |
4293 #ifdef ENABLE_LOGGING_AND_PROFILING | 4296 #ifdef ENABLE_LOGGING_AND_PROFILING |
4294 // Check if the current stack frame is marked as the outermost JS frame. | 4297 // Check if the current stack frame is marked as the outermost JS frame. |
4295 __ pop(ebx); | 4298 __ pop(ebx); |
4296 __ cmp(Operand(ebx), | 4299 __ cmp(Operand(ebx), |
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6191 __ Drop(1); | 6194 __ Drop(1); |
6192 __ ret(2 * kPointerSize); | 6195 __ ret(2 * kPointerSize); |
6193 } | 6196 } |
6194 | 6197 |
6195 | 6198 |
6196 #undef __ | 6199 #undef __ |
6197 | 6200 |
6198 } } // namespace v8::internal | 6201 } } // namespace v8::internal |
6199 | 6202 |
6200 #endif // V8_TARGET_ARCH_IA32 | 6203 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |