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

Side by Side Diff: src/scanner.cc

Issue 998893002: [scanner] Extend fast-smi parsing to the entire range minus Smi::kMinValue (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/scanner.h ('k') | 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 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 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 break; 993 break;
994 } 994 }
995 AddLiteralCharAdvance(); 995 AddLiteralCharAdvance();
996 } 996 }
997 } 997 }
998 } 998 }
999 999
1000 // Parse decimal digits and allow trailing fractional part. 1000 // Parse decimal digits and allow trailing fractional part.
1001 if (kind == DECIMAL) { 1001 if (kind == DECIMAL) {
1002 if (at_start) { 1002 if (at_start) {
1003 int value = 0; 1003 uint64_t value = 0;
1004 while (IsDecimalDigit(c0_)) { 1004 while (IsDecimalDigit(c0_)) {
1005 value = 10 * value + (c0_ - '0'); 1005 value = 10 * value + (c0_ - '0');
1006 1006
1007 uc32 first_char = c0_; 1007 uc32 first_char = c0_;
1008 Advance<false, false>(); 1008 Advance<false, false>();
1009 AddLiteralChar(first_char); 1009 AddLiteralChar(first_char);
1010 } 1010 }
1011 1011
1012 if (next_.literal_chars->one_byte_literal().length() < 10 && 1012 if (next_.literal_chars->one_byte_literal().length() <= 10 &&
1013 c0_ != '.' && c0_ != 'e' && c0_ != 'E') { 1013 value <= Smi::kMaxValue && c0_ != '.' && c0_ != 'e' && c0_ != 'E') {
1014 smi_value_ = value; 1014 smi_value_ = static_cast<int>(value);
1015 literal.Complete(); 1015 literal.Complete();
1016 HandleLeadSurrogate(); 1016 HandleLeadSurrogate();
1017 1017
1018 return Token::SMI; 1018 return Token::SMI;
1019 } 1019 }
1020 HandleLeadSurrogate(); 1020 HandleLeadSurrogate();
1021 } 1021 }
1022 1022
1023 ScanDecimalDigits(); // optional 1023 ScanDecimalDigits(); // optional
1024 if (c0_ == '.') { 1024 if (c0_ == '.') {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 1421
1422 double Scanner::DoubleValue() { 1422 double Scanner::DoubleValue() {
1423 DCHECK(is_literal_one_byte()); 1423 DCHECK(is_literal_one_byte());
1424 return StringToDouble( 1424 return StringToDouble(
1425 unicode_cache_, 1425 unicode_cache_,
1426 literal_one_byte_string(), 1426 literal_one_byte_string(),
1427 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY); 1427 ALLOW_HEX | ALLOW_OCTAL | ALLOW_IMPLICIT_OCTAL | ALLOW_BINARY);
1428 } 1428 }
1429 1429
1430 1430
1431 int Scanner::FindNumber(DuplicateFinder* finder, int value) {
1432 return finder->AddNumber(literal_one_byte_string(), value);
1433 }
1434
1435
1436 int Scanner::FindSymbol(DuplicateFinder* finder, int value) { 1431 int Scanner::FindSymbol(DuplicateFinder* finder, int value) {
1437 if (is_literal_one_byte()) { 1432 if (is_literal_one_byte()) {
1438 return finder->AddOneByteSymbol(literal_one_byte_string(), value); 1433 return finder->AddOneByteSymbol(literal_one_byte_string(), value);
1439 } 1434 }
1440 return finder->AddTwoByteSymbol(literal_two_byte_string(), value); 1435 return finder->AddTwoByteSymbol(literal_two_byte_string(), value);
1441 } 1436 }
1442 1437
1443 1438
1444 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) { 1439 int DuplicateFinder::AddOneByteSymbol(Vector<const uint8_t> key, int value) {
1445 return AddSymbol(key, true, value); 1440 return AddSymbol(key, true, value);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 } 1569 }
1575 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); 1570 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u));
1576 } 1571 }
1577 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); 1572 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f));
1578 1573
1579 backing_store_.AddBlock(bytes); 1574 backing_store_.AddBlock(bytes);
1580 return backing_store_.EndSequence().start(); 1575 return backing_store_.EndSequence().start();
1581 } 1576 }
1582 1577
1583 } } // namespace v8::internal 1578 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/scanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698