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

Side by Side Diff: src/ast.h

Issue 633373003: Simplify AST ID generation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_AST_H_ 5 #ifndef V8_AST_H_
6 #define V8_AST_H_ 6 #define V8_AST_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/assembler.h" 10 #include "src/assembler.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 int node_count_; 177 int node_count_;
178 int feedback_slots_; 178 int feedback_slots_;
179 }; 179 };
180 180
181 181
182 class AstNode: public ZoneObject { 182 class AstNode: public ZoneObject {
183 public: 183 public:
184 // For generating IDs for AstNodes. 184 // For generating IDs for AstNodes.
185 class IdGen { 185 class IdGen {
186 public: 186 public:
187 explicit IdGen(int id = 0) : id_(id) {} 187 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {}
188 188
189 int GetNextId() { return ReserveIdRange(1); } 189 int GetNextId() { return ReserveIdRange(1); }
190 int ReserveIdRange(int n) { 190 int ReserveIdRange(int n) {
191 int tmp = id_; 191 int tmp = id_;
192 id_ += n; 192 id_ += n;
193 return tmp; 193 return tmp;
194 } 194 }
195 195
196 private: 196 private:
197 int id_; 197 int id_;
198
199 DISALLOW_COPY_AND_ASSIGN(IdGen);
198 }; 200 };
199 201
200 #define DECLARE_TYPE_ENUM(type) k##type, 202 #define DECLARE_TYPE_ENUM(type) k##type,
201 enum NodeType { 203 enum NodeType {
202 AST_NODE_LIST(DECLARE_TYPE_ENUM) 204 AST_NODE_LIST(DECLARE_TYPE_ENUM)
203 kInvalid = -1 205 kInvalid = -1
204 }; 206 };
205 #undef DECLARE_TYPE_ENUM 207 #undef DECLARE_TYPE_ENUM
206 208
207 void* operator new(size_t size, Zone* zone) { 209 void* operator new(size_t size, Zone* zone) {
(...skipping 3378 matching lines...) Expand 10 before | Expand all | Expand 10 after
3586 Zone* zone_; 3588 Zone* zone_;
3587 Visitor visitor_; 3589 Visitor visitor_;
3588 AstValueFactory* ast_value_factory_; 3590 AstValueFactory* ast_value_factory_;
3589 AstNode::IdGen* id_gen_; 3591 AstNode::IdGen* id_gen_;
3590 }; 3592 };
3591 3593
3592 3594
3593 } } // namespace v8::internal 3595 } } // namespace v8::internal
3594 3596
3595 #endif // V8_AST_H_ 3597 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698