void set_bounds(Bounds bounds) { bounds_ = bounds; }
// Whether the expression is parenthesized
- bool is_parenthesized() const {
- return IsParenthesizedField::decode(bit_field_);
+ bool is_single_parenthesized() const {
+ return IsSingleParenthesizedField::decode(bit_field_);
}
bool is_multi_parenthesized() const {
return IsMultiParenthesizedField::decode(bit_field_);
}
void increase_parenthesization_level() {
- bit_field_ =
- IsMultiParenthesizedField::update(bit_field_, is_parenthesized());
- bit_field_ = IsParenthesizedField::update(bit_field_, true);
+ bit_field_ = IsMultiParenthesizedField::update(bit_field_,
+ is_single_parenthesized());
+ bit_field_ = IsSingleParenthesizedField::update(bit_field_, true);
}
// Type feedback information for assignments and properties.
int base_id_;
Bounds bounds_;
class ToBooleanTypesField : public BitField16<byte, 0, 8> {};
- class IsParenthesizedField : public BitField16<bool, 8, 1> {};
+ class IsSingleParenthesizedField : public BitField16<bool, 8, 1> {};
class IsMultiParenthesizedField : public BitField16<bool, 9, 1> {};
uint16_t bit_field_;
// Ends with 16-bit field; deriving classes in turn begin with
kIsFunction
};
- enum IsParenthesizedFlag {
- kIsParenthesized,
- kNotParenthesized
- };
+ enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
enum ArityRestriction {
NORMAL_ARITY,
// function will be called immediately:
// - (function() { ... })();
// - var x = function() { ... }();
- bool is_parenthesized() {
- return IsParenthesized::decode(bitfield_) == kIsParenthesized;
+ bool should_eager_compile() const {
+ return EagerCompileHintBit::decode(bitfield_) == kShouldEagerCompile;
}
- void set_parenthesized() {
- bitfield_ = IsParenthesized::update(bitfield_, kIsParenthesized);
+ void set_should_eager_compile() {
+ bitfield_ = EagerCompileHintBit::update(bitfield_, kShouldEagerCompile);
}
FunctionKind kind() { return FunctionKindBits::decode(bitfield_); }
int parameter_count, FunctionType function_type,
ParameterFlag has_duplicate_parameters,
IsFunctionFlag is_function,
- IsParenthesizedFlag is_parenthesized, FunctionKind kind,
+ EagerCompileHint eager_compile_hint, FunctionKind kind,
int position)
: Expression(zone, position),
raw_name_(name),
Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters) |
IsFunction::encode(is_function) |
- IsParenthesized::encode(is_parenthesized) |
+ EagerCompileHintBit::encode(eager_compile_hint) |
FunctionKindBits::encode(kind);
DCHECK(IsValidFunctionKind(kind));
}
class Pretenure : public BitField<bool, 2, 1> {};
class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
- class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {};
+ class EagerCompileHintBit : public BitField<EagerCompileHint, 5, 1> {};
class FunctionKindBits : public BitField<FunctionKind, 6, 8> {};
};
FunctionLiteral::ParameterFlag has_duplicate_parameters,
FunctionLiteral::FunctionType function_type,
FunctionLiteral::IsFunctionFlag is_function,
- FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
+ FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
int position) {
return new (zone_) FunctionLiteral(
zone_, name, ast_value_factory, scope, body, materialized_literal_count,
expected_property_count, handler_count, parameter_count, function_type,
- has_duplicate_parameters, is_function, is_parenthesized, kind,
+ has_duplicate_parameters, is_function, eager_compile_hint, kind,
position);
}
// Generate code
Handle<ScopeInfo> scope_info;
- if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) {
+ if (FLAG_lazy && allow_lazy && !literal->should_eager_compile()) {
Handle<Code> code = isolate->builtins()->CompileLazy();
info.SetCode(code);
// There's no need in theory for a lazy-compiled function to have a type
materialized_literal_count, expected_property_count, handler_count,
parameter_count, FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
- FunctionLiteral::kNotParenthesized, kind, pos);
+ FunctionLiteral::kShouldLazyCompile, kind, pos);
return function_literal;
}
function_state.handler_count(), 0,
FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kGlobalOrEval,
- FunctionLiteral::kNotParenthesized, FunctionKind::kNormalFunction, 0);
+ FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction,
+ 0);
}
}
}
Expression* left = binop->left();
Expression* right = binop->right();
- if (left->is_parenthesized() || right->is_parenthesized()) {
+ if (left->is_single_parenthesized() || right->is_single_parenthesized()) {
ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
*ok = false;
return;
int expected_property_count = -1;
int handler_count = 0;
FormalParameterErrorLocations error_locs;
- FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_
- ? FunctionLiteral::kIsParenthesized
- : FunctionLiteral::kNotParenthesized;
+ FunctionLiteral::EagerCompileHint eager_compile_hint =
+ parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile
+ : FunctionLiteral::kShouldLazyCompile;
// Parse function body.
{
AstNodeFactory function_factory(ast_value_factory());
function_name, ast_value_factory(), scope, body,
materialized_literal_count, expected_property_count, handler_count,
num_parameters, duplicate_parameters, function_type,
- FunctionLiteral::kIsFunction, parenthesized, kind, pos);
+ FunctionLiteral::kIsFunction, eager_compile_hint, kind, pos);
function_literal->set_function_token_position(function_token_pos);
if (scope->has_rest_parameter()) {
Token::Value op,
PreParserExpression right) {
ValidArrowParam valid_arrow_param_list =
- (op == Token::COMMA && !left.is_parenthesized() &&
- !right.is_parenthesized()) ?
- std::min(left.ValidateArrowParams(), right.ValidateArrowParams())
- : kInvalidArrowParam;
+ (op == Token::COMMA && !left.is_single_parenthesized() &&
+ !right.is_single_parenthesized())
+ ? std::min(left.ValidateArrowParams(), right.ValidateArrowParams())
+ : kInvalidArrowParam;
return PreParserExpression(
TypeField::encode(kBinaryOperationExpression) |
IsValidArrowParamListField::encode(valid_arrow_param_list));
return TypeField::decode(code_) == kBinaryOperationExpression;
}
- bool is_parenthesized() const {
+ bool is_single_parenthesized() const {
return ParenthesizationField::decode(code_) != kNotParenthesized;
}
void increase_parenthesization_level() {
code_ = ParenthesizationField::update(
- code_, is_parenthesized() ? kMultiParenthesizedExpression
- : kParanthesizedExpression);
+ code_, is_single_parenthesized() ? kMultiParenthesizedExpression
+ : kParanthesizedExpression);
}
// Dummy implementation for making expression->somefunc() work in both Parser
// More dummy implementations of things PreParser doesn't need to track:
void set_index(int index) {} // For YieldExpressions
- void set_parenthesized() {}
+ void set_should_eager_compile() {}
int position() const { return RelocInfo::kNoPosition; }
void set_function_token_position(int position) {}
FunctionLiteral::ParameterFlag has_duplicate_parameters,
FunctionLiteral::FunctionType function_type,
FunctionLiteral::IsFunctionFlag is_function,
- FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind,
+ FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
int position) {
return PreParserExpression::Default();
}
// be called immediately. If we happen to have parsed a preceding
// function literal eagerly, we can also compile it eagerly.
if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
- result->AsFunctionLiteral()->set_parenthesized();
+ result->AsFunctionLiteral()->set_should_eager_compile();
}
}
Scanner::Location spread_pos;
if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
// If the tag function looks like an IIFE, set_parenthesized() to
// force eager compilation.
- expression->AsFunctionLiteral()->set_parenthesized();
+ expression->AsFunctionLiteral()->set_should_eager_compile();
}
}
expression =
materialized_literal_count, expected_property_count, handler_count,
num_parameters, FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
- FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction,
+ FunctionLiteral::kShouldLazyCompile, FunctionKind::kArrowFunction,
scope->start_position());
function_literal->set_function_token_position(scope->start_position());