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

Unified Diff: src/scanner.cc

Issue 2831016: [Isolates] Static mutable data of Scanner class moved to ScannerCharacterClasses / Isolate. (Closed)
Patch Set: . Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index 89431190198fad3171559f866d999d5a625ee002..f7c986daaa8fc041e85a9b2697326f0971b88a58 100755
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -34,18 +34,6 @@
namespace v8 {
namespace internal {
-// ----------------------------------------------------------------------------
-// Character predicates
-
-
-unibrow::Predicate<IdentifierStart, 128> Scanner::kIsIdentifierStart;
-unibrow::Predicate<IdentifierPart, 128> Scanner::kIsIdentifierPart;
-unibrow::Predicate<unibrow::LineTerminator, 128> Scanner::kIsLineTerminator;
-unibrow::Predicate<unibrow::WhiteSpace, 128> Scanner::kIsWhiteSpace;
-
-
-StaticResource<Scanner::Utf8Decoder> Scanner::utf8_decoder_;
-
// ----------------------------------------------------------------------------
// UTF8Buffer
@@ -335,7 +323,9 @@ void KeywordMatcher::Step(uc32 input) {
// Scanner
Scanner::Scanner(ParserMode pre)
- : stack_overflow_(false), is_pre_parsing_(pre == PREPARSE) { }
+ : stack_overflow_(false), is_pre_parsing_(pre == PREPARSE),
+ character_classes_(Isolate::Current()->
+ scanner_character_classes()) { }
void Scanner::Initialize(Handle<String> source,
@@ -477,9 +467,10 @@ bool Scanner::SkipJavaScriptWhiteSpace() {
while (true) {
// We treat byte-order marks (BOMs) as whitespace for better
// compatibility with Spidermonkey and other JavaScript engines.
- while (kIsWhiteSpace.get(c0_) || IsByteOrderMark(c0_)) {
+ while (character_classes_->is_white_space_.get(c0_) ||
+ IsByteOrderMark(c0_)) {
// IsWhiteSpace() includes line terminators!
- if (kIsLineTerminator.get(c0_)) {
+ if (character_classes_->is_line_terminator_.get(c0_)) {
// Ignore line terminators, but remember them. This is necessary
// for automatic semicolon insertion.
has_line_terminator_before_next_ = true;
@@ -519,7 +510,8 @@ Token::Value Scanner::SkipSingleLineComment() {
// separately by the lexical grammar and becomes part of the
// stream of input elements for the syntactic grammar (see
// ECMA-262, section 7.4, page 12).
- while (c0_ >= 0 && !kIsLineTerminator.get(c0_)) {
+ while (c0_ >= 0 &&
+ !character_classes_->is_line_terminator_.get(c0_)) {
Advance();
}
@@ -748,7 +740,8 @@ Token::Value Scanner::ScanJsonIdentifier(const char* text,
Advance();
text++;
}
- if (kIsIdentifierPart.get(c0_)) return Token::ILLEGAL;
+ if (character_classes_->is_identifier_part_.get(c0_))
+ return Token::ILLEGAL;
TerminateLiteral();
return token;
}
@@ -972,7 +965,7 @@ void Scanner::ScanJavaScript() {
break;
default:
- if (kIsIdentifierStart.get(c0_)) {
+ if (character_classes_->is_identifier_start_.get(c0_)) {
token = ScanIdentifier();
} else if (IsDecimalDigit(c0_)) {
token = ScanNumber(false);
@@ -1051,7 +1044,7 @@ void Scanner::ScanEscape() {
Advance();
// Skip escaped newlines.
- if (kIsLineTerminator.get(c)) {
+ if (character_classes_->is_line_terminator_.get(c)) {
// Allow CR+LF newlines in multiline string literals.
if (IsCarriageReturn(c) && IsLineFeed(c0_)) Advance();
// Allow LF+CR newlines in multiline string literals.
@@ -1093,7 +1086,8 @@ Token::Value Scanner::ScanString() {
Advance(); // consume quote
StartLiteral();
- while (c0_ != quote && c0_ >= 0 && !kIsLineTerminator.get(c0_)) {
+ while (c0_ != quote && c0_ >= 0 &&
+ !character_classes_->is_line_terminator_.get(c0_)) {
uc32 c = c0_;
Advance();
if (c == '\\') {
@@ -1207,7 +1201,8 @@ Token::Value Scanner::ScanNumber(bool seen_period) {
// not be an identifier start or a decimal digit; see ECMA-262
// section 7.8.3, page 17 (note that we read only one decimal digit
// if the value is 0).
- if (IsDecimalDigit(c0_) || kIsIdentifierStart.get(c0_))
+ if (IsDecimalDigit(c0_) ||
+ character_classes_->is_identifier_start_.get(c0_))
return Token::ILLEGAL;
return Token::NUMBER;
@@ -1227,7 +1222,7 @@ uc32 Scanner::ScanIdentifierUnicodeEscape() {
Token::Value Scanner::ScanIdentifier() {
- ASSERT(kIsIdentifierStart.get(c0_));
+ ASSERT(character_classes_->is_identifier_start_.get(c0_));
StartLiteral();
KeywordMatcher keyword_match;
@@ -1236,7 +1231,8 @@ Token::Value Scanner::ScanIdentifier() {
if (c0_ == '\\') {
uc32 c = ScanIdentifierUnicodeEscape();
// Only allow legal identifier start characters.
- if (!kIsIdentifierStart.get(c)) return Token::ILLEGAL;
+ if (!character_classes_->is_identifier_start_.get(c))
+ return Token::ILLEGAL;
AddChar(c);
keyword_match.Fail();
} else {
@@ -1246,11 +1242,12 @@ Token::Value Scanner::ScanIdentifier() {
}
// Scan the rest of the identifier characters.
- while (kIsIdentifierPart.get(c0_)) {
+ while (character_classes_->is_identifier_part_.get(c0_)) {
if (c0_ == '\\') {
uc32 c = ScanIdentifierUnicodeEscape();
// Only allow legal identifier part characters.
- if (!kIsIdentifierPart.get(c)) return Token::ILLEGAL;
+ if (!character_classes_->is_identifier_part_.get(c))
+ return Token::ILLEGAL;
AddChar(c);
keyword_match.Fail();
} else {
@@ -1266,12 +1263,12 @@ Token::Value Scanner::ScanIdentifier() {
-bool Scanner::IsIdentifier(unibrow::CharacterStream* buffer) {
+bool ScannerCharacterClasses::IsIdentifier(unibrow::CharacterStream* buffer) {
// Checks whether the buffer contains an identifier (no escape).
if (!buffer->has_more()) return false;
- if (!kIsIdentifierStart.get(buffer->GetNext())) return false;
+ if (!is_identifier_start_.get(buffer->GetNext())) return false;
while (buffer->has_more()) {
- if (!kIsIdentifierPart.get(buffer->GetNext())) return false;
+ if (!is_identifier_part_.get(buffer->GetNext())) return false;
}
return true;
}
@@ -1294,11 +1291,11 @@ bool Scanner::ScanRegExpPattern(bool seen_equal) {
AddChar('=');
while (c0_ != '/' || in_character_class) {
- if (kIsLineTerminator.get(c0_) || c0_ < 0)
+ if (character_classes_->is_line_terminator_.get(c0_) || c0_ < 0)
return false;
if (c0_ == '\\') { // escaped character
AddCharAdvance();
- if (kIsLineTerminator.get(c0_) || c0_ < 0)
+ if (character_classes_->is_line_terminator_.get(c0_) || c0_ < 0)
return false;
AddCharAdvance();
} else { // unescaped character
@@ -1319,7 +1316,7 @@ bool Scanner::ScanRegExpPattern(bool seen_equal) {
bool Scanner::ScanRegExpFlags() {
// Scan regular expression flags.
StartLiteral();
- while (kIsIdentifierPart.get(c0_)) {
+ while (character_classes_->is_identifier_part_.get(c0_)) {
if (c0_ == '\\') {
uc32 c = ScanIdentifierUnicodeEscape();
if (c != static_cast<uc32>(unibrow::Utf8::kBadChar)) {
« 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