summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/node-aux-data-inl.h
blob: 679320ab6f9dc3e25d7261f74635f383d6ee18cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_COMPILER_NODE_AUX_DATA_INL_H_
#define V8_COMPILER_NODE_AUX_DATA_INL_H_

#include "src/compiler/graph.h"
#include "src/compiler/node.h"
#include "src/compiler/node-aux-data.h"

namespace v8 {
namespace internal {
namespace compiler {

template <class T>
NodeAuxData<T>::NodeAuxData(Zone* zone)
    : aux_data_(ZoneAllocator(zone)) {}


template <class T>
void NodeAuxData<T>::Set(Node* node, const T& data) {
  int id = node->id();
  if (id >= static_cast<int>(aux_data_.size())) {
    aux_data_.resize(id + 1);
  }
  aux_data_[id] = data;
}


template <class T>
T NodeAuxData<T>::Get(Node* node) {
  int id = node->id();
  if (id >= static_cast<int>(aux_data_.size())) {
    return T();
  }
  return aux_data_[id];
}
}
}
}  // namespace v8::internal::compiler

#endif