[parser] Move optimization disabling to parser
Move the one remaining optimization disabling in AST numbering (native function literals) to be in the parser. Bug: v8:7178 Change-Id: Icd96020622cbe64afa11b42c5831618247e3e021 Reviewed-on: https://chromium-review.googlesource.com/814399 Commit-Queue: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#50170}
This commit is contained in:
parent
9a241228cf
commit
06309e15a0
@ -16,10 +16,7 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
|
|||||||
public:
|
public:
|
||||||
AstNumberingVisitor(uintptr_t stack_limit, Zone* zone,
|
AstNumberingVisitor(uintptr_t stack_limit, Zone* zone,
|
||||||
Compiler::EagerInnerFunctionLiterals* eager_literals)
|
Compiler::EagerInnerFunctionLiterals* eager_literals)
|
||||||
: zone_(zone),
|
: zone_(zone), eager_literals_(eager_literals), suspend_count_(0) {
|
||||||
eager_literals_(eager_literals),
|
|
||||||
suspend_count_(0),
|
|
||||||
dont_optimize_reason_(kNoReason) {
|
|
||||||
InitializeAstVisitor(stack_limit);
|
InitializeAstVisitor(stack_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,19 +36,12 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
|
|||||||
void VisitArguments(ZoneList<Expression*>* arguments);
|
void VisitArguments(ZoneList<Expression*>* arguments);
|
||||||
void VisitLiteralProperty(LiteralProperty* property);
|
void VisitLiteralProperty(LiteralProperty* property);
|
||||||
|
|
||||||
void DisableOptimization(BailoutReason reason) {
|
|
||||||
dont_optimize_reason_ = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
BailoutReason dont_optimize_reason() const { return dont_optimize_reason_; }
|
|
||||||
|
|
||||||
Zone* zone() const { return zone_; }
|
Zone* zone() const { return zone_; }
|
||||||
|
|
||||||
Zone* zone_;
|
Zone* zone_;
|
||||||
Compiler::EagerInnerFunctionLiterals* eager_literals_;
|
Compiler::EagerInnerFunctionLiterals* eager_literals_;
|
||||||
int suspend_count_;
|
int suspend_count_;
|
||||||
FunctionKind function_kind_;
|
FunctionKind function_kind_;
|
||||||
BailoutReason dont_optimize_reason_;
|
|
||||||
|
|
||||||
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
|
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
|
||||||
DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
|
DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
|
||||||
@ -80,7 +70,6 @@ void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) {
|
|||||||
|
|
||||||
void AstNumberingVisitor::VisitNativeFunctionLiteral(
|
void AstNumberingVisitor::VisitNativeFunctionLiteral(
|
||||||
NativeFunctionLiteral* node) {
|
NativeFunctionLiteral* node) {
|
||||||
DisableOptimization(kNativeFunctionLiteral);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AstNumberingVisitor::VisitDoExpression(DoExpression* node) {
|
void AstNumberingVisitor::VisitDoExpression(DoExpression* node) {
|
||||||
@ -396,7 +385,6 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
|
|||||||
VisitDeclarations(scope->declarations());
|
VisitDeclarations(scope->declarations());
|
||||||
VisitStatements(node->body());
|
VisitStatements(node->body());
|
||||||
|
|
||||||
node->set_dont_optimize_reason(dont_optimize_reason());
|
|
||||||
node->set_suspend_count(suspend_count_);
|
node->set_suspend_count(suspend_count_);
|
||||||
|
|
||||||
return !HasStackOverflow();
|
return !HasStackOverflow();
|
||||||
|
@ -383,6 +383,11 @@ class ParserBase {
|
|||||||
void AddProperty() { expected_property_count_++; }
|
void AddProperty() { expected_property_count_++; }
|
||||||
int expected_property_count() { return expected_property_count_; }
|
int expected_property_count() { return expected_property_count_; }
|
||||||
|
|
||||||
|
void DisableOptimization(BailoutReason reason) {
|
||||||
|
dont_optimize_reason_ = reason;
|
||||||
|
}
|
||||||
|
BailoutReason dont_optimize_reason() { return dont_optimize_reason_; }
|
||||||
|
|
||||||
FunctionKind kind() const { return scope()->function_kind(); }
|
FunctionKind kind() const { return scope()->function_kind(); }
|
||||||
FunctionState* outer() const { return outer_function_state_; }
|
FunctionState* outer() const { return outer_function_state_; }
|
||||||
|
|
||||||
@ -463,6 +468,9 @@ class ParserBase {
|
|||||||
|
|
||||||
ZoneList<typename ExpressionClassifier::Error> reported_errors_;
|
ZoneList<typename ExpressionClassifier::Error> reported_errors_;
|
||||||
|
|
||||||
|
// A reason, if any, why this function should not be optimized.
|
||||||
|
BailoutReason dont_optimize_reason_;
|
||||||
|
|
||||||
// Record whether the next (=== immediately following) function literal is
|
// Record whether the next (=== immediately following) function literal is
|
||||||
// preceded by a parenthesis / exclamation mark. Also record the previous
|
// preceded by a parenthesis / exclamation mark. Also record the previous
|
||||||
// state.
|
// state.
|
||||||
@ -1540,6 +1548,7 @@ ParserBase<Impl>::FunctionState::FunctionState(
|
|||||||
destructuring_assignments_to_rewrite_(16, scope->zone()),
|
destructuring_assignments_to_rewrite_(16, scope->zone()),
|
||||||
non_patterns_to_rewrite_(0, scope->zone()),
|
non_patterns_to_rewrite_(0, scope->zone()),
|
||||||
reported_errors_(16, scope->zone()),
|
reported_errors_(16, scope->zone()),
|
||||||
|
dont_optimize_reason_(kNoReason),
|
||||||
next_function_is_likely_called_(false),
|
next_function_is_likely_called_(false),
|
||||||
previous_function_was_likely_called_(false),
|
previous_function_was_likely_called_(false),
|
||||||
contains_function_or_eval_(false) {
|
contains_function_or_eval_(false) {
|
||||||
@ -4064,6 +4073,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
|
|||||||
template <typename Impl>
|
template <typename Impl>
|
||||||
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseNativeDeclaration(
|
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseNativeDeclaration(
|
||||||
bool* ok) {
|
bool* ok) {
|
||||||
|
function_state_->DisableOptimization(kNativeFunctionLiteral);
|
||||||
|
|
||||||
int pos = peek_position();
|
int pos = peek_position();
|
||||||
Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
|
Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
|
||||||
// Allow "eval" or "arguments" for backward compatibility.
|
// Allow "eval" or "arguments" for backward compatibility.
|
||||||
|
Loading…
Reference in New Issue
Block a user