Chromium Code Reviews| 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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 data_ = copy; | 39 data_ = copy; |
| 40 AcquireDataOwnership(); | 40 AcquireDataOwnership(); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 ParseInfo::ParseInfo(Zone* zone) | 44 ParseInfo::ParseInfo(Zone* zone) |
| 45 : zone_(zone), | 45 : zone_(zone), |
| 46 flags_(0), | 46 flags_(0), |
| 47 source_stream_(nullptr), | 47 source_stream_(nullptr), |
| 48 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), | 48 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), |
| 49 character_stream_(nullptr), | |
| 49 extension_(nullptr), | 50 extension_(nullptr), |
| 50 compile_options_(ScriptCompiler::kNoCompileOptions), | 51 compile_options_(ScriptCompiler::kNoCompileOptions), |
| 51 script_scope_(nullptr), | 52 script_scope_(nullptr), |
| 52 unicode_cache_(nullptr), | 53 unicode_cache_(nullptr), |
| 53 stack_limit_(0), | 54 stack_limit_(0), |
| 54 hash_seed_(0), | 55 hash_seed_(0), |
| 55 isolate_(nullptr), | 56 isolate_(nullptr), |
| 56 cached_data_(nullptr), | 57 cached_data_(nullptr), |
| 57 ast_value_factory_(nullptr), | 58 ast_value_factory_(nullptr), |
| 58 literal_(nullptr), | 59 literal_(nullptr), |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 original_scope_(NULL), | 822 original_scope_(NULL), |
| 822 target_stack_(NULL), | 823 target_stack_(NULL), |
| 823 compile_options_(info->compile_options()), | 824 compile_options_(info->compile_options()), |
| 824 cached_parse_data_(NULL), | 825 cached_parse_data_(NULL), |
| 825 total_preparse_skipped_(0), | 826 total_preparse_skipped_(0), |
| 826 pre_parse_timer_(NULL), | 827 pre_parse_timer_(NULL), |
| 827 parsing_on_main_thread_(true) { | 828 parsing_on_main_thread_(true) { |
| 828 // Even though we were passed ParseInfo, we should not store it in | 829 // Even though we were passed ParseInfo, we should not store it in |
| 829 // Parser - this makes sure that Isolate is not accidentally accessed via | 830 // Parser - this makes sure that Isolate is not accidentally accessed via |
| 830 // ParseInfo during background parsing. | 831 // ParseInfo during background parsing. |
| 831 DCHECK(!info->script().is_null() || info->source_stream() != NULL); | 832 DCHECK(!info->script().is_null() || info->source_stream() != nullptr || |
| 833 info->character_stream() != nullptr); | |
| 832 set_allow_lazy(info->allow_lazy_parsing()); | 834 set_allow_lazy(info->allow_lazy_parsing()); |
| 833 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 835 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
| 834 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && | 836 set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
| 835 info->isolate()->is_tail_call_elimination_enabled()); | 837 info->isolate()->is_tail_call_elimination_enabled()); |
| 836 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); | 838 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); |
| 837 set_allow_harmony_for_in(FLAG_harmony_for_in); | 839 set_allow_harmony_for_in(FLAG_harmony_for_in); |
| 838 set_allow_harmony_function_sent(FLAG_harmony_function_sent); | 840 set_allow_harmony_function_sent(FLAG_harmony_function_sent); |
| 839 set_allow_harmony_restrictive_declarations( | 841 set_allow_harmony_restrictive_declarations( |
| 840 FLAG_harmony_restrictive_declarations); | 842 FLAG_harmony_restrictive_declarations); |
| 841 set_allow_harmony_exponentiation_operator( | 843 set_allow_harmony_exponentiation_operator( |
| (...skipping 4623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5465 void Parser::ParseOnBackground(ParseInfo* info) { | 5467 void Parser::ParseOnBackground(ParseInfo* info) { |
| 5466 parsing_on_main_thread_ = false; | 5468 parsing_on_main_thread_ = false; |
| 5467 | 5469 |
| 5468 DCHECK(info->literal() == NULL); | 5470 DCHECK(info->literal() == NULL); |
| 5469 FunctionLiteral* result = NULL; | 5471 FunctionLiteral* result = NULL; |
| 5470 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); | 5472 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); |
| 5471 | 5473 |
| 5472 CompleteParserRecorder recorder; | 5474 CompleteParserRecorder recorder; |
| 5473 if (produce_cached_parse_data()) log_ = &recorder; | 5475 if (produce_cached_parse_data()) log_ = &recorder; |
| 5474 | 5476 |
| 5475 DCHECK(info->source_stream() != NULL); | 5477 std::unique_ptr<Utf16CharacterStream> stream; |
| 5476 ExternalStreamingStream stream(info->source_stream(), | 5478 Utf16CharacterStream* stream_ptr; |
| 5477 info->source_stream_encoding()); | 5479 if (info->character_stream()) { |
| 5478 scanner_.Initialize(&stream); | 5480 DCHECK(info->source_stream() == nullptr); |
| 5481 stream_ptr = info->character_stream(); | |
| 5482 } else { | |
| 5483 DCHECK(info->character_stream() == nullptr); | |
| 5484 stream.reset(new ExternalStreamingStream(info->source_stream(), | |
| 5485 info->source_stream_encoding())); | |
| 5486 stream_ptr = stream.get(); | |
| 5487 } | |
| 5488 scanner_.Initialize(stream_ptr); | |
| 5479 DCHECK(info->context().is_null() || info->context()->IsNativeContext()); | 5489 DCHECK(info->context().is_null() || info->context()->IsNativeContext()); |
| 5480 | 5490 |
| 5481 // When streaming, we don't know the length of the source until we have parsed | 5491 // When streaming, we don't know the length of the source until we have |
|
marja
2016/07/29 08:43:52
These changes seem bogus, it was under 80 chars be
jochen (gone - plz use gerrit)
2016/07/29 08:54:35
reverted
| |
| 5482 // it. The raw data can be UTF-8, so we wouldn't know the source length until | 5492 // parsed |
| 5493 // it. The raw data can be UTF-8, so we wouldn't know the source length | |
| 5494 // until | |
| 5483 // we have decoded it anyway even if we knew the raw data length (which we | 5495 // we have decoded it anyway even if we knew the raw data length (which we |
| 5484 // don't). We work around this by storing all the scopes which need their end | 5496 // don't). We work around this by storing all the scopes which need their |
| 5497 // end | |
| 5485 // position set at the end of the script (the top scope and possible eval | 5498 // position set at the end of the script (the top scope and possible eval |
| 5486 // scopes) and set their end position after we know the script length. | 5499 // scopes) and set their end position after we know the script length. |
| 5487 result = DoParseProgram(info); | 5500 result = DoParseProgram(info); |
| 5488 | 5501 |
| 5489 info->set_literal(result); | 5502 info->set_literal(result); |
| 5490 | 5503 |
| 5491 // We cannot internalize on a background thread; a foreground task will take | 5504 // We cannot internalize on a background thread; a foreground task will take |
| 5492 // care of calling Parser::Internalize just before compilation. | 5505 // care of calling Parser::Internalize just before compilation. |
| 5493 | 5506 |
| 5494 if (produce_cached_parse_data()) { | 5507 if (produce_cached_parse_data()) { |
| (...skipping 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7096 node->Print(Isolate::Current()); | 7109 node->Print(Isolate::Current()); |
| 7097 } | 7110 } |
| 7098 #endif // DEBUG | 7111 #endif // DEBUG |
| 7099 | 7112 |
| 7100 #undef CHECK_OK | 7113 #undef CHECK_OK |
| 7101 #undef CHECK_OK_VOID | 7114 #undef CHECK_OK_VOID |
| 7102 #undef CHECK_FAILED | 7115 #undef CHECK_FAILED |
| 7103 | 7116 |
| 7104 } // namespace internal | 7117 } // namespace internal |
| 7105 } // namespace v8 | 7118 } // namespace v8 |
| OLD | NEW |