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

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

Issue 1994643002: Simpler implementation of expression classifiers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@nickie-1708193003-class-rev
Patch Set: Bug fix 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..c561ba619a28b61b500e8175142c2d826a85834e 100644
--- a/src/parsing/expression-classifier.h
+++ b/src/parsing/expression-classifier.h
@@ -371,62 +371,43 @@ class ExpressionClassifier {
DCHECK_EQ(inner->reported_errors_, reported_errors_);
DCHECK_EQ(inner->reported_errors_begin_, reported_errors_end_);
DCHECK_EQ(inner->reported_errors_end_, reported_errors_->length());
+
if (merge_non_patterns) MergeNonPatterns(inner);
- // Propagate errors from inner, but don't overwrite already recorded
- // errors.
- unsigned non_arrow_inner_invalid_productions =
- inner->invalid_productions_ & ~ArrowFormalParametersProduction;
- if (non_arrow_inner_invalid_productions) {
- unsigned errors = non_arrow_inner_invalid_productions & productions &
- ~invalid_productions_;
- // As an exception to the above, the result continues to be a valid arrow
- // formal parameters if the inner expression is a valid binding pattern.
- if (productions & ArrowFormalParametersProduction &&
- is_valid_arrow_formal_parameters()) {
- // Also copy function properties if expecting an arrow function
- // parameter.
- function_properties_ |= inner->function_properties_;
-
- if (!inner->is_valid_binding_pattern())
- errors |= ArrowFormalParametersProduction;
+
+ // Propagate errors from inner, excluding arrow formal parameters.
+ unsigned errors = inner->invalid_productions_ & productions &
+ ~ArrowFormalParametersProduction;
+ bool keep_inner = errors & ~invalid_productions_;
+ bool copy_arrow = false;
+
+ // If there's nothing to add, the inner classifier's array can be dropped.
+ if (keep_inner) invalid_productions_ |= errors;
+
+ // As an exception to error propagation, the result continues to be valid
+ // as arrow formal parameters if the inner expression is a valid binding
+ // pattern.
+ if (productions & ArrowFormalParametersProduction &&
+ is_valid_arrow_formal_parameters()) {
+ // Also copy function properties if expecting an arrow function
+ // parameter.
+ function_properties_ |= inner->function_properties_;
+ if (!inner->is_valid_binding_pattern()) {
+ keep_inner = copy_arrow = true;
+ invalid_productions_ |= ArrowFormalParametersProduction;
}
+ }
- if (errors != 0) {
- invalid_productions_ |= errors;
- int arrow_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)
- continue;
- if (errors & (1 << reported_errors_->at(i).kind))
- Move(i);
- if (reported_errors_->at(i).kind == kBindingPatternProduction &&
- errors & ArrowFormalParametersProduction) {
- if (reported_errors_end_ <= i) {
- Move(i);
- reported_errors_->at(reported_errors_end_-1).kind =
- kArrowFormalParametersProduction;
- } else {
- DCHECK_EQ(reported_errors_end_, i+1);
- arrow_index = i;
- }
- }
- }
- if (arrow_index < inner->reported_errors_end_) {
- if (reported_errors_end_ < inner->reported_errors_end_) {
- Replace(reported_errors_end_, arrow_index);
- reported_errors_->at(reported_errors_end_++).kind =
- kArrowFormalParametersProduction;
- } else {
- Add(reported_errors_->at(arrow_index));
- reported_errors_->at(reported_errors_end_-1).kind =
- kArrowFormalParametersProduction;
- }
- }
+ if (keep_inner) {
+ reported_errors_end_ = inner->reported_errors_end_;
+ if (copy_arrow) {
+ Add(inner->reported_error(kBindingPatternProduction));
+ reported_errors_->at(reported_errors_end_-1).kind =
+ kArrowFormalParametersProduction;
}
+ } else {
+ reported_errors_->Rewind(reported_errors_end_);
}
- reported_errors_->Rewind(reported_errors_end_);
+
inner->reported_errors_begin_ = inner->reported_errors_end_ =
reported_errors_end_;
}
@@ -469,22 +450,6 @@ class ExpressionClassifier {
reported_errors_end_++;
}
- V8_INLINE void Move(int i) {
- DCHECK_LE(reported_errors_end_, i);
- DCHECK_LT(i, reported_errors_->length());
- if (reported_errors_end_ < i)
- reported_errors_->at(reported_errors_end_) = reported_errors_->at(i);
- reported_errors_end_++;
- }
-
- V8_INLINE void Replace(int j, int i) {
- DCHECK_LT(i, reported_errors_->length());
- DCHECK_LE(j, reported_errors_end_);
- DCHECK(j == reported_errors_end_ ||
- reported_errors_->at(j).kind == kUnusedError);
- if (i != j) reported_errors_->at(j) = reported_errors_->at(i);
- }
-
Zone* zone_;
ZoneList<typename Traits::Type::Expression>* non_patterns_to_rewrite_;
int non_pattern_begin_;
« 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