Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: src/source-position-table.h

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef V8_SOURCE_POSITION_TABLE_H_ 5 #ifndef V8_SOURCE_POSITION_TABLE_H_
6 #define V8_SOURCE_POSITION_TABLE_H_ 6 #define V8_SOURCE_POSITION_TABLE_H_
7 7
8 #include "src/assert-scope.h" 8 #include "src/assert-scope.h"
9 #include "src/checks.h" 9 #include "src/checks.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
11 #include "src/handles.h" 11 #include "src/handles.h"
12 #include "src/source-position.h"
12 #include "src/zone/zone-containers.h" 13 #include "src/zone/zone-containers.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 17
17 class AbstractCode; 18 class AbstractCode;
18 class BytecodeArray; 19 class BytecodeArray;
19 class ByteArray; 20 class ByteArray;
20 class Isolate; 21 class Isolate;
21 class Zone; 22 class Zone;
22 23
23 struct PositionTableEntry { 24 struct PositionTableEntry {
24 PositionTableEntry() 25 PositionTableEntry()
25 : code_offset(0), source_position(0), is_statement(false) {} 26 : code_offset(0), source_position(0), is_statement(false) {}
26 PositionTableEntry(int offset, int source, bool statement) 27 PositionTableEntry(int offset, int64_t source, bool statement)
27 : code_offset(offset), source_position(source), is_statement(statement) {} 28 : code_offset(offset), source_position(source), is_statement(statement) {}
28 29
29 int code_offset; 30 int code_offset;
30 int source_position; 31 int64_t source_position;
31 bool is_statement; 32 bool is_statement;
32 }; 33 };
33 34
34 class V8_EXPORT_PRIVATE SourcePositionTableBuilder { 35 class V8_EXPORT_PRIVATE SourcePositionTableBuilder {
35 public: 36 public:
36 enum RecordingMode { OMIT_SOURCE_POSITIONS, RECORD_SOURCE_POSITIONS }; 37 enum RecordingMode { OMIT_SOURCE_POSITIONS, RECORD_SOURCE_POSITIONS };
37 38
38 SourcePositionTableBuilder(Zone* zone, 39 SourcePositionTableBuilder(Zone* zone,
39 RecordingMode mode = RECORD_SOURCE_POSITIONS); 40 RecordingMode mode = RECORD_SOURCE_POSITIONS);
40 41
41 void AddPosition(size_t code_offset, int source_position, bool is_statement); 42 void AddPosition(size_t code_offset, SourcePosition source_position,
43 bool is_statement);
42 44
43 Handle<ByteArray> ToSourcePositionTable(Isolate* isolate, 45 Handle<ByteArray> ToSourcePositionTable(Isolate* isolate,
44 Handle<AbstractCode> code); 46 Handle<AbstractCode> code);
45 47
46 private: 48 private:
47 void AddEntry(const PositionTableEntry& entry); 49 void AddEntry(const PositionTableEntry& entry);
48 50
49 inline bool Omit() const { return mode_ == OMIT_SOURCE_POSITIONS; } 51 inline bool Omit() const { return mode_ == OMIT_SOURCE_POSITIONS; }
50 52
51 RecordingMode mode_; 53 RecordingMode mode_;
52 ZoneVector<byte> bytes_; 54 ZoneVector<byte> bytes_;
53 #ifdef ENABLE_SLOW_DCHECKS 55 #ifdef ENABLE_SLOW_DCHECKS
54 ZoneVector<PositionTableEntry> raw_entries_; 56 ZoneVector<PositionTableEntry> raw_entries_;
55 #endif 57 #endif
56 PositionTableEntry previous_; // Previously written entry, to compute delta. 58 PositionTableEntry previous_; // Previously written entry, to compute delta.
57 }; 59 };
58 60
59 class V8_EXPORT_PRIVATE SourcePositionTableIterator { 61 class V8_EXPORT_PRIVATE SourcePositionTableIterator {
60 public: 62 public:
61 explicit SourcePositionTableIterator(ByteArray* byte_array); 63 explicit SourcePositionTableIterator(ByteArray* byte_array);
62 64
63 void Advance(); 65 void Advance();
64 66
65 int code_offset() const { 67 int code_offset() const {
66 DCHECK(!done()); 68 DCHECK(!done());
67 return current_.code_offset; 69 return current_.code_offset;
68 } 70 }
69 int source_position() const { 71 SourcePosition source_position() const {
70 DCHECK(!done()); 72 DCHECK(!done());
71 return current_.source_position; 73 return SourcePosition::FromRaw(current_.source_position);
72 } 74 }
73 bool is_statement() const { 75 bool is_statement() const {
74 DCHECK(!done()); 76 DCHECK(!done());
75 return current_.is_statement; 77 return current_.is_statement;
76 } 78 }
77 bool done() const { return index_ == kDone; } 79 bool done() const { return index_ == kDone; }
78 80
79 private: 81 private:
80 static const int kDone = -1; 82 static const int kDone = -1;
81 83
82 ByteArray* table_; 84 ByteArray* table_;
83 int index_; 85 int index_;
84 PositionTableEntry current_; 86 PositionTableEntry current_;
85 DisallowHeapAllocation no_gc; 87 DisallowHeapAllocation no_gc;
86 }; 88 };
87 89
88 } // namespace internal 90 } // namespace internal
89 } // namespace v8 91 } // namespace v8
90 92
91 #endif // V8_SOURCE_POSITION_TABLE_H_ 93 #endif // V8_SOURCE_POSITION_TABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698