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