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

Unified Diff: src/scopes.h

Issue 113393: Optimize the scope creation code by lazily allocating the hash maps... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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 | « src/objects.cc ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.h
===================================================================
--- src/scopes.h (revision 1937)
+++ src/scopes.h (working copy)
@@ -35,7 +35,6 @@
// A hash map to support fast local variable declaration and lookup.
-
class LocalsMap: public HashMap {
public:
LocalsMap();
@@ -53,6 +52,23 @@
};
+// The dynamic scope part holds hash maps for the variables that will
+// be looked up dynamically from within eval and with scopes. The objects
+// are allocated on-demand from Scope::NonLocal to avoid wasting memory
+// and setup time for scopes that don't need them.
+class DynamicScopePart : public ZoneObject {
+ public:
+ LocalsMap* GetMap(Variable::Mode mode) {
+ int index = mode - Variable::DYNAMIC;
+ ASSERT(index >= 0 && index < 3);
+ return &maps_[index];
+ }
+
+ private:
+ LocalsMap maps_[3];
+};
+
+
// Global invariants after AST construction: Each reference (i.e. identifier)
// to a JavaScript variable (including global properties) is represented by a
// VariableProxy node. Immediately after AST construction and before variable
@@ -278,9 +294,7 @@
// parameter list in source order
ZoneList<Variable*> params_;
// variables that must be looked up dynamically
- LocalsMap dynamics_;
- LocalsMap dynamics_local_;
- LocalsMap dynamics_global_;
+ DynamicScopePart* dynamics_;
// unresolved variables referred to from this scope
ZoneList<VariableProxy*> unresolved_;
// declarations
« no previous file with comments | « src/objects.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698