54 if (static_cast<unsigned>(c) <= 9)
return c;
55 c = (c | 0x20) - (
'a' -
'0');
56 if (static_cast<unsigned>(c) <= 5)
return c + 10;
90 inline unsigned pos()
const {
return pos_; }
97 unsigned buffered_chars =
99 if (code_unit_count <= buffered_chars) {
101 pos_ += code_unit_count;
102 return code_unit_count;
138 return &utf8_decoder_;
146 return kIsWhiteSpaceOrLineTerminator.get(c);
155 kIsWhiteSpaceOrLineTerminator;
168 : unicode_constants_(constants),
192 static bool Match(
void* first,
void* second);
201 static const int kBufferSize = 100;
208 char number_buffer_[kBufferSize];
220 if (backing_store_.
length() > 0) {
225 INLINE(
void AddChar(uint32_t code_unit)) {
226 if (position_ >= backing_store_.
length()) ExpandBuffer();
229 backing_store_[position_] =
static_cast<byte>(code_unit);
235 ASSERT(code_unit < 0x10000u);
236 *
reinterpret_cast<uint16_t*
>(&backing_store_[position_]) = code_unit;
244 (memcmp(keyword.
start(), backing_store_.
start(), position_) == 0);
249 ASSERT((position_ & 0x1) == 0);
258 reinterpret_cast<const uint8_t*
>(backing_store_.
start()),
263 return is_one_byte_ ? position_ : (position_ >> 1);
272 static const int kInitialCapacity = 16;
273 static const int kGrowthFactory = 4;
274 static const int kMinConversionSlack = 256;
275 static const int kMaxGrowth = 1 *
MB;
276 inline int NewCapacity(
int min_capacity) {
277 int capacity =
Max(min_capacity, backing_store_.
length());
278 int new_capacity =
Min(capacity * kGrowthFactory, capacity + kMaxGrowth);
282 void ExpandBuffer() {
286 backing_store_ = new_store;
289 void ConvertToTwoByte() {
291 Vector<byte> new_store;
292 int new_content_size = position_ *
kUC16Size;
293 if (new_content_size >= backing_store_.
length()) {
298 new_store = backing_store_;
300 uint8_t* src = backing_store_.
start();
302 for (
int i = position_ - 1; i >= 0; i--) {
305 if (new_store.start() != backing_store_.
start()) {
307 backing_store_ = new_store;
309 position_ = new_content_size;
310 is_one_byte_ =
false;
315 Vector<byte> backing_store_;
331 : scanner_(self), complete_(
false) {
332 scanner_->StartLiteral();
335 if (!complete_) scanner_->DropLiteral();
338 scanner_->TerminateLiteral();
391 return current_.literal_chars->length() != source_length;
395 return current_.literal_chars->is_contextual_keyword(keyword);
399 return next_.literal_chars->is_contextual_keyword(keyword);
408 if (is_literal_one_byte() &&
409 literal_length() == length &&
412 reinterpret_cast<const char*
>(literal_one_byte_string().
start());
413 return !strncmp(token, data, length);
418 if (is_literal_one_byte() &&
419 literal_length() == 3 &&
422 reinterpret_cast<const char*
>(literal_one_byte_string().
start());
423 *is_get = strncmp(token,
"get", 3) == 0;
424 *is_set = !*is_get && strncmp(token,
"set", 3) == 0;
446 return harmony_scoping_;
449 harmony_scoping_ = scoping;
452 return harmony_modules_;
458 return harmony_numeric_literals_;
461 harmony_numeric_literals_ = numeric_literals;
467 return has_line_terminator_before_next_ ||
468 has_multiline_comment_before_next_;
486 static const int kCharacterLookaheadBufferSize = 1;
489 uc32 ScanOctalEscape(
uc32 c,
int length);
497 current_.literal_chars =
NULL;
501 inline void StartLiteral() {
502 LiteralBuffer* free_buffer = (current_.literal_chars == &literal_buffer1_) ?
503 &literal_buffer2_ : &literal_buffer1_;
504 free_buffer->Reset();
505 next_.literal_chars = free_buffer;
508 INLINE(
void AddLiteralChar(
uc32 c)) {
510 next_.literal_chars->AddChar(c);
514 inline void TerminateLiteral() {
520 inline void DropLiteral() {
521 next_.literal_chars =
NULL;
524 inline void AddLiteralCharAdvance() {
530 void Advance() { c0_ = source_->
Advance(); }
531 void PushBack(
uc32 ch) {
557 Vector<const uint8_t> literal_one_byte_string() {
559 return current_.literal_chars->one_byte_literal();
561 Vector<const uint16_t> literal_two_byte_string() {
563 return current_.literal_chars->two_byte_literal();
565 bool is_literal_one_byte() {
567 return current_.literal_chars->is_one_byte();
569 int literal_length()
const {
571 return current_.literal_chars->length();
575 Vector<const uint8_t> next_literal_one_byte_string() {
577 return next_.literal_chars->one_byte_literal();
579 Vector<const uint16_t> next_literal_two_byte_string() {
581 return next_.literal_chars->two_byte_literal();
583 bool is_next_literal_one_byte() {
585 return next_.literal_chars->is_one_byte();
587 int next_literal_length()
const {
589 return next_.literal_chars->length();
592 uc32 ScanHexNumber(
int expected_length);
597 bool SkipWhiteSpace();
603 void ScanDecimalDigits();
606 Token::Value ScanIdentifierSuffix(LiteralScope* literal);
616 uc32 ScanIdentifierUnicodeEscape();
620 bool ScanLiteralUnicodeEscape();
624 return source_->
pos() - kCharacterLookaheadBufferSize;
627 UnicodeCache* unicode_cache_;
630 LiteralBuffer literal_buffer1_;
631 LiteralBuffer literal_buffer2_;
637 Utf16CharacterStream* source_;
649 bool has_line_terminator_before_next_;
652 bool has_multiline_comment_before_next_;
654 bool harmony_scoping_;
656 bool harmony_modules_;
658 bool harmony_numeric_literals_;
663 #endif // V8_SCANNER_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
bool HarmonyModules() const
const uint16_t * buffer_cursor_
bool IsIdentifierPart(unibrow::uchar c)
LiteralScope(Scanner *self)
static const unsigned kMaxChar
virtual unsigned SlowSeekForward(unsigned code_unit_count)=0
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
Vector< const uint8_t > one_byte_literal()
static const uc32 kEndOfInput
#define ASSERT_NOT_NULL(p)
int FindSymbol(DuplicateFinder *finder, int value)
void SetHarmonyScoping(bool scoping)
int AddOneByteSymbol(Vector< const uint8_t > key, int value)
const uint16_t * buffer_end_
bool IsWhiteSpace(unibrow::uchar c)
Scanner(UnicodeCache *scanner_contants)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT enable GDBJIT interface for all code objects dump only objects containing this substring stress the GC compactor to flush out pretty print source code print source AST function name where to insert a breakpoint print scopes for builtins trace contexts operations print stuff during garbage collection report code statistics after GC report handles after GC trace cache state transitions print interface inference details prints when objects are turned into dictionaries report heap spill statistics along with trace isolate state changes trace regexp bytecode execution Minimal Log all events to the log file Log API events to the log file Log heap samples on garbage collection for the hp2ps tool log positions Log suspect operations Used with turns on browser compatible mode for profiling v8 log
#define ASSERT(condition)
bool is_contextual_keyword(Vector< const char > keyword)
Vector< const uint16_t > two_byte_literal()
void SetHarmonyModules(bool modules)
bool HasAnyLineTerminatorBeforeNext() const
bool HarmonyScoping() const
bool UnescapedLiteralMatches(const char *data, int length)
bool literal_contains_escapes() const
int AddTwoByteSymbol(Vector< const uint16_t > key, int value)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static void MemCopy(void *dest, const void *src, size_t size)
DuplicateFinder(UnicodeCache *constants)
void SeekForward(int pos)
int AddNumber(Vector< const uint8_t > key, int value)
void IsGetOrSet(bool *is_get, bool *is_set)
virtual void PushBack(int32_t code_unit)=0
static Vector< T > New(int length)
void Initialize(Utf16CharacterStream *source)
bool IsLineTerminator(unibrow::uchar c)
int FindNumber(DuplicateFinder *finder, int value)
static Location invalid()
Location location() const
static const int kNoOctalLocation
bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c)
void clear_octal_position()
void LogSymbol(ParserRecorder *log, int position)
bool is_next_contextual_keyword(Vector< const char > keyword)
virtual bool ReadBlock()=0
enforce strict mode enable harmony semantics for typeof enable harmony modules(implies block scoping)") DEFINE_bool(harmony_symbols
void SetHarmonyNumericLiterals(bool numeric_literals)
Token::Value peek() const
Handle< String > AllocateNextLiteralString(Isolate *isolate, PretenureFlag tenured)
Location octal_position() const
INLINE(void AddChar(uint32_t code_unit))
StaticResource< Utf8Decoder > * utf8_decoder()
Token::Value current_token()
bool is_literal_contextual_keyword(Vector< const char > keyword)
virtual ~Utf16CharacterStream()
bool HarmonyNumericLiterals() const
unibrow::Utf8Decoder< 512 > Utf8Decoder
bool IsIdentifierStart(unibrow::uchar c)
unsigned SeekForward(unsigned code_unit_count)
bool ScanRegExpPattern(bool seen_equal)
Handle< String > AllocateInternalizedString(Isolate *isolate)
UnicodeCache * unicode_cache()
Location peek_location() const