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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 function_in_register = false; | 189 function_in_register = false; |
190 // Context is returned in eax. It replaces the context passed to us. | 190 // Context is returned in eax. It replaces the context passed to us. |
191 // It's saved in the stack and kept live in esi. | 191 // It's saved in the stack and kept live in esi. |
192 __ mov(esi, eax); | 192 __ mov(esi, eax); |
193 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); | 193 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); |
194 | 194 |
195 // Copy parameters into context if necessary. | 195 // Copy parameters into context if necessary. |
196 int num_parameters = info->scope()->num_parameters(); | 196 int num_parameters = info->scope()->num_parameters(); |
197 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 197 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
198 for (int i = first_parameter; i < num_parameters; i++) { | 198 for (int i = first_parameter; i < num_parameters; i++) { |
199 Variable* var = | 199 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
200 (i == -1) ? info->scope()->receiver() : info->scope()->parameter(i); | |
201 if (var->IsContextSlot()) { | 200 if (var->IsContextSlot()) { |
202 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 201 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
203 (num_parameters - 1 - i) * kPointerSize; | 202 (num_parameters - 1 - i) * kPointerSize; |
204 // Load parameter from stack. | 203 // Load parameter from stack. |
205 __ mov(eax, Operand(ebp, parameter_offset)); | 204 __ mov(eax, Operand(ebp, parameter_offset)); |
206 // Store it in the context. | 205 // Store it in the context. |
207 int context_offset = Context::SlotOffset(var->index()); | 206 int context_offset = Context::SlotOffset(var->index()); |
208 __ mov(Operand(esi, context_offset), eax); | 207 __ mov(Operand(esi, context_offset), eax); |
209 // Update the write barrier. This clobbers eax and ebx. | 208 // Update the write barrier. This clobbers eax and ebx. |
210 if (need_write_barrier) { | 209 if (need_write_barrier) { |
(...skipping 13 matching lines...) Expand all Loading... |
224 } | 223 } |
225 | 224 |
226 // Register holding this function and new target are both trashed in case we | 225 // Register holding this function and new target are both trashed in case we |
227 // bailout here. But since that can happen only when new target is not used | 226 // bailout here. But since that can happen only when new target is not used |
228 // and we allocate a context, the value of |function_in_register| is correct. | 227 // and we allocate a context, the value of |function_in_register| is correct. |
229 PrepareForBailoutForId(BailoutId::FunctionContext(), | 228 PrepareForBailoutForId(BailoutId::FunctionContext(), |
230 BailoutState::NO_REGISTERS); | 229 BailoutState::NO_REGISTERS); |
231 | 230 |
232 // Possibly set up a local binding to the this function which is used in | 231 // Possibly set up a local binding to the this function which is used in |
233 // derived constructors with super calls. | 232 // derived constructors with super calls. |
234 Variable* this_function_var = info->scope()->this_function_var(); | 233 Variable* this_function_var = scope()->this_function_var(); |
235 if (this_function_var != nullptr) { | 234 if (this_function_var != nullptr) { |
236 Comment cmnt(masm_, "[ This function"); | 235 Comment cmnt(masm_, "[ This function"); |
237 if (!function_in_register) { | 236 if (!function_in_register) { |
238 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 237 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
239 // The write barrier clobbers register again, keep it marked as such. | 238 // The write barrier clobbers register again, keep it marked as such. |
240 } | 239 } |
241 SetVar(this_function_var, edi, ebx, ecx); | 240 SetVar(this_function_var, edi, ebx, ecx); |
242 } | 241 } |
243 | 242 |
244 // Possibly set up a local binding to the new target value. | 243 // Possibly set up a local binding to the new target value. |
245 Variable* new_target_var = info->scope()->new_target_var(); | 244 Variable* new_target_var = scope()->new_target_var(); |
246 if (new_target_var != nullptr) { | 245 if (new_target_var != nullptr) { |
247 Comment cmnt(masm_, "[ new.target"); | 246 Comment cmnt(masm_, "[ new.target"); |
248 SetVar(new_target_var, edx, ebx, ecx); | 247 SetVar(new_target_var, edx, ebx, ecx); |
249 } | 248 } |
250 | 249 |
251 // Possibly allocate RestParameters | 250 // Possibly allocate RestParameters |
252 int rest_index; | 251 int rest_index; |
253 Variable* rest_param = info->scope()->rest_parameter(&rest_index); | 252 Variable* rest_param = scope()->rest_parameter(&rest_index); |
254 if (rest_param) { | 253 if (rest_param) { |
255 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 254 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
256 if (!function_in_register) { | 255 if (!function_in_register) { |
257 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 256 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
258 } | 257 } |
259 FastNewRestParameterStub stub(isolate()); | 258 FastNewRestParameterStub stub(isolate()); |
260 __ CallStub(&stub); | 259 __ CallStub(&stub); |
261 function_in_register = false; | 260 function_in_register = false; |
262 SetVar(rest_param, eax, ebx, edx); | 261 SetVar(rest_param, eax, ebx, edx); |
263 } | 262 } |
264 | 263 |
265 Variable* arguments = info->scope()->arguments(); | 264 Variable* arguments = scope()->arguments(); |
266 if (arguments != NULL) { | 265 if (arguments != NULL) { |
267 // Arguments object must be allocated after the context object, in | 266 // Arguments object must be allocated after the context object, in |
268 // case the "arguments" or ".arguments" variables are in the context. | 267 // case the "arguments" or ".arguments" variables are in the context. |
269 Comment cmnt(masm_, "[ Allocate arguments object"); | 268 Comment cmnt(masm_, "[ Allocate arguments object"); |
270 if (!function_in_register) { | 269 if (!function_in_register) { |
271 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 270 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
272 } | 271 } |
273 if (is_strict(language_mode()) || !has_simple_parameters()) { | 272 if (is_strict(language_mode()) || !has_simple_parameters()) { |
274 FastNewStrictArgumentsStub stub(isolate()); | 273 FastNewStrictArgumentsStub stub(isolate()); |
275 __ CallStub(&stub); | 274 __ CallStub(&stub); |
(...skipping 10 matching lines...) Expand all Loading... |
286 | 285 |
287 if (FLAG_trace) { | 286 if (FLAG_trace) { |
288 __ CallRuntime(Runtime::kTraceEnter); | 287 __ CallRuntime(Runtime::kTraceEnter); |
289 } | 288 } |
290 | 289 |
291 // Visit the declarations and body. | 290 // Visit the declarations and body. |
292 PrepareForBailoutForId(BailoutId::FunctionEntry(), | 291 PrepareForBailoutForId(BailoutId::FunctionEntry(), |
293 BailoutState::NO_REGISTERS); | 292 BailoutState::NO_REGISTERS); |
294 { | 293 { |
295 Comment cmnt(masm_, "[ Declarations"); | 294 Comment cmnt(masm_, "[ Declarations"); |
296 VisitDeclarations(info->scope()->declarations()); | 295 VisitDeclarations(scope()->declarations()); |
297 } | 296 } |
298 | 297 |
299 // Assert that the declarations do not use ICs. Otherwise the debugger | 298 // Assert that the declarations do not use ICs. Otherwise the debugger |
300 // won't be able to redirect a PC at an IC to the correct IC in newly | 299 // won't be able to redirect a PC at an IC to the correct IC in newly |
301 // recompiled code. | 300 // recompiled code. |
302 DCHECK_EQ(0, ic_total_count_); | 301 DCHECK_EQ(0, ic_total_count_); |
303 | 302 |
304 { | 303 { |
305 Comment cmnt(masm_, "[ Stack check"); | 304 Comment cmnt(masm_, "[ Stack check"); |
306 PrepareForBailoutForId(BailoutId::Declarations(), | 305 PrepareForBailoutForId(BailoutId::Declarations(), |
(...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 __ mov(Operand(ebp, frame_offset), value); | 3518 __ mov(Operand(ebp, frame_offset), value); |
3520 } | 3519 } |
3521 | 3520 |
3522 | 3521 |
3523 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 3522 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
3524 __ mov(dst, ContextOperand(esi, context_index)); | 3523 __ mov(dst, ContextOperand(esi, context_index)); |
3525 } | 3524 } |
3526 | 3525 |
3527 | 3526 |
3528 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 3527 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
3529 DeclarationScope* closure_scope = scope()->GetClosureScope(); | 3528 Scope* closure_scope = scope()->ClosureScope(); |
3530 if (closure_scope->is_script_scope() || | 3529 if (closure_scope->is_script_scope() || |
3531 closure_scope->is_module_scope()) { | 3530 closure_scope->is_module_scope()) { |
3532 // Contexts nested in the native context have a canonical empty function | 3531 // Contexts nested in the native context have a canonical empty function |
3533 // as their closure, not the anonymous closure containing the global | 3532 // as their closure, not the anonymous closure containing the global |
3534 // code. | 3533 // code. |
3535 __ mov(eax, NativeContextOperand()); | 3534 __ mov(eax, NativeContextOperand()); |
3536 PushOperand(ContextOperand(eax, Context::CLOSURE_INDEX)); | 3535 PushOperand(ContextOperand(eax, Context::CLOSURE_INDEX)); |
3537 } else if (closure_scope->is_eval_scope()) { | 3536 } else if (closure_scope->is_eval_scope()) { |
3538 // Contexts nested inside eval code have the same closure as the context | 3537 // Contexts nested inside eval code have the same closure as the context |
3539 // calling eval, not the anonymous closure containing the eval code. | 3538 // calling eval, not the anonymous closure containing the eval code. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3677 isolate->builtins()->OnStackReplacement()->entry(), | 3676 isolate->builtins()->OnStackReplacement()->entry(), |
3678 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3677 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3679 return ON_STACK_REPLACEMENT; | 3678 return ON_STACK_REPLACEMENT; |
3680 } | 3679 } |
3681 | 3680 |
3682 | 3681 |
3683 } // namespace internal | 3682 } // namespace internal |
3684 } // namespace v8 | 3683 } // namespace v8 |
3685 | 3684 |
3686 #endif // V8_TARGET_ARCH_IA32 | 3685 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |