V8 Project
scanner.h
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
5 // Features shared by parsing and pre-parsing scanners.
6 
7 #ifndef V8_SCANNER_H_
8 #define V8_SCANNER_H_
9 
10 #include "src/allocation.h"
11 #include "src/base/logging.h"
12 #include "src/char-predicates.h"
13 #include "src/globals.h"
14 #include "src/hashmap.h"
15 #include "src/list.h"
16 #include "src/token.h"
17 #include "src/unicode-inl.h"
18 #include "src/utils.h"
19 
20 namespace v8 {
21 namespace internal {
22 
23 
24 class AstRawString;
25 class AstValueFactory;
26 class ParserRecorder;
27 
28 
29 // Returns the value (0 .. 15) of a hexadecimal character c.
30 // If c is not a legal hexadecimal character, returns a value < 0.
31 inline int HexValue(uc32 c) {
32  c -= '0';
33  if (static_cast<unsigned>(c) <= 9) return c;
34  c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36.
35  if (static_cast<unsigned>(c) <= 5) return c + 10;
36  return -1;
37 }
38 
39 
40 // ---------------------------------------------------------------------
41 // Buffered stream of UTF-16 code units, using an internal UTF-16 buffer.
42 // A code unit is a 16 bit value representing either a 16 bit code point
43 // or one part of a surrogate pair that make a single 21 bit code point.
44 
46  public:
48  virtual ~Utf16CharacterStream() { }
49 
50  // Returns and advances past the next UTF-16 code unit in the input
51  // stream. If there are no more code units, it returns a negative
52  // value.
53  inline uc32 Advance() {
55  pos_++;
56  return static_cast<uc32>(*(buffer_cursor_++));
57  }
58  // Note: currently the following increment is necessary to avoid a
59  // parser problem! The scanner treats the final kEndOfInput as
60  // a code unit with a position, and does math relative to that
61  // position.
62  pos_++;
63 
64  return kEndOfInput;
65  }
66 
67  // Return the current position in the code unit stream.
68  // Starts at zero.
69  inline unsigned pos() const { return pos_; }
70 
71  // Skips forward past the next code_unit_count UTF-16 code units
72  // in the input, or until the end of input if that comes sooner.
73  // Returns the number of code units actually skipped. If less
74  // than code_unit_count,
75  inline unsigned SeekForward(unsigned code_unit_count) {
76  unsigned buffered_chars =
77  static_cast<unsigned>(buffer_end_ - buffer_cursor_);
78  if (code_unit_count <= buffered_chars) {
79  buffer_cursor_ += code_unit_count;
80  pos_ += code_unit_count;
81  return code_unit_count;
82  }
83  return SlowSeekForward(code_unit_count);
84  }
85 
86  // Pushes back the most recently read UTF-16 code unit (or negative
87  // value if at end of input), i.e., the value returned by the most recent
88  // call to Advance.
89  // Must not be used right after calling SeekForward.
90  virtual void PushBack(int32_t code_unit) = 0;
91 
92  protected:
93  static const uc32 kEndOfInput = -1;
94 
95  // Ensures that the buffer_cursor_ points to the code_unit at
96  // position pos_ of the input, if possible. If the position
97  // is at or after the end of the input, return false. If there
98  // are more code_units available, return true.
99  virtual bool ReadBlock() = 0;
100  virtual unsigned SlowSeekForward(unsigned code_unit_count) = 0;
101 
104  unsigned pos_;
105 };
106 
107 
108 // ---------------------------------------------------------------------
109 // Caching predicates used by scanners.
110 
112  public:
115 
117  return &utf8_decoder_;
118  }
119 
123  bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); }
125  return kIsWhiteSpaceOrLineTerminator.get(c);
126  }
127 
128  private:
136 
138 };
139 
140 
141 // ---------------------------------------------------------------------
142 // DuplicateFinder discovers duplicate symbols.
143 
145  public:
146  explicit DuplicateFinder(UnicodeCache* constants)
147  : unicode_constants_(constants),
148  backing_store_(16),
149  map_(&Match) { }
150 
151  int AddOneByteSymbol(Vector<const uint8_t> key, int value);
152  int AddTwoByteSymbol(Vector<const uint16_t> key, int value);
153  // Add a a number literal by converting it (if necessary)
154  // to the string that ToString(ToNumber(literal)) would generate.
155  // and then adding that string with AddOneByteSymbol.
156  // This string is the actual value used as key in an object literal,
157  // and the one that must be different from the other keys.
158  int AddNumber(Vector<const uint8_t> key, int value);
159 
160  private:
161  int AddSymbol(Vector<const uint8_t> key, bool is_one_byte, int value);
162  // Backs up the key and its length in the backing store.
163  // The backup is stored with a base 127 encoding of the
164  // length (plus a bit saying whether the string is one byte),
165  // followed by the bytes of the key.
166  uint8_t* BackupKey(Vector<const uint8_t> key, bool is_one_byte);
167 
168  // Compare two encoded keys (both pointing into the backing store)
169  // for having the same base-127 encoded lengths and representation.
170  // and then having the same 'length' bytes following.
171  static bool Match(void* first, void* second);
172  // Creates a hash from a sequence of bytes.
173  static uint32_t Hash(Vector<const uint8_t> key, bool is_one_byte);
174  // Checks whether a string containing a JS number is its canonical
175  // form.
176  static bool IsNumberCanonical(Vector<const uint8_t> key);
177 
178  // Size of buffer. Sufficient for using it to call DoubleToCString in
179  // from conversions.h.
180  static const int kBufferSize = 100;
181 
183  // Backing store used to store strings used as hashmap keys.
186  // Buffer used for string->number->canonical string conversions.
188 };
189 
190 
191 // ----------------------------------------------------------------------------
192 // LiteralBuffer - Collector of chars of literals.
193 
195  public:
197 
199  if (backing_store_.length() > 0) {
201  }
202  }
203 
204  INLINE(void AddChar(uint32_t code_unit)) {
206  if (is_one_byte_) {
207  if (code_unit <= unibrow::Latin1::kMaxChar) {
208  backing_store_[position_] = static_cast<byte>(code_unit);
210  return;
211  }
213  }
214  DCHECK(code_unit < 0x10000u);
215  *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
216  position_ += kUC16Size;
217  }
218 
219  bool is_one_byte() const { return is_one_byte_; }
220 
222  return is_one_byte() && keyword.length() == position_ &&
223  (memcmp(keyword.start(), backing_store_.start(), position_) == 0);
224  }
225 
228  DCHECK((position_ & 0x1) == 0);
229  return Vector<const uint16_t>(
230  reinterpret_cast<const uint16_t*>(backing_store_.start()),
231  position_ >> 1);
232  }
233 
236  return Vector<const uint8_t>(
237  reinterpret_cast<const uint8_t*>(backing_store_.start()),
238  position_);
239  }
240 
241  int length() const {
242  return is_one_byte_ ? position_ : (position_ >> 1);
243  }
244 
245  void Reset() {
246  position_ = 0;
247  is_one_byte_ = true;
248  }
249 
250  Handle<String> Internalize(Isolate* isolate) const;
251 
252  private:
253  static const int kInitialCapacity = 16;
254  static const int kGrowthFactory = 4;
255  static const int kMinConversionSlack = 256;
256  static const int kMaxGrowth = 1 * MB;
257  inline int NewCapacity(int min_capacity) {
258  int capacity = Max(min_capacity, backing_store_.length());
259  int new_capacity = Min(capacity * kGrowthFactory, capacity + kMaxGrowth);
260  return new_capacity;
261  }
262 
263  void ExpandBuffer() {
265  MemCopy(new_store.start(), backing_store_.start(), position_);
267  backing_store_ = new_store;
268  }
269 
272  Vector<byte> new_store;
273  int new_content_size = position_ * kUC16Size;
274  if (new_content_size >= backing_store_.length()) {
275  // Ensure room for all currently read code units as UC16 as well
276  // as the code unit about to be stored.
277  new_store = Vector<byte>::New(NewCapacity(new_content_size));
278  } else {
279  new_store = backing_store_;
280  }
281  uint8_t* src = backing_store_.start();
282  uint16_t* dst = reinterpret_cast<uint16_t*>(new_store.start());
283  for (int i = position_ - 1; i >= 0; i--) {
284  dst[i] = src[i];
285  }
286  if (new_store.start() != backing_store_.start()) {
288  backing_store_ = new_store;
289  }
290  position_ = new_content_size;
291  is_one_byte_ = false;
292  }
293 
297 
299 };
300 
301 
302 // ----------------------------------------------------------------------------
303 // JavaScript Scanner.
304 
305 class Scanner {
306  public:
307  // Scoped helper for literal recording. Automatically drops the literal
308  // if aborting the scanning before it's complete.
309  class LiteralScope {
310  public:
311  explicit LiteralScope(Scanner* self)
312  : scanner_(self), complete_(false) {
314  }
316  if (!complete_) scanner_->DropLiteral();
317  }
318  void Complete() {
320  complete_ = true;
321  }
322 
323  private:
325  bool complete_;
326  };
327 
328  // Representation of an interval of source positions.
329  struct Location {
330  Location(int b, int e) : beg_pos(b), end_pos(e) { }
331  Location() : beg_pos(0), end_pos(0) { }
332 
333  bool IsValid() const {
334  return beg_pos >= 0 && end_pos >= beg_pos;
335  }
336 
337  static Location invalid() { return Location(-1, -1); }
338 
339  int beg_pos;
340  int end_pos;
341  };
342 
343  // -1 is outside of the range of any real source code.
344  static const int kNoOctalLocation = -1;
345 
346  explicit Scanner(UnicodeCache* scanner_contants);
347 
348  void Initialize(Utf16CharacterStream* source);
349 
350  // Returns the next token and advances input.
351  Token::Value Next();
352  // Returns the current token again.
354  // Returns the location information for the current token
355  // (the token last returned by Next()).
356  Location location() const { return current_.location; }
357 
358  // Similar functions for the upcoming token.
359 
360  // One token look-ahead (past the token returned by Next()).
361  Token::Value peek() const { return next_.token; }
362 
363  Location peek_location() const { return next_.location; }
364 
367  int source_length = (location.end_pos - location.beg_pos);
368  if (current_.token == Token::STRING) {
369  // Subtract delimiters.
370  source_length -= 2;
371  }
372  return current_.literal_chars->length() != source_length;
373  }
377  }
380  return next_.literal_chars->is_contextual_keyword(keyword);
381  }
382 
383  const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory);
384  const AstRawString* NextSymbol(AstValueFactory* ast_value_factory);
385 
386  double DoubleValue();
387  bool UnescapedLiteralMatches(const char* data, int length) {
388  if (is_literal_one_byte() &&
389  literal_length() == length &&
391  const char* token =
392  reinterpret_cast<const char*>(literal_one_byte_string().start());
393  return !strncmp(token, data, length);
394  }
395  return false;
396  }
397  void IsGetOrSet(bool* is_get, bool* is_set) {
398  if (is_literal_one_byte() &&
399  literal_length() == 3 &&
401  const char* token =
402  reinterpret_cast<const char*>(literal_one_byte_string().start());
403  *is_get = strncmp(token, "get", 3) == 0;
404  *is_set = !*is_get && strncmp(token, "set", 3) == 0;
405  }
406  }
407 
408  int FindNumber(DuplicateFinder* finder, int value);
409  int FindSymbol(DuplicateFinder* finder, int value);
410 
412 
413  // Returns the location of the last seen octal literal.
414  Location octal_position() const { return octal_pos_; }
416 
417  // Seek forward to the given position. This operation does not
418  // work in general, for instance when there are pushed back
419  // characters, but works for seeking forward until simple delimiter
420  // tokens, which is what it is used for.
421  void SeekForward(int pos);
422 
423  bool HarmonyScoping() const {
424  return harmony_scoping_;
425  }
426  void SetHarmonyScoping(bool scoping) {
427  harmony_scoping_ = scoping;
428  }
429  bool HarmonyModules() const {
430  return harmony_modules_;
431  }
432  void SetHarmonyModules(bool modules) {
433  harmony_modules_ = modules;
434  }
435  bool HarmonyNumericLiterals() const {
437  }
438  void SetHarmonyNumericLiterals(bool numeric_literals) {
439  harmony_numeric_literals_ = numeric_literals;
440  }
441  bool HarmonyClasses() const {
442  return harmony_classes_;
443  }
444  void SetHarmonyClasses(bool classes) {
445  harmony_classes_ = classes;
446  }
447 
448  // Returns true if there was a line terminator before the peek'ed token,
449  // possibly inside a multi-line comment.
453  }
454 
455  // Scans the input as a regular expression pattern, previous
456  // character(s) must be /(=). Returns true if a pattern is scanned.
457  bool ScanRegExpPattern(bool seen_equal);
458  // Returns true if regexp flags are scanned (always since flags can
459  // be empty).
460  bool ScanRegExpFlags();
461 
462  const LiteralBuffer* source_url() const { return &source_url_; }
464  return &source_mapping_url_;
465  }
466 
467  bool IdentifierIsFutureStrictReserved(const AstRawString* string) const;
468 
469  private:
470  // The current and look-ahead token.
471  struct TokenDesc {
475  };
476 
477  static const int kCharacterLookaheadBufferSize = 1;
478 
479  // Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
480  uc32 ScanOctalEscape(uc32 c, int length);
481 
482  // Call this after setting source_ to the input.
483  void Init() {
484  // Set c0_ (one character ahead)
486  Advance();
487  // Initialize current_ to not refer to a literal.
489  }
490 
491  // Literal buffer support
492  inline void StartLiteral() {
495  free_buffer->Reset();
496  next_.literal_chars = free_buffer;
497  }
498 
499  INLINE(void AddLiteralChar(uc32 c)) {
501  next_.literal_chars->AddChar(c);
502  }
503 
504  // Complete scanning of a literal.
505  inline void TerminateLiteral() {
506  // Does nothing in the current implementation.
507  }
508 
509  // Stops scanning of a literal and drop the collected characters,
510  // e.g., due to an encountered error.
511  inline void DropLiteral() {
513  }
514 
515  inline void AddLiteralCharAdvance() {
516  AddLiteralChar(c0_);
517  Advance();
518  }
519 
520  // Low-level scanning support.
521  void Advance() { c0_ = source_->Advance(); }
522  void PushBack(uc32 ch) {
523  source_->PushBack(c0_);
524  c0_ = ch;
525  }
526 
528  Advance();
529  return tok;
530  }
531 
532  inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_) {
533  Advance();
534  if (c0_ == next) {
535  Advance();
536  return then;
537  } else {
538  return else_;
539  }
540  }
541 
542  // Returns the literal string, if any, for the current token (the
543  // token last returned by Next()). The string is 0-terminated.
544  // Literal strings are collected for identifiers, strings, and
545  // numbers.
546  // These functions only give the correct result if the literal
547  // was scanned between calls to StartLiteral() and TerminateLiteral().
551  }
555  }
559  }
560  int literal_length() const {
562  return current_.literal_chars->length();
563  }
564  // Returns the literal string for the next token (the token that
565  // would be returned if Next() were called).
569  }
573  }
576  return next_.literal_chars->is_one_byte();
577  }
578  int next_literal_length() const {
580  return next_.literal_chars->length();
581  }
582 
583  uc32 ScanHexNumber(int expected_length);
584 
585  // Scans a single JavaScript token.
586  void Scan();
587 
588  bool SkipWhiteSpace();
593  // Scans a possible HTML comment -- begins with '<!'.
595 
596  void ScanDecimalDigits();
597  Token::Value ScanNumber(bool seen_period);
599  Token::Value ScanIdentifierSuffix(LiteralScope* literal);
600 
602 
603  // Scans an escape-sequence which is part of a string and adds the
604  // decoded character to the current literal. Returns true if a pattern
605  // is scanned.
606  bool ScanEscape();
607  // Decodes a Unicode escape-sequence which is part of an identifier.
608  // If the escape sequence cannot be decoded the result is kBadChar.
610  // Scans a Unicode escape-sequence and adds its characters,
611  // uninterpreted, to the current literal. Used for parsing RegExp
612  // flags.
614 
615  // Return the current source position.
616  int source_pos() {
618  }
619 
621 
622  // Buffers collecting literal strings, numbers, etc.
625 
626  // Values parsed from magic comments.
629 
630  TokenDesc current_; // desc for current token (as returned by Next())
631  TokenDesc next_; // desc for next token (one token look-ahead)
632 
633  // Input stream. Must be initialized to an Utf16CharacterStream.
635 
636 
637  // Start position of the octal literal last scanned.
639 
640  // One Unicode character look-ahead; c0_ < 0 at the end of the input.
642 
643  // Whether there is a line terminator whitespace character after
644  // the current token, and before the next. Does not count newlines
645  // inside multiline comments.
647  // Whether there is a multi-line comment that contains a
648  // line-terminator after the current token, and before the next.
650  // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
652  // Whether we scan 'module', 'import', 'export' as keywords.
654  // Whether we scan 0o777 and 0b111 as numbers.
656  // Whether we scan 'class', 'extends', 'static' and 'super' as keywords.
658 };
659 
660 } } // namespace v8::internal
661 
662 #endif // V8_SCANNER_H_
static const unsigned kMaxChar
Definition: unicode.h:118
bool get(uchar c)
Definition: unicode-inl.h:14
int AddNumber(Vector< const uint8_t > key, int value)
Definition: scanner.cc:1256
int AddTwoByteSymbol(Vector< const uint16_t > key, int value)
Definition: scanner.cc:1238
int AddOneByteSymbol(Vector< const uint8_t > key, int value)
Definition: scanner.cc:1233
static const int kBufferSize
Definition: scanner.h:180
int AddSymbol(Vector< const uint8_t > key, bool is_one_byte, int value)
Definition: scanner.cc:1243
static bool Match(void *first, void *second)
Definition: scanner.cc:1323
static uint32_t Hash(Vector< const uint8_t > key, bool is_one_byte)
Definition: scanner.cc:1309
uint8_t * BackupKey(Vector< const uint8_t > key, bool is_one_byte)
Definition: scanner.cc:1345
UnicodeCache * unicode_constants_
Definition: scanner.h:182
static bool IsNumberCanonical(Vector< const uint8_t > key)
Definition: scanner.cc:1281
DuplicateFinder(UnicodeCache *constants)
Definition: scanner.h:146
char number_buffer_[kBufferSize]
Definition: scanner.h:187
SequenceCollector< unsigned char > backing_store_
Definition: scanner.h:184
static const int kMaxGrowth
Definition: scanner.h:256
static const int kMinConversionSlack
Definition: scanner.h:255
static const int kGrowthFactory
Definition: scanner.h:254
INLINE(void AddChar(uint32_t code_unit))
Definition: scanner.h:204
Vector< const uint8_t > one_byte_literal() const
Definition: scanner.h:234
Vector< const uint16_t > two_byte_literal() const
Definition: scanner.h:226
static const int kInitialCapacity
Definition: scanner.h:253
Handle< String > Internalize(Isolate *isolate) const
Definition: scanner.cc:23
bool is_contextual_keyword(Vector< const char > keyword) const
Definition: scanner.h:221
bool is_one_byte() const
Definition: scanner.h:219
DISALLOW_COPY_AND_ASSIGN(LiteralBuffer)
int NewCapacity(int min_capacity)
Definition: scanner.h:257
Vector< byte > backing_store_
Definition: scanner.h:296
void SeekForward(int pos)
Definition: scanner.cc:660
Scanner(UnicodeCache *scanner_contants)
Definition: scanner.cc:34
Token::Value Next()
Definition: scanner.cc:219
Token::Value peek() const
Definition: scanner.h:361
int FindNumber(DuplicateFinder *finder, int value)
Definition: scanner.cc:1220
bool has_multiline_comment_before_next_
Definition: scanner.h:649
UnicodeCache * unicode_cache()
Definition: scanner.h:411
Utf16CharacterStream * source_
Definition: scanner.h:634
Vector< const uint16_t > next_literal_two_byte_string()
Definition: scanner.h:570
Vector< const uint8_t > literal_one_byte_string()
Definition: scanner.h:548
bool is_literal_one_byte()
Definition: scanner.h:556
void Initialize(Utf16CharacterStream *source)
Definition: scanner.cc:43
void SetHarmonyClasses(bool classes)
Definition: scanner.h:444
void SetHarmonyModules(bool modules)
Definition: scanner.h:432
UnicodeCache * unicode_cache_
Definition: scanner.h:620
bool HarmonyClasses() const
Definition: scanner.h:441
bool is_next_contextual_keyword(Vector< const char > keyword)
Definition: scanner.h:378
void SetHarmonyNumericLiterals(bool numeric_literals)
Definition: scanner.h:438
static const int kNoOctalLocation
Definition: scanner.h:344
bool HarmonyModules() const
Definition: scanner.h:429
Token::Value ScanString()
Definition: scanner.cc:757
int FindSymbol(DuplicateFinder *finder, int value)
Definition: scanner.cc:1225
bool literal_contains_escapes() const
Definition: scanner.h:365
bool is_next_literal_one_byte()
Definition: scanner.h:574
Token::Value ScanNumber(bool seen_period)
Definition: scanner.cc:786
void IsGetOrSet(bool *is_get, bool *is_set)
Definition: scanner.h:397
LiteralBuffer source_mapping_url_
Definition: scanner.h:628
Token::Value Select(uc32 next, Token::Value then, Token::Value else_)
Definition: scanner.h:532
Token::Value SkipMultiLineComment()
Definition: scanner.cc:370
bool UnescapedLiteralMatches(const char *data, int length)
Definition: scanner.h:387
void SetHarmonyScoping(bool scoping)
Definition: scanner.h:426
Location peek_location() const
Definition: scanner.h:363
bool has_line_terminator_before_next_
Definition: scanner.h:646
bool HarmonyNumericLiterals() const
Definition: scanner.h:435
Location octal_pos_
Definition: scanner.h:638
const LiteralBuffer * source_url() const
Definition: scanner.h:462
bool ScanRegExpPattern(bool seen_equal)
Definition: scanner.cc:1098
Token::Value current_token()
Definition: scanner.h:353
bool harmony_numeric_literals_
Definition: scanner.h:655
int literal_length() const
Definition: scanner.h:560
LiteralBuffer literal_buffer2_
Definition: scanner.h:624
bool ScanLiteralUnicodeEscape()
Definition: scanner.cc:1145
uc32 ScanOctalEscape(uc32 c, int length)
Definition: scanner.cc:734
const LiteralBuffer * source_mapping_url() const
Definition: scanner.h:463
Token::Value ScanIdentifierOrKeyword()
Definition: scanner.cc:1028
void ScanDecimalDigits()
Definition: scanner.cc:780
LiteralBuffer source_url_
Definition: scanner.h:627
Token::Value SkipSourceURLComment()
Definition: scanner.cc:308
uc32 ScanHexNumber(int expected_length)
Definition: scanner.cc:56
void PushBack(uc32 ch)
Definition: scanner.h:522
bool IdentifierIsFutureStrictReserved(const AstRawString *string) const
Definition: scanner.cc:1017
bool HarmonyScoping() const
Definition: scanner.h:423
void clear_octal_position()
Definition: scanner.h:415
LiteralBuffer literal_buffer1_
Definition: scanner.h:623
void AddLiteralCharAdvance()
Definition: scanner.h:515
static const int kCharacterLookaheadBufferSize
Definition: scanner.h:477
Token::Value SkipSingleLineComment()
Definition: scanner.cc:292
Vector< const uint8_t > next_literal_one_byte_string()
Definition: scanner.h:566
void TerminateLiteral()
Definition: scanner.h:505
const AstRawString * NextSymbol(AstValueFactory *ast_value_factory)
Definition: scanner.cc:1203
Vector< const uint16_t > literal_two_byte_string()
Definition: scanner.h:552
uc32 ScanIdentifierUnicodeEscape()
Definition: scanner.cc:892
INLINE(void AddLiteralChar(uc32 c))
Definition: scanner.h:499
Token::Value ScanIdentifierSuffix(LiteralScope *literal)
Definition: scanner.cc:1075
Location octal_position() const
Definition: scanner.h:414
bool is_literal_contextual_keyword(Vector< const char > keyword)
Definition: scanner.h:374
Token::Value ScanHtmlComment()
Definition: scanner.cc:396
bool HasAnyLineTerminatorBeforeNext() const
Definition: scanner.h:450
Token::Value Select(Token::Value tok)
Definition: scanner.h:527
void TryToParseSourceURLComment()
Definition: scanner.cc:318
int next_literal_length() const
Definition: scanner.h:578
TokenDesc current_
Definition: scanner.h:630
Location location() const
Definition: scanner.h:356
const AstRawString * CurrentSymbol(AstValueFactory *ast_value_factory)
Definition: scanner.cc:1195
unibrow::Predicate< IdentifierStart, 128 > kIsIdentifierStart
Definition: scanner.h:129
bool IsIdentifierPart(unibrow::uchar c)
Definition: scanner.h:121
unibrow::Utf8Decoder< 512 > Utf8Decoder
Definition: scanner.h:114
bool IsLineTerminator(unibrow::uchar c)
Definition: scanner.h:122
bool IsWhiteSpace(unibrow::uchar c)
Definition: scanner.h:123
bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c)
Definition: scanner.h:124
bool IsIdentifierStart(unibrow::uchar c)
Definition: scanner.h:120
StaticResource< Utf8Decoder > utf8_decoder_
Definition: scanner.h:135
StaticResource< Utf8Decoder > * utf8_decoder()
Definition: scanner.h:116
unibrow::Predicate< WhiteSpaceOrLineTerminator, 128 > kIsWhiteSpaceOrLineTerminator
Definition: scanner.h:134
unibrow::Predicate< unibrow::LineTerminator, 128 > kIsLineTerminator
Definition: scanner.h:131
unibrow::Predicate< WhiteSpace, 128 > kIsWhiteSpace
Definition: scanner.h:132
unibrow::Predicate< IdentifierPart, 128 > kIsIdentifierPart
Definition: scanner.h:130
DISALLOW_COPY_AND_ASSIGN(UnicodeCache)
virtual unsigned SlowSeekForward(unsigned code_unit_count)=0
virtual void PushBack(int32_t code_unit)=0
const uint16_t * buffer_end_
Definition: scanner.h:103
unsigned SeekForward(unsigned code_unit_count)
Definition: scanner.h:75
static const uc32 kEndOfInput
Definition: scanner.h:93
const uint16_t * buffer_cursor_
Definition: scanner.h:102
T * start() const
Definition: vector.h:47
int length() const
Definition: vector.h:41
static Vector< T > New(int length)
Definition: vector.h:27
enable harmony numeric enable harmony object literal extensions true
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS 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 enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_NOT_NULL(p)
Definition: logging.h:213
#define DCHECK(condition)
Definition: logging.h:205
unsigned short uint16_t
Definition: unicode.cc:23
unsigned int uchar
Definition: unicode.h:17
int int32_t
Definition: unicode.cc:24
const int kOneByteSize
Definition: globals.h:186
static LifetimePosition Min(LifetimePosition a, LifetimePosition b)
const int kUC16Size
Definition: globals.h:187
static LifetimePosition Max(LifetimePosition a, LifetimePosition b)
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
int HexValue(uc32 c)
Definition: scanner.h:31
const int MB
Definition: globals.h:107
int32_t uc32
Definition: globals.h:185
void MemCopy(void *dest, const void *src, size_t size)
Definition: utils.h:350
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
@ STRING
static Location invalid()
Definition: scanner.h:337
LiteralBuffer * literal_chars
Definition: scanner.h:474