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

Side by Side Diff: src/compiler/node-aux-data.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 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 #ifndef V8_COMPILER_NODE_AUX_DATA_H_ 5 #ifndef V8_COMPILER_NODE_AUX_DATA_H_
6 #define V8_COMPILER_NODE_AUX_DATA_H_ 6 #define V8_COMPILER_NODE_AUX_DATA_H_
7 7
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/zone/zone-containers.h" 9 #include "src/zone/zone-containers.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 class Node; 16 class Node;
17 17
18 template <class T> 18 template <class T, T def()>
19 class NodeAuxData { 19 class NodeAuxData {
20 public: 20 public:
21 explicit NodeAuxData(Zone* zone) : aux_data_(zone) {} 21 explicit NodeAuxData(Zone* zone) : aux_data_(zone) {}
22 22
23 void Set(Node* node, T const& data) { 23 void Set(Node* node, T const& data) {
24 size_t const id = node->id(); 24 size_t const id = node->id();
25 if (id >= aux_data_.size()) aux_data_.resize(id + 1); 25 if (id >= aux_data_.size()) aux_data_.resize(id + 1, def());
26 aux_data_[id] = data; 26 aux_data_[id] = data;
27 } 27 }
28 28
29 T Get(Node* node) const { 29 T Get(Node* node) const {
30 size_t const id = node->id(); 30 size_t const id = node->id();
31 return (id < aux_data_.size()) ? aux_data_[id] : T(); 31 return (id < aux_data_.size()) ? aux_data_[id] : def();
32 } 32 }
33 33
34 class const_iterator; 34 class const_iterator;
35 friend class const_iterator; 35 friend class const_iterator;
36 36
37 const_iterator begin() const; 37 const_iterator begin() const;
38 const_iterator end() const; 38 const_iterator end() const;
39 39
40 private: 40 private:
41 ZoneVector<T> aux_data_; 41 ZoneVector<T> aux_data_;
42 }; 42 };
43 43
44 44 template <class T, T def()>
45 template <class T> 45 class NodeAuxData<T, def>::const_iterator {
46 class NodeAuxData<T>::const_iterator {
47 public: 46 public:
48 typedef std::forward_iterator_tag iterator_category; 47 typedef std::forward_iterator_tag iterator_category;
49 typedef int difference_type; 48 typedef int difference_type;
50 typedef std::pair<size_t, T> value_type; 49 typedef std::pair<size_t, T> value_type;
51 typedef value_type* pointer; 50 typedef value_type* pointer;
52 typedef value_type& reference; 51 typedef value_type& reference;
53 52
54 const_iterator(const ZoneVector<T>* data, size_t current) 53 const_iterator(const ZoneVector<T>* data, size_t current)
55 : data_(data), current_(current) {} 54 : data_(data), current_(current) {}
56 const_iterator(const const_iterator& other) 55 const_iterator(const const_iterator& other)
(...skipping 12 matching lines...) Expand all
69 ++current_; 68 ++current_;
70 return *this; 69 return *this;
71 } 70 }
72 const_iterator operator++(int); 71 const_iterator operator++(int);
73 72
74 private: 73 private:
75 const ZoneVector<T>* data_; 74 const ZoneVector<T>* data_;
76 size_t current_; 75 size_t current_;
77 }; 76 };
78 77
79 template <class T> 78 template <class T, T def()>
80 typename NodeAuxData<T>::const_iterator NodeAuxData<T>::begin() const { 79 typename NodeAuxData<T, def>::const_iterator NodeAuxData<T, def>::begin()
81 return typename NodeAuxData<T>::const_iterator(&aux_data_, 0); 80 const {
81 return typename NodeAuxData<T, def>::const_iterator(&aux_data_, 0);
82 } 82 }
83 83
84 template <class T> 84 template <class T, T def()>
85 typename NodeAuxData<T>::const_iterator NodeAuxData<T>::end() const { 85 typename NodeAuxData<T, def>::const_iterator NodeAuxData<T, def>::end() const {
86 return typename NodeAuxData<T>::const_iterator(&aux_data_, aux_data_.size()); 86 return typename NodeAuxData<T, def>::const_iterator(&aux_data_,
87 aux_data_.size());
87 } 88 }
88 89
89 } // namespace compiler 90 } // namespace compiler
90 } // namespace internal 91 } // namespace internal
91 } // namespace v8 92 } // namespace v8
92 93
93 #endif // V8_COMPILER_NODE_AUX_DATA_H_ 94 #endif // V8_COMPILER_NODE_AUX_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698