summaryrefslogtreecommitdiff
path: root/chromium/v8/src/compiler/node-aux-data.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-06-18 14:10:49 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-06-18 13:53:24 +0000
commit813fbf95af77a531c57a8c497345ad2c61d475b3 (patch)
tree821b2c8de8365f21b6c9ba17a236fb3006a1d506 /chromium/v8/src/compiler/node-aux-data.h
parentaf6588f8d723931a298c995fa97259bb7f7deb55 (diff)
downloadqtwebengine-chromium-813fbf95af77a531c57a8c497345ad2c61d475b3.tar.gz
BASELINE: Update chromium to 44.0.2403.47
Change-Id: Ie056fedba95cf5e5c76b30c4b2c80fca4764aa2f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/v8/src/compiler/node-aux-data.h')
-rw-r--r--chromium/v8/src/compiler/node-aux-data.h72
1 files changed, 66 insertions, 6 deletions
diff --git a/chromium/v8/src/compiler/node-aux-data.h b/chromium/v8/src/compiler/node-aux-data.h
index a08dc580ff6..7a882921a71 100644
--- a/chromium/v8/src/compiler/node-aux-data.h
+++ b/chromium/v8/src/compiler/node-aux-data.h
@@ -5,6 +5,7 @@
#ifndef V8_COMPILER_NODE_AUX_DATA_H_
#define V8_COMPILER_NODE_AUX_DATA_H_
+#include "src/compiler/node.h"
#include "src/zone-containers.h"
namespace v8 {
@@ -12,22 +13,81 @@ namespace internal {
namespace compiler {
// Forward declarations.
-class Graph;
class Node;
template <class T>
class NodeAuxData {
public:
- inline explicit NodeAuxData(Zone* zone);
+ explicit NodeAuxData(Zone* zone) : aux_data_(zone) {}
- inline void Set(Node* node, const T& data);
- inline T Get(Node* node) const;
+ void Set(Node* node, T const& data) {
+ size_t const id = node->id();
+ if (id >= aux_data_.size()) aux_data_.resize(id + 1);
+ aux_data_[id] = data;
+ }
+
+ T Get(Node* node) const {
+ size_t const id = node->id();
+ return (id < aux_data_.size()) ? aux_data_[id] : T();
+ }
+
+ class const_iterator;
+ friend class const_iterator;
+
+ const_iterator begin() const;
+ const_iterator end() const;
private:
ZoneVector<T> aux_data_;
};
+
+
+template <class T>
+class NodeAuxData<T>::const_iterator {
+ public:
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+ typedef std::pair<size_t, T> value_type;
+ typedef value_type* pointer;
+ typedef value_type& reference;
+
+ const_iterator(const ZoneVector<T>* data, size_t current)
+ : data_(data), current_(current) {}
+ const_iterator(const const_iterator& other)
+ : data_(other.data_), current_(other.current_) {}
+
+ value_type operator*() const {
+ return std::make_pair(current_, (*data_)[current_]);
+ }
+ bool operator==(const const_iterator& other) const {
+ return current_ == other.current_ && data_ == other.data_;
+ }
+ bool operator!=(const const_iterator& other) const {
+ return !(*this == other);
+ }
+ const_iterator& operator++() {
+ ++current_;
+ return *this;
+ }
+ const_iterator operator++(int);
+
+ private:
+ const ZoneVector<T>* data_;
+ size_t current_;
+};
+
+template <class T>
+typename NodeAuxData<T>::const_iterator NodeAuxData<T>::begin() const {
+ return typename NodeAuxData<T>::const_iterator(&aux_data_, 0);
}
+
+template <class T>
+typename NodeAuxData<T>::const_iterator NodeAuxData<T>::end() const {
+ return typename NodeAuxData<T>::const_iterator(&aux_data_, aux_data_.size());
}
-} // namespace v8::internal::compiler
-#endif
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_NODE_AUX_DATA_H_