OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 1803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 } | 1814 } |
1815 | 1815 |
1816 // Parses a single function literal, from the opening parentheses before | 1816 // Parses a single function literal, from the opening parentheses before |
1817 // parameters to the closing brace after the body. | 1817 // parameters to the closing brace after the body. |
1818 // Returns a FunctionEntry describing the body of the function in enough | 1818 // Returns a FunctionEntry describing the body of the function in enough |
1819 // detail that it can be lazily compiled. | 1819 // detail that it can be lazily compiled. |
1820 // The scanner is expected to have matched the "function" or "function*" | 1820 // The scanner is expected to have matched the "function" or "function*" |
1821 // keyword and parameters, and have consumed the initial '{'. | 1821 // keyword and parameters, and have consumed the initial '{'. |
1822 // At return, unless an error occurred, the scanner is positioned before the | 1822 // At return, unless an error occurred, the scanner is positioned before the |
1823 // the final '}'. | 1823 // the final '}'. |
1824 PreParseResult PreParseLazyFunction(LanguageMode language_mode, | 1824 PreParseResult PreParseLazyFunction( |
1825 FunctionKind kind, ParserRecorder* log); | 1825 LanguageMode language_mode, FunctionKind kind, ParserRecorder* log, |
| 1826 Scanner::BookmarkScope* bookmark = nullptr); |
1826 | 1827 |
1827 private: | 1828 private: |
1828 friend class PreParserTraits; | 1829 friend class PreParserTraits; |
1829 | 1830 |
| 1831 static const int kLazyParseTrialLimit = 200; |
| 1832 |
1830 // These types form an algebra over syntactic categories that is just | 1833 // These types form an algebra over syntactic categories that is just |
1831 // rich enough to let us recognize and propagate the constructs that | 1834 // rich enough to let us recognize and propagate the constructs that |
1832 // are either being counted in the preparser data, or is important | 1835 // are either being counted in the preparser data, or is important |
1833 // to throw the correct syntax error exceptions. | 1836 // to throw the correct syntax error exceptions. |
1834 | 1837 |
1835 // All ParseXXX functions take as the last argument an *ok parameter | 1838 // All ParseXXX functions take as the last argument an *ok parameter |
1836 // which is set to false if parsing failed; it is unchanged otherwise. | 1839 // which is set to false if parsing failed; it is unchanged otherwise. |
1837 // By making the 'exception handling' explicit, we are forced to check | 1840 // By making the 'exception handling' explicit, we are forced to check |
1838 // for failure at the call sites. | 1841 // for failure at the call sites. |
1839 Statement ParseStatementListItem(bool* ok); | 1842 Statement ParseStatementListItem(bool* ok); |
1840 void ParseStatementList(int end_token, bool* ok); | 1843 void ParseStatementList(int end_token, bool* ok, |
| 1844 Scanner::BookmarkScope* bookmark = nullptr); |
1841 Statement ParseStatement(bool* ok); | 1845 Statement ParseStatement(bool* ok); |
1842 Statement ParseSubStatement(bool* ok); | 1846 Statement ParseSubStatement(bool* ok); |
1843 Statement ParseFunctionDeclaration(bool* ok); | 1847 Statement ParseFunctionDeclaration(bool* ok); |
1844 Statement ParseClassDeclaration(bool* ok); | 1848 Statement ParseClassDeclaration(bool* ok); |
1845 Statement ParseBlock(bool* ok); | 1849 Statement ParseBlock(bool* ok); |
1846 Statement ParseVariableStatement(VariableDeclarationContext var_context, | 1850 Statement ParseVariableStatement(VariableDeclarationContext var_context, |
1847 bool* ok); | 1851 bool* ok); |
1848 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, | 1852 Statement ParseVariableDeclarations(VariableDeclarationContext var_context, |
1849 int* num_decl, | 1853 int* num_decl, |
1850 Scanner::Location* first_initializer_loc, | 1854 Scanner::Location* first_initializer_loc, |
(...skipping 21 matching lines...) Expand all Loading... |
1872 V8_INLINE PreParserStatementList | 1876 V8_INLINE PreParserStatementList |
1873 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1877 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, |
1874 Variable* fvar, Token::Value fvar_init_op, | 1878 Variable* fvar, Token::Value fvar_init_op, |
1875 FunctionKind kind, bool* ok); | 1879 FunctionKind kind, bool* ok); |
1876 | 1880 |
1877 Expression ParseFunctionLiteral( | 1881 Expression ParseFunctionLiteral( |
1878 Identifier name, Scanner::Location function_name_location, | 1882 Identifier name, Scanner::Location function_name_location, |
1879 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1883 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
1880 FunctionLiteral::FunctionType function_type, | 1884 FunctionLiteral::FunctionType function_type, |
1881 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1885 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
1882 void ParseLazyFunctionLiteralBody(bool* ok); | 1886 void ParseLazyFunctionLiteralBody(bool* ok, |
| 1887 Scanner::BookmarkScope* bookmark = nullptr); |
1883 | 1888 |
1884 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1889 PreParserExpression ParseClassLiteral(PreParserIdentifier name, |
1885 Scanner::Location class_name_location, | 1890 Scanner::Location class_name_location, |
1886 bool name_is_strict_reserved, int pos, | 1891 bool name_is_strict_reserved, int pos, |
1887 bool* ok); | 1892 bool* ok); |
1888 }; | 1893 }; |
1889 | 1894 |
1890 | 1895 |
1891 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1896 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
1892 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1897 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 *ok = false; | 3845 *ok = false; |
3841 return; | 3846 return; |
3842 } | 3847 } |
3843 has_seen_constructor_ = true; | 3848 has_seen_constructor_ = true; |
3844 return; | 3849 return; |
3845 } | 3850 } |
3846 } | 3851 } |
3847 } } // v8::internal | 3852 } } // v8::internal |
3848 | 3853 |
3849 #endif // V8_PREPARSER_H | 3854 #endif // V8_PREPARSER_H |
OLD | NEW |