[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:
|
||||
AstNumberingVisitor(uintptr_t stack_limit, Zone* zone,
|
||||
Compiler::EagerInnerFunctionLiterals* eager_literals)
|
||||
: zone_(zone),
|
||||
eager_literals_(eager_literals),
|
||||
suspend_count_(0),
|
||||
dont_optimize_reason_(kNoReason) {
|
||||
: zone_(zone), eager_literals_(eager_literals), suspend_count_(0) {
|
||||
InitializeAstVisitor(stack_limit);
|
||||
}
|
||||
|
||||
@ -39,19 +36,12 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
|
||||
void VisitArguments(ZoneList<Expression*>* arguments);
|
||||
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_;
|
||||
Compiler::EagerInnerFunctionLiterals* eager_literals_;
|
||||
int suspend_count_;
|
||||
FunctionKind function_kind_;
|
||||
BailoutReason dont_optimize_reason_;
|
||||
|
||||
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
|
||||
DISALLOW_COPY_AND_ASSIGN(AstNumberingVisitor);
|
||||
@ -80,7 +70,6 @@ void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) {
|
||||
|
||||
void AstNumberingVisitor::VisitNativeFunctionLiteral(
|
||||
NativeFunctionLiteral* node) {
|
||||
DisableOptimization(kNativeFunctionLiteral);
|
||||
}
|
||||
|
||||
void AstNumberingVisitor::VisitDoExpression(DoExpression* node) {
|
||||
@ -396,7 +385,6 @@ bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
|
||||
VisitDeclarations(scope->declarations());
|
||||
VisitStatements(node->body());
|
||||
|
||||
node->set_dont_optimize_reason(dont_optimize_reason());
|
||||
node->set_suspend_count(suspend_count_);
|
||||
|
||||
return !HasStackOverflow();
|
||||
|
@ -383,6 +383,11 @@ class ParserBase {
|
||||
void AddProperty() { 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(); }
|
||||
FunctionState* outer() const { return outer_function_state_; }
|
||||
|
||||
@ -463,6 +468,9 @@ class ParserBase {
|
||||
|
||||
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
|
||||
// preceded by a parenthesis / exclamation mark. Also record the previous
|
||||
// state.
|
||||
@ -1540,6 +1548,7 @@ ParserBase<Impl>::FunctionState::FunctionState(
|
||||
destructuring_assignments_to_rewrite_(16, scope->zone()),
|
||||
non_patterns_to_rewrite_(0, scope->zone()),
|
||||
reported_errors_(16, scope->zone()),
|
||||
dont_optimize_reason_(kNoReason),
|
||||
next_function_is_likely_called_(false),
|
||||
previous_function_was_likely_called_(false),
|
||||
contains_function_or_eval_(false) {
|
||||
@ -4064,6 +4073,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
|
||||
template <typename Impl>
|
||||
typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseNativeDeclaration(
|
||||
bool* ok) {
|
||||
function_state_->DisableOptimization(kNativeFunctionLiteral);
|
||||
|
||||
int pos = peek_position();
|
||||
Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
|
||||
// Allow "eval" or "arguments" for backward compatibility.
|
||||
|
Loading…
Reference in New Issue
Block a user