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

Unified Diff: src/scopes.cc

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/scopes.h ('k') | src/utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.cc
===================================================================
--- src/scopes.cc (revision 1937)
+++ src/scopes.cc (working copy)
@@ -112,9 +112,7 @@
locals_(false),
temps_(0),
params_(0),
- dynamics_(false),
- dynamics_local_(false),
- dynamics_global_(false),
+ dynamics_(NULL),
unresolved_(0),
decls_(0) {
}
@@ -125,9 +123,9 @@
inner_scopes_(4),
type_(type),
scope_name_(Factory::empty_symbol()),
- locals_(),
temps_(4),
params_(4),
+ dynamics_(NULL),
unresolved_(16),
decls_(4),
receiver_(NULL),
@@ -477,9 +475,11 @@
PrintMap(&printer, n1, &locals_);
Indent(n1, "// dynamic vars\n");
- PrintMap(&printer, n1, &dynamics_);
- PrintMap(&printer, n1, &dynamics_local_);
- PrintMap(&printer, n1, &dynamics_global_);
+ if (dynamics_ != NULL) {
+ PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC));
+ PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC_LOCAL));
+ PrintMap(&printer, n1, dynamics_->GetMap(Variable::DYNAMIC_GLOBAL));
+ }
// Print inner scopes (disable by providing negative n).
if (n >= 0) {
@@ -495,23 +495,8 @@
Variable* Scope::NonLocal(Handle<String> name, Variable::Mode mode) {
- // Space optimization: reuse existing non-local with the same name
- // and mode.
- LocalsMap* map = NULL;
- switch (mode) {
- case Variable::DYNAMIC:
- map = &dynamics_;
- break;
- case Variable::DYNAMIC_LOCAL:
- map = &dynamics_local_;
- break;
- case Variable::DYNAMIC_GLOBAL:
- map = &dynamics_global_;
- break;
- default:
- UNREACHABLE();
- break;
- }
+ if (dynamics_ == NULL) dynamics_ = new DynamicScopePart();
+ LocalsMap* map = dynamics_->GetMap(mode);
Variable* var = map->Lookup(name);
if (var == NULL) {
// Declare a new non-local.
« no previous file with comments | « src/scopes.h ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698