| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "test/cctest/interpreter/source-position-matcher.h" | 5 #include "test/cctest/interpreter/source-position-matcher.h" |
| 6 | 6 |
| 7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 #include "src/objects.h" | 8 #include "src/objects.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 namespace interpreter { | 12 namespace interpreter { |
| 13 | 13 |
| 14 // Comparer for PositionTableEntry instances. | 14 // Comparer for PositionTableEntry instances. |
| 15 struct PositionTableEntryComparer { | 15 struct PositionTableEntryComparer { |
| 16 bool operator()(const PositionTableEntry& lhs, | 16 bool operator()(const PositionTableEntry& lhs, |
| 17 const PositionTableEntry& rhs) { | 17 const PositionTableEntry& rhs) const { |
| 18 int lhs_type_score = type_score(lhs); | 18 int lhs_type_score = type_score(lhs); |
| 19 int rhs_type_score = type_score(rhs); | 19 int rhs_type_score = type_score(rhs); |
| 20 if (lhs_type_score == rhs_type_score) { | 20 if (lhs_type_score == rhs_type_score) { |
| 21 return lhs.source_position < rhs.source_position; | 21 return lhs.source_position < rhs.source_position; |
| 22 } else { | 22 } else { |
| 23 return lhs_type_score < rhs_type_score; | 23 return lhs_type_score < rhs_type_score; |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 int type_score(const PositionTableEntry& entry) { | 27 int type_score(const PositionTableEntry& entry) const { |
| 28 return entry.is_statement ? 1 : 0; | 28 return entry.is_statement ? 1 : 0; |
| 29 } | 29 } |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // | 32 // |
| 33 // The principles for comparing source positions in bytecode arrays | 33 // The principles for comparing source positions in bytecode arrays |
| 34 // are: | 34 // are: |
| 35 // | 35 // |
| 36 // 1. The number of statement positions must be the same in both. | 36 // 1. The number of statement positions must be the same in both. |
| 37 // | 37 // |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 positions->push_back({iterator->bytecode_offset(), | 216 positions->push_back({iterator->bytecode_offset(), |
| 217 iterator->source_position(), | 217 iterator->source_position(), |
| 218 iterator->is_statement()}); | 218 iterator->is_statement()}); |
| 219 iterator->Advance(); | 219 iterator->Advance(); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace interpreter | 223 } // namespace interpreter |
| 224 } // namespace internal | 224 } // namespace internal |
| 225 } // namespace v8 | 225 } // namespace v8 |
| OLD | NEW |