| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 function_in_register_r4 = false; | 202 function_in_register_r4 = false; |
| 203 // Context is returned in r3. It replaces the context passed to us. | 203 // Context is returned in r3. It replaces the context passed to us. |
| 204 // It's saved in the stack and kept live in cp. | 204 // It's saved in the stack and kept live in cp. |
| 205 __ mr(cp, r3); | 205 __ mr(cp, r3); |
| 206 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 206 __ StoreP(r3, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 207 // Copy any necessary parameters into the context. | 207 // Copy any necessary parameters into the context. |
| 208 int num_parameters = info->scope()->num_parameters(); | 208 int num_parameters = info->scope()->num_parameters(); |
| 209 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; | 209 int first_parameter = info->scope()->has_this_declaration() ? -1 : 0; |
| 210 for (int i = first_parameter; i < num_parameters; i++) { | 210 for (int i = first_parameter; i < num_parameters; i++) { |
| 211 Variable* var = | 211 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
| 212 (i == -1) ? info->scope()->receiver() : info->scope()->parameter(i); | |
| 213 if (var->IsContextSlot()) { | 212 if (var->IsContextSlot()) { |
| 214 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 213 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 215 (num_parameters - 1 - i) * kPointerSize; | 214 (num_parameters - 1 - i) * kPointerSize; |
| 216 // Load parameter from stack. | 215 // Load parameter from stack. |
| 217 __ LoadP(r3, MemOperand(fp, parameter_offset), r0); | 216 __ LoadP(r3, MemOperand(fp, parameter_offset), r0); |
| 218 // Store it in the context. | 217 // Store it in the context. |
| 219 MemOperand target = ContextMemOperand(cp, var->index()); | 218 MemOperand target = ContextMemOperand(cp, var->index()); |
| 220 __ StoreP(r3, target, r0); | 219 __ StoreP(r3, target, r0); |
| 221 | 220 |
| 222 // Update the write barrier. | 221 // Update the write barrier. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 234 } | 233 } |
| 235 | 234 |
| 236 // Register holding this function and new target are both trashed in case we | 235 // Register holding this function and new target are both trashed in case we |
| 237 // bailout here. But since that can happen only when new target is not used | 236 // bailout here. But since that can happen only when new target is not used |
| 238 // and we allocate a context, the value of |function_in_register| is correct. | 237 // and we allocate a context, the value of |function_in_register| is correct. |
| 239 PrepareForBailoutForId(BailoutId::FunctionContext(), | 238 PrepareForBailoutForId(BailoutId::FunctionContext(), |
| 240 BailoutState::NO_REGISTERS); | 239 BailoutState::NO_REGISTERS); |
| 241 | 240 |
| 242 // Possibly set up a local binding to the this function which is used in | 241 // Possibly set up a local binding to the this function which is used in |
| 243 // derived constructors with super calls. | 242 // derived constructors with super calls. |
| 244 Variable* this_function_var = info->scope()->this_function_var(); | 243 Variable* this_function_var = scope()->this_function_var(); |
| 245 if (this_function_var != nullptr) { | 244 if (this_function_var != nullptr) { |
| 246 Comment cmnt(masm_, "[ This function"); | 245 Comment cmnt(masm_, "[ This function"); |
| 247 if (!function_in_register_r4) { | 246 if (!function_in_register_r4) { |
| 248 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 247 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 249 // The write barrier clobbers register again, keep it marked as such. | 248 // The write barrier clobbers register again, keep it marked as such. |
| 250 } | 249 } |
| 251 SetVar(this_function_var, r4, r3, r5); | 250 SetVar(this_function_var, r4, r3, r5); |
| 252 } | 251 } |
| 253 | 252 |
| 254 // Possibly set up a local binding to the new target value. | 253 // Possibly set up a local binding to the new target value. |
| 255 Variable* new_target_var = info->scope()->new_target_var(); | 254 Variable* new_target_var = scope()->new_target_var(); |
| 256 if (new_target_var != nullptr) { | 255 if (new_target_var != nullptr) { |
| 257 Comment cmnt(masm_, "[ new.target"); | 256 Comment cmnt(masm_, "[ new.target"); |
| 258 SetVar(new_target_var, r6, r3, r5); | 257 SetVar(new_target_var, r6, r3, r5); |
| 259 } | 258 } |
| 260 | 259 |
| 261 // Possibly allocate RestParameters | 260 // Possibly allocate RestParameters |
| 262 int rest_index; | 261 int rest_index; |
| 263 Variable* rest_param = info->scope()->rest_parameter(&rest_index); | 262 Variable* rest_param = scope()->rest_parameter(&rest_index); |
| 264 if (rest_param) { | 263 if (rest_param) { |
| 265 Comment cmnt(masm_, "[ Allocate rest parameter array"); | 264 Comment cmnt(masm_, "[ Allocate rest parameter array"); |
| 266 if (!function_in_register_r4) { | 265 if (!function_in_register_r4) { |
| 267 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 266 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 268 } | 267 } |
| 269 FastNewRestParameterStub stub(isolate()); | 268 FastNewRestParameterStub stub(isolate()); |
| 270 __ CallStub(&stub); | 269 __ CallStub(&stub); |
| 271 function_in_register_r4 = false; | 270 function_in_register_r4 = false; |
| 272 SetVar(rest_param, r3, r4, r5); | 271 SetVar(rest_param, r3, r4, r5); |
| 273 } | 272 } |
| 274 | 273 |
| 275 Variable* arguments = info->scope()->arguments(); | 274 Variable* arguments = scope()->arguments(); |
| 276 if (arguments != NULL) { | 275 if (arguments != NULL) { |
| 277 // Function uses arguments object. | 276 // Function uses arguments object. |
| 278 Comment cmnt(masm_, "[ Allocate arguments object"); | 277 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 279 if (!function_in_register_r4) { | 278 if (!function_in_register_r4) { |
| 280 // Load this again, if it's used by the local context below. | 279 // Load this again, if it's used by the local context below. |
| 281 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 280 __ LoadP(r4, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 282 } | 281 } |
| 283 if (is_strict(language_mode()) || !has_simple_parameters()) { | 282 if (is_strict(language_mode()) || !has_simple_parameters()) { |
| 284 FastNewStrictArgumentsStub stub(isolate()); | 283 FastNewStrictArgumentsStub stub(isolate()); |
| 285 __ CallStub(&stub); | 284 __ CallStub(&stub); |
| (...skipping 3325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3611 __ StoreP(value, MemOperand(fp, frame_offset), r0); | 3610 __ StoreP(value, MemOperand(fp, frame_offset), r0); |
| 3612 } | 3611 } |
| 3613 | 3612 |
| 3614 | 3613 |
| 3615 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 3614 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 3616 __ LoadP(dst, ContextMemOperand(cp, context_index), r0); | 3615 __ LoadP(dst, ContextMemOperand(cp, context_index), r0); |
| 3617 } | 3616 } |
| 3618 | 3617 |
| 3619 | 3618 |
| 3620 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 3619 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 3621 DeclarationScope* closure_scope = scope()->GetClosureScope(); | 3620 Scope* closure_scope = scope()->ClosureScope(); |
| 3622 if (closure_scope->is_script_scope() || | 3621 if (closure_scope->is_script_scope() || |
| 3623 closure_scope->is_module_scope()) { | 3622 closure_scope->is_module_scope()) { |
| 3624 // Contexts nested in the native context have a canonical empty function | 3623 // Contexts nested in the native context have a canonical empty function |
| 3625 // as their closure, not the anonymous closure containing the global | 3624 // as their closure, not the anonymous closure containing the global |
| 3626 // code. | 3625 // code. |
| 3627 __ LoadNativeContextSlot(Context::CLOSURE_INDEX, ip); | 3626 __ LoadNativeContextSlot(Context::CLOSURE_INDEX, ip); |
| 3628 } else if (closure_scope->is_eval_scope()) { | 3627 } else if (closure_scope->is_eval_scope()) { |
| 3629 // Contexts created by a call to eval have the same closure as the | 3628 // Contexts created by a call to eval have the same closure as the |
| 3630 // context calling eval, not the anonymous closure containing the eval | 3629 // context calling eval, not the anonymous closure containing the eval |
| 3631 // code. Fetch it from the context. | 3630 // code. Fetch it from the context. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3767 | 3766 |
| 3768 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); | 3767 DCHECK(Assembler::IsCrSet(Assembler::instr_at(cmp_address))); |
| 3769 | 3768 |
| 3770 DCHECK(interrupt_address == | 3769 DCHECK(interrupt_address == |
| 3771 isolate->builtins()->OnStackReplacement()->entry()); | 3770 isolate->builtins()->OnStackReplacement()->entry()); |
| 3772 return ON_STACK_REPLACEMENT; | 3771 return ON_STACK_REPLACEMENT; |
| 3773 } | 3772 } |
| 3774 } // namespace internal | 3773 } // namespace internal |
| 3775 } // namespace v8 | 3774 } // namespace v8 |
| 3776 #endif // V8_TARGET_ARCH_PPC | 3775 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |