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

Side by Side Diff: src/parser.h

Issue 6542061: [Isolates] Less TLS reads in parser and full codegens. (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // Linked list implementation of stack of states. 384 // Linked list implementation of stack of states.
385 RegExpParserState* previous_state_; 385 RegExpParserState* previous_state_;
386 // Builder for the stored disjunction. 386 // Builder for the stored disjunction.
387 RegExpBuilder* builder_; 387 RegExpBuilder* builder_;
388 // Stored disjunction type (capture, look-ahead or grouping), if any. 388 // Stored disjunction type (capture, look-ahead or grouping), if any.
389 SubexpressionType group_type_; 389 SubexpressionType group_type_;
390 // Stored disjunction's capture index (if any). 390 // Stored disjunction's capture index (if any).
391 int disjunction_capture_index_; 391 int disjunction_capture_index_;
392 }; 392 };
393 393
394 Isolate* isolate() { return isolate_; }
395
394 uc32 current() { return current_; } 396 uc32 current() { return current_; }
395 bool has_more() { return has_more_; } 397 bool has_more() { return has_more_; }
396 bool has_next() { return next_pos_ < in()->length(); } 398 bool has_next() { return next_pos_ < in()->length(); }
397 uc32 Next(); 399 uc32 Next();
398 FlatStringReader* in() { return in_; } 400 FlatStringReader* in() { return in_; }
399 void ScanForCaptures(); 401 void ScanForCaptures();
400 402
403 Isolate* isolate_;
401 Handle<String>* error_; 404 Handle<String>* error_;
402 ZoneList<RegExpCapture*>* captures_; 405 ZoneList<RegExpCapture*>* captures_;
403 FlatStringReader* in_; 406 FlatStringReader* in_;
404 uc32 current_; 407 uc32 current_;
405 int next_pos_; 408 int next_pos_;
406 // The capture count is only valid after we have scanned for captures. 409 // The capture count is only valid after we have scanned for captures.
407 int capture_count_; 410 int capture_count_;
408 bool has_more_; 411 bool has_more_;
409 bool multiline_; 412 bool multiline_;
410 bool simple_; 413 bool simple_;
(...skipping 22 matching lines...) Expand all
433 void ReportMessageAt(Scanner::Location loc, 436 void ReportMessageAt(Scanner::Location loc,
434 const char* message, 437 const char* message,
435 Vector<const char*> args); 438 Vector<const char*> args);
436 439
437 protected: 440 protected:
438 enum Mode { 441 enum Mode {
439 PARSE_LAZILY, 442 PARSE_LAZILY,
440 PARSE_EAGERLY 443 PARSE_EAGERLY
441 }; 444 };
442 445
446 Isolate* isolate() { return isolate_; }
447
443 // Report syntax error 448 // Report syntax error
444 void ReportUnexpectedToken(Token::Value token); 449 void ReportUnexpectedToken(Token::Value token);
445 void ReportInvalidPreparseData(Handle<String> name, bool* ok); 450 void ReportInvalidPreparseData(Handle<String> name, bool* ok);
446 void ReportMessage(const char* message, Vector<const char*> args); 451 void ReportMessage(const char* message, Vector<const char*> args);
447 452
448 bool inside_with() const { return with_nesting_level_ > 0; } 453 bool inside_with() const { return with_nesting_level_ > 0; }
449 Scanner& scanner() { return scanner_; } 454 Scanner& scanner() { return scanner_; }
450 Mode mode() const { return mode_; } 455 Mode mode() const { return mode_; }
451 ScriptDataImpl* pre_data() const { return pre_data_; } 456 ScriptDataImpl* pre_data() const { return pre_data_; }
452 457
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 return scanner_.peek(); 556 return scanner_.peek();
552 } 557 }
553 558
554 INLINE(Token::Value Next()) { 559 INLINE(Token::Value Next()) {
555 // BUG 1215673: Find a thread safe way to set a stack limit in 560 // BUG 1215673: Find a thread safe way to set a stack limit in
556 // pre-parse mode. Otherwise, we cannot safely pre-parse from other 561 // pre-parse mode. Otherwise, we cannot safely pre-parse from other
557 // threads. 562 // threads.
558 if (stack_overflow_) { 563 if (stack_overflow_) {
559 return Token::ILLEGAL; 564 return Token::ILLEGAL;
560 } 565 }
561 if (StackLimitCheck(isolate_).HasOverflowed()) { 566 if (StackLimitCheck(isolate()).HasOverflowed()) {
562 // Any further calls to Next or peek will return the illegal token. 567 // Any further calls to Next or peek will return the illegal token.
563 stack_overflow_ = true; 568 stack_overflow_ = true;
564 } 569 }
565 return scanner_.Next(); 570 return scanner_.Next();
566 } 571 }
567 572
568 INLINE(void Consume(Token::Value token)); 573 INLINE(void Consume(Token::Value token));
569 void Expect(Token::Value token, bool* ok); 574 void Expect(Token::Value token, bool* ok);
570 bool Check(Token::Value token); 575 bool Check(Token::Value token);
571 void ExpectSemicolon(bool* ok); 576 void ExpectSemicolon(bool* ok);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // The grammar is given section 15.12.1.2 (and appendix A.8.2). 705 // The grammar is given section 15.12.1.2 (and appendix A.8.2).
701 class JsonParser BASE_EMBEDDED { 706 class JsonParser BASE_EMBEDDED {
702 public: 707 public:
703 // Parse JSON input as a single JSON value. 708 // Parse JSON input as a single JSON value.
704 // Returns null handle and sets exception if parsing failed. 709 // Returns null handle and sets exception if parsing failed.
705 static Handle<Object> Parse(Handle<String> source) { 710 static Handle<Object> Parse(Handle<String> source) {
706 return JsonParser().ParseJson(source); 711 return JsonParser().ParseJson(source);
707 } 712 }
708 713
709 private: 714 private:
710 JsonParser() { } 715 JsonParser() : isolate_(Isolate::Current()) { }
711 ~JsonParser() { } 716 ~JsonParser() { }
712 717
718 Isolate* isolate() { return isolate_; }
719
713 // Parse a string containing a single JSON value. 720 // Parse a string containing a single JSON value.
714 Handle<Object> ParseJson(Handle<String>); 721 Handle<Object> ParseJson(Handle<String>);
715 // Parse a single JSON value from input (grammar production JSONValue). 722 // Parse a single JSON value from input (grammar production JSONValue).
716 // A JSON value is either a (double-quoted) string literal, a number literal, 723 // A JSON value is either a (double-quoted) string literal, a number literal,
717 // one of "true", "false", or "null", or an object or array literal. 724 // one of "true", "false", or "null", or an object or array literal.
718 Handle<Object> ParseJsonValue(); 725 Handle<Object> ParseJsonValue();
719 // Parse a JSON object literal (grammar production JSONObject). 726 // Parse a JSON object literal (grammar production JSONObject).
720 // An object literal is a squiggly-braced and comma separated sequence 727 // An object literal is a squiggly-braced and comma separated sequence
721 // (possibly empty) of key/value pairs, where the key is a JSON string 728 // (possibly empty) of key/value pairs, where the key is a JSON string
722 // literal, the value is a JSON value, and the two are separated by a colon. 729 // literal, the value is a JSON value, and the two are separated by a colon.
723 // A JSON array dosn't allow numbers and identifiers as keys, like a 730 // A JSON array dosn't allow numbers and identifiers as keys, like a
724 // JavaScript array. 731 // JavaScript array.
725 Handle<Object> ParseJsonObject(); 732 Handle<Object> ParseJsonObject();
726 // Parses a JSON array literal (grammar production JSONArray). An array 733 // Parses a JSON array literal (grammar production JSONArray). An array
727 // literal is a square-bracketed and comma separated sequence (possibly empty) 734 // literal is a square-bracketed and comma separated sequence (possibly empty)
728 // of JSON values. 735 // of JSON values.
729 // A JSON array doesn't allow leaving out values from the sequence, nor does 736 // A JSON array doesn't allow leaving out values from the sequence, nor does
730 // it allow a terminal comma, like a JavaScript array does. 737 // it allow a terminal comma, like a JavaScript array does.
731 Handle<Object> ParseJsonArray(); 738 Handle<Object> ParseJsonArray();
732 739
733 // Mark that a parsing error has happened at the current token, and 740 // Mark that a parsing error has happened at the current token, and
734 // return a null handle. Primarily for readability. 741 // return a null handle. Primarily for readability.
735 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); } 742 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); }
736 // Converts the currently parsed literal to a JavaScript String. 743 // Converts the currently parsed literal to a JavaScript String.
737 Handle<String> GetString(); 744 Handle<String> GetString();
738 745
746 Isolate* isolate_;
739 JsonScanner scanner_; 747 JsonScanner scanner_;
740 bool stack_overflow_; 748 bool stack_overflow_;
741 }; 749 };
742 } } // namespace v8::internal 750 } } // namespace v8::internal
743 751
744 #endif // V8_PARSER_H_ 752 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698