30 #include "../include/v8stdint.h"
45 #if V8_LIBC_MSVCRT && (_MSC_VER < 1800)
73 bool is_reference_error) {
85 bool is_reference_error) {
95 bool is_reference_error) {
101 pre_parser_->LogSymbol();
102 if (scanner->
current_token() == Token::FUTURE_RESERVED_WORD) {
105 Token::FUTURE_STRICT_RESERVED_WORD) {
122 pre_parser_->LogSymbol();
131 return pre_parser_->ParseV8Intrinsic(ok);
138 bool name_is_strict_reserved,
140 int function_token_position,
141 FunctionLiteral::FunctionType type,
143 return pre_parser_->ParseFunctionLiteral(
144 name, function_name_location, name_is_strict_reserved, is_generator,
145 function_token_position, type, ok);
155 scope_->SetStrictMode(strict_mode);
158 function_state.set_is_generator(is_generator);
162 ParseLazyFunctionLiteralBody(&ok);
191 #define CHECK_OK ok); \
192 if (!*ok) return kUnknownSourceElements; \
194 #define DUMMY ) // to make indentation work
198 PreParser::Statement PreParser::ParseSourceElement(
bool* ok) {
211 case Token::FUNCTION:
212 return ParseFunctionDeclaration(ok);
215 return ParseVariableStatement(kSourceElement, ok);
217 return ParseStatement(ok);
222 PreParser::SourceElements PreParser::ParseSourceElements(
int end_token,
227 bool directive_prologue =
true;
228 while (peek() != end_token) {
230 directive_prologue =
false;
232 Statement statement = ParseSourceElement(
CHECK_OK);
233 if (directive_prologue) {
234 if (statement.IsUseStrictLiteral()) {
236 }
else if (!statement.IsStringLiteral()) {
237 directive_prologue =
false;
241 return kUnknownSourceElements;
246 #define CHECK_OK ok); \
247 if (!*ok) return Statement::Default(); \
249 #define DUMMY ) // to make indentation work
253 PreParser::Statement PreParser::ParseStatement(
bool* ok) {
281 return ParseBlock(ok);
286 return ParseVariableStatement(kStatement, ok);
288 case Token::SEMICOLON:
290 return Statement::Default();
293 return ParseIfStatement(ok);
296 return ParseDoWhileStatement(ok);
299 return ParseWhileStatement(ok);
302 return ParseForStatement(ok);
304 case Token::CONTINUE:
305 return ParseContinueStatement(ok);
308 return ParseBreakStatement(ok);
311 return ParseReturnStatement(ok);
314 return ParseWithStatement(ok);
317 return ParseSwitchStatement(ok);
320 return ParseThrowStatement(ok);
323 return ParseTryStatement(ok);
325 case Token::FUNCTION: {
327 Statement statement = ParseFunctionDeclaration(
CHECK_OK);
331 end_location.end_pos,
335 return Statement::Default();
341 case Token::DEBUGGER:
342 return ParseDebuggerStatement(ok);
345 return ParseExpressionOrLabelledStatement(ok);
350 PreParser::Statement PreParser::ParseFunctionDeclaration(
bool* ok) {
359 bool is_strict_reserved =
false;
362 ParseFunctionLiteral(name,
367 FunctionLiteral::DECLARATION,
369 return Statement::FunctionDeclaration();
373 PreParser::Statement PreParser::ParseBlock(
bool* ok) {
381 while (peek() != Token::RBRACE) {
388 Expect(Token::RBRACE, ok);
389 return Statement::Default();
393 PreParser::Statement PreParser::ParseVariableStatement(
394 VariableDeclarationContext var_context,
399 Statement result = ParseVariableDeclarations(var_context,
413 PreParser::Statement PreParser::ParseVariableDeclarations(
414 VariableDeclarationContext var_context,
415 VariableDeclarationProperties* decl_props,
431 bool require_initializer =
false;
448 if (var_context != kSourceElement && var_context != kForStatement) {
451 return Statement::Default();
453 require_initializer =
true;
458 return Statement::Default();
473 return Statement::Default();
476 if (var_context != kSourceElement &&
477 var_context != kForStatement) {
480 return Statement::Default();
484 return Statement::Default();
497 if (peek() == Token::ASSIGN || require_initializer) {
500 if (decl_props !=
NULL) *decl_props = kHasInitializers;
504 if (num_decl !=
NULL) *num_decl = nvars;
505 return Statement::Default();
509 PreParser::Statement PreParser::ParseExpressionOrLabelledStatement(
bool* ok) {
519 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) {
522 ASSERT(!expr.AsIdentifier().IsFutureReserved());
524 (!expr.AsIdentifier().IsFutureStrictReserved() &&
525 !expr.AsIdentifier().IsYield()));
527 return ParseStatement(ok);
534 return Statement::ExpressionStatement(expr);
538 PreParser::Statement PreParser::ParseIfStatement(
bool* ok) {
547 if (peek() == Token::ELSE) {
551 return Statement::Default();
555 PreParser::Statement PreParser::ParseContinueStatement(
bool* ok) {
561 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
562 tok != Token::SEMICOLON &&
563 tok != Token::RBRACE &&
569 return Statement::Default();
573 PreParser::Statement PreParser::ParseBreakStatement(
bool* ok) {
579 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
580 tok != Token::SEMICOLON &&
581 tok != Token::RBRACE &&
587 return Statement::Default();
591 PreParser::Statement PreParser::ParseReturnStatement(
bool* ok) {
606 if (!
scanner()->HasAnyLineTerminatorBeforeNext() &&
607 tok != Token::SEMICOLON &&
608 tok != Token::RBRACE &&
613 return Statement::Default();
617 PreParser::Statement PreParser::ParseWithStatement(
bool* ok) {
624 return Statement::Default();
631 BlockState block_state(&
scope_, &with_scope);
633 return Statement::Default();
637 PreParser::Statement PreParser::ParseSwitchStatement(
bool* ok) {
648 while (token != Token::RBRACE) {
659 token != Token::RBRACE) {
664 Expect(Token::RBRACE, ok);
665 return Statement::Default();
669 PreParser::Statement PreParser::ParseDoWhileStatement(
bool* ok) {
678 Expect(Token::RPAREN, ok);
679 if (peek() == Token::SEMICOLON)
Consume(Token::SEMICOLON);
680 return Statement::Default();
684 PreParser::Statement PreParser::ParseWhileStatement(
bool* ok) {
693 return Statement::Default();
697 bool PreParser::CheckInOrOf(
bool accept_OF) {
707 PreParser::Statement PreParser::ParseForStatement(
bool* ok) {
713 if (peek() != Token::SEMICOLON) {
718 VariableDeclarationProperties decl_props = kHasNoInitializers;
719 ParseVariableDeclarations(
720 kForStatement, &decl_props, &decl_count,
CHECK_OK);
721 bool has_initializers = decl_props == kHasInitializers;
722 bool accept_IN = decl_count == 1 && !(is_let && has_initializers);
723 bool accept_OF = !has_initializers;
724 if (accept_IN && CheckInOrOf(accept_OF)) {
729 return Statement::Default();
733 if (CheckInOrOf(lhs.IsIdentifier())) {
738 return Statement::Default();
746 if (peek() != Token::SEMICOLON) {
751 if (peek() != Token::RPAREN) {
757 return Statement::Default();
761 PreParser::Statement PreParser::ParseThrowStatement(
bool* ok) {
766 if (
scanner()->HasAnyLineTerminatorBeforeNext()) {
769 return Statement::Default();
773 return Statement::Default();
777 PreParser::Statement PreParser::ParseTryStatement(
bool* ok) {
794 if (tok != Token::CATCH && tok != Token::FINALLY) {
797 return Statement::Default();
799 if (tok == Token::CATCH) {
806 BlockState block_state(&
scope_, &with_scope);
811 if (tok == Token::FINALLY) {
815 return Statement::Default();
819 PreParser::Statement PreParser::ParseDebuggerStatement(
bool* ok) {
828 return Statement::Default();
833 #define CHECK_OK ok); \
834 if (!*ok) return Expression::Default(); \
836 #define DUMMY ) // to make indentation work
841 Identifier function_name,
842 Scanner::Location function_name_location,
843 bool name_is_strict_reserved,
845 int function_token_pos,
846 FunctionLiteral::FunctionType function_type,
855 function_state.set_is_generator(is_generator);
860 bool done = (peek() == Token::RPAREN);
861 DuplicateFinder duplicate_finder(
scanner()->unicode_cache());
869 bool is_strict_reserved =
false;
872 if (!eval_args_error_loc.IsValid() && param_name.IsEvalOrArguments()) {
875 if (!reserved_error_loc.IsValid() && is_strict_reserved) {
881 if (!dupe_error_loc.IsValid() && prev_value != 0) {
885 done = (peek() == Token::RPAREN);
899 if (is_lazily_parsed) {
900 ParseLazyFunctionLiteralBody(
CHECK_OK);
902 ParseSourceElements(Token::RBRACE, ok);
909 if (function_name.IsEvalOrArguments()) {
914 if (name_is_strict_reserved) {
919 if (eval_args_error_loc.IsValid()) {
924 if (dupe_error_loc.IsValid()) {
929 if (reserved_error_loc.IsValid()) {
943 void PreParser::ParseLazyFunctionLiteralBody(
bool* ok) {
947 ParseSourceElements(Token::RBRACE, ok);
979 void PreParser::LogSymbol() {
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
static PreParserExpression Default()
PreParserExpression ParseV8Intrinsic(bool *ok)
static PreParserIdentifier Arguments()
ExpressionT ParseExpression(bool accept_IN, bool *ok)
static PreParserIdentifier Yield()
bool allow_generators() const
bool peek_any_identifier()
PreParserIdentifier AsIdentifier()
void CheckOctalLiteral(int beg_pos, int end_pos, bool *ok)
int FindSymbol(DuplicateFinder *finder, int value)
PreParserExpression ExpressionFromString(int pos, Scanner *scanner, PreParserFactory *factory=NULL)
static PreParserIdentifier Eval()
PreParserIdentifier GetSymbol(Scanner *scanner)
bool parenthesized_function_
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 message
void CheckStrictModeLValue(PreParserExpression expression, bool *ok)
PreParserIdentifier Identifier
bool Check(Token::Value token)
void ReportUnexpectedToken(Token::Value token)
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
Scanner * scanner() const
#define ASSERT(condition)
ExpressionT ParseAssignmentExpression(bool accept_IN, bool *ok)
void Consume(Token::Value token)
PreParserTraits::Type::Scope * scope_
bool allow_for_of() const
bool UnescapedLiteralMatches(const char *data, int length)
IdentifierT ParseIdentifierOrStrictReservedWord(bool *is_strict_reserved, bool *ok)
bool is_generator() const
static PreParserExpression UseStrictStringLiteral()
bool stack_overflow() const
void ReportMessageAt(Scanner::Location location, const char *message, bool is_reference_error=false)
void ExpectSemicolon(bool *ok)
bool allow_harmony_scoping() const
static PreParserExpression StringLiteral()
static PreParserIdentifier FutureStrictReserved()
void ReportMessage(const char *message, Vector< const char * > args, bool is_reference_error=false)
bool CheckContextualKeyword(Vector< const char > keyword)
PreParserExpression ParseFunctionLiteral(PreParserIdentifier name, Scanner::Location function_name_location, bool name_is_strict_reserved, bool is_generator, int function_token_position, FunctionLiteral::FunctionType type, bool *ok)
FunctionState * function_state_
PreParserExpression Expression
virtual void LogFunction(int start, int end, int literals, int properties, StrictMode strict_mode)=0
static PreParserIdentifier Default()
Vector< const char > CStrVector(const char *data)
static Location invalid()
bool allow_natives_syntax() const
Location location() const
PreParseResult PreParseLazyFunction(StrictMode strict_mode, bool is_generator, ParserRecorder *log)
virtual void ResumeRecording()
void LogSymbol(ParserRecorder *log, int position)
void ReportMessageAt(Scanner::Location location, const char *message, Vector< const char * > args, bool is_reference_error=false)
#define ASSERT_EQ(v1, v2)
Token::Value current_token()
static PreParserIdentifier FutureReserved()
PreParserTraits::Type::ExpressionList ParseArguments(bool *ok)
void Expect(Token::Value token, bool *ok)
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 name
virtual void LogMessage(int start, int end, const char *message, const char *argument_opt)=0
IdentifierT ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, bool *ok)
virtual void PauseRecording()
Location peek_location() const