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

Side by Side Diff: src/parsing/parser.cc

Issue 2195603002: Create a character stream and hook it up to the parse info (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 4 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/parsing/parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 4627 matching lines...) Expand 10 before | Expand all | Expand 10 after
5469 void Parser::ParseOnBackground(ParseInfo* info) { 5471 void Parser::ParseOnBackground(ParseInfo* info) {
5470 parsing_on_main_thread_ = false; 5472 parsing_on_main_thread_ = false;
5471 5473
5472 DCHECK(info->literal() == NULL); 5474 DCHECK(info->literal() == NULL);
5473 FunctionLiteral* result = NULL; 5475 FunctionLiteral* result = NULL;
5474 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 5476 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
5475 5477
5476 CompleteParserRecorder recorder; 5478 CompleteParserRecorder recorder;
5477 if (produce_cached_parse_data()) log_ = &recorder; 5479 if (produce_cached_parse_data()) log_ = &recorder;
5478 5480
5479 DCHECK(info->source_stream() != NULL); 5481 std::unique_ptr<Utf16CharacterStream> stream;
5480 ExternalStreamingStream stream(info->source_stream(), 5482 Utf16CharacterStream* stream_ptr;
5481 info->source_stream_encoding()); 5483 if (info->character_stream()) {
5482 scanner_.Initialize(&stream); 5484 DCHECK(info->source_stream() == nullptr);
5485 stream_ptr = info->character_stream();
5486 } else {
5487 DCHECK(info->character_stream() == nullptr);
5488 stream.reset(new ExternalStreamingStream(info->source_stream(),
5489 info->source_stream_encoding()));
5490 stream_ptr = stream.get();
5491 }
5492 scanner_.Initialize(stream_ptr);
5483 DCHECK(info->context().is_null() || info->context()->IsNativeContext()); 5493 DCHECK(info->context().is_null() || info->context()->IsNativeContext());
5484 5494
5485 // When streaming, we don't know the length of the source until we have parsed 5495 // When streaming, we don't know the length of the source until we have parsed
5486 // it. The raw data can be UTF-8, so we wouldn't know the source length until 5496 // it. The raw data can be UTF-8, so we wouldn't know the source length until
5487 // we have decoded it anyway even if we knew the raw data length (which we 5497 // we have decoded it anyway even if we knew the raw data length (which we
5488 // don't). We work around this by storing all the scopes which need their end 5498 // don't). We work around this by storing all the scopes which need their end
5489 // position set at the end of the script (the top scope and possible eval 5499 // position set at the end of the script (the top scope and possible eval
5490 // scopes) and set their end position after we know the script length. 5500 // scopes) and set their end position after we know the script length.
5491 result = DoParseProgram(info); 5501 result = DoParseProgram(info);
5492 5502
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
7100 node->Print(Isolate::Current()); 7110 node->Print(Isolate::Current());
7101 } 7111 }
7102 #endif // DEBUG 7112 #endif // DEBUG
7103 7113
7104 #undef CHECK_OK 7114 #undef CHECK_OK
7105 #undef CHECK_OK_VOID 7115 #undef CHECK_OK_VOID
7106 #undef CHECK_FAILED 7116 #undef CHECK_FAILED
7107 7117
7108 } // namespace internal 7118 } // namespace internal
7109 } // namespace v8 7119 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698