Revision: 24593
Author: [email protected]
Date: Tue Oct 14 10:24:18 2014 UTC
Log: Squeeze the layout of various AST node types.
The following AST node types were improved (in decreasing number of
importance for asm.js-like source code): Expression, VariableProxy,
Assignment, BinaryOperation, Declaration, Property, Call.
BUG=chromium:417697
LOG=y
[email protected]
Review URL: https://codereview.chromium.org/646803004
https://code.google.com/p/v8/source/detail?r=24593
Modified:
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
=======================================
--- /branches/bleeding_edge/src/ast.cc Fri Oct 10 13:22:10 2014 UTC
+++ /branches/bleeding_edge/src/ast.cc Tue Oct 14 10:24:18 2014 UTC
@@ -62,12 +62,12 @@
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position,
IdGen* id_gen)
: Expression(zone, position, 0, id_gen),
- raw_name_(var->raw_name()),
- interface_(var->interface()),
- variable_feedback_slot_(FeedbackVectorSlot::Invalid()),
is_this_(var->is_this()),
is_assigned_(false),
- is_resolved_(false) {
+ is_resolved_(false),
+ variable_feedback_slot_(FeedbackVectorSlot::Invalid()),
+ raw_name_(var->raw_name()),
+ interface_(var->interface()) {
BindTo(var);
}
@@ -75,12 +75,12 @@
VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool
is_this,
Interface* interface, int position, IdGen*
id_gen)
: Expression(zone, position, 0, id_gen),
- raw_name_(name),
- interface_(interface),
- variable_feedback_slot_(FeedbackVectorSlot::Invalid()),
is_this_(is_this),
is_assigned_(false),
- is_resolved_(false) {}
+ is_resolved_(false),
+ variable_feedback_slot_(FeedbackVectorSlot::Invalid()),
+ raw_name_(name),
+ interface_(interface) {}
void VariableProxy::BindTo(Variable* var) {
@@ -100,12 +100,12 @@
Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
Expression* value, int pos, IdGen* id_gen)
: Expression(zone, pos, num_ids(), id_gen),
+ is_uninitialized_(false),
+ store_mode_(STANDARD_STORE),
op_(op),
target_(target),
value_(value),
- binary_operation_(NULL),
- is_uninitialized_(false),
- store_mode_(STANDARD_STORE) {}
+ binary_operation_(NULL) {}
Token::Value Assignment::binary_op() const {
@@ -434,7 +434,7 @@
bool BinaryOperation::ResultOverwriteAllowed() const {
- switch (op_) {
+ switch (op()) {
case Token::COMMA:
case Token::OR:
case Token::AND:
=======================================
--- /branches/bleeding_edge/src/ast.h Fri Oct 10 13:27:52 2014 UTC
+++ /branches/bleeding_edge/src/ast.h Tue Oct 14 10:24:18 2014 UTC
@@ -391,22 +391,22 @@
protected:
Expression(Zone* zone, int pos, int num_ids_needed_by_subclass, IdGen*
id_gen)
: AstNode(pos),
+ base_id_(
+ id_gen->ReserveIdRange(num_ids_needed_by_subclass +
num_ids())),
+ bounds_(Bounds::Unbounded(zone)),
is_parenthesized_(false),
- is_multi_parenthesized_(false),
- bounds_(Bounds::Unbounded(zone)),
- base_id_(
- id_gen->ReserveIdRange(num_ids_needed_by_subclass +
num_ids())) {}
+ is_multi_parenthesized_(false) {}
void set_to_boolean_types(byte types) { to_boolean_types_ = types; }
static int num_ids() { return 2; }
int base_id() const { return base_id_; }
private:
+ const int base_id_;
+ Bounds bounds_;
byte to_boolean_types_;
bool is_parenthesized_ : 1;
bool is_multi_parenthesized_ : 1;
- Bounds bounds_;
- const int base_id_;
};
@@ -511,21 +511,15 @@
virtual bool IsInlineable() const;
protected:
- Declaration(Zone* zone,
- VariableProxy* proxy,
- VariableMode mode,
- Scope* scope,
+ Declaration(Zone* zone, VariableProxy* proxy, VariableMode mode, Scope*
scope,
int pos)
- : AstNode(pos),
- proxy_(proxy),
- mode_(mode),
- scope_(scope) {
+ : AstNode(pos), mode_(mode), proxy_(proxy), scope_(scope) {
DCHECK(IsDeclaredVariableMode(mode));
}
private:
- VariableProxy* proxy_;
VariableMode mode_;
+ VariableProxy* proxy_;
// Nested scope from which the declaration originated.
Scope* scope_;
@@ -1711,15 +1705,15 @@
VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
Interface* interface, int position, IdGen* id_gen);
+ bool is_this_ : 1;
+ bool is_assigned_ : 1;
+ bool is_resolved_ : 1;
+ FeedbackVectorSlot variable_feedback_slot_;
union {
const AstRawString* raw_name_; // if !is_resolved_
Variable* var_; // if is_resolved_
};
Interface* interface_;
- FeedbackVectorSlot variable_feedback_slot_;
- bool is_this_ : 1;
- bool is_assigned_ : 1;
- bool is_resolved_ : 1;
};
@@ -1773,25 +1767,24 @@
protected:
Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen*
id_gen)
: Expression(zone, pos, num_ids(), id_gen),
- obj_(obj),
- key_(key),
- property_feedback_slot_(FeedbackVectorSlot::Invalid()),
is_for_call_(false),
is_uninitialized_(false),
- is_string_access_(false) {}
+ is_string_access_(false),
+ property_feedback_slot_(FeedbackVectorSlot::Invalid()),
+ obj_(obj),
+ key_(key) {}
static int num_ids() { return 2; }
int base_id() const { return Expression::base_id() +
Expression::num_ids(); }
private:
+ bool is_for_call_ : 1;
+ bool is_uninitialized_ : 1;
+ bool is_string_access_ : 1;
+ FeedbackVectorSlot property_feedback_slot_;
Expression* obj_;
Expression* key_;
- FeedbackVectorSlot property_feedback_slot_;
-
SmallMapList receiver_types_;
- bool is_for_call_ : 1;
- bool is_uninitialized_ : 1;
- bool is_string_access_ : 1;
};
@@ -1870,9 +1863,9 @@
Call(Zone* zone, Expression* expression, ZoneList<Expression*>*
arguments,
int pos, IdGen* id_gen)
: Expression(zone, pos, num_ids(), id_gen),
+ call_feedback_slot_(FeedbackVectorSlot::Invalid()),
expression_(expression),
- arguments_(arguments),
- call_feedback_slot_(FeedbackVectorSlot::Invalid()) {
+ arguments_(arguments) {
if (expression->IsProperty()) {
expression->AsProperty()->mark_for_call();
}
@@ -1882,12 +1875,12 @@
int base_id() const { return Expression::base_id() +
Expression::num_ids(); }
private:
+ FeedbackVectorSlot call_feedback_slot_;
Expression* expression_;
ZoneList<Expression*>* arguments_;
Handle<JSFunction> target_;
Handle<Cell> cell_;
Handle<AllocationSite> allocation_site_;
- FeedbackVectorSlot call_feedback_slot_;
};
@@ -2035,7 +2028,7 @@
virtual bool ResultOverwriteAllowed() const OVERRIDE;
- Token::Value op() const { return op_; }
+ Token::Value op() const { return static_cast<Token::Value>(op_); }
Expression* left() const { return left_; }
Expression* right() const { return right_; }
Handle<AllocationSite> allocation_site() const { return
allocation_site_; }
@@ -2050,8 +2043,14 @@
TypeFeedbackId BinaryOperationFeedbackId() const {
return TypeFeedbackId(base_id() + 1);
}
- Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
- void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; }
+ Maybe<int> fixed_right_arg() const {
+ return has_fixed_right_arg_ ? Maybe<int>(fixed_right_arg_value_)
+ : Maybe<int>();
+ }
+ void set_fixed_right_arg(Maybe<int> arg) {
+ has_fixed_right_arg_ = arg.has_value;
+ if (arg.has_value) fixed_right_arg_value_ = arg.value;
+ }
virtual void RecordToBooleanTypeFeedback(
TypeFeedbackOracle* oracle) OVERRIDE;
@@ -2060,7 +2059,7 @@
BinaryOperation(Zone* zone, Token::Value op, Expression* left,
Expression* right, int pos, IdGen* id_gen)
: Expression(zone, pos, num_ids(), id_gen),
- op_(op),
+ op_(static_cast<byte>(op)),
left_(left),
right_(right) {
DCHECK(Token::IsBinaryOp(op));
@@ -2070,14 +2069,14 @@
int base_id() const { return Expression::base_id() +
Expression::num_ids(); }
private:
- Token::Value op_;
+ const byte op_; // actually Token::Value
+ // TODO(rossberg): the fixed arg should probably be represented as a
Constant
+ // type for the RHS. Currenty it's actually a Maybe<int>
+ bool has_fixed_right_arg_;
+ int fixed_right_arg_value_;
Expression* left_;
Expression* right_;
Handle<AllocationSite> allocation_site_;
-
- // TODO(rossberg): the fixed arg should probably be represented as a
Constant
- // type for the RHS.
- Maybe<int> fixed_right_arg_;
};
@@ -2271,14 +2270,14 @@
}
private:
+ bool is_uninitialized_ : 1;
+ IcCheckType key_type_ : 1;
+ KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
+ // must have extra bit.
Token::Value op_;
Expression* target_;
Expression* value_;
BinaryOperation* binary_operation_;
- bool is_uninitialized_ : 1;
- IcCheckType key_type_ : 1;
- KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed,
- // must have extra bit.
SmallMapList receiver_types_;
};
--
--
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.