Revision: 24413
Author: [email protected]
Date: Mon Oct 6 12:56:11 2014 UTC
Log: Squeeze the layout of variable proxy nodes.
Around 200MB less peak memory usage in the bug mentioned below.
BUG=417697
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/629983002
https://code.google.com/p/v8/source/detail?r=24413
Modified:
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/parser.cc
/branches/bleeding_edge/src/rewriter.cc
/branches/bleeding_edge/src/scopes.cc
=======================================
--- /branches/bleeding_edge/src/ast.cc Thu Oct 2 13:05:11 2014 UTC
+++ /branches/bleeding_edge/src/ast.cc Mon Oct 6 12:56:11 2014 UTC
@@ -62,12 +62,12 @@
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position,
IdGen* id_gen)
: Expression(zone, position, id_gen),
- name_(var->raw_name()),
- var_(NULL), // Will be set by the call to BindTo.
+ raw_name_(var->raw_name()),
+ interface_(var->interface()),
+ variable_feedback_slot_(kInvalidFeedbackSlot),
is_this_(var->is_this()),
is_assigned_(false),
- interface_(var->interface()),
- variable_feedback_slot_(kInvalidFeedbackSlot) {
+ is_resolved_(false) {
BindTo(var);
}
@@ -75,25 +75,24 @@
VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool
is_this,
Interface* interface, int position, IdGen*
id_gen)
: Expression(zone, position, id_gen),
- name_(name),
- var_(NULL),
+ raw_name_(name),
+ interface_(interface),
+ variable_feedback_slot_(kInvalidFeedbackSlot),
is_this_(is_this),
is_assigned_(false),
- interface_(interface),
- variable_feedback_slot_(kInvalidFeedbackSlot) {}
+ is_resolved_(false) {}
void VariableProxy::BindTo(Variable* var) {
- DCHECK(var_ == NULL); // must be bound only once
- DCHECK(var != NULL); // must bind
DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
- DCHECK((is_this() && var->is_this()) || name_ == var->raw_name());
+ DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name());
// Ideally CONST-ness should match. However, this is very hard to achieve
// because we don't know the exact semantics of conflicting (const and
// non-const) multiple variable declarations, const vars introduced via
// eval() etc. Const-ness and variable declarations are a complete mess
// in JS. Sigh...
- var_ = var;
+ set_var(var);
+ set_is_resolved();
var->set_is_used();
}
=======================================
--- /branches/bleeding_edge/src/ast.h Thu Oct 2 13:05:11 2014 UTC
+++ /branches/bleeding_edge/src/ast.h Mon Oct 6 12:56:11 2014 UTC
@@ -1636,19 +1636,35 @@
DECLARE_NODE_TYPE(VariableProxy)
virtual bool IsValidReferenceExpression() const OVERRIDE {
- return var_ == NULL ? true : var_->IsValidReference();
+ return !is_resolved() || var()->IsValidReference();
}
- bool IsArguments() const { return var_ != NULL && var_->is_arguments(); }
+ bool IsArguments() const { return is_resolved() &&
var()->is_arguments(); }
- Handle<String> name() const { return name_->string(); }
- const AstRawString* raw_name() const { return name_; }
- Variable* var() const { return var_; }
+ Handle<String> name() const { return raw_name()->string(); }
+ const AstRawString* raw_name() const {
+ return is_resolved() ? var_->raw_name() : raw_name_;
+ }
+
+ Variable* var() const {
+ DCHECK(is_resolved());
+ return var_;
+ }
+ void set_var(Variable* v) {
+ DCHECK(!is_resolved());
+ DCHECK_NOT_NULL(v);
+ var_ = v;
+ }
+
bool is_this() const { return is_this_; }
- Interface* interface() const { return interface_; }
bool is_assigned() const { return is_assigned_; }
void set_is_assigned() { is_assigned_ = true; }
+
+ bool is_resolved() const { return is_resolved_; }
+ void set_is_resolved() { is_resolved_ = true; }
+
+ Interface* interface() const { return interface_; }
// Bind this proxy to the variable var. Interfaces must match.
void BindTo(Variable* var);
@@ -1666,12 +1682,15 @@
VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
Interface* interface, int position, IdGen* id_gen);
- const AstRawString* name_;
- Variable* var_; // resolved variable, or NULL
- bool is_this_;
- bool is_assigned_;
+ union {
+ const AstRawString* raw_name_; // if !is_resolved_
+ Variable* var_; // if is_resolved_
+ };
Interface* interface_;
int variable_feedback_slot_;
+ bool is_this_ : 1;
+ bool is_assigned_ : 1;
+ bool is_resolved_ : 1;
};
=======================================
--- /branches/bleeding_edge/src/parser.cc Thu Oct 2 11:52:54 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc Mon Oct 6 12:56:11 2014 UTC
@@ -2259,7 +2259,7 @@
}
// Record the end position of the initializer.
- if (proxy->var() != NULL) {
+ if (proxy->is_resolved()) {
proxy->var()->set_initializer_position(position());
}
=======================================
--- /branches/bleeding_edge/src/rewriter.cc Fri Aug 22 11:12:29 2014 UTC
+++ /branches/bleeding_edge/src/rewriter.cc Mon Oct 6 12:56:11 2014 UTC
@@ -253,9 +253,8 @@
// the end position of the function generated for executing the eval
code
// coincides with the end of the with scope which is the position
of '1'.
int pos = function->end_position();
- VariableProxy* result_proxy = processor.factory()->NewVariableProxy(
- result->raw_name(), false, result->interface(), pos);
- result_proxy->BindTo(result);
+ VariableProxy* result_proxy =
+ processor.factory()->NewVariableProxy(result, pos);
Statement* result_statement =
processor.factory()->NewReturnStatement(result_proxy, pos);
body->Add(result_statement, info->zone());
=======================================
--- /branches/bleeding_edge/src/scopes.cc Fri Sep 19 12:50:50 2014 UTC
+++ /branches/bleeding_edge/src/scopes.cc Mon Oct 6 12:56:11 2014 UTC
@@ -1031,7 +1031,7 @@
// If the proxy is already resolved there's nothing to do
// (functions and consts may be resolved by the parser).
- if (proxy->var() != NULL) return true;
+ if (proxy->is_resolved()) return true;
// Otherwise, try to resolve the variable.
BindingKind binding_kind;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.