OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 #ifdef DEBUG | 107 #ifdef DEBUG |
108 if (strlen(FLAG_stop_at) > 0 && | 108 if (strlen(FLAG_stop_at) > 0 && |
109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 109 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
110 __ int3(); | 110 __ int3(); |
111 } | 111 } |
112 #endif | 112 #endif |
113 | 113 |
114 // Sloppy mode functions and builtins need to replace the receiver with the | 114 // Sloppy mode functions and builtins need to replace the receiver with the |
115 // global proxy when called as functions (without an explicit receiver | 115 // global proxy when called as functions (without an explicit receiver |
116 // object). | 116 // object). |
117 if (info->strict_mode() == SLOPPY && !info->is_native()) { | 117 if (info->strict_mode() == SLOPPY && !info->is_native() && |
| 118 info->scope()->has_this_declaration()) { |
118 Label ok; | 119 Label ok; |
119 // +1 for return address. | 120 // +1 for return address. |
120 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; | 121 int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize; |
121 __ mov(ecx, Operand(esp, receiver_offset)); | 122 __ mov(ecx, Operand(esp, receiver_offset)); |
122 | 123 |
123 __ cmp(ecx, isolate()->factory()->undefined_value()); | 124 __ cmp(ecx, isolate()->factory()->undefined_value()); |
124 __ j(not_equal, &ok, Label::kNear); | 125 __ j(not_equal, &ok, Label::kNear); |
125 | 126 |
126 __ mov(ecx, GlobalObjectOperand()); | 127 __ mov(ecx, GlobalObjectOperand()); |
127 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset)); | 128 __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 203 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
203 } | 204 } |
204 function_in_register = false; | 205 function_in_register = false; |
205 // Context is returned in eax. It replaces the context passed to us. | 206 // Context is returned in eax. It replaces the context passed to us. |
206 // It's saved in the stack and kept live in esi. | 207 // It's saved in the stack and kept live in esi. |
207 __ mov(esi, eax); | 208 __ mov(esi, eax); |
208 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); | 209 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); |
209 | 210 |
210 // Copy parameters into context if necessary. | 211 // Copy parameters into context if necessary. |
211 int num_parameters = info->scope()->num_parameters(); | 212 int num_parameters = info->scope()->num_parameters(); |
212 for (int i = 0; i < num_parameters; i++) { | 213 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
213 Variable* var = scope()->parameter(i); | 214 for (int i = first_parameter; i < num_parameters; i++) { |
| 215 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
214 if (var->IsContextSlot()) { | 216 if (var->IsContextSlot()) { |
215 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 217 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
216 (num_parameters - 1 - i) * kPointerSize; | 218 (num_parameters - 1 - i) * kPointerSize; |
217 // Load parameter from stack. | 219 // Load parameter from stack. |
218 __ mov(eax, Operand(ebp, parameter_offset)); | 220 __ mov(eax, Operand(ebp, parameter_offset)); |
219 // Store it in the context. | 221 // Store it in the context. |
220 int context_offset = Context::SlotOffset(var->index()); | 222 int context_offset = Context::SlotOffset(var->index()); |
221 __ mov(Operand(esi, context_offset), eax); | 223 __ mov(Operand(esi, context_offset), eax); |
222 // Update the write barrier. This clobbers eax and ebx. | 224 // Update the write barrier. This clobbers eax and ebx. |
223 if (need_write_barrier) { | 225 if (need_write_barrier) { |
(...skipping 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5282 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5284 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5283 Assembler::target_address_at(call_target_address, | 5285 Assembler::target_address_at(call_target_address, |
5284 unoptimized_code)); | 5286 unoptimized_code)); |
5285 return OSR_AFTER_STACK_CHECK; | 5287 return OSR_AFTER_STACK_CHECK; |
5286 } | 5288 } |
5287 | 5289 |
5288 | 5290 |
5289 } } // namespace v8::internal | 5291 } } // namespace v8::internal |
5290 | 5292 |
5291 #endif // V8_TARGET_ARCH_IA32 | 5293 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |