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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 10 matching lines...) Expand all Loading... |
220 } | 221 } |
221 | 222 |
222 // Register holding this function and new target are both trashed in case we | 223 // Register holding this function and new target are both trashed in case we |
223 // bailout here. But since that can happen only when new target is not used | 224 // bailout here. But since that can happen only when new target is not used |
224 // and we allocate a context, the value of |function_in_register| is correct. | 225 // and we allocate a context, the value of |function_in_register| is correct. |
225 PrepareForBailoutForId(BailoutId::FunctionContext(), | 226 PrepareForBailoutForId(BailoutId::FunctionContext(), |
226 BailoutState::NO_REGISTERS); | 227 BailoutState::NO_REGISTERS); |
227 | 228 |
228 // Possibly set up a local binding to the this function which is used in | 229 // Possibly set up a local binding to the this function which is used in |
229 // derived constructors with super calls. | 230 // derived constructors with super calls. |
230 Variable* this_function_var = scope()->this_function_var(); | 231 Variable* this_function_var = info->scope()->this_function_var(); |
231 if (this_function_var != nullptr) { | 232 if (this_function_var != nullptr) { |
232 Comment cmnt(masm_, "[ This function"); | 233 Comment cmnt(masm_, "[ This function"); |
233 if (!function_in_register) { | 234 if (!function_in_register) { |
234 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 235 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
235 // The write barrier clobbers register again, keep it marked as such. | 236 // The write barrier clobbers register again, keep it marked as such. |
236 } | 237 } |
237 SetVar(this_function_var, edi, ebx, ecx); | 238 SetVar(this_function_var, edi, ebx, ecx); |
238 } | 239 } |
239 | 240 |
240 // Possibly set up a local binding to the new target value. | 241 // Possibly set up a local binding to the new target value. |
241 Variable* new_target_var = scope()->new_target_var(); | 242 Variable* new_target_var = info->scope()->new_target_var(); |
242 if (new_target_var != nullptr) { | 243 if (new_target_var != nullptr) { |
243 Comment cmnt(masm_, "[ new.target"); | 244 Comment cmnt(masm_, "[ new.target"); |
244 SetVar(new_target_var, edx, ebx, ecx); | 245 SetVar(new_target_var, edx, ebx, ecx); |
245 } | 246 } |
246 | 247 |
247 // Possibly allocate RestParameters | 248 // Possibly allocate RestParameters |
248 int rest_index; | 249 int rest_index; |
249 Variable* rest_param = scope()->rest_parameter(&rest_index); | 250 Variable* rest_param = info->scope()->rest_parameter(&rest_index); |
250 if (rest_param) { | 251 if (rest_param) { |
251 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 252 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
252 if (!function_in_register) { | 253 if (!function_in_register) { |
253 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 254 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
254 } | 255 } |
255 FastNewRestParameterStub stub(isolate()); | 256 FastNewRestParameterStub stub(isolate()); |
256 __ CallStub(&stub); | 257 __ CallStub(&stub); |
257 function_in_register = false; | 258 function_in_register = false; |
258 SetVar(rest_param, eax, ebx, edx); | 259 SetVar(rest_param, eax, ebx, edx); |
259 } | 260 } |
260 | 261 |
261 Variable* arguments = scope()->arguments(); | 262 Variable* arguments = info->scope()->arguments(); |
262 if (arguments != NULL) { | 263 if (arguments != NULL) { |
263 // Arguments object must be allocated after the context object, in | 264 // Arguments object must be allocated after the context object, in |
264 // case the "arguments" or ".arguments" variables are in the context. | 265 // case the "arguments" or ".arguments" variables are in the context. |
265 Comment cmnt(masm_, "[ Allocate arguments object"); | 266 Comment cmnt(masm_, "[ Allocate arguments object"); |
266 if (!function_in_register) { | 267 if (!function_in_register) { |
267 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 268 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
268 } | 269 } |
269 if (is_strict(language_mode()) || !has_simple_parameters()) { | 270 if (is_strict(language_mode()) || !has_simple_parameters()) { |
270 FastNewStrictArgumentsStub stub(isolate()); | 271 FastNewStrictArgumentsStub stub(isolate()); |
271 __ CallStub(&stub); | 272 __ CallStub(&stub); |
(...skipping 3238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3510 __ mov(Operand(ebp, frame_offset), value); | 3511 __ mov(Operand(ebp, frame_offset), value); |
3511 } | 3512 } |
3512 | 3513 |
3513 | 3514 |
3514 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 3515 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
3515 __ mov(dst, ContextOperand(esi, context_index)); | 3516 __ mov(dst, ContextOperand(esi, context_index)); |
3516 } | 3517 } |
3517 | 3518 |
3518 | 3519 |
3519 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 3520 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
3520 Scope* closure_scope = scope()->ClosureScope(); | 3521 DeclarationScope* closure_scope = scope()->GetClosureScope(); |
3521 if (closure_scope->is_script_scope() || | 3522 if (closure_scope->is_script_scope() || |
3522 closure_scope->is_module_scope()) { | 3523 closure_scope->is_module_scope()) { |
3523 // Contexts nested in the native context have a canonical empty function | 3524 // Contexts nested in the native context have a canonical empty function |
3524 // as their closure, not the anonymous closure containing the global | 3525 // as their closure, not the anonymous closure containing the global |
3525 // code. | 3526 // code. |
3526 __ mov(eax, NativeContextOperand()); | 3527 __ mov(eax, NativeContextOperand()); |
3527 PushOperand(ContextOperand(eax, Context::CLOSURE_INDEX)); | 3528 PushOperand(ContextOperand(eax, Context::CLOSURE_INDEX)); |
3528 } else if (closure_scope->is_eval_scope()) { | 3529 } else if (closure_scope->is_eval_scope()) { |
3529 // Contexts nested inside eval code have the same closure as the context | 3530 // Contexts nested inside eval code have the same closure as the context |
3530 // calling eval, not the anonymous closure containing the eval code. | 3531 // calling eval, not the anonymous closure containing the eval code. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 isolate->builtins()->OnStackReplacement()->entry(), | 3669 isolate->builtins()->OnStackReplacement()->entry(), |
3669 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3670 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3670 return ON_STACK_REPLACEMENT; | 3671 return ON_STACK_REPLACEMENT; |
3671 } | 3672 } |
3672 | 3673 |
3673 | 3674 |
3674 } // namespace internal | 3675 } // namespace internal |
3675 } // namespace v8 | 3676 } // namespace v8 |
3676 | 3677 |
3677 #endif // V8_TARGET_ARCH_X87 | 3678 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |