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

Side by Side Diff: src/scanner.h

Issue 969353003: Speed up identifier, keyword and smi parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use char predicates Created 5 years, 9 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 | « src/char-predicates-inl.h ('k') | src/scanner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 // Features shared by parsing and pre-parsing scanners. 5 // Features shared by parsing and pre-parsing scanners.
6 6
7 #ifndef V8_SCANNER_H_ 7 #ifndef V8_SCANNER_H_
8 #define V8_SCANNER_H_ 8 #define V8_SCANNER_H_
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 next_.literal_chars = NULL; 558 next_.literal_chars = NULL;
559 next_.raw_literal_chars = NULL; 559 next_.raw_literal_chars = NULL;
560 } 560 }
561 561
562 inline void AddLiteralCharAdvance() { 562 inline void AddLiteralCharAdvance() {
563 AddLiteralChar(c0_); 563 AddLiteralChar(c0_);
564 Advance(); 564 Advance();
565 } 565 }
566 566
567 // Low-level scanning support. 567 // Low-level scanning support.
568 template <bool capture_raw = false> 568 template <bool capture_raw = false, bool check_surrogate = true>
569 void Advance() { 569 void Advance() {
570 if (capture_raw) { 570 if (capture_raw) {
571 AddRawLiteralChar(c0_); 571 AddRawLiteralChar(c0_);
572 } 572 }
573 c0_ = source_->Advance(); 573 c0_ = source_->Advance();
574 if (check_surrogate) HandleLeadSurrugate();
575 }
576
577 void HandleLeadSurrugate() {
574 if (unibrow::Utf16::IsLeadSurrogate(c0_)) { 578 if (unibrow::Utf16::IsLeadSurrogate(c0_)) {
575 uc32 c1 = source_->Advance(); 579 uc32 c1 = source_->Advance();
576 if (!unibrow::Utf16::IsTrailSurrogate(c1)) { 580 if (!unibrow::Utf16::IsTrailSurrogate(c1)) {
577 source_->PushBack(c1); 581 source_->PushBack(c1);
578 } else { 582 } else {
579 c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1); 583 c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1);
580 } 584 }
581 } 585 }
582 } 586 }
583 587
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 bool harmony_classes_; 752 bool harmony_classes_;
749 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL 753 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL
750 bool harmony_templates_; 754 bool harmony_templates_;
751 // Whether we allow \u{xxxxx}. 755 // Whether we allow \u{xxxxx}.
752 bool harmony_unicode_; 756 bool harmony_unicode_;
753 }; 757 };
754 758
755 } } // namespace v8::internal 759 } } // namespace v8::internal
756 760
757 #endif // V8_SCANNER_H_ 761 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/char-predicates-inl.h ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698