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

Unified Diff: src/ast.h

Issue 7383013: Avoid TLS load in AstNode constructor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
};
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698