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

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

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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/compiler/source-position.h"
6 #include "src/compiler/graph.h"
7 #include "src/compiler/node-aux-data.h"
8
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12
13 class SourcePositionTable::Decorator final : public GraphDecorator {
14 public:
15 explicit Decorator(SourcePositionTable* source_positions)
16 : source_positions_(source_positions) {}
17
18 void Decorate(Node* node) final {
19 source_positions_->SetSourcePosition(node,
20 source_positions_->current_position_);
21 }
22
23 private:
24 SourcePositionTable* source_positions_;
25 };
26
27
28 SourcePositionTable::SourcePositionTable(Graph* graph)
29 : graph_(graph),
30 decorator_(nullptr),
31 current_position_(SourcePosition::Unknown()),
32 table_(graph->zone()) {}
33
34
35 void SourcePositionTable::AddDecorator() {
36 DCHECK_NULL(decorator_);
37 decorator_ = new (graph_->zone()) Decorator(this);
38 graph_->AddDecorator(decorator_);
39 }
40
41
42 void SourcePositionTable::RemoveDecorator() {
43 DCHECK_NOT_NULL(decorator_);
44 graph_->RemoveDecorator(decorator_);
45 decorator_ = nullptr;
46 }
47
48
49 SourcePosition SourcePositionTable::GetSourcePosition(Node* node) const {
50 return table_.Get(node);
51 }
52
53 void SourcePositionTable::SetSourcePosition(Node* node,
54 SourcePosition position) {
55 table_.Set(node, position);
56 }
57
58 void SourcePositionTable::Print(std::ostream& os) const {
59 os << "{";
60 bool needs_comma = false;
61 for (auto i : table_) {
62 SourcePosition pos = i.second;
63 if (pos.IsKnown()) {
64 if (needs_comma) {
65 os << ",";
66 }
67 os << "\"" << i.first << "\""
68 << ":" << pos.raw();
69 needs_comma = true;
70 }
71 }
72 os << "}";
73 }
74
75 } // namespace compiler
76 } // namespace internal
77 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698