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

Side by Side Diff: src/compiler/node-marker.h

Issue 1184693002: [turbofan] Inline hot functions for NodeMarkerBase. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | src/compiler/node-marker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_MARKER_H_ 5 #ifndef V8_COMPILER_NODE_MARKER_H_
6 #define V8_COMPILER_NODE_MARKER_H_ 6 #define V8_COMPILER_NODE_MARKER_H_
7 7
8 #include "src/base/macros.h" 8 #include "src/compiler/node.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 // Forward declarations. 14 // Forward declarations.
15 class Graph; 15 class Graph;
16 class Node;
17
18
19 // Marks are used during traversal of the graph to distinguish states of nodes.
20 // Each node has a mark which is a monotonically increasing integer, and a
21 // {NodeMarker} has a range of values that indicate states of a node.
22 typedef uint32_t Mark;
23 16
24 17
25 // Base class for templatized NodeMarkers. 18 // Base class for templatized NodeMarkers.
26 class NodeMarkerBase { 19 class NodeMarkerBase {
27 public: 20 public:
28 NodeMarkerBase(Graph* graph, uint32_t num_states); 21 NodeMarkerBase(Graph* graph, uint32_t num_states);
29 22
30 Mark Get(Node* node); 23 V8_INLINE Mark Get(Node* node) {
31 void Set(Node* node, Mark mark); 24 Mark mark = node->mark();
25 if (mark < mark_min_) {
26 mark = mark_min_;
27 node->set_mark(mark_min_);
28 }
29 DCHECK_LT(mark, mark_max_);
30 return mark - mark_min_;
31 }
32 V8_INLINE void Set(Node* node, Mark mark) {
33 DCHECK_LT(mark, mark_max_ - mark_min_);
34 DCHECK_LT(node->mark(), mark_max_);
35 node->set_mark(mark + mark_min_);
36 }
32 void Reset(Graph* graph); 37 void Reset(Graph* graph);
33 38
34 private: 39 private:
35 Mark mark_min_; 40 Mark mark_min_;
36 Mark mark_max_; 41 Mark mark_max_;
37 42
38 DISALLOW_COPY_AND_ASSIGN(NodeMarkerBase); 43 DISALLOW_COPY_AND_ASSIGN(NodeMarkerBase);
39 }; 44 };
40 45
41 46
42 // A NodeMarker uses monotonically increasing marks to assign local "states" 47 // A NodeMarker uses monotonically increasing marks to assign local "states"
43 // to nodes. Only one NodeMarker per graph is valid at a given time. 48 // to nodes. Only one NodeMarker per graph is valid at a given time.
44 template <typename State> 49 template <typename State>
45 class NodeMarker : public NodeMarkerBase { 50 class NodeMarker : public NodeMarkerBase {
46 public: 51 public:
47 NodeMarker(Graph* graph, uint32_t num_states) 52 V8_INLINE NodeMarker(Graph* graph, uint32_t num_states)
48 : NodeMarkerBase(graph, num_states) {} 53 : NodeMarkerBase(graph, num_states) {}
49 54
50 State Get(Node* node) { 55 V8_INLINE State Get(Node* node) {
51 return static_cast<State>(NodeMarkerBase::Get(node)); 56 return static_cast<State>(NodeMarkerBase::Get(node));
52 } 57 }
53 58
54 void Set(Node* node, State state) { 59 V8_INLINE void Set(Node* node, State state) {
55 NodeMarkerBase::Set(node, static_cast<Mark>(state)); 60 NodeMarkerBase::Set(node, static_cast<Mark>(state));
56 } 61 }
57 }; 62 };
58 63
59 } // namespace compiler 64 } // namespace compiler
60 } // namespace internal 65 } // namespace internal
61 } // namespace v8 66 } // namespace v8
62 67
63 #endif // V8_COMPILER_NODE_MARKER_H_ 68 #endif // V8_COMPILER_NODE_MARKER_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/node-marker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698