Commit 7c914dd0 authored by Adam Klein's avatar Adam Klein Committed by Commit Bot

[ast] Slim down FunctionLiteral

This patch moves the has_braces_ bool to the bit_field_, and moves
function_literal_id_ into the freed-up slack space. This saves
4 bytes on 32-bit platforms and 8 bytes on 64-bit.

Change-Id: Ib5ba475915e46494c75019cfc184aafe72f6407f
Reviewed-on: https://chromium-review.googlesource.com/947467Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51742}
parent f7a93fbd
......@@ -2279,7 +2279,9 @@ class FunctionLiteral final : public Expression {
void set_suspend_count(int suspend_count) { suspend_count_ = suspend_count; }
int return_position() {
return std::max(start_position(), end_position() - (has_braces_ ? 1 : 0));
return std::max(
start_position(),
end_position() - (HasBracesField::decode(bit_field_) ? 1 : 0));
}
int function_literal_id() const { return function_literal_id_; }
......@@ -2315,19 +2317,19 @@ class FunctionLiteral final : public Expression {
function_length_(function_length),
function_token_position_(kNoSourcePosition),
suspend_count_(0),
has_braces_(has_braces),
function_literal_id_(function_literal_id),
raw_name_(name ? ast_value_factory->NewConsString(name) : nullptr),
scope_(scope),
body_(body),
raw_inferred_name_(ast_value_factory->empty_cons_string()),
function_literal_id_(function_literal_id),
produced_preparsed_scope_data_(produced_preparsed_scope_data) {
bit_field_ |= FunctionTypeBits::encode(function_type) |
Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters ==
kHasDuplicateParameters) |
DontOptimizeReasonField::encode(BailoutReason::kNoReason) |
RequiresInstanceFieldsInitializer::encode(false);
RequiresInstanceFieldsInitializer::encode(false) |
HasBracesField::encode(has_braces);
if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
DCHECK_EQ(body == nullptr, expected_property_count < 0);
}
......@@ -2340,20 +2342,21 @@ class FunctionLiteral final : public Expression {
: public BitField<BailoutReason, HasDuplicateParameters::kNext, 8> {};
class RequiresInstanceFieldsInitializer
: public BitField<bool, DontOptimizeReasonField::kNext, 1> {};
class HasBracesField
: public BitField<bool, RequiresInstanceFieldsInitializer::kNext, 1> {};
int expected_property_count_;
int parameter_count_;
int function_length_;
int function_token_position_;
int suspend_count_;
bool has_braces_;
int function_literal_id_;
const AstConsString* raw_name_;
DeclarationScope* scope_;
ZoneList<Statement*>* body_;
const AstConsString* raw_inferred_name_;
Handle<String> inferred_name_;
int function_literal_id_;
ProducedPreParsedScopeData* produced_preparsed_scope_data_;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment