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 3 // found in the LICENSE file. 4 5 #ifndef TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_ 6 #define TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_ 7 8 #include "src/interpreter/bytecode-array-iterator.h" 9 #include "src/interpreter/source-position-table.h" 10 #include "src/objects.h" 11 #include "src/v8.h" 12 13 namespace v8 { 14 namespace internal { 15 namespace interpreter { 16 17 class SourcePositionMatcher final { 18 public: 19 bool Match(Handle<BytecodeArray> original, Handle<BytecodeArray> optimized); 20 21 private: 22 bool HasNewExpressionPositionsInOptimized( 23 const std::vector<PositionTableEntry>* const original_positions, 24 const std::vector<PositionTableEntry>* const optimized_positions); 25 26 bool CompareExpressionPositions( 27 const std::vector<PositionTableEntry>* const original_positions, 28 const std::vector<PositionTableEntry>* const optimized_positions); 29 30 void StripUnneededExpressionPositions( 31 Handle<BytecodeArray> bytecode_array, 32 std::vector<PositionTableEntry>* positions, 33 int next_statement_bytecode_offset); 34 35 bool ExpressionPositionIsNeeded(Handle<BytecodeArray> bytecode_array, 36 int start_offset, int end_offset); 37 38 void MoveToNextStatement( 39 SourcePositionTableIterator* iterator, 40 std::vector<PositionTableEntry>* expression_positions); 41 42 void AdvanceBytecodeIterator(BytecodeArrayIterator* iterator, 43 int bytecode_offset); 44 }; 45 46 } // namespace interpreter 47 } // namespace internal 48 } // namespace v8 49 50 #endif // TEST_CCTEST_INTERPRETER_SOURCE_POSITION_COMPARER_H_ 51