Reorder fields of AstNode subclasses for better packing
BUG= Review-Url: https://codereview.chromium.org/2149663003 Cr-Commit-Position: refs/heads/master@{#37834}
This commit is contained in:
parent
a51f429772
commit
3cd82879e6
@ -177,8 +177,8 @@ VariableProxy::VariableProxy(Zone* zone, Variable* var, int start_position,
|
||||
bit_field_(IsThisField::encode(var->is_this()) |
|
||||
IsAssignedField::encode(false) |
|
||||
IsResolvedField::encode(false)),
|
||||
raw_name_(var->raw_name()),
|
||||
end_position_(end_position) {
|
||||
end_position_(end_position),
|
||||
raw_name_(var->raw_name()) {
|
||||
BindTo(var);
|
||||
}
|
||||
|
||||
@ -189,8 +189,8 @@ VariableProxy::VariableProxy(Zone* zone, const AstRawString* name,
|
||||
bit_field_(IsThisField::encode(variable_kind == Variable::THIS) |
|
||||
IsAssignedField::encode(false) |
|
||||
IsResolvedField::encode(false)),
|
||||
raw_name_(name),
|
||||
end_position_(end_position) {}
|
||||
end_position_(end_position),
|
||||
raw_name_(name) {}
|
||||
|
||||
void VariableProxy::BindTo(Variable* var) {
|
||||
DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name());
|
||||
|
180
src/ast/ast.h
180
src/ast/ast.h
@ -229,6 +229,8 @@ class AstNode: public ZoneObject {
|
||||
|
||||
int position_;
|
||||
NodeType node_type_;
|
||||
// Ends with NodeType which is uint8_t sized. Deriving classes in turn begin
|
||||
// sub-int32_t-sized fields for optimum packing efficiency.
|
||||
};
|
||||
|
||||
|
||||
@ -358,8 +360,8 @@ class Expression : public AstNode {
|
||||
protected:
|
||||
Expression(Zone* zone, int pos, NodeType type)
|
||||
: AstNode(pos, type),
|
||||
base_id_(BailoutId::None().ToInt()),
|
||||
bit_field_(0) {}
|
||||
bit_field_(0),
|
||||
base_id_(BailoutId::None().ToInt()) {}
|
||||
static int parent_num_ids() { return 0; }
|
||||
void set_to_boolean_types(uint16_t types) {
|
||||
bit_field_ = ToBooleanTypesField::update(bit_field_, types);
|
||||
@ -373,11 +375,9 @@ class Expression : public AstNode {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
uint16_t bit_field_;
|
||||
int base_id_;
|
||||
class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {};
|
||||
uint16_t bit_field_;
|
||||
// Ends with 16-bit field; deriving classes in turn begin with
|
||||
// 16-bit fields for optimum packing efficiency.
|
||||
};
|
||||
|
||||
|
||||
@ -409,9 +409,9 @@ class BreakableStatement : public Statement {
|
||||
BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
|
||||
BreakableType breakable_type, int position, NodeType type)
|
||||
: Statement(zone, position, type),
|
||||
labels_(labels),
|
||||
breakable_type_(breakable_type),
|
||||
base_id_(BailoutId::None().ToInt()) {
|
||||
base_id_(BailoutId::None().ToInt()),
|
||||
labels_(labels) {
|
||||
DCHECK(labels == NULL || labels->length() > 0);
|
||||
}
|
||||
static int parent_num_ids() { return 0; }
|
||||
@ -424,10 +424,10 @@ class BreakableStatement : public Statement {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
ZoneList<const AstRawString*>* labels_;
|
||||
BreakableType breakable_type_;
|
||||
Label break_target_;
|
||||
int base_id_;
|
||||
Label break_target_;
|
||||
ZoneList<const AstRawString*>* labels_;
|
||||
};
|
||||
|
||||
|
||||
@ -938,10 +938,10 @@ class WithStatement final : public Statement {
|
||||
WithStatement(Zone* zone, Scope* scope, Expression* expression,
|
||||
Statement* statement, int pos)
|
||||
: Statement(zone, pos, kWithStatement),
|
||||
base_id_(BailoutId::None().ToInt()),
|
||||
scope_(scope),
|
||||
expression_(expression),
|
||||
statement_(statement),
|
||||
base_id_(BailoutId::None().ToInt()) {}
|
||||
statement_(statement) {}
|
||||
static int parent_num_ids() { return 0; }
|
||||
|
||||
int base_id() const {
|
||||
@ -952,10 +952,10 @@ class WithStatement final : public Statement {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
int base_id_;
|
||||
Scope* scope_;
|
||||
Expression* expression_;
|
||||
Statement* statement_;
|
||||
int base_id_;
|
||||
};
|
||||
|
||||
|
||||
@ -1056,10 +1056,10 @@ class IfStatement final : public Statement {
|
||||
IfStatement(Zone* zone, Expression* condition, Statement* then_statement,
|
||||
Statement* else_statement, int pos)
|
||||
: Statement(zone, pos, kIfStatement),
|
||||
base_id_(BailoutId::None().ToInt()),
|
||||
condition_(condition),
|
||||
then_statement_(then_statement),
|
||||
else_statement_(else_statement),
|
||||
base_id_(BailoutId::None().ToInt()) {}
|
||||
else_statement_(else_statement) {}
|
||||
static int parent_num_ids() { return 0; }
|
||||
|
||||
int base_id() const {
|
||||
@ -1070,10 +1070,10 @@ class IfStatement final : public Statement {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
int base_id_;
|
||||
Expression* condition_;
|
||||
Statement* then_statement_;
|
||||
Statement* else_statement_;
|
||||
int base_id_;
|
||||
};
|
||||
|
||||
|
||||
@ -1098,12 +1098,12 @@ class TryStatement : public Statement {
|
||||
protected:
|
||||
TryStatement(Zone* zone, Block* try_block, int pos, NodeType type)
|
||||
: Statement(zone, pos, type),
|
||||
try_block_(try_block),
|
||||
catch_predicted_(false) {}
|
||||
catch_predicted_(false),
|
||||
try_block_(try_block) {}
|
||||
|
||||
private:
|
||||
Block* try_block_;
|
||||
bool catch_predicted_;
|
||||
Block* try_block_;
|
||||
};
|
||||
|
||||
|
||||
@ -1133,16 +1133,16 @@ class TryCatchStatement final : public TryStatement {
|
||||
Variable* variable, Block* catch_block,
|
||||
bool clear_pending_message, int pos)
|
||||
: TryStatement(zone, try_block, pos, kTryCatchStatement),
|
||||
clear_pending_message_(clear_pending_message),
|
||||
scope_(scope),
|
||||
variable_(variable),
|
||||
catch_block_(catch_block),
|
||||
clear_pending_message_(clear_pending_message) {}
|
||||
catch_block_(catch_block) {}
|
||||
|
||||
private:
|
||||
bool clear_pending_message_;
|
||||
Scope* scope_;
|
||||
Variable* variable_;
|
||||
Block* catch_block_;
|
||||
bool clear_pending_message_;
|
||||
};
|
||||
|
||||
|
||||
@ -1282,9 +1282,9 @@ class MaterializedLiteral : public Expression {
|
||||
protected:
|
||||
MaterializedLiteral(Zone* zone, int literal_index, int pos, NodeType type)
|
||||
: Expression(zone, pos, type),
|
||||
literal_index_(literal_index),
|
||||
is_simple_(false),
|
||||
depth_(0) {}
|
||||
depth_(0),
|
||||
literal_index_(literal_index) {}
|
||||
|
||||
// A materialized literal is simple if the values consist of only
|
||||
// constants and simple object and array literals.
|
||||
@ -1293,7 +1293,7 @@ class MaterializedLiteral : public Expression {
|
||||
friend class CompileTimeValue;
|
||||
|
||||
void set_depth(int depth) {
|
||||
DCHECK(depth >= 1);
|
||||
DCHECK_LE(1, depth);
|
||||
depth_ = depth;
|
||||
}
|
||||
|
||||
@ -1310,9 +1310,9 @@ class MaterializedLiteral : public Expression {
|
||||
Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
|
||||
|
||||
private:
|
||||
bool is_simple_ : 1;
|
||||
int depth_ : 31;
|
||||
int literal_index_;
|
||||
bool is_simple_;
|
||||
int depth_;
|
||||
|
||||
friend class AstLiteralReindexer;
|
||||
};
|
||||
@ -1323,12 +1323,13 @@ class MaterializedLiteral : public Expression {
|
||||
// to the code generator.
|
||||
class ObjectLiteralProperty final : public ZoneObject {
|
||||
public:
|
||||
enum Kind {
|
||||
enum Kind : uint8_t {
|
||||
CONSTANT, // Property with constant value (compile time).
|
||||
COMPUTED, // Property with computed value (execution time).
|
||||
MATERIALIZED_LITERAL, // Property value is a materialized literal.
|
||||
GETTER, SETTER, // Property is an accessor function.
|
||||
PROTOTYPE // Property is __proto__.
|
||||
GETTER,
|
||||
SETTER, // Property is an accessor function.
|
||||
PROTOTYPE // Property is __proto__.
|
||||
};
|
||||
|
||||
Expression* key() { return key_; }
|
||||
@ -1463,24 +1464,24 @@ class ObjectLiteral final : public MaterializedLiteral {
|
||||
|
||||
protected:
|
||||
ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
|
||||
int boilerplate_properties, int pos)
|
||||
uint32_t boilerplate_properties, int pos)
|
||||
: MaterializedLiteral(zone, literal_index, pos, kObjectLiteral),
|
||||
properties_(properties),
|
||||
boilerplate_properties_(boilerplate_properties),
|
||||
fast_elements_(false),
|
||||
has_elements_(false),
|
||||
may_store_doubles_(false) {}
|
||||
may_store_doubles_(false),
|
||||
properties_(properties) {}
|
||||
static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
uint32_t boilerplate_properties_ : 29;
|
||||
bool fast_elements_ : 1;
|
||||
bool has_elements_ : 1;
|
||||
bool may_store_doubles_ : 1;
|
||||
FeedbackVectorSlot slot_;
|
||||
Handle<FixedArray> constant_properties_;
|
||||
ZoneList<Property*>* properties_;
|
||||
int boilerplate_properties_;
|
||||
bool fast_elements_;
|
||||
bool has_elements_;
|
||||
bool may_store_doubles_;
|
||||
FeedbackVectorSlot slot_;
|
||||
};
|
||||
|
||||
|
||||
@ -1518,14 +1519,14 @@ class RegExpLiteral final : public MaterializedLiteral {
|
||||
RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags,
|
||||
int literal_index, int pos)
|
||||
: MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral),
|
||||
pattern_(pattern),
|
||||
flags_(flags) {
|
||||
flags_(flags),
|
||||
pattern_(pattern) {
|
||||
set_depth(1);
|
||||
}
|
||||
|
||||
private:
|
||||
const AstRawString* const pattern_;
|
||||
int const flags_;
|
||||
const AstRawString* const pattern_;
|
||||
};
|
||||
|
||||
|
||||
@ -1592,17 +1593,17 @@ class ArrayLiteral final : public MaterializedLiteral {
|
||||
ArrayLiteral(Zone* zone, ZoneList<Expression*>* values,
|
||||
int first_spread_index, int literal_index, int pos)
|
||||
: MaterializedLiteral(zone, literal_index, pos, kArrayLiteral),
|
||||
values_(values),
|
||||
first_spread_index_(first_spread_index) {}
|
||||
first_spread_index_(first_spread_index),
|
||||
values_(values) {}
|
||||
static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
Handle<FixedArray> constant_elements_;
|
||||
ZoneList<Expression*>* values_;
|
||||
int first_spread_index_;
|
||||
FeedbackVectorSlot literal_slot_;
|
||||
Handle<FixedArray> constant_elements_;
|
||||
ZoneList<Expression*>* values_;
|
||||
};
|
||||
|
||||
|
||||
@ -1683,15 +1684,15 @@ class VariableProxy final : public Expression {
|
||||
// Start with 16-bit (or smaller) field, which should get packed together
|
||||
// with Expression's trailing 16-bit field.
|
||||
uint8_t bit_field_;
|
||||
// Position is stored in the AstNode superclass, but VariableProxy needs to
|
||||
// know its end position too (for error messages). It cannot be inferred from
|
||||
// the variable name length because it can contain escapes.
|
||||
int end_position_;
|
||||
FeedbackVectorSlot variable_feedback_slot_;
|
||||
union {
|
||||
const AstRawString* raw_name_; // if !is_resolved_
|
||||
Variable* var_; // if is_resolved_
|
||||
};
|
||||
// Position is stored in the AstNode superclass, but VariableProxy needs to
|
||||
// know its end position too (for error messages). It cannot be inferred from
|
||||
// the variable name length because it can contain escapes.
|
||||
int end_position_;
|
||||
};
|
||||
|
||||
|
||||
@ -1898,9 +1899,9 @@ class Call final : public Expression {
|
||||
Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
|
||||
int pos)
|
||||
: Expression(zone, pos, kCall),
|
||||
bit_field_(IsUninitializedField::encode(false)),
|
||||
expression_(expression),
|
||||
arguments_(arguments),
|
||||
bit_field_(IsUninitializedField::encode(false)) {
|
||||
arguments_(arguments) {
|
||||
if (expression->IsProperty()) {
|
||||
expression->AsProperty()->mark_for_call();
|
||||
}
|
||||
@ -1910,15 +1911,15 @@ class Call final : public Expression {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
class IsUninitializedField : public BitField8<bool, 0, 1> {};
|
||||
class IsTailField : public BitField8<bool, 1, 1> {};
|
||||
uint8_t bit_field_;
|
||||
FeedbackVectorSlot ic_slot_;
|
||||
FeedbackVectorSlot stub_slot_;
|
||||
Expression* expression_;
|
||||
ZoneList<Expression*>* arguments_;
|
||||
Handle<JSFunction> target_;
|
||||
Handle<AllocationSite> allocation_site_;
|
||||
class IsUninitializedField : public BitField8<bool, 0, 1> {};
|
||||
class IsTailField : public BitField8<bool, 1, 1> {};
|
||||
uint8_t bit_field_;
|
||||
};
|
||||
|
||||
|
||||
@ -1969,21 +1970,21 @@ class CallNew final : public Expression {
|
||||
CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
|
||||
int pos)
|
||||
: Expression(zone, pos, kCallNew),
|
||||
is_monomorphic_(false),
|
||||
expression_(expression),
|
||||
arguments_(arguments),
|
||||
is_monomorphic_(false) {}
|
||||
arguments_(arguments) {}
|
||||
|
||||
static int parent_num_ids() { return Expression::num_ids(); }
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
bool is_monomorphic_;
|
||||
FeedbackVectorSlot callnew_feedback_slot_;
|
||||
Expression* expression_;
|
||||
ZoneList<Expression*>* arguments_;
|
||||
bool is_monomorphic_;
|
||||
Handle<JSFunction> target_;
|
||||
Handle<AllocationSite> allocation_site_;
|
||||
FeedbackVectorSlot callnew_feedback_slot_;
|
||||
};
|
||||
|
||||
|
||||
@ -2024,8 +2025,8 @@ class CallRuntime final : public Expression {
|
||||
CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments,
|
||||
int pos)
|
||||
: Expression(zone, pos, kCallRuntime),
|
||||
function_(NULL),
|
||||
context_index_(context_index),
|
||||
function_(NULL),
|
||||
arguments_(arguments) {}
|
||||
|
||||
static int parent_num_ids() { return Expression::num_ids(); }
|
||||
@ -2033,8 +2034,8 @@ class CallRuntime final : public Expression {
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
const Runtime::Function* function_;
|
||||
int context_index_;
|
||||
const Runtime::Function* function_;
|
||||
ZoneList<Expression*>* arguments_;
|
||||
};
|
||||
|
||||
@ -2208,10 +2209,10 @@ class CountOperation final : public Expression {
|
||||
// Starts with 16-bit field, which should get packed together with
|
||||
// Expression's trailing 16-bit field.
|
||||
uint16_t bit_field_;
|
||||
FeedbackVectorSlot slot_;
|
||||
Type* type_;
|
||||
Expression* expression_;
|
||||
SmallMapList receiver_types_;
|
||||
FeedbackVectorSlot slot_;
|
||||
};
|
||||
|
||||
|
||||
@ -2276,15 +2277,15 @@ class Spread final : public Expression {
|
||||
protected:
|
||||
Spread(Zone* zone, Expression* expression, int pos, int expr_pos)
|
||||
: Expression(zone, pos, kSpread),
|
||||
expression_(expression),
|
||||
expr_pos_(expr_pos) {}
|
||||
expr_pos_(expr_pos),
|
||||
expression_(expression) {}
|
||||
static int parent_num_ids() { return Expression::num_ids(); }
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
Expression* expression_;
|
||||
int expr_pos_;
|
||||
Expression* expression_;
|
||||
};
|
||||
|
||||
|
||||
@ -2397,11 +2398,11 @@ class Assignment final : public Expression {
|
||||
// Starts with 16-bit field, which should get packed together with
|
||||
// Expression's trailing 16-bit field.
|
||||
uint16_t bit_field_;
|
||||
FeedbackVectorSlot slot_;
|
||||
Expression* target_;
|
||||
Expression* value_;
|
||||
BinaryOperation* binary_operation_;
|
||||
SmallMapList receiver_types_;
|
||||
FeedbackVectorSlot slot_;
|
||||
};
|
||||
|
||||
|
||||
@ -2476,16 +2477,16 @@ class Yield final : public Expression {
|
||||
Yield(Zone* zone, Expression* generator_object, Expression* expression,
|
||||
int pos, OnException on_exception)
|
||||
: Expression(zone, pos, kYield),
|
||||
generator_object_(generator_object),
|
||||
expression_(expression),
|
||||
on_exception_(on_exception),
|
||||
yield_id_(-1) {}
|
||||
yield_id_(-1),
|
||||
generator_object_(generator_object),
|
||||
expression_(expression) {}
|
||||
|
||||
private:
|
||||
Expression* generator_object_;
|
||||
Expression* expression_;
|
||||
OnException on_exception_;
|
||||
int yield_id_;
|
||||
Expression* generator_object_;
|
||||
Expression* expression_;
|
||||
};
|
||||
|
||||
|
||||
@ -2648,17 +2649,17 @@ class FunctionLiteral final : public Expression {
|
||||
EagerCompileHint eager_compile_hint, FunctionKind kind,
|
||||
int position, bool is_function)
|
||||
: Expression(zone, position, kFunctionLiteral),
|
||||
raw_name_(name),
|
||||
scope_(scope),
|
||||
body_(body),
|
||||
raw_inferred_name_(ast_value_factory->empty_string()),
|
||||
ast_properties_(zone),
|
||||
dont_optimize_reason_(kNoReason),
|
||||
materialized_literal_count_(materialized_literal_count),
|
||||
expected_property_count_(expected_property_count),
|
||||
parameter_count_(parameter_count),
|
||||
function_token_position_(kNoSourcePosition),
|
||||
yield_count_(0) {
|
||||
yield_count_(0),
|
||||
raw_name_(name),
|
||||
scope_(scope),
|
||||
body_(body),
|
||||
raw_inferred_name_(ast_value_factory->empty_string()),
|
||||
ast_properties_(zone) {
|
||||
bitfield_ =
|
||||
FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
|
||||
HasDuplicateParameters::encode(has_duplicate_parameters ==
|
||||
@ -2682,12 +2683,6 @@ class FunctionLiteral final : public Expression {
|
||||
// with Expression's trailing 16-bit field.
|
||||
uint16_t bitfield_;
|
||||
|
||||
const AstString* raw_name_;
|
||||
Scope* scope_;
|
||||
ZoneList<Statement*>* body_;
|
||||
const AstString* raw_inferred_name_;
|
||||
Handle<String> inferred_name_;
|
||||
AstProperties ast_properties_;
|
||||
BailoutReason dont_optimize_reason_;
|
||||
|
||||
int materialized_literal_count_;
|
||||
@ -2695,6 +2690,13 @@ class FunctionLiteral final : public Expression {
|
||||
int parameter_count_;
|
||||
int function_token_position_;
|
||||
int yield_count_;
|
||||
|
||||
const AstString* raw_name_;
|
||||
Scope* scope_;
|
||||
ZoneList<Statement*>* body_;
|
||||
const AstString* raw_inferred_name_;
|
||||
Handle<String> inferred_name_;
|
||||
AstProperties ast_properties_;
|
||||
};
|
||||
|
||||
|
||||
@ -2750,26 +2752,26 @@ class ClassLiteral final : public Expression {
|
||||
ZoneList<Property*>* properties, int start_position,
|
||||
int end_position)
|
||||
: Expression(zone, start_position, kClassLiteral),
|
||||
end_position_(end_position),
|
||||
scope_(scope),
|
||||
class_variable_proxy_(class_variable_proxy),
|
||||
extends_(extends),
|
||||
constructor_(constructor),
|
||||
properties_(properties),
|
||||
end_position_(end_position) {}
|
||||
properties_(properties) {}
|
||||
|
||||
static int parent_num_ids() { return Expression::num_ids(); }
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
|
||||
int end_position_;
|
||||
FeedbackVectorSlot prototype_slot_;
|
||||
FeedbackVectorSlot proxy_slot_;
|
||||
Scope* scope_;
|
||||
VariableProxy* class_variable_proxy_;
|
||||
Expression* extends_;
|
||||
FunctionLiteral* constructor_;
|
||||
ZoneList<Property*>* properties_;
|
||||
int end_position_;
|
||||
FeedbackVectorSlot prototype_slot_;
|
||||
FeedbackVectorSlot proxy_slot_;
|
||||
};
|
||||
|
||||
|
||||
@ -3232,10 +3234,8 @@ class AstNodeFactory final BASE_EMBEDDED {
|
||||
}
|
||||
|
||||
ObjectLiteral* NewObjectLiteral(
|
||||
ZoneList<ObjectLiteral::Property*>* properties,
|
||||
int literal_index,
|
||||
int boilerplate_properties,
|
||||
int pos) {
|
||||
ZoneList<ObjectLiteral::Property*>* properties, int literal_index,
|
||||
uint32_t boilerplate_properties, int pos) {
|
||||
return new (local_zone_) ObjectLiteral(
|
||||
local_zone_, properties, literal_index, boilerplate_properties, pos);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user