Optimized layout padding in 4 classes in ast.h

This reduces sizeof of these classes by 8 bytes on 64-bit
(16 bytes considering allocation size granularity for some of these classes).

I don't know how many instances remain at the end of loading a page. These objects are Zone objects which makes it more difficult to count the number
of instances. But looking at allocations only on cnn.com I've got 70K for
BinaryOperation, 20K for CompareOperation, 1.5K for CaseClause. There aren't
not many allocations of NativeFunctionLiteral but I decided to fix it too to
keep the same layout pattern.

Before:
    class v8::internal::CaseClause [sizeof = 56]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      <padding> (4 bytes)
      [sizeof=8] v8::internal::Expression* label_
      [sizeof=8] v8::internal::Label body_target_
      [sizeof=8] v8::internal::ZoneList<v8::internal::Statement *>* statements_
      [sizeof=8] v8::internal::AstType* compare_type_
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      <padding> (4 bytes)
    }

After:
    class v8::internal::CaseClause [sizeof = 48]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      [sizeof=8] v8::internal::Expression* label_
      [sizeof=8] v8::internal::Label body_target_
      [sizeof=8] v8::internal::ZoneList<v8::internal::Statement *>* statements_
      [sizeof=8] v8::internal::AstType* compare_type_
    }

Before:
    class v8::internal::BinaryOperation [sizeof = 56]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      [sizeof=1] bool has_fixed_right_arg_
      <padding> (3 bytes)
      [sizeof=4] int fixed_right_arg_value_
      <padding> (4 bytes)
      [sizeof=8] v8::internal::Expression* left_
      [sizeof=8] v8::internal::Expression* right_
      [sizeof=8] v8::internal::Handle<v8::internal::AllocationSite> allocation_site_
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      <padding> (4 bytes)
    }

After:
    class v8::internal::BinaryOperation [sizeof = 48]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      [sizeof=8] v8::internal::Expression* left_
      [sizeof=8] v8::internal::Expression* right_
      [sizeof=8] v8::internal::Handle<v8::internal::AllocationSite> allocation_site_
      [sizeof=1] bool has_fixed_right_arg_
      <padding> (3 bytes)
      [sizeof=4] int fixed_right_arg_value_
    }

Before:
    class v8::internal::CompareOperation [sizeof = 48]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      <padding> (4 bytes)
      [sizeof=8] v8::internal::Expression* left_
      [sizeof=8] v8::internal::Expression* right_
      [sizeof=8] v8::internal::AstType* combined_type_
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      <padding> (4 bytes)
    }

After:
    class v8::internal::CompareOperation [sizeof = 40]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      [sizeof=4] v8::internal::FeedbackSlot feedback_slot_
      [sizeof=8] v8::internal::Expression* left_
      [sizeof=8] v8::internal::Expression* right_
      [sizeof=8] v8::internal::AstType* combined_type_
    }

Before:
    class v8::internal::NativeFunctionLiteral [sizeof = 40]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      <padding> (4 bytes)
      [sizeof=8] v8::internal::AstRawString* name_
      [sizeof=8] v8::Extension* extension_
      [sizeof=4] v8::internal::FeedbackSlot literal_feedback_slot_
      <padding> (4 bytes)
    }

After:
    class v8::internal::NativeFunctionLiteral [sizeof = 32]
      : public v8::internal::Expression {
      [sizeof=12] v8::internal::Expression
      [sizeof=4] v8::internal::FeedbackSlot literal_feedback_slot_
      [sizeof=8] v8::internal::AstRawString* name_
      [sizeof=8] v8::Extension* extension_
    }

BUG=chromium:710933

Review-Url: https://codereview.chromium.org/2843293003
Cr-Commit-Position: refs/heads/master@{#44989}
This commit is contained in:
stanisc 2017-04-28 13:58:53 -07:00 committed by Commit bot
parent 7e4282d503
commit 6408032e61

View File

@ -977,11 +977,11 @@ class CaseClause final : public Expression {
CaseClause(Expression* label, ZoneList<Statement*>* statements, int pos);
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
FeedbackSlot feedback_slot_;
Expression* label_;
Label body_target_;
ZoneList<Statement*>* statements_;
AstType* compare_type_;
FeedbackSlot feedback_slot_;
};
@ -2183,10 +2183,10 @@ class BinaryOperation final : public Expression {
BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos)
: Expression(pos, kBinaryOperation),
has_fixed_right_arg_(false),
fixed_right_arg_value_(0),
left_(left),
right_(right) {
right_(right),
has_fixed_right_arg_(false),
fixed_right_arg_value_(0) {
bit_field_ |= OperatorField::encode(op);
DCHECK(Token::IsBinaryOp(op));
}
@ -2194,14 +2194,14 @@ class BinaryOperation final : public Expression {
static int parent_num_ids() { return Expression::num_ids(); }
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
FeedbackSlot feedback_slot_;
Expression* left_;
Expression* right_;
Handle<AllocationSite> allocation_site_;
// 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_;
FeedbackSlot feedback_slot_;
class OperatorField
: public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
@ -2329,11 +2329,11 @@ class CompareOperation final : public Expression {
static int parent_num_ids() { return Expression::num_ids(); }
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
FeedbackSlot feedback_slot_;
Expression* left_;
Expression* right_;
AstType* combined_type_;
FeedbackSlot feedback_slot_;
class OperatorField
: public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
};
@ -2932,9 +2932,9 @@ class NativeFunctionLiteral final : public Expression {
name_(name),
extension_(extension) {}
FeedbackSlot literal_feedback_slot_;
const AstRawString* name_;
v8::Extension* extension_;
FeedbackSlot literal_feedback_slot_;
};