v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scanner.h
Go to the documentation of this file.
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 // Features shared by parsing and pre-parsing scanners.
29 
30 #ifndef V8_SCANNER_H_
31 #define V8_SCANNER_H_
32 
33 #include "allocation.h"
34 #include "char-predicates.h"
35 #include "checks.h"
36 #include "globals.h"
37 #include "hashmap.h"
38 #include "list.h"
39 #include "token.h"
40 #include "unicode-inl.h"
41 #include "utils.h"
42 
43 namespace v8 {
44 namespace internal {
45 
46 
47 class ParserRecorder;
48 
49 
50 // Returns the value (0 .. 15) of a hexadecimal character c.
51 // If c is not a legal hexadecimal character, returns a value < 0.
52 inline int HexValue(uc32 c) {
53  c -= '0';
54  if (static_cast<unsigned>(c) <= 9) return c;
55  c = (c | 0x20) - ('a' - '0'); // detect 0x11..0x16 and 0x31..0x36.
56  if (static_cast<unsigned>(c) <= 5) return c + 10;
57  return -1;
58 }
59 
60 
61 // ---------------------------------------------------------------------
62 // Buffered stream of UTF-16 code units, using an internal UTF-16 buffer.
63 // A code unit is a 16 bit value representing either a 16 bit code point
64 // or one part of a surrogate pair that make a single 21 bit code point.
65 
67  public:
69  virtual ~Utf16CharacterStream() { }
70 
71  // Returns and advances past the next UTF-16 code unit in the input
72  // stream. If there are no more code units, it returns a negative
73  // value.
74  inline uc32 Advance() {
76  pos_++;
77  return static_cast<uc32>(*(buffer_cursor_++));
78  }
79  // Note: currently the following increment is necessary to avoid a
80  // parser problem! The scanner treats the final kEndOfInput as
81  // a code unit with a position, and does math relative to that
82  // position.
83  pos_++;
84 
85  return kEndOfInput;
86  }
87 
88  // Return the current position in the code unit stream.
89  // Starts at zero.
90  inline unsigned pos() const { return pos_; }
91 
92  // Skips forward past the next code_unit_count UTF-16 code units
93  // in the input, or until the end of input if that comes sooner.
94  // Returns the number of code units actually skipped. If less
95  // than code_unit_count,
96  inline unsigned SeekForward(unsigned code_unit_count) {
97  unsigned buffered_chars =
98  static_cast<unsigned>(buffer_end_ - buffer_cursor_);
99  if (code_unit_count <= buffered_chars) {
100  buffer_cursor_ += code_unit_count;
101  pos_ += code_unit_count;
102  return code_unit_count;
103  }
104  return SlowSeekForward(code_unit_count);
105  }
106 
107  // Pushes back the most recently read UTF-16 code unit (or negative
108  // value if at end of input), i.e., the value returned by the most recent
109  // call to Advance.
110  // Must not be used right after calling SeekForward.
111  virtual void PushBack(int32_t code_unit) = 0;
112 
113  protected:
114  static const uc32 kEndOfInput = -1;
115 
116  // Ensures that the buffer_cursor_ points to the code_unit at
117  // position pos_ of the input, if possible. If the position
118  // is at or after the end of the input, return false. If there
119  // are more code_units available, return true.
120  virtual bool ReadBlock() = 0;
121  virtual unsigned SlowSeekForward(unsigned code_unit_count) = 0;
122 
125  unsigned pos_;
126 };
127 
128 
129 // ---------------------------------------------------------------------
130 // Caching predicates used by scanners.
131 
133  public:
136 
138  return &utf8_decoder_;
139  }
140 
141  bool IsIdentifierStart(unibrow::uchar c) { return kIsIdentifierStart.get(c); }
142  bool IsIdentifierPart(unibrow::uchar c) { return kIsIdentifierPart.get(c); }
143  bool IsLineTerminator(unibrow::uchar c) { return kIsLineTerminator.get(c); }
144  bool IsWhiteSpace(unibrow::uchar c) { return kIsWhiteSpace.get(c); }
146  return kIsWhiteSpaceOrLineTerminator.get(c);
147  }
148 
149  private:
150  unibrow::Predicate<IdentifierStart, 128> kIsIdentifierStart;
151  unibrow::Predicate<IdentifierPart, 128> kIsIdentifierPart;
155  kIsWhiteSpaceOrLineTerminator;
156  StaticResource<Utf8Decoder> utf8_decoder_;
157 
158  DISALLOW_COPY_AND_ASSIGN(UnicodeCache);
159 };
160 
161 
162 // ---------------------------------------------------------------------
163 // DuplicateFinder discovers duplicate symbols.
164 
166  public:
167  explicit DuplicateFinder(UnicodeCache* constants)
168  : unicode_constants_(constants),
169  backing_store_(16),
170  map_(&Match) { }
171 
172  int AddOneByteSymbol(Vector<const uint8_t> key, int value);
173  int AddTwoByteSymbol(Vector<const uint16_t> key, int value);
174  // Add a a number literal by converting it (if necessary)
175  // to the string that ToString(ToNumber(literal)) would generate.
176  // and then adding that string with AddAsciiSymbol.
177  // This string is the actual value used as key in an object literal,
178  // and the one that must be different from the other keys.
179  int AddNumber(Vector<const uint8_t> key, int value);
180 
181  private:
182  int AddSymbol(Vector<const uint8_t> key, bool is_one_byte, int value);
183  // Backs up the key and its length in the backing store.
184  // The backup is stored with a base 127 encoding of the
185  // length (plus a bit saying whether the string is one byte),
186  // followed by the bytes of the key.
187  uint8_t* BackupKey(Vector<const uint8_t> key, bool is_one_byte);
188 
189  // Compare two encoded keys (both pointing into the backing store)
190  // for having the same base-127 encoded lengths and ASCII-ness,
191  // and then having the same 'length' bytes following.
192  static bool Match(void* first, void* second);
193  // Creates a hash from a sequence of bytes.
194  static uint32_t Hash(Vector<const uint8_t> key, bool is_one_byte);
195  // Checks whether a string containing a JS number is its canonical
196  // form.
197  static bool IsNumberCanonical(Vector<const uint8_t> key);
198 
199  // Size of buffer. Sufficient for using it to call DoubleToCString in
200  // from conversions.h.
201  static const int kBufferSize = 100;
202 
203  UnicodeCache* unicode_constants_;
204  // Backing store used to store strings used as hashmap keys.
205  SequenceCollector<unsigned char> backing_store_;
206  HashMap map_;
207  // Buffer used for string->number->canonical string conversions.
208  char number_buffer_[kBufferSize];
209 };
210 
211 
212 // ----------------------------------------------------------------------------
213 // LiteralBuffer - Collector of chars of literals.
214 
216  public:
217  LiteralBuffer() : is_one_byte_(true), position_(0), backing_store_() { }
218 
220  if (backing_store_.length() > 0) {
221  backing_store_.Dispose();
222  }
223  }
224 
225  INLINE(void AddChar(uint32_t code_unit)) {
226  if (position_ >= backing_store_.length()) ExpandBuffer();
227  if (is_one_byte_) {
228  if (code_unit <= unibrow::Latin1::kMaxChar) {
229  backing_store_[position_] = static_cast<byte>(code_unit);
230  position_ += kOneByteSize;
231  return;
232  }
233  ConvertToTwoByte();
234  }
235  ASSERT(code_unit < 0x10000u);
236  *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit;
237  position_ += kUC16Size;
238  }
239 
240  bool is_one_byte() { return is_one_byte_; }
241 
243  return is_one_byte() && keyword.length() == position_ &&
244  (memcmp(keyword.start(), backing_store_.start(), position_) == 0);
245  }
246 
248  ASSERT(!is_one_byte_);
249  ASSERT((position_ & 0x1) == 0);
250  return Vector<const uint16_t>(
251  reinterpret_cast<const uint16_t*>(backing_store_.start()),
252  position_ >> 1);
253  }
254 
256  ASSERT(is_one_byte_);
257  return Vector<const uint8_t>(
258  reinterpret_cast<const uint8_t*>(backing_store_.start()),
259  position_);
260  }
261 
262  int length() {
263  return is_one_byte_ ? position_ : (position_ >> 1);
264  }
265 
266  void Reset() {
267  position_ = 0;
268  is_one_byte_ = true;
269  }
270 
271  private:
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);
279  return new_capacity;
280  }
281 
282  void ExpandBuffer() {
283  Vector<byte> new_store = Vector<byte>::New(NewCapacity(kInitialCapacity));
284  OS::MemCopy(new_store.start(), backing_store_.start(), position_);
285  backing_store_.Dispose();
286  backing_store_ = new_store;
287  }
288 
289  void ConvertToTwoByte() {
290  ASSERT(is_one_byte_);
291  Vector<byte> new_store;
292  int new_content_size = position_ * kUC16Size;
293  if (new_content_size >= backing_store_.length()) {
294  // Ensure room for all currently read code units as UC16 as well
295  // as the code unit about to be stored.
296  new_store = Vector<byte>::New(NewCapacity(new_content_size));
297  } else {
298  new_store = backing_store_;
299  }
300  uint8_t* src = backing_store_.start();
301  uint16_t* dst = reinterpret_cast<uint16_t*>(new_store.start());
302  for (int i = position_ - 1; i >= 0; i--) {
303  dst[i] = src[i];
304  }
305  if (new_store.start() != backing_store_.start()) {
306  backing_store_.Dispose();
307  backing_store_ = new_store;
308  }
309  position_ = new_content_size;
310  is_one_byte_ = false;
311  }
312 
313  bool is_one_byte_;
314  int position_;
315  Vector<byte> backing_store_;
316 
317  DISALLOW_COPY_AND_ASSIGN(LiteralBuffer);
318 };
319 
320 
321 // ----------------------------------------------------------------------------
322 // JavaScript Scanner.
323 
324 class Scanner {
325  public:
326  // Scoped helper for literal recording. Automatically drops the literal
327  // if aborting the scanning before it's complete.
328  class LiteralScope {
329  public:
330  explicit LiteralScope(Scanner* self)
331  : scanner_(self), complete_(false) {
332  scanner_->StartLiteral();
333  }
335  if (!complete_) scanner_->DropLiteral();
336  }
337  void Complete() {
338  scanner_->TerminateLiteral();
339  complete_ = true;
340  }
341 
342  private:
343  Scanner* scanner_;
344  bool complete_;
345  };
346 
347  // Representation of an interval of source positions.
348  struct Location {
349  Location(int b, int e) : beg_pos(b), end_pos(e) { }
350  Location() : beg_pos(0), end_pos(0) { }
351 
352  bool IsValid() const {
353  return beg_pos >= 0 && end_pos >= beg_pos;
354  }
355 
356  static Location invalid() { return Location(-1, -1); }
357 
358  int beg_pos;
359  int end_pos;
360  };
361 
362  // -1 is outside of the range of any real source code.
363  static const int kNoOctalLocation = -1;
364 
365  explicit Scanner(UnicodeCache* scanner_contants);
366 
367  void Initialize(Utf16CharacterStream* source);
368 
369  // Returns the next token and advances input.
370  Token::Value Next();
371  // Returns the current token again.
372  Token::Value current_token() { return current_.token; }
373  // Returns the location information for the current token
374  // (the token last returned by Next()).
375  Location location() const { return current_.location; }
376 
377  // Similar functions for the upcoming token.
378 
379  // One token look-ahead (past the token returned by Next()).
380  Token::Value peek() const { return next_.token; }
381 
382  Location peek_location() const { return next_.location; }
383 
385  Location location = current_.location;
386  int source_length = (location.end_pos - location.beg_pos);
387  if (current_.token == Token::STRING) {
388  // Subtract delimiters.
389  source_length -= 2;
390  }
391  return current_.literal_chars->length() != source_length;
392  }
394  ASSERT_NOT_NULL(current_.literal_chars);
395  return current_.literal_chars->is_contextual_keyword(keyword);
396  }
398  ASSERT_NOT_NULL(next_.literal_chars);
399  return next_.literal_chars->is_contextual_keyword(keyword);
400  }
401 
403  PretenureFlag tenured);
405 
406  double DoubleValue();
407  bool UnescapedLiteralMatches(const char* data, int length) {
408  if (is_literal_one_byte() &&
409  literal_length() == length &&
411  const char* token =
412  reinterpret_cast<const char*>(literal_one_byte_string().start());
413  return !strncmp(token, data, length);
414  }
415  return false;
416  }
417  void IsGetOrSet(bool* is_get, bool* is_set) {
418  if (is_literal_one_byte() &&
419  literal_length() == 3 &&
421  const char* token =
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;
425  }
426  }
427 
428  int FindNumber(DuplicateFinder* finder, int value);
429  int FindSymbol(DuplicateFinder* finder, int value);
430 
431  void LogSymbol(ParserRecorder* log, int position);
432 
433  UnicodeCache* unicode_cache() { return unicode_cache_; }
434 
435  // Returns the location of the last seen octal literal.
436  Location octal_position() const { return octal_pos_; }
437  void clear_octal_position() { octal_pos_ = Location::invalid(); }
438 
439  // Seek forward to the given position. This operation does not
440  // work in general, for instance when there are pushed back
441  // characters, but works for seeking forward until simple delimiter
442  // tokens, which is what it is used for.
443  void SeekForward(int pos);
444 
445  bool HarmonyScoping() const {
446  return harmony_scoping_;
447  }
448  void SetHarmonyScoping(bool scoping) {
449  harmony_scoping_ = scoping;
450  }
451  bool HarmonyModules() const {
452  return harmony_modules_;
453  }
455  harmony_modules_ = modules;
456  }
457  bool HarmonyNumericLiterals() const {
458  return harmony_numeric_literals_;
459  }
460  void SetHarmonyNumericLiterals(bool numeric_literals) {
461  harmony_numeric_literals_ = numeric_literals;
462  }
463 
464  // Returns true if there was a line terminator before the peek'ed token,
465  // possibly inside a multi-line comment.
467  return has_line_terminator_before_next_ ||
468  has_multiline_comment_before_next_;
469  }
470 
471  // Scans the input as a regular expression pattern, previous
472  // character(s) must be /(=). Returns true if a pattern is scanned.
473  bool ScanRegExpPattern(bool seen_equal);
474  // Returns true if regexp flags are scanned (always since flags can
475  // be empty).
476  bool ScanRegExpFlags();
477 
478  private:
479  // The current and look-ahead token.
480  struct TokenDesc {
481  Token::Value token;
482  Location location;
483  LiteralBuffer* literal_chars;
484  };
485 
486  static const int kCharacterLookaheadBufferSize = 1;
487 
488  // Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
489  uc32 ScanOctalEscape(uc32 c, int length);
490 
491  // Call this after setting source_ to the input.
492  void Init() {
493  // Set c0_ (one character ahead)
494  STATIC_ASSERT(kCharacterLookaheadBufferSize == 1);
495  Advance();
496  // Initialize current_ to not refer to a literal.
497  current_.literal_chars = NULL;
498  }
499 
500  // Literal buffer support
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;
506  }
507 
508  INLINE(void AddLiteralChar(uc32 c)) {
509  ASSERT_NOT_NULL(next_.literal_chars);
510  next_.literal_chars->AddChar(c);
511  }
512 
513  // Complete scanning of a literal.
514  inline void TerminateLiteral() {
515  // Does nothing in the current implementation.
516  }
517 
518  // Stops scanning of a literal and drop the collected characters,
519  // e.g., due to an encountered error.
520  inline void DropLiteral() {
521  next_.literal_chars = NULL;
522  }
523 
524  inline void AddLiteralCharAdvance() {
525  AddLiteralChar(c0_);
526  Advance();
527  }
528 
529  // Low-level scanning support.
530  void Advance() { c0_ = source_->Advance(); }
531  void PushBack(uc32 ch) {
532  source_->PushBack(c0_);
533  c0_ = ch;
534  }
535 
536  inline Token::Value Select(Token::Value tok) {
537  Advance();
538  return tok;
539  }
540 
541  inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_) {
542  Advance();
543  if (c0_ == next) {
544  Advance();
545  return then;
546  } else {
547  return else_;
548  }
549  }
550 
551  // Returns the literal string, if any, for the current token (the
552  // token last returned by Next()). The string is 0-terminated.
553  // Literal strings are collected for identifiers, strings, and
554  // numbers.
555  // These functions only give the correct result if the literal
556  // was scanned between calls to StartLiteral() and TerminateLiteral().
557  Vector<const uint8_t> literal_one_byte_string() {
558  ASSERT_NOT_NULL(current_.literal_chars);
559  return current_.literal_chars->one_byte_literal();
560  }
561  Vector<const uint16_t> literal_two_byte_string() {
562  ASSERT_NOT_NULL(current_.literal_chars);
563  return current_.literal_chars->two_byte_literal();
564  }
565  bool is_literal_one_byte() {
566  ASSERT_NOT_NULL(current_.literal_chars);
567  return current_.literal_chars->is_one_byte();
568  }
569  int literal_length() const {
570  ASSERT_NOT_NULL(current_.literal_chars);
571  return current_.literal_chars->length();
572  }
573  // Returns the literal string for the next token (the token that
574  // would be returned if Next() were called).
575  Vector<const uint8_t> next_literal_one_byte_string() {
576  ASSERT_NOT_NULL(next_.literal_chars);
577  return next_.literal_chars->one_byte_literal();
578  }
579  Vector<const uint16_t> next_literal_two_byte_string() {
580  ASSERT_NOT_NULL(next_.literal_chars);
581  return next_.literal_chars->two_byte_literal();
582  }
583  bool is_next_literal_one_byte() {
584  ASSERT_NOT_NULL(next_.literal_chars);
585  return next_.literal_chars->is_one_byte();
586  }
587  int next_literal_length() const {
588  ASSERT_NOT_NULL(next_.literal_chars);
589  return next_.literal_chars->length();
590  }
591 
592  uc32 ScanHexNumber(int expected_length);
593 
594  // Scans a single JavaScript token.
595  void Scan();
596 
597  bool SkipWhiteSpace();
598  Token::Value SkipSingleLineComment();
599  Token::Value SkipMultiLineComment();
600  // Scans a possible HTML comment -- begins with '<!'.
601  Token::Value ScanHtmlComment();
602 
603  void ScanDecimalDigits();
604  Token::Value ScanNumber(bool seen_period);
605  Token::Value ScanIdentifierOrKeyword();
606  Token::Value ScanIdentifierSuffix(LiteralScope* literal);
607 
608  Token::Value ScanString();
609 
610  // Scans an escape-sequence which is part of a string and adds the
611  // decoded character to the current literal. Returns true if a pattern
612  // is scanned.
613  bool ScanEscape();
614  // Decodes a Unicode escape-sequence which is part of an identifier.
615  // If the escape sequence cannot be decoded the result is kBadChar.
616  uc32 ScanIdentifierUnicodeEscape();
617  // Scans a Unicode escape-sequence and adds its characters,
618  // uninterpreted, to the current literal. Used for parsing RegExp
619  // flags.
620  bool ScanLiteralUnicodeEscape();
621 
622  // Return the current source position.
623  int source_pos() {
624  return source_->pos() - kCharacterLookaheadBufferSize;
625  }
626 
627  UnicodeCache* unicode_cache_;
628 
629  // Buffers collecting literal strings, numbers, etc.
630  LiteralBuffer literal_buffer1_;
631  LiteralBuffer literal_buffer2_;
632 
633  TokenDesc current_; // desc for current token (as returned by Next())
634  TokenDesc next_; // desc for next token (one token look-ahead)
635 
636  // Input stream. Must be initialized to an Utf16CharacterStream.
637  Utf16CharacterStream* source_;
638 
639 
640  // Start position of the octal literal last scanned.
641  Location octal_pos_;
642 
643  // One Unicode character look-ahead; c0_ < 0 at the end of the input.
644  uc32 c0_;
645 
646  // Whether there is a line terminator whitespace character after
647  // the current token, and before the next. Does not count newlines
648  // inside multiline comments.
649  bool has_line_terminator_before_next_;
650  // Whether there is a multi-line comment that contains a
651  // line-terminator after the current token, and before the next.
652  bool has_multiline_comment_before_next_;
653  // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
654  bool harmony_scoping_;
655  // Whether we scan 'module', 'import', 'export' as keywords.
656  bool harmony_modules_;
657  // Whether we scan 0o777 and 0b111 as numbers.
658  bool harmony_numeric_literals_;
659 };
660 
661 } } // namespace v8::internal
662 
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
Definition: flags.cc:269
bool HarmonyModules() const
Definition: scanner.h:451
bool get(uchar c)
Definition: unicode-inl.h:37
const uint16_t * buffer_cursor_
Definition: scanner.h:123
bool IsIdentifierPart(unibrow::uchar c)
Definition: scanner.h:142
static const unsigned kMaxChar
Definition: unicode.h:141
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
Definition: flags.cc:208
Vector< const uint8_t > one_byte_literal()
Definition: scanner.h:255
static const uc32 kEndOfInput
Definition: scanner.h:114
#define ASSERT_NOT_NULL(p)
Definition: checks.h:343
int FindSymbol(DuplicateFinder *finder, int value)
Definition: scanner.cc:1155
T Max(T a, T b)
Definition: utils.h:227
void SetHarmonyScoping(bool scoping)
Definition: scanner.h:448
int32_t uc32
Definition: globals.h:310
int AddOneByteSymbol(Vector< const uint8_t > key, int value)
Definition: scanner.cc:1172
int int32_t
Definition: unicode.cc:47
const uint16_t * buffer_end_
Definition: scanner.h:124
bool IsWhiteSpace(unibrow::uchar c)
Definition: scanner.h:144
Scanner(UnicodeCache *scanner_contants)
Definition: scanner.cc:47
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
Definition: flags.cc:806
#define ASSERT(condition)
Definition: checks.h:329
unsigned short uint16_t
Definition: unicode.cc:46
bool is_contextual_keyword(Vector< const char > keyword)
Definition: scanner.h:242
Vector< const uint16_t > two_byte_literal()
Definition: scanner.h:247
void SetHarmonyModules(bool modules)
Definition: scanner.h:454
bool HasAnyLineTerminatorBeforeNext() const
Definition: scanner.h:466
bool HarmonyScoping() const
Definition: scanner.h:445
bool UnescapedLiteralMatches(const char *data, int length)
Definition: scanner.h:407
uint8_t byte
Definition: globals.h:185
T * start() const
Definition: utils.h:426
bool literal_contains_escapes() const
Definition: scanner.h:384
int AddTwoByteSymbol(Vector< const uint16_t > key, int value)
Definition: scanner.cc:1177
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static void MemCopy(void *dest, const void *src, size_t size)
Definition: platform.h:399
DuplicateFinder(UnicodeCache *constants)
Definition: scanner.h:167
void SeekForward(int pos)
Definition: scanner.cc:601
int AddNumber(Vector< const uint8_t > key, int value)
Definition: scanner.cc:1195
int HexValue(uc32 c)
Definition: scanner.h:52
void IsGetOrSet(bool *is_get, bool *is_set)
Definition: scanner.h:417
int length() const
Definition: utils.h:420
virtual void PushBack(int32_t code_unit)=0
static Vector< T > New(int length)
Definition: utils.h:406
void Initialize(Utf16CharacterStream *source)
Definition: scanner.cc:55
bool IsLineTerminator(unibrow::uchar c)
Definition: scanner.h:143
int FindNumber(DuplicateFinder *finder, int value)
Definition: scanner.cc:1150
static Location invalid()
Definition: scanner.h:356
Location location() const
Definition: scanner.h:375
static const int kNoOctalLocation
Definition: scanner.h:363
bool IsWhiteSpaceOrLineTerminator(unibrow::uchar c)
Definition: scanner.h:145
void clear_octal_position()
Definition: scanner.h:437
void LogSymbol(ParserRecorder *log, int position)
Definition: scanner.cc:1163
bool is_next_contextual_keyword(Vector< const char > keyword)
Definition: scanner.h:397
enforce strict mode enable harmony semantics for typeof enable harmony modules(implies block scoping)") DEFINE_bool(harmony_symbols
void SetHarmonyNumericLiterals(bool numeric_literals)
Definition: scanner.h:460
Token::Value peek() const
Definition: scanner.h:380
Handle< String > AllocateNextLiteralString(Isolate *isolate, PretenureFlag tenured)
Definition: scanner.cc:1119
Location octal_position() const
Definition: scanner.h:436
INLINE(void AddChar(uint32_t code_unit))
Definition: scanner.h:225
StaticResource< Utf8Decoder > * utf8_decoder()
Definition: scanner.h:137
Token::Value current_token()
Definition: scanner.h:372
bool is_literal_contextual_keyword(Vector< const char > keyword)
Definition: scanner.h:393
const int kOneByteSize
Definition: globals.h:311
Token::Value Next()
Definition: scanner.cc:231
bool HarmonyNumericLiterals() const
Definition: scanner.h:457
T Min(T a, T b)
Definition: utils.h:234
unibrow::Utf8Decoder< 512 > Utf8Decoder
Definition: scanner.h:135
bool IsIdentifierStart(unibrow::uchar c)
Definition: scanner.h:141
unsigned SeekForward(unsigned code_unit_count)
Definition: scanner.h:96
bool ScanRegExpPattern(bool seen_equal)
Definition: scanner.cc:1022
Handle< String > AllocateInternalizedString(Isolate *isolate)
Definition: scanner.cc:1131
UnicodeCache * unicode_cache()
Definition: scanner.h:433
unsigned int uchar
Definition: unicode.h:40
Location peek_location() const
Definition: scanner.h:382
const int kUC16Size
Definition: globals.h:312
const int MB
Definition: globals.h:246