| 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 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3008 } | 3008 } |
| 3009 Node* value = NewNode(javascript()->TypeOf(), operand); | 3009 Node* value = NewNode(javascript()->TypeOf(), operand); |
| 3010 ast_context()->ProduceValue(value); | 3010 ast_context()->ProduceValue(value); |
| 3011 } | 3011 } |
| 3012 | 3012 |
| 3013 | 3013 |
| 3014 void AstGraphBuilder::VisitNot(UnaryOperation* expr) { | 3014 void AstGraphBuilder::VisitNot(UnaryOperation* expr) { |
| 3015 VisitForValue(expr->expression()); | 3015 VisitForValue(expr->expression()); |
| 3016 Node* operand = environment()->Pop(); | 3016 Node* operand = environment()->Pop(); |
| 3017 Node* input = BuildToBoolean(operand, expr->expression()->test_id()); | 3017 Node* input = BuildToBoolean(operand, expr->expression()->test_id()); |
| 3018 Node* value = NewNode(common()->Select(kMachAnyTagged), input, | 3018 Node* value = NewNode(common()->Select(MachineRepresentation::kTagged), input, |
| 3019 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | 3019 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); |
| 3020 ast_context()->ProduceValue(value); | 3020 ast_context()->ProduceValue(value); |
| 3021 } | 3021 } |
| 3022 | 3022 |
| 3023 | 3023 |
| 3024 void AstGraphBuilder::VisitComma(BinaryOperation* expr) { | 3024 void AstGraphBuilder::VisitComma(BinaryOperation* expr) { |
| 3025 VisitForEffect(expr->left()); | 3025 VisitForEffect(expr->left()); |
| 3026 Visit(expr->right()); | 3026 Visit(expr->right()); |
| 3027 ast_context()->ReplaceValue(); | 3027 ast_context()->ReplaceValue(); |
| 3028 } | 3028 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3250 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), | 3250 BuildVariableAssignment(new_target_var, object, Token::INIT, VectorSlotPair(), |
| 3251 BailoutId::None(), states); | 3251 BailoutId::None(), states); |
| 3252 return object; | 3252 return object; |
| 3253 } | 3253 } |
| 3254 | 3254 |
| 3255 | 3255 |
| 3256 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, | 3256 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, |
| 3257 Node* not_hole) { | 3257 Node* not_hole) { |
| 3258 Node* the_hole = jsgraph()->TheHoleConstant(); | 3258 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 3259 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); | 3259 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); |
| 3260 return NewNode(common()->Select(kMachAnyTagged, BranchHint::kFalse), check, | 3260 return NewNode( |
| 3261 for_hole, not_hole); | 3261 common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse), |
| 3262 check, for_hole, not_hole); |
| 3262 } | 3263 } |
| 3263 | 3264 |
| 3264 | 3265 |
| 3265 Node* AstGraphBuilder::BuildHoleCheckThenThrow(Node* value, Variable* variable, | 3266 Node* AstGraphBuilder::BuildHoleCheckThenThrow(Node* value, Variable* variable, |
| 3266 Node* not_hole, | 3267 Node* not_hole, |
| 3267 BailoutId bailout_id) { | 3268 BailoutId bailout_id) { |
| 3268 IfBuilder hole_check(this); | 3269 IfBuilder hole_check(this); |
| 3269 Node* the_hole = jsgraph()->TheHoleConstant(); | 3270 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 3270 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); | 3271 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); |
| 3271 hole_check.If(check); | 3272 hole_check.If(check); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3646 Node* AstGraphBuilder::BuildGlobalStore(Handle<Name> name, Node* value, | 3647 Node* AstGraphBuilder::BuildGlobalStore(Handle<Name> name, Node* value, |
| 3647 const VectorSlotPair& feedback) { | 3648 const VectorSlotPair& feedback) { |
| 3648 const Operator* op = | 3649 const Operator* op = |
| 3649 javascript()->StoreGlobal(language_mode(), name, feedback); | 3650 javascript()->StoreGlobal(language_mode(), name, feedback); |
| 3650 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); | 3651 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); |
| 3651 return node; | 3652 return node; |
| 3652 } | 3653 } |
| 3653 | 3654 |
| 3654 | 3655 |
| 3655 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { | 3656 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { |
| 3656 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 3657 return NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), object, |
| 3657 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); | 3658 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); |
| 3658 } | 3659 } |
| 3659 | 3660 |
| 3660 | 3661 |
| 3661 Node* AstGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { | 3662 Node* AstGraphBuilder::BuildLoadImmutableObjectField(Node* object, int offset) { |
| 3662 return graph()->NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, | 3663 return graph()->NewNode(jsgraph()->machine()->Load(MachineType::AnyTagged()), |
| 3664 object, |
| 3663 jsgraph()->IntPtrConstant(offset - kHeapObjectTag), | 3665 jsgraph()->IntPtrConstant(offset - kHeapObjectTag), |
| 3664 graph()->start(), graph()->start()); | 3666 graph()->start(), graph()->start()); |
| 3665 } | 3667 } |
| 3666 | 3668 |
| 3667 | 3669 |
| 3668 Node* AstGraphBuilder::BuildLoadGlobalObject() { | 3670 Node* AstGraphBuilder::BuildLoadGlobalObject() { |
| 3669 return BuildLoadNativeContextField(Context::EXTENSION_INDEX); | 3671 return BuildLoadNativeContextField(Context::EXTENSION_INDEX); |
| 3670 } | 3672 } |
| 3671 | 3673 |
| 3672 | 3674 |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4257 osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry) | 4259 osr_context = (i == last) ? graph->NewNode(op_inner, osr_loop_entry) |
| 4258 : graph->NewNode(op, osr_context, osr_context, | 4260 : graph->NewNode(op, osr_context, osr_context, |
| 4259 osr_loop_entry); | 4261 osr_loop_entry); |
| 4260 contexts()->at(i) = builder_->MergeValue(context, osr_context, control); | 4262 contexts()->at(i) = builder_->MergeValue(context, osr_context, control); |
| 4261 } | 4263 } |
| 4262 } | 4264 } |
| 4263 } | 4265 } |
| 4264 | 4266 |
| 4265 | 4267 |
| 4266 Node* AstGraphBuilder::NewPhi(int count, Node* input, Node* control) { | 4268 Node* AstGraphBuilder::NewPhi(int count, Node* input, Node* control) { |
| 4267 const Operator* phi_op = common()->Phi(kMachAnyTagged, count); | 4269 const Operator* phi_op = common()->Phi(MachineRepresentation::kTagged, count); |
| 4268 Node** buffer = EnsureInputBufferSize(count + 1); | 4270 Node** buffer = EnsureInputBufferSize(count + 1); |
| 4269 MemsetPointer(buffer, input, count); | 4271 MemsetPointer(buffer, input, count); |
| 4270 buffer[count] = control; | 4272 buffer[count] = control; |
| 4271 return graph()->NewNode(phi_op, count + 1, buffer, true); | 4273 return graph()->NewNode(phi_op, count + 1, buffer, true); |
| 4272 } | 4274 } |
| 4273 | 4275 |
| 4274 | 4276 |
| 4275 // TODO(mstarzinger): Revisit this once we have proper effect states. | 4277 // TODO(mstarzinger): Revisit this once we have proper effect states. |
| 4276 Node* AstGraphBuilder::NewEffectPhi(int count, Node* input, Node* control) { | 4278 Node* AstGraphBuilder::NewEffectPhi(int count, Node* input, Node* control) { |
| 4277 const Operator* phi_op = common()->EffectPhi(count); | 4279 const Operator* phi_op = common()->EffectPhi(count); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4319 return value; | 4321 return value; |
| 4320 } | 4322 } |
| 4321 | 4323 |
| 4322 | 4324 |
| 4323 Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) { | 4325 Node* AstGraphBuilder::MergeValue(Node* value, Node* other, Node* control) { |
| 4324 int inputs = control->op()->ControlInputCount(); | 4326 int inputs = control->op()->ControlInputCount(); |
| 4325 if (value->opcode() == IrOpcode::kPhi && | 4327 if (value->opcode() == IrOpcode::kPhi && |
| 4326 NodeProperties::GetControlInput(value) == control) { | 4328 NodeProperties::GetControlInput(value) == control) { |
| 4327 // Phi already exists, add input. | 4329 // Phi already exists, add input. |
| 4328 value->InsertInput(graph_zone(), inputs - 1, other); | 4330 value->InsertInput(graph_zone(), inputs - 1, other); |
| 4329 NodeProperties::ChangeOp(value, common()->Phi(kMachAnyTagged, inputs)); | 4331 NodeProperties::ChangeOp( |
| 4332 value, common()->Phi(MachineRepresentation::kTagged, inputs)); |
| 4330 } else if (value != other) { | 4333 } else if (value != other) { |
| 4331 // Phi does not exist yet, introduce one. | 4334 // Phi does not exist yet, introduce one. |
| 4332 value = NewPhi(inputs, value, control); | 4335 value = NewPhi(inputs, value, control); |
| 4333 value->ReplaceInput(inputs - 1, other); | 4336 value->ReplaceInput(inputs - 1, other); |
| 4334 } | 4337 } |
| 4335 return value; | 4338 return value; |
| 4336 } | 4339 } |
| 4337 | 4340 |
| 4338 } // namespace compiler | 4341 } // namespace compiler |
| 4339 } // namespace internal | 4342 } // namespace internal |
| 4340 } // namespace v8 | 4343 } // namespace v8 |
| OLD | NEW |