Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: src/parsing/expression-classifier.h

Issue 2002113002: Heuristic optimization in expression classifiers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@nickie-1708193003-class-rev
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/expression-classifier.h
diff --git a/src/parsing/expression-classifier.h b/src/parsing/expression-classifier.h
index 7b31a2143f281149e3751564ee5c0f8adcfbe6e2..1b50204b6e4910c7a3db76a2a74c86bfee120ec4 100644
--- a/src/parsing/expression-classifier.h
+++ b/src/parsing/expression-classifier.h
@@ -394,11 +394,21 @@ class ExpressionClassifier {
if (errors != 0) {
invalid_productions_ |= errors;
int arrow_index = inner->reported_errors_end_;
+ int hole_index = inner->reported_errors_end_;
for (int i = inner->reported_errors_begin_;
i < inner->reported_errors_end_; i++) {
- if (reported_errors_->at(i).kind == kUnusedError ||
- reported_errors_->at(i).kind == kArrowFormalParametersProduction)
+ if (reported_errors_->at(i).kind == kUnusedError) continue;
+ if (reported_errors_->at(i).kind ==
+ kArrowFormalParametersProduction) {
+ // Accumulate an ArrowFormalParametersProduction error as a hole in
+ // the list, to avoid having to shift all the remaining errors.
+ // This is an optimization for a frequently occurring case.
+ if (reported_errors_end_ == i) {
+ hole_index = reported_errors_end_++;
+ reported_errors_->at(i).kind = kUnusedError;
+ }
continue;
+ }
if (errors & (1 << reported_errors_->at(i).kind))
Move(i);
if (reported_errors_->at(i).kind == kBindingPatternProduction &&
@@ -414,7 +424,13 @@ class ExpressionClassifier {
}
}
if (arrow_index < inner->reported_errors_end_) {
- if (reported_errors_end_ < inner->reported_errors_end_) {
+ if (hole_index < inner->reported_errors_end_) {
+ // Use a hole in the list (if any exists) to store the additional
+ // ArrowFormalParametersProduction error.
+ Replace(hole_index, arrow_index);
+ reported_errors_->at(hole_index).kind =
+ kArrowFormalParametersProduction;
+ } else if (reported_errors_end_ < inner->reported_errors_end_) {
Replace(reported_errors_end_, arrow_index);
reported_errors_->at(reported_errors_end_++).kind =
kArrowFormalParametersProduction;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698