Revision: 4892
Author: [email protected]
Date: Thu Jun 17 06:14:39 2010
Log: [Isolates] Static mutable data of Scanner class moved to
ScannerCharacterClasses / Isolate.
Landing patch by Maxim.Mossienko with the following changes:
* Instead of exposing the whitespace predicate object in
ScannerCharacterClasses exposed IsWhiteSpace function.
* Fetching the current isolate earlier in conversion.cc
functions.
Original review: http://codereview.chromium.org/2799008/show
Review URL: http://codereview.chromium.org/2831016
http://code.google.com/p/v8/source/detail?r=4892
Modified:
/branches/experimental/isolates/src/conversions.cc
/branches/experimental/isolates/src/dateparser.h
/branches/experimental/isolates/src/heap.cc
/branches/experimental/isolates/src/isolate.cc
/branches/experimental/isolates/src/isolate.h
/branches/experimental/isolates/src/objects.cc
/branches/experimental/isolates/src/scanner.cc
/branches/experimental/isolates/src/scanner.h
=======================================
--- /branches/experimental/isolates/src/conversions.cc Wed May 5 06:51:27
2010
+++ /branches/experimental/isolates/src/conversions.cc Thu Jun 17 06:14:39
2010
@@ -120,9 +120,11 @@
// Returns true if a nonspace found and false if the end has reached.
template <class Iterator, class EndMark>
-static inline bool AdvanceToNonspace(Iterator* current, EndMark end) {
+static inline bool AdvanceToNonspace(ScannerCharacterClasses*
character_classes,
+ Iterator* current,
+ EndMark end) {
while (*current != end) {
- if (!Scanner::kIsWhiteSpace.get(**current)) return true;
+ if (!character_classes->IsWhiteSpace(**current)) return true;
++*current;
}
return false;
@@ -143,10 +145,12 @@
// Parsing integers with radix 2, 4, 8, 16, 32. Assumes current != end.
template <int radix_log_2, class Iterator, class EndMark>
-static double InternalStringToIntDouble(Iterator current,
- EndMark end,
- bool sign,
- bool allow_trailing_junk) {
+static double InternalStringToIntDouble(
+ ScannerCharacterClasses* character_classes,
+ Iterator current,
+ EndMark end,
+ bool sign,
+ bool allow_trailing_junk) {
ASSERT(current != end);
// Skip leading 0s.
@@ -168,7 +172,8 @@
} else if (radix > 10 && *current >= 'A' && *current < 'A' + radix -
10) {
digit = static_cast<char>(*current) - 'A' + 10;
} else {
- if (allow_trailing_junk || !AdvanceToNonspace(¤t, end)) {
+ if (allow_trailing_junk ||
+ !AdvanceToNonspace(character_classes, ¤t, end)) {
break;
} else {
return JUNK_STRING_VALUE;
@@ -199,7 +204,8 @@
exponent += radix_log_2;
}
- if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
+ if (!allow_trailing_junk &&
+ AdvanceToNonspace(character_classes, ¤t, end)) {
return JUNK_STRING_VALUE;
}
@@ -243,11 +249,16 @@
template <class Iterator, class EndMark>
-static double InternalStringToInt(Iterator current, EndMark end, int
radix) {
+static double InternalStringToInt(ScannerCharacterClasses*
character_classes,
+ Iterator current,
+ EndMark end,
+ int radix) {
const bool allow_trailing_junk = true;
const double empty_string_val = JUNK_STRING_VALUE;
- if (!AdvanceToNonspace(¤t, end)) return empty_string_val;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return empty_string_val;
+ }
bool sign = false;
bool leading_zero = false;
@@ -255,10 +266,14 @@
if (*current == '+') {
// Ignore leading sign; skip following spaces.
++current;
- if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return JUNK_STRING_VALUE;
+ }
} else if (*current == '-') {
++current;
- if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return JUNK_STRING_VALUE;
+ }
sign = true;
}
@@ -309,21 +324,21 @@
switch (radix) {
case 2:
return InternalStringToIntDouble<1>(
- current, end, sign, allow_trailing_junk);
+ character_classes, current, end, sign, allow_trailing_junk);
case 4:
return InternalStringToIntDouble<2>(
- current, end, sign, allow_trailing_junk);
+ character_classes, current, end, sign, allow_trailing_junk);
case 8:
return InternalStringToIntDouble<3>(
- current, end, sign, allow_trailing_junk);
+ character_classes, current, end, sign, allow_trailing_junk);
case 16:
return InternalStringToIntDouble<4>(
- current, end, sign, allow_trailing_junk);
+ character_classes, current, end, sign, allow_trailing_junk);
case 32:
return InternalStringToIntDouble<5>(
- current, end, sign, allow_trailing_junk);
+ character_classes, current, end, sign, allow_trailing_junk);
default:
UNREACHABLE();
}
@@ -348,7 +363,8 @@
if (current == end) break;
}
- if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
+ if (!allow_trailing_junk &&
+ AdvanceToNonspace(character_classes, ¤t, end)) {
return JUNK_STRING_VALUE;
}
@@ -412,7 +428,8 @@
v = v * multiplier + part;
} while (!done);
- if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
+ if (!allow_trailing_junk &&
+ AdvanceToNonspace(character_classes, ¤t, end)) {
return JUNK_STRING_VALUE;
}
@@ -426,7 +443,8 @@
// 2. *current - gets the current character in the sequence.
// 3. ++current (advances the position).
template <class Iterator, class EndMark>
-static double InternalStringToDouble(Iterator current,
+static double InternalStringToDouble(ScannerCharacterClasses*
character_classes,
+ Iterator current,
EndMark end,
int flags,
double empty_string_val) {
@@ -438,7 +456,9 @@
// 'parsing_done'.
// 4. 'current' is not dereferenced after the 'parsing_done' label.
// 5. Code before 'parsing_done' may rely on 'current != end'.
- if (!AdvanceToNonspace(¤t, end)) return empty_string_val;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return empty_string_val;
+ }
const bool allow_trailing_junk = (flags & ALLOW_TRAILING_JUNK) != 0;
@@ -460,11 +480,15 @@
if (*current == '+') {
// Ignore leading sign; skip following spaces.
++current;
- if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return JUNK_STRING_VALUE;
+ }
} else if (*current == '-') {
buffer[buffer_pos++] = '-';
++current;
- if (!AdvanceToNonspace(¤t, end)) return JUNK_STRING_VALUE;
+ if (!AdvanceToNonspace(character_classes, ¤t, end)) {
+ return JUNK_STRING_VALUE;
+ }
sign = true;
}
@@ -474,7 +498,8 @@
return JUNK_STRING_VALUE;
}
- if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
+ if (!allow_trailing_junk &&
+ AdvanceToNonspace(character_classes, ¤t, end)) {
return JUNK_STRING_VALUE;
}
@@ -497,7 +522,8 @@
}
bool sign = (buffer_pos > 0 && buffer[0] == '-');
- return InternalStringToIntDouble<4>(current,
+ return InternalStringToIntDouble<4>(character_classes,
+ current,
end,
sign,
allow_trailing_junk);
@@ -630,7 +656,8 @@
exponent += (sign == '-' ? -num : num);
}
- if (!allow_trailing_junk && AdvanceToNonspace(¤t, end)) {
+ if (!allow_trailing_junk &&
+ AdvanceToNonspace(character_classes, ¤t, end)) {
return JUNK_STRING_VALUE;
}
@@ -641,7 +668,8 @@
bool sign = buffer[0] == '-';
int start_pos = (sign ? 1 : 0);
- return InternalStringToIntDouble<3>(buffer + start_pos,
+ return InternalStringToIntDouble<3>(character_classes,
+ buffer + start_pos,
buffer + buffer_pos,
sign,
allow_trailing_junk);
@@ -693,18 +721,23 @@
}
double StringToDouble(String* str, int flags, double empty_string_val) {
+ ScannerCharacterClasses* character_classes =
+ Isolate::Current()->scanner_character_classes();
StringShape shape(str);
if (shape.IsSequentialAscii()) {
const char* begin = SeqAsciiString::cast(str)->GetChars();
const char* end = begin + str->length();
- return InternalStringToDouble(begin, end, flags, empty_string_val);
+ return InternalStringToDouble(character_classes, begin, end, flags,
+ empty_string_val);
} else if (shape.IsSequentialTwoByte()) {
const uc16* begin = SeqTwoByteString::cast(str)->GetChars();
const uc16* end = begin + str->length();
- return InternalStringToDouble(begin, end, flags, empty_string_val);
+ return InternalStringToDouble(character_classes, begin, end, flags,
+ empty_string_val);
} else {
StringInputBuffer buffer(str);
- return InternalStringToDouble(StringInputBufferIterator(&buffer),
+ return InternalStringToDouble(character_classes,
+ StringInputBufferIterator(&buffer),
StringInputBufferIterator::EndMarker(),
flags,
empty_string_val);
@@ -713,18 +746,21 @@
double StringToInt(String* str, int radix) {
+ ScannerCharacterClasses* character_classes =
+ Isolate::Current()->scanner_character_classes();
StringShape shape(str);
if (shape.IsSequentialAscii()) {
const char* begin = SeqAsciiString::cast(str)->GetChars();
const char* end = begin + str->length();
- return InternalStringToInt(begin, end, radix);
+ return InternalStringToInt(character_classes, begin, end, radix);
} else if (shape.IsSequentialTwoByte()) {
const uc16* begin = SeqTwoByteString::cast(str)->GetChars();
const uc16* end = begin + str->length();
- return InternalStringToInt(begin, end, radix);
+ return InternalStringToInt(character_classes, begin, end, radix);
} else {
StringInputBuffer buffer(str);
- return InternalStringToInt(StringInputBufferIterator(&buffer),
+ return InternalStringToInt(character_classes,
+ StringInputBufferIterator(&buffer),
StringInputBufferIterator::EndMarker(),
radix);
}
@@ -732,9 +768,11 @@
double StringToDouble(const char* str, int flags, double empty_string_val)
{
+ ScannerCharacterClasses* character_classes =
+ Isolate::Current()->scanner_character_classes();
const char* end = str + StrLength(str);
-
- return InternalStringToDouble(str, end, flags, empty_string_val);
+ return InternalStringToDouble(character_classes, str, end, flags,
+ empty_string_val);
}
=======================================
--- /branches/experimental/isolates/src/dateparser.h Sun May 2 23:43:25
2010
+++ /branches/experimental/isolates/src/dateparser.h Thu Jun 17 06:14:39
2010
@@ -69,7 +69,8 @@
explicit InputReader(Vector<Char> s)
: index_(0),
buffer_(s),
- has_read_number_(false) {
+ has_read_number_(false),
+
character_classes_(Isolate::Current()->scanner_character_classes()) {
Next();
}
@@ -102,7 +103,7 @@
bool Skip(uint32_t c) { return ch_ == c ? (Next(), true) : false; }
bool SkipWhiteSpace() {
- return Scanner::kIsWhiteSpace.get(ch_) ? (Next(), true) : false;
+ return character_classes_->IsWhiteSpace(ch_) ? (Next(), true) :
false;
}
bool SkipParentheses() {
@@ -138,6 +139,7 @@
Vector<Char> buffer_;
bool has_read_number_;
uint32_t ch_;
+ ScannerCharacterClasses* character_classes_;
};
enum KeywordType { INVALID, MONTH_NAME, TIME_ZONE_NAME, AM_PM };
=======================================
--- /branches/experimental/isolates/src/heap.cc Wed Jun 16 17:13:33 2010
+++ /branches/experimental/isolates/src/heap.cc Thu Jun 17 06:14:39 2010
@@ -2779,7 +2779,8 @@
PretenureFlag pretenure) {
// Count the number of characters in the UTF-8 string and check if
// it is an ASCII string.
- Access<Scanner::Utf8Decoder> decoder(Scanner::utf8_decoder());
+ Access<Scanner::Utf8Decoder> decoder(isolate_->
+ scanner_character_classes()->utf8_decoder());
decoder->Reset(string.start(), string.length());
int chars = 0;
bool is_ascii = true;
=======================================
--- /branches/experimental/isolates/src/isolate.cc Wed Jun 16 18:24:32 2010
+++ /branches/experimental/isolates/src/isolate.cc Thu Jun 17 06:14:39 2010
@@ -35,6 +35,7 @@
#include "isolate.h"
#include "log.h"
#include "serialize.h"
+#include "scanner.h"
#include "scopeinfo.h"
#include "simulator.h"
#include "stub-cache.h"
@@ -115,7 +116,8 @@
keyed_lookup_cache_(new KeyedLookupCache()),
context_slot_cache_(new ContextSlotCache()),
descriptor_lookup_cache_(new DescriptorLookupCache()),
- handle_scope_implementer_(NULL) {
+ handle_scope_implementer_(NULL),
+ scanner_character_classes_(new ScannerCharacterClasses()) {
heap_.isolate_ = this;
stack_guard_.isolate_ = this;
@@ -134,6 +136,9 @@
Isolate::~Isolate() {
+ delete scanner_character_classes_;
+ scanner_character_classes_ = NULL;
+
delete descriptor_lookup_cache_;
descriptor_lookup_cache_ = NULL;
delete context_slot_cache_;
=======================================
--- /branches/experimental/isolates/src/isolate.h Wed Jun 16 18:24:32 2010
+++ /branches/experimental/isolates/src/isolate.h Thu Jun 17 06:14:39 2010
@@ -45,6 +45,7 @@
class HandleScopeImplementer;
class SaveContext;
class StubCache;
+class ScannerCharacterClasses;
class ThreadLocalTop BASE_EMBEDDED {
public:
@@ -223,6 +224,10 @@
return handle_scope_implementer_;
}
Zone* zone() { return &zone_; }
+
+ ScannerCharacterClasses* scanner_character_classes() {
+ return scanner_character_classes_;
+ }
// SerializerDeserializer state.
static const int kPartialSnapshotCacheCapacity = 1300;
@@ -268,6 +273,7 @@
DescriptorLookupCache* descriptor_lookup_cache_;
v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
HandleScopeImplementer* handle_scope_implementer_;
+ ScannerCharacterClasses* scanner_character_classes_;
Zone zone_;
#define GLOBAL_BACKING_STORE(type, name,
initialvalue) \
=======================================
--- /branches/experimental/isolates/src/objects.cc Wed Jun 16 17:13:33 2010
+++ /branches/experimental/isolates/src/objects.cc Thu Jun 17 06:14:39 2010
@@ -1230,7 +1230,9 @@
// Normalize the object if the name is an actual string (not the
// hidden symbols) and is not a real identifier.
StringInputBuffer buffer(name);
- if (!Scanner::IsIdentifier(&buffer) && name != HEAP->hidden_symbol()) {
+ Isolate* isolate = Isolate::Current();
+ if (!isolate->scanner_character_classes()->IsIdentifier(&buffer) &&
+ name != isolate->heap()->hidden_symbol()) {
Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
if (obj->IsFailure()) return obj;
return AddSlowProperty(name, value, attributes);
@@ -4757,7 +4759,8 @@
bool String::IsEqualTo(Vector<const char> str) {
int slen = length();
- Access<Scanner::Utf8Decoder> decoder(Scanner::utf8_decoder());
+ Access<Scanner::Utf8Decoder> decoder(Isolate::Current()->
+ scanner_character_classes()->utf8_decoder());
decoder->Reset(str.start(), str.length());
int i;
for (i = 0; i < slen && decoder->has_more(); i++) {
=======================================
--- /branches/experimental/isolates/src/scanner.cc Wed Mar 3 05:16:10 2010
+++ /branches/experimental/isolates/src/scanner.cc Thu Jun 17 06:14:39 2010
@@ -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 @@
// 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 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
Token::Value Scanner::ScanIdentifier() {
- ASSERT(kIsIdentifierStart.get(c0_));
+ ASSERT(character_classes_->is_identifier_start_.get(c0_));
StartLiteral();
KeywordMatcher keyword_match;
@@ -1236,7 +1231,8 @@
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 @@
}
// 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 @@
-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 @@
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::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)) {
=======================================
--- /branches/experimental/isolates/src/scanner.h Wed Mar 3 05:16:10 2010
+++ /branches/experimental/isolates/src/scanner.h Thu Jun 17 06:14:39 2010
@@ -258,6 +258,9 @@
};
+class ScannerCharacterClasses;
+
+
enum ParserMode { PARSE, PREPARSE };
enum ParserLanguage { JAVASCRIPT, JSON };
@@ -346,17 +349,6 @@
void SeekForward(int pos);
bool stack_overflow() { return stack_overflow_; }
-
- static StaticResource<Utf8Decoder>* utf8_decoder() { return
&utf8_decoder_; }
-
- // Tells whether the buffer contains an identifier (no escapes).
- // Used for checking if a property name is an identifier.
- static bool IsIdentifier(unibrow::CharacterStream* buffer);
-
- static unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart;
- static unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart;
- static unibrow::Predicate<unibrow::LineTerminator, 128>
kIsLineTerminator;
- static unibrow::Predicate<unibrow::WhiteSpace, 128> kIsWhiteSpace;
static const int kCharacterLookaheadBufferSize = 1;
static const int kNoEndPosition = 1;
@@ -388,7 +380,6 @@
UTF8Buffer literal_buffer_2_;
bool stack_overflow_;
- static StaticResource<Utf8Decoder> utf8_decoder_;
// One Unicode character look-ahead; c0_ < 0 at the end of the input.
uc32 c0_;
@@ -406,6 +397,8 @@
bool is_pre_parsing_;
bool is_parsing_json_;
+ ScannerCharacterClasses* const character_classes_;
+
// Literal buffer support
void StartLiteral();
void AddChar(uc32 ch);
@@ -491,6 +484,38 @@
uc32 ScanIdentifierUnicodeEscape();
};
+
+class ScannerCharacterClasses {
+ public:
+ StaticResource<Scanner::Utf8Decoder>* utf8_decoder() {
+ return &utf8_decoder_;
+ }
+
+ // Tells whether the buffer contains an identifier (no escapes).
+ // Used for checking if a property name is an identifier.
+ bool IsIdentifier(unibrow::CharacterStream* buffer);
+
+ bool IsWhiteSpace(unibrow::uchar c) { return is_white_space_.get(c); }
+
+ private:
+ ScannerCharacterClasses() {}
+
+ //
--------------------------------------------------------------------------
+ // Character predicates
+
+ unibrow::Predicate<IdentifierStart, 128> is_identifier_start_;
+ unibrow::Predicate<IdentifierPart, 128> is_identifier_part_;
+ unibrow::Predicate<unibrow::LineTerminator, 128> is_line_terminator_;
+ unibrow::Predicate<unibrow::WhiteSpace, 128> is_white_space_;
+
+ StaticResource<Scanner::Utf8Decoder> utf8_decoder_;
+
+ friend class Isolate;
+ friend class Scanner;
+
+ DISALLOW_COPY_AND_ASSIGN(ScannerCharacterClasses);
+};
+
} } // namespace v8::internal
#endif // V8_SCANNER_H_
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev