OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 function_in_register_x1 = false; | 199 function_in_register_x1 = false; |
200 // Context is returned in x0. It replaces the context passed to us. | 200 // Context is returned in x0. It replaces the context passed to us. |
201 // It's saved in the stack and kept live in cp. | 201 // It's saved in the stack and kept live in cp. |
202 __ Mov(cp, x0); | 202 __ Mov(cp, x0); |
203 __ Str(x0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 203 __ Str(x0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
204 // Copy any necessary parameters into the context. | 204 // Copy any necessary parameters into the context. |
205 int num_parameters = info->scope()->num_parameters(); | 205 int num_parameters = info->scope()->num_parameters(); |
206 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 206 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
207 for (int i = first_parameter; i < num_parameters; i++) { | 207 for (int i = first_parameter; i < num_parameters; i++) { |
208 Variable* var = | 208 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
209 (i == -1) ? info->scope()->receiver() : info->scope()->parameter(i); | |
210 if (var->IsContextSlot()) { | 209 if (var->IsContextSlot()) { |
211 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 210 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
212 (num_parameters - 1 - i) * kPointerSize; | 211 (num_parameters - 1 - i) * kPointerSize; |
213 // Load parameter from stack. | 212 // Load parameter from stack. |
214 __ Ldr(x10, MemOperand(fp, parameter_offset)); | 213 __ Ldr(x10, MemOperand(fp, parameter_offset)); |
215 // Store it in the context. | 214 // Store it in the context. |
216 MemOperand target = ContextMemOperand(cp, var->index()); | 215 MemOperand target = ContextMemOperand(cp, var->index()); |
217 __ Str(x10, target); | 216 __ Str(x10, target); |
218 | 217 |
219 // Update the write barrier. | 218 // Update the write barrier. |
(...skipping 11 matching lines...) Expand all Loading... |
231 } | 230 } |
232 | 231 |
233 // Register holding this function and new target are both trashed in case we | 232 // Register holding this function and new target are both trashed in case we |
234 // bailout here. But since that can happen only when new target is not used | 233 // bailout here. But since that can happen only when new target is not used |
235 // and we allocate a context, the value of |function_in_register| is correct. | 234 // and we allocate a context, the value of |function_in_register| is correct. |
236 PrepareForBailoutForId(BailoutId::FunctionContext(), | 235 PrepareForBailoutForId(BailoutId::FunctionContext(), |
237 BailoutState::NO_REGISTERS); | 236 BailoutState::NO_REGISTERS); |
238 | 237 |
239 // Possibly set up a local binding to the this function which is used in | 238 // Possibly set up a local binding to the this function which is used in |
240 // derived constructors with super calls. | 239 // derived constructors with super calls. |
241 Variable* this_function_var = info->scope()->this_function_var(); | 240 Variable* this_function_var = scope()->this_function_var(); |
242 if (this_function_var != nullptr) { | 241 if (this_function_var != nullptr) { |
243 Comment cmnt(masm_, "[ This function"); | 242 Comment cmnt(masm_, "[ This function"); |
244 if (!function_in_register_x1) { | 243 if (!function_in_register_x1) { |
245 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 244 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
246 // The write barrier clobbers register again, keep it marked as such. | 245 // The write barrier clobbers register again, keep it marked as such. |
247 } | 246 } |
248 SetVar(this_function_var, x1, x0, x2); | 247 SetVar(this_function_var, x1, x0, x2); |
249 } | 248 } |
250 | 249 |
251 // Possibly set up a local binding to the new target value. | 250 // Possibly set up a local binding to the new target value. |
252 Variable* new_target_var = info->scope()->new_target_var(); | 251 Variable* new_target_var = scope()->new_target_var(); |
253 if (new_target_var != nullptr) { | 252 if (new_target_var != nullptr) { |
254 Comment cmnt(masm_, "[ new.target"); | 253 Comment cmnt(masm_, "[ new.target"); |
255 SetVar(new_target_var, x3, x0, x2); | 254 SetVar(new_target_var, x3, x0, x2); |
256 } | 255 } |
257 | 256 |
258 // Possibly allocate RestParameters | 257 // Possibly allocate RestParameters |
259 int rest_index; | 258 int rest_index; |
260 Variable* rest_param = info->scope()->rest_parameter(&rest_index); | 259 Variable* rest_param = scope()->rest_parameter(&rest_index); |
261 if (rest_param) { | 260 if (rest_param) { |
262 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 261 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
263 if (!function_in_register_x1) { | 262 if (!function_in_register_x1) { |
264 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 263 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
265 } | 264 } |
266 FastNewRestParameterStub stub(isolate()); | 265 FastNewRestParameterStub stub(isolate()); |
267 __ CallStub(&stub); | 266 __ CallStub(&stub); |
268 function_in_register_x1 = false; | 267 function_in_register_x1 = false; |
269 SetVar(rest_param, x0, x1, x2); | 268 SetVar(rest_param, x0, x1, x2); |
270 } | 269 } |
271 | 270 |
272 Variable* arguments = info->scope()->arguments(); | 271 Variable* arguments = scope()->arguments(); |
273 if (arguments != NULL) { | 272 if (arguments != NULL) { |
274 // Function uses arguments object. | 273 // Function uses arguments object. |
275 Comment cmnt(masm_, "[ Allocate arguments object"); | 274 Comment cmnt(masm_, "[ Allocate arguments object"); |
276 if (!function_in_register_x1) { | 275 if (!function_in_register_x1) { |
277 // Load this again, if it's used by the local context below. | 276 // Load this again, if it's used by the local context below. |
278 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 277 __ Ldr(x1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
279 } | 278 } |
280 if (is_strict(language_mode()) || !has_simple_parameters()) { | 279 if (is_strict(language_mode()) || !has_simple_parameters()) { |
281 FastNewStrictArgumentsStub stub(isolate()); | 280 FastNewStrictArgumentsStub stub(isolate()); |
282 __ CallStub(&stub); | 281 __ CallStub(&stub); |
(...skipping 3400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3683 __ Str(value, MemOperand(fp, frame_offset)); | 3682 __ Str(value, MemOperand(fp, frame_offset)); |
3684 } | 3683 } |
3685 | 3684 |
3686 | 3685 |
3687 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 3686 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
3688 __ Ldr(dst, ContextMemOperand(cp, context_index)); | 3687 __ Ldr(dst, ContextMemOperand(cp, context_index)); |
3689 } | 3688 } |
3690 | 3689 |
3691 | 3690 |
3692 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 3691 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
3693 DeclarationScope* closure_scope = scope()->GetClosureScope(); | 3692 Scope* closure_scope = scope()->ClosureScope(); |
3694 if (closure_scope->is_script_scope() || | 3693 if (closure_scope->is_script_scope() || |
3695 closure_scope->is_module_scope()) { | 3694 closure_scope->is_module_scope()) { |
3696 // Contexts nested in the native context have a canonical empty function | 3695 // Contexts nested in the native context have a canonical empty function |
3697 // as their closure, not the anonymous closure containing the global | 3696 // as their closure, not the anonymous closure containing the global |
3698 // code. | 3697 // code. |
3699 DCHECK(kSmiTag == 0); | 3698 DCHECK(kSmiTag == 0); |
3700 __ LoadNativeContextSlot(Context::CLOSURE_INDEX, x10); | 3699 __ LoadNativeContextSlot(Context::CLOSURE_INDEX, x10); |
3701 } else if (closure_scope->is_eval_scope()) { | 3700 } else if (closure_scope->is_eval_scope()) { |
3702 // Contexts created by a call to eval have the same closure as the | 3701 // Contexts created by a call to eval have the same closure as the |
3703 // context calling eval, not the anonymous closure containing the eval | 3702 // context calling eval, not the anonymous closure containing the eval |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3854 } | 3853 } |
3855 | 3854 |
3856 return INTERRUPT; | 3855 return INTERRUPT; |
3857 } | 3856 } |
3858 | 3857 |
3859 | 3858 |
3860 } // namespace internal | 3859 } // namespace internal |
3861 } // namespace v8 | 3860 } // namespace v8 |
3862 | 3861 |
3863 #endif // V8_TARGET_ARCH_ARM64 | 3862 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |