| 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-branch-analysis.h" | 5 #include "src/compiler/bytecode-branch-analysis.h" |
| 6 | 6 |
| 7 #include "src/interpreter/bytecode-array-iterator.h" | 7 #include "src/interpreter/bytecode-array-iterator.h" |
| 8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const ZoneVector<int>* BytecodeBranchAnalysis::ForwardBranchesTargetting( | 104 const ZoneVector<int>* BytecodeBranchAnalysis::ForwardBranchesTargetting( |
| 105 int offset) const { | 105 int offset) const { |
| 106 auto iterator = branch_infos_.find(offset); | 106 auto iterator = branch_infos_.find(offset); |
| 107 if (branch_infos_.end() != iterator) { | 107 if (branch_infos_.end() != iterator) { |
| 108 return iterator->second->fore_edge_offsets(); | 108 return iterator->second->fore_edge_offsets(); |
| 109 } else { | 109 } else { |
| 110 return nullptr; | 110 return nullptr; |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void BytecodeBranchAnalysis::AddExceptionalBranch(int throw_offset, | |
| 115 int handler_offset) { | |
| 116 DCHECK(is_reachable(handler_offset)); // Handler was marked reachable. | |
| 117 DCHECK_LT(throw_offset, handler_offset); // Always a forward branch. | |
| 118 AddBranch(throw_offset, handler_offset); | |
| 119 } | |
| 120 | |
| 121 void BytecodeBranchAnalysis::AddBranch(int source_offset, int target_offset) { | 114 void BytecodeBranchAnalysis::AddBranch(int source_offset, int target_offset) { |
| 122 BytecodeBranchInfo* branch_info = nullptr; | 115 BytecodeBranchInfo* branch_info = nullptr; |
| 123 auto iterator = branch_infos_.find(target_offset); | 116 auto iterator = branch_infos_.find(target_offset); |
| 124 if (branch_infos_.end() == iterator) { | 117 if (branch_infos_.end() == iterator) { |
| 125 branch_info = new (zone()) BytecodeBranchInfo(zone()); | 118 branch_info = new (zone()) BytecodeBranchInfo(zone()); |
| 126 branch_infos_.insert(std::make_pair(target_offset, branch_info)); | 119 branch_infos_.insert(std::make_pair(target_offset, branch_info)); |
| 127 } else { | 120 } else { |
| 128 branch_info = iterator->second; | 121 branch_info = iterator->second; |
| 129 } | 122 } |
| 130 branch_info->AddBranch(source_offset, target_offset); | 123 branch_info->AddBranch(source_offset, target_offset); |
| 131 } | 124 } |
| 132 | 125 |
| 133 void BytecodeBranchAnalysis::AnalyzeExceptionHandlers() { | 126 void BytecodeBranchAnalysis::AnalyzeExceptionHandlers() { |
| 134 HandlerTable* table = HandlerTable::cast(bytecode_array()->handler_table()); | 127 HandlerTable* table = HandlerTable::cast(bytecode_array()->handler_table()); |
| 135 for (int i = 0; i < table->NumberOfRangeEntries(); ++i) { | 128 for (int i = 0; i < table->NumberOfRangeEntries(); ++i) { |
| 136 reachable_.Add(table->GetRangeHandler(i)); | 129 reachable_.Add(table->GetRangeHandler(i)); |
| 137 } | 130 } |
| 138 } | 131 } |
| 139 | 132 |
| 140 } // namespace compiler | 133 } // namespace compiler |
| 141 } // namespace internal | 134 } // namespace internal |
| 142 } // namespace v8 | 135 } // namespace v8 |
| OLD | NEW |