OLD | NEW |
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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 ZoneList<Expression*>* ParseArguments(bool* ok); | 539 ZoneList<Expression*>* ParseArguments(bool* ok); |
540 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, | 540 FunctionLiteral* ParseFunctionLiteral(Handle<String> var_name, |
541 int function_token_position, | 541 int function_token_position, |
542 FunctionLiteralType type, | 542 FunctionLiteralType type, |
543 bool* ok); | 543 bool* ok); |
544 | 544 |
545 | 545 |
546 // Magical syntax support. | 546 // Magical syntax support. |
547 Expression* ParseV8Intrinsic(bool* ok); | 547 Expression* ParseV8Intrinsic(bool* ok); |
548 | 548 |
549 INLINE(Token::Value peek()) { return scanner_.peek(); } | 549 INLINE(Token::Value peek()) { |
550 INLINE(Token::Value Next()) { return scanner_.NextCheckStack(); } | 550 if (stack_overflow_) return Token::ILLEGAL; |
| 551 return scanner_.peek(); |
| 552 } |
| 553 |
| 554 INLINE(Token::Value Next()) { |
| 555 // 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 |
| 557 // threads. |
| 558 if (stack_overflow_) { |
| 559 return Token::ILLEGAL; |
| 560 } |
| 561 if (StackLimitCheck().HasOverflowed()) { |
| 562 // Any further calls to Next or peek will return the illegal token. |
| 563 stack_overflow_ = true; |
| 564 } |
| 565 return scanner_.Next(); |
| 566 } |
| 567 |
551 INLINE(void Consume(Token::Value token)); | 568 INLINE(void Consume(Token::Value token)); |
552 void Expect(Token::Value token, bool* ok); | 569 void Expect(Token::Value token, bool* ok); |
553 bool Check(Token::Value token); | 570 bool Check(Token::Value token); |
554 void ExpectSemicolon(bool* ok); | 571 void ExpectSemicolon(bool* ok); |
555 | 572 |
556 Handle<String> GetSymbol(bool* ok); | 573 Handle<String> GetSymbol(bool* ok); |
557 | 574 |
558 // Get odd-ball literals. | 575 // Get odd-ball literals. |
559 Literal* GetLiteralUndefined(); | 576 Literal* GetLiteralUndefined(); |
560 Literal* GetLiteralTheHole(); | 577 Literal* GetLiteralTheHole(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 649 |
633 TemporaryScope* temp_scope_; | 650 TemporaryScope* temp_scope_; |
634 Mode mode_; | 651 Mode mode_; |
635 | 652 |
636 Target* target_stack_; // for break, continue statements | 653 Target* target_stack_; // for break, continue statements |
637 bool allow_natives_syntax_; | 654 bool allow_natives_syntax_; |
638 v8::Extension* extension_; | 655 v8::Extension* extension_; |
639 bool is_pre_parsing_; | 656 bool is_pre_parsing_; |
640 ScriptDataImpl* pre_data_; | 657 ScriptDataImpl* pre_data_; |
641 FuncNameInferrer* fni_; | 658 FuncNameInferrer* fni_; |
| 659 bool stack_overflow_; |
642 }; | 660 }; |
643 | 661 |
644 | 662 |
645 // Support for handling complex values (array and object literals) that | 663 // Support for handling complex values (array and object literals) that |
646 // can be fully handled at compile time. | 664 // can be fully handled at compile time. |
647 class CompileTimeValue: public AllStatic { | 665 class CompileTimeValue: public AllStatic { |
648 public: | 666 public: |
649 enum Type { | 667 enum Type { |
650 OBJECT_LITERAL_FAST_ELEMENTS, | 668 OBJECT_LITERAL_FAST_ELEMENTS, |
651 OBJECT_LITERAL_SLOW_ELEMENTS, | 669 OBJECT_LITERAL_SLOW_ELEMENTS, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 // it allow a terminal comma, like a JavaScript array does. | 729 // it allow a terminal comma, like a JavaScript array does. |
712 Handle<Object> ParseJsonArray(); | 730 Handle<Object> ParseJsonArray(); |
713 | 731 |
714 // Mark that a parsing error has happened at the current token, and | 732 // Mark that a parsing error has happened at the current token, and |
715 // return a null handle. Primarily for readability. | 733 // return a null handle. Primarily for readability. |
716 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); } | 734 Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); } |
717 // Converts the currently parsed literal to a JavaScript String. | 735 // Converts the currently parsed literal to a JavaScript String. |
718 Handle<String> GetString(); | 736 Handle<String> GetString(); |
719 | 737 |
720 JsonScanner scanner_; | 738 JsonScanner scanner_; |
| 739 bool stack_overflow_; |
721 }; | 740 }; |
722 } } // namespace v8::internal | 741 } } // namespace v8::internal |
723 | 742 |
724 #endif // V8_PARSER_H_ | 743 #endif // V8_PARSER_H_ |
OLD | NEW |