| 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/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/js-type-feedback.h" | 10 #include "src/compiler/js-type-feedback.h" |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 // point, there is no need to really emit an actual call. Optimize this! | 1413 // point, there is no need to really emit an actual call. Optimize this! |
| 1414 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kMaxSmi, 0)); | 1414 Node* guard = NewNode(javascript()->CallRuntime(Runtime::kMaxSmi, 0)); |
| 1415 PrepareFrameState(guard, stmt->HandlerId()); | 1415 PrepareFrameState(guard, stmt->HandlerId()); |
| 1416 | 1416 |
| 1417 // Clear message object as we enter the catch block. | 1417 // Clear message object as we enter the catch block. |
| 1418 Node* the_hole = jsgraph()->TheHoleConstant(); | 1418 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 1419 BuildStoreExternal(message_object, kMachAnyTagged, the_hole); | 1419 BuildStoreExternal(message_object, kMachAnyTagged, the_hole); |
| 1420 | 1420 |
| 1421 // Create a catch scope that binds the exception. | 1421 // Create a catch scope that binds the exception. |
| 1422 Node* exception = try_control.GetExceptionNode(); | 1422 Node* exception = try_control.GetExceptionNode(); |
| 1423 Unique<String> name = MakeUnique(stmt->variable()->name()); | 1423 Handle<String> name = stmt->variable()->name(); |
| 1424 const Operator* op = javascript()->CreateCatchContext(name); | 1424 const Operator* op = javascript()->CreateCatchContext(name); |
| 1425 Node* context = NewNode(op, exception, GetFunctionClosureForContext()); | 1425 Node* context = NewNode(op, exception, GetFunctionClosureForContext()); |
| 1426 | 1426 |
| 1427 // Evaluate the catch-block. | 1427 // Evaluate the catch-block. |
| 1428 VisitInScope(stmt->catch_block(), stmt->scope(), context); | 1428 VisitInScope(stmt->catch_block(), stmt->scope(), context); |
| 1429 try_control.EndCatch(); | 1429 try_control.EndCatch(); |
| 1430 | 1430 |
| 1431 // TODO(mstarzinger): Remove bailout once everything works. | 1431 // TODO(mstarzinger): Remove bailout once everything works. |
| 1432 if (!FLAG_turbo_try_catch) SetStackOverflow(); | 1432 if (!FLAG_turbo_try_catch) SetStackOverflow(); |
| 1433 } | 1433 } |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3610 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, | 3610 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, |
| 3611 const VectorSlotPair& feedback) { | 3611 const VectorSlotPair& feedback) { |
| 3612 const Operator* op = javascript()->LoadProperty(feedback, language_mode()); | 3612 const Operator* op = javascript()->LoadProperty(feedback, language_mode()); |
| 3613 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); | 3613 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); |
| 3614 return Record(js_type_feedback_, node, feedback.slot()); | 3614 return Record(js_type_feedback_, node, feedback.slot()); |
| 3615 } | 3615 } |
| 3616 | 3616 |
| 3617 | 3617 |
| 3618 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, | 3618 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, |
| 3619 const VectorSlotPair& feedback) { | 3619 const VectorSlotPair& feedback) { |
| 3620 const Operator* op = | 3620 const Operator* op = javascript()->LoadNamed(name, feedback, language_mode()); |
| 3621 javascript()->LoadNamed(MakeUnique(name), feedback, language_mode()); | |
| 3622 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); | 3621 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); |
| 3623 return Record(js_type_feedback_, node, feedback.slot()); | 3622 return Record(js_type_feedback_, node, feedback.slot()); |
| 3624 } | 3623 } |
| 3625 | 3624 |
| 3626 | 3625 |
| 3627 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, | 3626 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, |
| 3628 const VectorSlotPair& feedback, | 3627 const VectorSlotPair& feedback, |
| 3629 TypeFeedbackId id) { | 3628 TypeFeedbackId id) { |
| 3630 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); | 3629 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); |
| 3631 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); | 3630 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); |
| 3632 if (FLAG_vector_stores) { | 3631 if (FLAG_vector_stores) { |
| 3633 return Record(js_type_feedback_, node, feedback.slot()); | 3632 return Record(js_type_feedback_, node, feedback.slot()); |
| 3634 } | 3633 } |
| 3635 return Record(js_type_feedback_, node, id); | 3634 return Record(js_type_feedback_, node, id); |
| 3636 } | 3635 } |
| 3637 | 3636 |
| 3638 | 3637 |
| 3639 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, | 3638 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, |
| 3640 Node* value, | 3639 Node* value, |
| 3641 const VectorSlotPair& feedback, | 3640 const VectorSlotPair& feedback, |
| 3642 TypeFeedbackId id) { | 3641 TypeFeedbackId id) { |
| 3643 const Operator* op = | 3642 const Operator* op = |
| 3644 javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback); | 3643 javascript()->StoreNamed(language_mode(), name, feedback); |
| 3645 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); | 3644 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); |
| 3646 if (FLAG_vector_stores) { | 3645 if (FLAG_vector_stores) { |
| 3647 return Record(js_type_feedback_, node, feedback.slot()); | 3646 return Record(js_type_feedback_, node, feedback.slot()); |
| 3648 } | 3647 } |
| 3649 return Record(js_type_feedback_, node, id); | 3648 return Record(js_type_feedback_, node, id); |
| 3650 } | 3649 } |
| 3651 | 3650 |
| 3652 | 3651 |
| 3653 Node* AstGraphBuilder::BuildNamedSuperLoad(Node* receiver, Node* home_object, | 3652 Node* AstGraphBuilder::BuildNamedSuperLoad(Node* receiver, Node* home_object, |
| 3654 Handle<Name> name, | 3653 Handle<Name> name, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3694 const Operator* op = javascript()->CallRuntime(function_id, 4); | 3693 const Operator* op = javascript()->CallRuntime(function_id, 4); |
| 3695 Node* node = NewNode(op, receiver, home_object, name_node, value); | 3694 Node* node = NewNode(op, receiver, home_object, name_node, value); |
| 3696 return Record(js_type_feedback_, node, id); | 3695 return Record(js_type_feedback_, node, id); |
| 3697 } | 3696 } |
| 3698 | 3697 |
| 3699 | 3698 |
| 3700 Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global, | 3699 Node* AstGraphBuilder::BuildGlobalLoad(Node* script_context, Node* global, |
| 3701 Handle<Name> name, | 3700 Handle<Name> name, |
| 3702 const VectorSlotPair& feedback, | 3701 const VectorSlotPair& feedback, |
| 3703 TypeofMode typeof_mode, int slot_index) { | 3702 TypeofMode typeof_mode, int slot_index) { |
| 3704 const Operator* op = javascript()->LoadGlobal(MakeUnique(name), feedback, | 3703 const Operator* op = |
| 3705 typeof_mode, slot_index); | 3704 javascript()->LoadGlobal(name, feedback, typeof_mode, slot_index); |
| 3706 Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector()); | 3705 Node* node = NewNode(op, script_context, global, BuildLoadFeedbackVector()); |
| 3707 return Record(js_type_feedback_, node, feedback.slot()); | 3706 return Record(js_type_feedback_, node, feedback.slot()); |
| 3708 } | 3707 } |
| 3709 | 3708 |
| 3710 | 3709 |
| 3711 Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global, | 3710 Node* AstGraphBuilder::BuildGlobalStore(Node* script_context, Node* global, |
| 3712 Handle<Name> name, Node* value, | 3711 Handle<Name> name, Node* value, |
| 3713 const VectorSlotPair& feedback, | 3712 const VectorSlotPair& feedback, |
| 3714 TypeFeedbackId id, int slot_index) { | 3713 TypeFeedbackId id, int slot_index) { |
| 3715 const Operator* op = javascript()->StoreGlobal( | 3714 const Operator* op = |
| 3716 language_mode(), MakeUnique(name), feedback, slot_index); | 3715 javascript()->StoreGlobal(language_mode(), name, feedback, slot_index); |
| 3717 Node* node = | 3716 Node* node = |
| 3718 NewNode(op, script_context, global, value, BuildLoadFeedbackVector()); | 3717 NewNode(op, script_context, global, value, BuildLoadFeedbackVector()); |
| 3719 if (FLAG_vector_stores) { | 3718 if (FLAG_vector_stores) { |
| 3720 return Record(js_type_feedback_, node, feedback.slot()); | 3719 return Record(js_type_feedback_, node, feedback.slot()); |
| 3721 } | 3720 } |
| 3722 return Record(js_type_feedback_, node, id); | 3721 return Record(js_type_feedback_, node, id); |
| 3723 } | 3722 } |
| 3724 | 3723 |
| 3725 | 3724 |
| 3726 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { | 3725 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3791 | 3790 |
| 3792 Node* AstGraphBuilder::BuildToBoolean(Node* input) { | 3791 Node* AstGraphBuilder::BuildToBoolean(Node* input) { |
| 3793 // TODO(bmeurer, mstarzinger): Refactor this into a separate optimization | 3792 // TODO(bmeurer, mstarzinger): Refactor this into a separate optimization |
| 3794 // method. | 3793 // method. |
| 3795 switch (input->opcode()) { | 3794 switch (input->opcode()) { |
| 3796 case IrOpcode::kNumberConstant: { | 3795 case IrOpcode::kNumberConstant: { |
| 3797 NumberMatcher m(input); | 3796 NumberMatcher m(input); |
| 3798 return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN()); | 3797 return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN()); |
| 3799 } | 3798 } |
| 3800 case IrOpcode::kHeapConstant: { | 3799 case IrOpcode::kHeapConstant: { |
| 3801 Handle<HeapObject> object = HeapObjectMatcher(input).Value().handle(); | 3800 Handle<HeapObject> object = HeapObjectMatcher(input).Value(); |
| 3802 return jsgraph_->BooleanConstant(object->BooleanValue()); | 3801 return jsgraph_->BooleanConstant(object->BooleanValue()); |
| 3803 } | 3802 } |
| 3804 case IrOpcode::kJSEqual: | 3803 case IrOpcode::kJSEqual: |
| 3805 case IrOpcode::kJSNotEqual: | 3804 case IrOpcode::kJSNotEqual: |
| 3806 case IrOpcode::kJSStrictEqual: | 3805 case IrOpcode::kJSStrictEqual: |
| 3807 case IrOpcode::kJSStrictNotEqual: | 3806 case IrOpcode::kJSStrictNotEqual: |
| 3808 case IrOpcode::kJSLessThan: | 3807 case IrOpcode::kJSLessThan: |
| 3809 case IrOpcode::kJSLessThanOrEqual: | 3808 case IrOpcode::kJSLessThanOrEqual: |
| 3810 case IrOpcode::kJSGreaterThan: | 3809 case IrOpcode::kJSGreaterThan: |
| 3811 case IrOpcode::kJSGreaterThanOrEqual: | 3810 case IrOpcode::kJSGreaterThanOrEqual: |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4293 // Phi does not exist yet, introduce one. | 4292 // Phi does not exist yet, introduce one. |
| 4294 value = NewPhi(inputs, value, control); | 4293 value = NewPhi(inputs, value, control); |
| 4295 value->ReplaceInput(inputs - 1, other); | 4294 value->ReplaceInput(inputs - 1, other); |
| 4296 } | 4295 } |
| 4297 return value; | 4296 return value; |
| 4298 } | 4297 } |
| 4299 | 4298 |
| 4300 } // namespace compiler | 4299 } // namespace compiler |
| 4301 } // namespace internal | 4300 } // namespace internal |
| 4302 } // namespace v8 | 4301 } // namespace v8 |
| OLD | NEW |