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

Side by Side Diff: src/parsing/expression-classifier.h

Issue 2045733004: Optimization: Saves 30M instructions on x64 parsing ~6MB of JS code in parser-shell (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 15
16 template <typename Traits> 16 template <typename Traits>
17 class ExpressionClassifier { 17 class ExpressionClassifier {
18 public: 18 public:
19 struct Error { 19 struct Error {
20 Error() 20 Error() { reset(); }
21 : location(Scanner::Location::invalid()),
22 message(MessageTemplate::kNone),
23 type(kSyntaxError),
24 arg(nullptr) {}
25 21
26 Scanner::Location location; 22 Scanner::Location location;
27 MessageTemplate::Template message : 30; 23 MessageTemplate::Template message : 30;
28 ParseErrorType type : 2; 24 ParseErrorType type : 2;
29 const char* arg; 25 const char* arg;
26
27 V8_INLINE void reset() {
28 location.beg_pos = location.end_pos = -1;
29 message = MessageTemplate::kNone;
30 type = kSyntaxError;
31 arg = nullptr;
32 }
30 }; 33 };
31 34
32 enum TargetProduction { 35 enum TargetProduction {
33 ExpressionProduction = 1 << 0, 36 ExpressionProduction = 1 << 0,
34 FormalParameterInitializerProduction = 1 << 1, 37 FormalParameterInitializerProduction = 1 << 1,
35 BindingPatternProduction = 1 << 2, 38 BindingPatternProduction = 1 << 2,
36 AssignmentPatternProduction = 1 << 3, 39 AssignmentPatternProduction = 1 << 3,
37 DistinctFormalParametersProduction = 1 << 4, 40 DistinctFormalParametersProduction = 1 << 4,
38 StrictModeFormalParametersProduction = 1 << 5, 41 StrictModeFormalParametersProduction = 1 << 5,
39 ArrowFormalParametersProduction = 1 << 6, 42 ArrowFormalParametersProduction = 1 << 6,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 const char* arg = nullptr) { 316 const char* arg = nullptr) {
314 if (has_tail_call_expression()) return; 317 if (has_tail_call_expression()) return;
315 invalid_productions_ |= TailCallExpressionProduction; 318 invalid_productions_ |= TailCallExpressionProduction;
316 tail_call_expression_error_.location = loc; 319 tail_call_expression_error_.location = loc;
317 tail_call_expression_error_.message = message; 320 tail_call_expression_error_.message = message;
318 tail_call_expression_error_.arg = arg; 321 tail_call_expression_error_.arg = arg;
319 } 322 }
320 323
321 void ForgiveCoverInitializedNameError() { 324 void ForgiveCoverInitializedNameError() {
322 invalid_productions_ &= ~CoverInitializedNameProduction; 325 invalid_productions_ &= ~CoverInitializedNameProduction;
323 cover_initialized_name_error_ = Error(); 326 cover_initialized_name_error_.reset();
324 } 327 }
325 328
326 void ForgiveAssignmentPatternError() { 329 void ForgiveAssignmentPatternError() {
327 invalid_productions_ &= ~AssignmentPatternProduction; 330 invalid_productions_ &= ~AssignmentPatternProduction;
328 assignment_pattern_error_ = Error(); 331 assignment_pattern_error_.reset();
329 } 332 }
330 333
331 void Accumulate(ExpressionClassifier* inner, 334 void Accumulate(ExpressionClassifier* inner,
332 unsigned productions = StandardProductions, 335 unsigned productions = StandardProductions,
333 bool merge_non_patterns = true) { 336 bool merge_non_patterns = true) {
334 if (merge_non_patterns) MergeNonPatterns(inner); 337 if (merge_non_patterns) MergeNonPatterns(inner);
335 // Propagate errors from inner, but don't overwrite already recorded 338 // Propagate errors from inner, but don't overwrite already recorded
336 // errors. 339 // errors.
337 unsigned non_arrow_inner_invalid_productions = 340 unsigned non_arrow_inner_invalid_productions =
338 inner->invalid_productions_ & ~ArrowFormalParametersProduction; 341 inner->invalid_productions_ & ~ArrowFormalParametersProduction;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 Error async_arrow_formal_parameters_error_; 423 Error async_arrow_formal_parameters_error_;
421 Error async_binding_pattern_error_; 424 Error async_binding_pattern_error_;
422 DuplicateFinder* duplicate_finder_; 425 DuplicateFinder* duplicate_finder_;
423 }; 426 };
424 427
425 428
426 } // namespace internal 429 } // namespace internal
427 } // namespace v8 430 } // namespace v8
428 431
429 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H 432 #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