Index: src/ast.h |
diff --git a/src/ast.h b/src/ast.h |
index 27d82cb34139c5efaed5786a6ca58bbea30c86f3..e9003a104f2cbfdf06dd10449e4aae6a8f2dcdf7 100644 |
--- a/src/ast.h |
+++ b/src/ast.h |
@@ -134,11 +134,15 @@ class AstNode: public ZoneObject { |
static const int kNoNumber = -1; |
static const int kFunctionEntryId = 2; // Using 0 could disguise errors. |
- AstNode() { |
- Isolate* isolate = Isolate::Current(); |
+ // Override ZoneObjects's new to count allocated AST nodes. |
+ void* operator new(size_t size, Zone* zone) { |
+ Isolate* isolate = zone->isolate(); |
isolate->set_ast_node_count(isolate->ast_node_count() + 1); |
+ return zone->New(size); |
} |
+ AstNode() {} |
+ |
virtual ~AstNode() { } |
virtual void Accept(AstVisitor* v) = 0; |
@@ -173,6 +177,11 @@ class AstNode: public ZoneObject { |
return tmp; |
} |
+ private: |
+ // Hidden to prevent accidental usage. It would have to load the |
+ // current zone from the TLS. |
+ void* operator new(size_t size); |
+ |
friend class CaseClause; // Generates AST IDs. |
}; |