OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 127 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
128 | 128 |
129 #ifdef DEBUG | 129 #ifdef DEBUG |
130 if (strlen(FLAG_stop_at) > 0 && | 130 if (strlen(FLAG_stop_at) > 0 && |
131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 131 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
132 __ int3(); | 132 __ int3(); |
133 } | 133 } |
134 #endif | 134 #endif |
135 | 135 |
136 // Strict mode functions and builtins need to replace the receiver | 136 // Classic mode functions and builtins need to replace the receiver with the |
137 // with undefined when called as functions (without an explicit | 137 // global proxy when called as functions (without an explicit receiver |
138 // receiver object). ecx is zero for method calls and non-zero for | 138 // object). |
139 // function calls. | 139 if (info->is_classic_mode() && !info->is_native()) { |
140 if (!info->is_classic_mode() || info->is_native()) { | |
141 Label ok; | 140 Label ok; |
142 __ test(ecx, ecx); | 141 __ test(ecx, ecx); |
143 __ j(zero, &ok, Label::kNear); | 142 __ j(zero, &ok, Label::kNear); |
| 143 |
144 // +1 for return address. | 144 // +1 for return address. |
145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; | 145 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; |
146 __ mov(ecx, Operand(esp, receiver_offset)); | 146 __ mov(ecx, Operand(esp, receiver_offset)); |
147 __ JumpIfSmi(ecx, &ok); | 147 |
148 __ CmpObjectType(ecx, JS_GLOBAL_PROXY_TYPE, ecx); | 148 __ cmp(ecx, isolate()->factory()->undefined_value()); |
149 __ j(not_equal, &ok, Label::kNear); | 149 __ j(not_equal, &ok, Label::kNear); |
150 __ mov(Operand(esp, receiver_offset), | 150 |
151 Immediate(isolate()->factory()->undefined_value())); | 151 __ mov(ecx, GlobalObjectOperand()); |
| 152 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); |
| 153 |
| 154 __ mov(Operand(esp, receiver_offset), ecx); |
| 155 |
152 __ bind(&ok); | 156 __ bind(&ok); |
153 } | 157 } |
154 | 158 |
155 // Open a frame scope to indicate that there is a frame on the stack. The | 159 // Open a frame scope to indicate that there is a frame on the stack. The |
156 // MANUAL indicates that the scope shouldn't actually generate code to set up | 160 // MANUAL indicates that the scope shouldn't actually generate code to set up |
157 // the frame (that is done below). | 161 // the frame (that is done below). |
158 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 162 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
159 | 163 |
160 info->set_prologue_offset(masm_->pc_offset()); | 164 info->set_prologue_offset(masm_->pc_offset()); |
161 __ Prologue(BUILD_FUNCTION_FRAME); | 165 __ Prologue(BUILD_FUNCTION_FRAME); |
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 NOT_CONTEXTUAL); | 2750 NOT_CONTEXTUAL); |
2747 } else { | 2751 } else { |
2748 EmitKeyedCallWithIC(expr, property->key()); | 2752 EmitKeyedCallWithIC(expr, property->key()); |
2749 } | 2753 } |
2750 | 2754 |
2751 } else { | 2755 } else { |
2752 // Call to an arbitrary expression not handled specially above. | 2756 // Call to an arbitrary expression not handled specially above. |
2753 { PreservePositionScope scope(masm()->positions_recorder()); | 2757 { PreservePositionScope scope(masm()->positions_recorder()); |
2754 VisitForStackValue(callee); | 2758 VisitForStackValue(callee); |
2755 } | 2759 } |
2756 // Push the hole as receiver. | 2760 __ push(Immediate(isolate()->factory()->undefined_value())); |
2757 // It will be correctly replaced in the call stub. | |
2758 __ push(Immediate(isolate()->factory()->the_hole_value())); | |
2759 // Emit function call. | 2761 // Emit function call. |
2760 EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT); | 2762 EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
2761 } | 2763 } |
2762 | 2764 |
2763 #ifdef DEBUG | 2765 #ifdef DEBUG |
2764 // RecordJSReturnSite should have been called. | 2766 // RecordJSReturnSite should have been called. |
2765 ASSERT(expr->return_is_recorded_); | 2767 ASSERT(expr->return_is_recorded_); |
2766 #endif | 2768 #endif |
2767 } | 2769 } |
2768 | 2770 |
2769 | 2771 |
2770 void FullCodeGenerator::VisitCallNew(CallNew* expr) { | 2772 void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3686 Label runtime, done; | 3688 Label runtime, done; |
3687 // Check for non-function argument (including proxy). | 3689 // Check for non-function argument (including proxy). |
3688 __ JumpIfSmi(eax, &runtime); | 3690 __ JumpIfSmi(eax, &runtime); |
3689 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); | 3691 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); |
3690 __ j(not_equal, &runtime); | 3692 __ j(not_equal, &runtime); |
3691 | 3693 |
3692 // InvokeFunction requires the function in edi. Move it in there. | 3694 // InvokeFunction requires the function in edi. Move it in there. |
3693 __ mov(edi, result_register()); | 3695 __ mov(edi, result_register()); |
3694 ParameterCount count(arg_count); | 3696 ParameterCount count(arg_count); |
3695 __ InvokeFunction(edi, count, CALL_FUNCTION, | 3697 __ InvokeFunction(edi, count, CALL_FUNCTION, |
3696 NullCallWrapper(), CALL_AS_METHOD); | 3698 NullCallWrapper(), CALL_AS_FUNCTION); |
3697 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3699 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
3698 __ jmp(&done); | 3700 __ jmp(&done); |
3699 | 3701 |
3700 __ bind(&runtime); | 3702 __ bind(&runtime); |
3701 __ push(eax); | 3703 __ push(eax); |
3702 __ CallRuntime(Runtime::kCall, args->length()); | 3704 __ CallRuntime(Runtime::kCall, args->length()); |
3703 __ bind(&done); | 3705 __ bind(&done); |
3704 | 3706 |
3705 context()->Plug(eax); | 3707 context()->Plug(eax); |
3706 } | 3708 } |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4889 | 4891 |
4890 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4892 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4891 Assembler::target_address_at(call_target_address)); | 4893 Assembler::target_address_at(call_target_address)); |
4892 return OSR_AFTER_STACK_CHECK; | 4894 return OSR_AFTER_STACK_CHECK; |
4893 } | 4895 } |
4894 | 4896 |
4895 | 4897 |
4896 } } // namespace v8::internal | 4898 } } // namespace v8::internal |
4897 | 4899 |
4898 #endif // V8_TARGET_ARCH_IA32 | 4900 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |