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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H 5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H
6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H 6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H
7 7
8 #include "src/messages.h" 8 #include "src/messages.h"
9 #include "src/parsing/scanner.h" 9 #include "src/parsing/scanner.h"
10 #include "src/parsing/token.h" 10 #include "src/parsing/token.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // parameter. 387 // parameter.
388 function_properties_ |= inner->function_properties_; 388 function_properties_ |= inner->function_properties_;
389 389
390 if (!inner->is_valid_binding_pattern()) 390 if (!inner->is_valid_binding_pattern())
391 errors |= ArrowFormalParametersProduction; 391 errors |= ArrowFormalParametersProduction;
392 } 392 }
393 393
394 if (errors != 0) { 394 if (errors != 0) {
395 invalid_productions_ |= errors; 395 invalid_productions_ |= errors;
396 int arrow_index = inner->reported_errors_end_; 396 int arrow_index = inner->reported_errors_end_;
397 int hole_index = inner->reported_errors_end_;
397 for (int i = inner->reported_errors_begin_; 398 for (int i = inner->reported_errors_begin_;
398 i < inner->reported_errors_end_; i++) { 399 i < inner->reported_errors_end_; i++) {
399 if (reported_errors_->at(i).kind == kUnusedError || 400 if (reported_errors_->at(i).kind == kUnusedError) continue;
400 reported_errors_->at(i).kind == kArrowFormalParametersProduction) 401 if (reported_errors_->at(i).kind ==
402 kArrowFormalParametersProduction) {
403 // Accumulate an ArrowFormalParametersProduction error as a hole in
404 // the list, to avoid having to shift all the remaining errors.
405 // This is an optimization for a frequently occurring case.
406 if (reported_errors_end_ == i) {
407 hole_index = reported_errors_end_++;
408 reported_errors_->at(i).kind = kUnusedError;
409 }
401 continue; 410 continue;
411 }
402 if (errors & (1 << reported_errors_->at(i).kind)) 412 if (errors & (1 << reported_errors_->at(i).kind))
403 Move(i); 413 Move(i);
404 if (reported_errors_->at(i).kind == kBindingPatternProduction && 414 if (reported_errors_->at(i).kind == kBindingPatternProduction &&
405 errors & ArrowFormalParametersProduction) { 415 errors & ArrowFormalParametersProduction) {
406 if (reported_errors_end_ <= i) { 416 if (reported_errors_end_ <= i) {
407 Move(i); 417 Move(i);
408 reported_errors_->at(reported_errors_end_-1).kind = 418 reported_errors_->at(reported_errors_end_-1).kind =
409 kArrowFormalParametersProduction; 419 kArrowFormalParametersProduction;
410 } else { 420 } else {
411 DCHECK_EQ(reported_errors_end_, i+1); 421 DCHECK_EQ(reported_errors_end_, i+1);
412 arrow_index = i; 422 arrow_index = i;
413 } 423 }
414 } 424 }
415 } 425 }
416 if (arrow_index < inner->reported_errors_end_) { 426 if (arrow_index < inner->reported_errors_end_) {
417 if (reported_errors_end_ < inner->reported_errors_end_) { 427 if (hole_index < inner->reported_errors_end_) {
428 // Use a hole in the list (if any exists) to store the additional
429 // ArrowFormalParametersProduction error.
430 Replace(hole_index, arrow_index);
431 reported_errors_->at(hole_index).kind =
432 kArrowFormalParametersProduction;
433 } else if (reported_errors_end_ < inner->reported_errors_end_) {
418 Replace(reported_errors_end_, arrow_index); 434 Replace(reported_errors_end_, arrow_index);
419 reported_errors_->at(reported_errors_end_++).kind = 435 reported_errors_->at(reported_errors_end_++).kind =
420 kArrowFormalParametersProduction; 436 kArrowFormalParametersProduction;
421 } else { 437 } else {
422 Add(reported_errors_->at(arrow_index)); 438 Add(reported_errors_->at(arrow_index));
423 reported_errors_->at(reported_errors_end_-1).kind = 439 reported_errors_->at(reported_errors_end_-1).kind =
424 kArrowFormalParametersProduction; 440 kArrowFormalParametersProduction;
425 } 441 }
426 } 442 }
427 } 443 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 }; 513 };
498 514
499 515
500 #undef ERROR_CODES 516 #undef ERROR_CODES
501 517
502 518
503 } // namespace internal 519 } // namespace internal
504 } // namespace v8 520 } // namespace v8
505 521
506 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H 522 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H
OLDNEW
« 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