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