blob: 0bb5bed886c2cfdb9b8bbdba70498b9b57c6a87a [file] [log] [blame]
Ben Murdoch61f157c2016-09-16 13:49:30 +01001// 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
13namespace v8 {
14namespace internal {
15namespace interpreter {
16
17class 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_