OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/bytecode-branch-analysis.h" | 10 #include "src/compiler/bytecode-branch-analysis.h" |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 Node* value = environment()->LookupAccumulator(); | 734 Node* value = environment()->LookupAccumulator(); |
735 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); | 735 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); |
736 } | 736 } |
737 | 737 |
738 void BytecodeGraphBuilder::VisitMov() { | 738 void BytecodeGraphBuilder::VisitMov() { |
739 Node* value = | 739 Node* value = |
740 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 740 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
741 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); | 741 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); |
742 } | 742 } |
743 | 743 |
744 Node* BytecodeGraphBuilder::BuildLoadGlobal(uint32_t feedback_slot_index, | 744 Node* BytecodeGraphBuilder::BuildLoadGlobal(Handle<Name> name, |
| 745 uint32_t feedback_slot_index, |
745 TypeofMode typeof_mode) { | 746 TypeofMode typeof_mode) { |
746 VectorSlotPair feedback = CreateVectorSlotPair(feedback_slot_index); | 747 VectorSlotPair feedback = CreateVectorSlotPair(feedback_slot_index); |
747 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, | 748 DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, |
748 feedback_vector()->GetKind(feedback.slot())); | 749 feedback_vector()->GetKind(feedback.slot())); |
749 Handle<Name> name(feedback_vector()->GetName(feedback.slot())); | |
750 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); | 750 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); |
751 return NewNode(op, GetFunctionClosure()); | 751 return NewNode(op, GetFunctionClosure()); |
752 } | 752 } |
753 | 753 |
754 void BytecodeGraphBuilder::VisitLdaGlobal() { | 754 void BytecodeGraphBuilder::VisitLdaGlobal() { |
755 PrepareEagerCheckpoint(); | 755 PrepareEagerCheckpoint(); |
756 Node* node = BuildLoadGlobal(bytecode_iterator().GetIndexOperand(0), | 756 Handle<Name> name = |
757 TypeofMode::NOT_INSIDE_TYPEOF); | 757 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 758 uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); |
| 759 Node* node = |
| 760 BuildLoadGlobal(name, feedback_slot_index, TypeofMode::NOT_INSIDE_TYPEOF); |
758 environment()->BindAccumulator(node, Environment::kAttachFrameState); | 761 environment()->BindAccumulator(node, Environment::kAttachFrameState); |
759 } | 762 } |
760 | 763 |
761 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { | 764 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { |
762 PrepareEagerCheckpoint(); | 765 PrepareEagerCheckpoint(); |
763 Node* node = BuildLoadGlobal(bytecode_iterator().GetIndexOperand(0), | 766 Handle<Name> name = |
764 TypeofMode::INSIDE_TYPEOF); | 767 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 768 uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); |
| 769 Node* node = |
| 770 BuildLoadGlobal(name, feedback_slot_index, TypeofMode::INSIDE_TYPEOF); |
765 environment()->BindAccumulator(node, Environment::kAttachFrameState); | 771 environment()->BindAccumulator(node, Environment::kAttachFrameState); |
766 } | 772 } |
767 | 773 |
768 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { | 774 void BytecodeGraphBuilder::BuildStoreGlobal(LanguageMode language_mode) { |
769 PrepareEagerCheckpoint(); | 775 PrepareEagerCheckpoint(); |
770 Handle<Name> name = | 776 Handle<Name> name = |
771 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); | 777 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
772 VectorSlotPair feedback = | 778 VectorSlotPair feedback = |
773 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); | 779 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
774 Node* value = environment()->LookupAccumulator(); | 780 Node* value = environment()->LookupAccumulator(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 | 949 |
944 void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { | 950 void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { |
945 uint32_t depth = bytecode_iterator().GetUnsignedImmediateOperand(2); | 951 uint32_t depth = bytecode_iterator().GetUnsignedImmediateOperand(2); |
946 | 952 |
947 // Check if any context in the depth has an extension. | 953 // Check if any context in the depth has an extension. |
948 Environment* slow_environment = CheckContextExtensions(depth); | 954 Environment* slow_environment = CheckContextExtensions(depth); |
949 | 955 |
950 // Fast path, do a global load. | 956 // Fast path, do a global load. |
951 { | 957 { |
952 PrepareEagerCheckpoint(); | 958 PrepareEagerCheckpoint(); |
953 Node* node = | 959 Handle<Name> name = |
954 BuildLoadGlobal(bytecode_iterator().GetIndexOperand(1), typeof_mode); | 960 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
| 961 uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); |
| 962 Node* node = BuildLoadGlobal(name, feedback_slot_index, typeof_mode); |
955 environment()->BindAccumulator(node, Environment::kAttachFrameState); | 963 environment()->BindAccumulator(node, Environment::kAttachFrameState); |
956 } | 964 } |
957 | 965 |
958 // Only build the slow path if there were any slow-path checks. | 966 // Only build the slow path if there were any slow-path checks. |
959 if (slow_environment != nullptr) { | 967 if (slow_environment != nullptr) { |
960 // Add a merge to the fast environment. | 968 // Add a merge to the fast environment. |
961 NewMerge(); | 969 NewMerge(); |
962 Environment* fast_environment = environment(); | 970 Environment* fast_environment = environment(); |
963 | 971 |
964 // Slow path, do a runtime load lookup. | 972 // Slow path, do a runtime load lookup. |
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 it->source_position().ScriptOffset(), start_position_.InliningId())); | 2215 it->source_position().ScriptOffset(), start_position_.InliningId())); |
2208 it->Advance(); | 2216 it->Advance(); |
2209 } else { | 2217 } else { |
2210 DCHECK_GT(it->code_offset(), offset); | 2218 DCHECK_GT(it->code_offset(), offset); |
2211 } | 2219 } |
2212 } | 2220 } |
2213 | 2221 |
2214 } // namespace compiler | 2222 } // namespace compiler |
2215 } // namespace internal | 2223 } // namespace internal |
2216 } // namespace v8 | 2224 } // namespace v8 |
OLD | NEW |