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

Side by Side Diff: runtime/vm/token_position.h

Issue 2772193004: Resolve initialization order fiasco between code_descriptors.cc and token_position.cc. (Closed)
Patch Set: Created 3 years, 8 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 | « runtime/vm/code_descriptors.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_TOKEN_POSITION_H_ 5 #ifndef RUNTIME_VM_TOKEN_POSITION_H_
6 #define RUNTIME_VM_TOKEN_POSITION_H_ 6 #define RUNTIME_VM_TOKEN_POSITION_H_
7 7
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return !(*this > b); 72 return !(*this > b);
73 } 73 }
74 74
75 bool operator>=(const TokenPosition& b) { 75 bool operator>=(const TokenPosition& b) {
76 // TODO(johnmccutchan): Assert that this is a source position. 76 // TODO(johnmccutchan): Assert that this is a source position.
77 return !(*this < b); 77 return !(*this < b);
78 } 78 }
79 79
80 static const intptr_t kMaxSentinelDescriptors = 64; 80 static const intptr_t kMaxSentinelDescriptors = 64;
81 81
82 #define DECLARE_VALUES(name, value) static const TokenPosition k##name; 82 #define DECLARE_VALUES(name, value) \
83 static const intptr_t k##name##Pos = value; \
84 static const TokenPosition k##name;
83 SENTINEL_TOKEN_DESCRIPTORS(DECLARE_VALUES); 85 SENTINEL_TOKEN_DESCRIPTORS(DECLARE_VALUES);
84 #undef DECLARE_VALUES 86 #undef DECLARE_VALUES
87 static const intptr_t kMinSourcePos = 0;
85 static const TokenPosition kMinSource; 88 static const TokenPosition kMinSource;
89 static const intptr_t kMaxSourcePos = kSmiMax32 - kMaxSentinelDescriptors - 2;
86 static const TokenPosition kMaxSource; 90 static const TokenPosition kMaxSource;
87 91
88 // Decode from a snapshot. 92 // Decode from a snapshot.
89 static TokenPosition SnapshotDecode(int32_t value); 93 static TokenPosition SnapshotDecode(int32_t value);
90 94
91 // Encode for writing into a snapshot. 95 // Encode for writing into a snapshot.
92 int32_t SnapshotEncode(); 96 int32_t SnapshotEncode();
93 97
94 // Increment the token position. 98 // Increment the token position.
95 TokenPosition Next() { 99 TokenPosition Next() {
96 ASSERT(IsReal()); 100 ASSERT(IsReal());
97 value_++; 101 value_++;
98 return *this; 102 return *this;
99 } 103 }
100 104
101 // The raw value. 105 // The raw value.
102 // TODO(johnmccutchan): Make this private. 106 // TODO(johnmccutchan): Make this private.
103 intptr_t value() const { return value_; } 107 intptr_t value() const { return value_; }
104 108
105 // Return the source position. 109 // Return the source position.
106 intptr_t Pos() const { 110 intptr_t Pos() const {
107 if (IsSynthetic()) { 111 if (IsSynthetic()) {
108 return FromSynthetic().Pos(); 112 return FromSynthetic().Pos();
109 } 113 }
110 return value_; 114 return value_;
111 } 115 }
112 116
113 // Token position constants.
114 static const intptr_t kNoSourcePos = -1;
115 static const intptr_t kMinSourcePos = 0;
116 static const intptr_t kMaxSourcePos = kSmiMax32 - kMaxSentinelDescriptors - 2;
117
118 // Is |this| a classifying sentinel source position? 117 // Is |this| a classifying sentinel source position?
119 // Classifying positions are used by the profiler to group instructions whose 118 // Classifying positions are used by the profiler to group instructions whose
120 // cost isn't naturally attributable to a source location. 119 // cost isn't naturally attributable to a source location.
121 bool IsClassifying() const { 120 bool IsClassifying() const {
122 return (value_ >= kBox.value()) && (value_ <= kLast.value()); 121 return (value_ >= kBox.value()) && (value_ <= kLast.value());
123 } 122 }
124 123
125 // Is |this| the no source position sentinel? 124 // Is |this| the no source position sentinel?
126 bool IsNoSource() const { return *this == kNoSource; } 125 bool IsNoSource() const { return *this == kNoSource; }
127 126
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 185
187 private: 186 private:
188 int32_t value_; 187 int32_t value_;
189 188
190 DISALLOW_ALLOCATION(); 189 DISALLOW_ALLOCATION();
191 }; 190 };
192 191
193 } // namespace dart 192 } // namespace dart
194 193
195 #endif // RUNTIME_VM_TOKEN_POSITION_H_ 194 #endif // RUNTIME_VM_TOKEN_POSITION_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698