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

Side by Side Diff: src/compiler/source-position.cc

Issue 1109763002: [turbofan] Treat uninitialized source positions as unknown. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « src/compiler/source-position.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/source-position.h" 5 #include "src/compiler/source-position.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/node-aux-data.h" 7 #include "src/compiler/node-aux-data.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 namespace compiler { 11 namespace compiler {
12 12
13 class SourcePositionTable::Decorator final : public GraphDecorator { 13 class SourcePositionTable::Decorator final : public GraphDecorator {
14 public: 14 public:
15 explicit Decorator(SourcePositionTable* source_positions) 15 explicit Decorator(SourcePositionTable* source_positions)
16 : source_positions_(source_positions) {} 16 : source_positions_(source_positions) {}
17 17
18 void Decorate(Node* node, bool incomplete) final { 18 void Decorate(Node* node, bool incomplete) final {
19 DCHECK(!source_positions_->current_position_.IsInvalid());
20 source_positions_->table_.Set(node, source_positions_->current_position_); 19 source_positions_->table_.Set(node, source_positions_->current_position_);
21 } 20 }
22 21
23 private: 22 private:
24 SourcePositionTable* source_positions_; 23 SourcePositionTable* source_positions_;
25 }; 24 };
26 25
27 26
28 SourcePositionTable::SourcePositionTable(Graph* graph) 27 SourcePositionTable::SourcePositionTable(Graph* graph)
29 : graph_(graph), 28 : graph_(graph),
30 decorator_(nullptr), 29 decorator_(nullptr),
31 current_position_(SourcePosition::Invalid()), 30 current_position_(SourcePosition::Unknown()),
32 table_(graph->zone()) {} 31 table_(graph->zone()) {}
33 32
34 33
35 void SourcePositionTable::AddDecorator() { 34 void SourcePositionTable::AddDecorator() {
36 DCHECK_NULL(decorator_); 35 DCHECK_NULL(decorator_);
37 decorator_ = new (graph_->zone()) Decorator(this); 36 decorator_ = new (graph_->zone()) Decorator(this);
38 graph_->AddDecorator(decorator_); 37 graph_->AddDecorator(decorator_);
39 } 38 }
40 39
41 40
42 void SourcePositionTable::RemoveDecorator() { 41 void SourcePositionTable::RemoveDecorator() {
43 DCHECK_NOT_NULL(decorator_); 42 DCHECK_NOT_NULL(decorator_);
44 graph_->RemoveDecorator(decorator_); 43 graph_->RemoveDecorator(decorator_);
45 decorator_ = nullptr; 44 decorator_ = nullptr;
46 } 45 }
47 46
48 47
49 SourcePosition SourcePositionTable::GetSourcePosition(Node* node) const { 48 SourcePosition SourcePositionTable::GetSourcePosition(Node* node) const {
50 return table_.Get(node); 49 return table_.Get(node);
51 } 50 }
52 51
53 52
54 void SourcePositionTable::Print(std::ostream& os) const { 53 void SourcePositionTable::Print(std::ostream& os) const {
55 os << "{"; 54 os << "{";
56 bool needs_comma = false; 55 bool needs_comma = false;
57 for (auto i : table_) { 56 for (auto i : table_) {
58 SourcePosition pos = i.second; 57 SourcePosition pos = i.second;
59 if (!pos.IsUnknown()) { 58 if (pos.IsKnown()) {
60 if (needs_comma) { 59 if (needs_comma) {
61 os << ","; 60 os << ",";
62 } 61 }
63 os << "\"" << i.first << "\"" 62 os << "\"" << i.first << "\""
64 << ":" << pos.raw(); 63 << ":" << pos.raw();
65 needs_comma = true; 64 needs_comma = true;
66 } 65 }
67 } 66 }
68 os << "}"; 67 os << "}";
69 } 68 }
70 69
71 } // namespace compiler 70 } // namespace compiler
72 } // namespace internal 71 } // namespace internal
73 } // namespace v8 72 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/source-position.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698