| 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 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/ast-loop-assignment-analyzer.h" | 9 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 10 #include "src/compiler/control-builders.h" | 10 #include "src/compiler/control-builders.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 } | 566 } |
| 567 | 567 |
| 568 | 568 |
| 569 void AstGraphBuilder::CreateGraphBody(bool stack_check) { | 569 void AstGraphBuilder::CreateGraphBody(bool stack_check) { |
| 570 DeclarationScope* scope = info()->scope(); | 570 DeclarationScope* scope = info()->scope(); |
| 571 | 571 |
| 572 // Build the arguments object if it is used. | 572 // Build the arguments object if it is used. |
| 573 BuildArgumentsObject(scope->arguments()); | 573 BuildArgumentsObject(scope->arguments()); |
| 574 | 574 |
| 575 // Build rest arguments array if it is used. | 575 // Build rest arguments array if it is used. |
| 576 int rest_index = 0; | 576 Variable* rest_parameter = scope->rest_parameter(); |
| 577 Variable* rest_parameter = scope->rest_parameter(&rest_index); | 577 BuildRestArgumentsArray(rest_parameter); |
| 578 BuildRestArgumentsArray(rest_parameter, rest_index); | |
| 579 | 578 |
| 580 // Build assignment to {.this_function} variable if it is used. | 579 // Build assignment to {.this_function} variable if it is used. |
| 581 BuildThisFunctionVariable(scope->this_function_var()); | 580 BuildThisFunctionVariable(scope->this_function_var()); |
| 582 | 581 |
| 583 // Build assignment to {new.target} variable if it is used. | 582 // Build assignment to {new.target} variable if it is used. |
| 584 BuildNewTargetVariable(scope->new_target_var()); | 583 BuildNewTargetVariable(scope->new_target_var()); |
| 585 | 584 |
| 586 // Emit tracing call if requested to do so. | 585 // Emit tracing call if requested to do so. |
| 587 if (FLAG_trace) { | 586 if (FLAG_trace) { |
| 588 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter)); | 587 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter)); |
| (...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3206 PrepareFrameState(object, BailoutId::None()); | 3205 PrepareFrameState(object, BailoutId::None()); |
| 3207 | 3206 |
| 3208 // Assign the object to the {arguments} variable. This should never lazy | 3207 // Assign the object to the {arguments} variable. This should never lazy |
| 3209 // deopt, so it is fine to send invalid bailout id. | 3208 // deopt, so it is fine to send invalid bailout id. |
| 3210 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 3209 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
| 3211 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), | 3210 BuildVariableAssignment(arguments, object, Token::ASSIGN, VectorSlotPair(), |
| 3212 BailoutId::None()); | 3211 BailoutId::None()); |
| 3213 return object; | 3212 return object; |
| 3214 } | 3213 } |
| 3215 | 3214 |
| 3216 | 3215 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest) { |
| 3217 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { | |
| 3218 if (rest == nullptr) return nullptr; | 3216 if (rest == nullptr) return nullptr; |
| 3219 | 3217 |
| 3220 // Allocate and initialize a new arguments object. | 3218 // Allocate and initialize a new arguments object. |
| 3221 CreateArgumentsType type = CreateArgumentsType::kRestParameter; | 3219 CreateArgumentsType type = CreateArgumentsType::kRestParameter; |
| 3222 const Operator* op = javascript()->CreateArguments(type); | 3220 const Operator* op = javascript()->CreateArguments(type); |
| 3223 Node* object = NewNode(op, GetFunctionClosure()); | 3221 Node* object = NewNode(op, GetFunctionClosure()); |
| 3224 PrepareFrameState(object, BailoutId::None()); | 3222 PrepareFrameState(object, BailoutId::None()); |
| 3225 | 3223 |
| 3226 // Assign the object to the {rest} variable. This should never lazy | 3224 // Assign the object to the {rest} variable. This should never lazy |
| 3227 // deopt, so it is fine to send invalid bailout id. | 3225 // deopt, so it is fine to send invalid bailout id. |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4325 // Phi does not exist yet, introduce one. | 4323 // Phi does not exist yet, introduce one. |
| 4326 value = NewPhi(inputs, value, control); | 4324 value = NewPhi(inputs, value, control); |
| 4327 value->ReplaceInput(inputs - 1, other); | 4325 value->ReplaceInput(inputs - 1, other); |
| 4328 } | 4326 } |
| 4329 return value; | 4327 return value; |
| 4330 } | 4328 } |
| 4331 | 4329 |
| 4332 } // namespace compiler | 4330 } // namespace compiler |
| 4333 } // namespace internal | 4331 } // namespace internal |
| 4334 } // namespace v8 | 4332 } // namespace v8 |
| OLD | NEW |