Chromium Code Reviews| Index: src/parsing/parser.cc |
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
| index 039d924b9737dc8cbde230cdcfe90ba60e22c1b4..cd3d3cd3c68451b1d409a649c3672bb94ddb6d3a 100644 |
| --- a/src/parsing/parser.cc |
| +++ b/src/parsing/parser.cc |
| @@ -46,6 +46,7 @@ ParseInfo::ParseInfo(Zone* zone) |
| flags_(0), |
| source_stream_(nullptr), |
| source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), |
| + character_stream_(nullptr), |
| extension_(nullptr), |
| compile_options_(ScriptCompiler::kNoCompileOptions), |
| script_scope_(nullptr), |
| @@ -828,7 +829,8 @@ Parser::Parser(ParseInfo* info) |
| // Even though we were passed ParseInfo, we should not store it in |
| // Parser - this makes sure that Isolate is not accidentally accessed via |
| // ParseInfo during background parsing. |
| - DCHECK(!info->script().is_null() || info->source_stream() != NULL); |
| + DCHECK(!info->script().is_null() || info->source_stream() != nullptr || |
| + info->character_stream() != nullptr); |
| set_allow_lazy(info->allow_lazy_parsing()); |
| set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
| set_allow_tailcalls(FLAG_harmony_tailcalls && !info->is_native() && |
| @@ -5472,16 +5474,27 @@ void Parser::ParseOnBackground(ParseInfo* info) { |
| CompleteParserRecorder recorder; |
| if (produce_cached_parse_data()) log_ = &recorder; |
| - DCHECK(info->source_stream() != NULL); |
| - ExternalStreamingStream stream(info->source_stream(), |
| - info->source_stream_encoding()); |
| - scanner_.Initialize(&stream); |
| + std::unique_ptr<Utf16CharacterStream> stream; |
| + Utf16CharacterStream* stream_ptr; |
| + if (info->character_stream()) { |
| + DCHECK(info->source_stream() == nullptr); |
| + stream_ptr = info->character_stream(); |
| + } else { |
| + DCHECK(info->character_stream() == nullptr); |
| + stream.reset(new ExternalStreamingStream(info->source_stream(), |
| + info->source_stream_encoding())); |
| + stream_ptr = stream.get(); |
| + } |
| + scanner_.Initialize(stream_ptr); |
| DCHECK(info->context().is_null() || info->context()->IsNativeContext()); |
| - // When streaming, we don't know the length of the source until we have parsed |
| - // it. The raw data can be UTF-8, so we wouldn't know the source length until |
| + // 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
|
| + // parsed |
| + // it. The raw data can be UTF-8, so we wouldn't know the source length |
| + // until |
| // we have decoded it anyway even if we knew the raw data length (which we |
| - // don't). We work around this by storing all the scopes which need their end |
| + // don't). We work around this by storing all the scopes which need their |
| + // end |
| // position set at the end of the script (the top scope and possible eval |
| // scopes) and set their end position after we know the script length. |
| result = DoParseProgram(info); |