| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/background-parsing-task.h" | 5 #include "src/background-parsing-task.h" |
| 6 #include "src/debug.h" |
| 6 | 7 |
| 7 namespace v8 { | 8 namespace v8 { |
| 8 namespace internal { | 9 namespace internal { |
| 9 | 10 |
| 10 BackgroundParsingTask::BackgroundParsingTask( | 11 BackgroundParsingTask::BackgroundParsingTask( |
| 11 StreamedSource* source, ScriptCompiler::CompileOptions options, | 12 StreamedSource* source, ScriptCompiler::CompileOptions options, |
| 12 int stack_size, Isolate* isolate) | 13 int stack_size, Isolate* isolate) |
| 13 : source_(source), stack_size_(stack_size) { | 14 : source_(source), stack_size_(stack_size) { |
| 14 // We don't set the context to the CompilationInfo yet, because the background | 15 // We don't set the context to the CompilationInfo yet, because the background |
| 15 // thread cannot do anything with it anyway. We set it just before compilation | 16 // thread cannot do anything with it anyway. We set it just before compilation |
| 16 // on the foreground thread. | 17 // on the foreground thread. |
| 17 DCHECK(options == ScriptCompiler::kProduceParserCache || | 18 DCHECK(options == ScriptCompiler::kProduceParserCache || |
| 18 options == ScriptCompiler::kProduceCodeCache || | 19 options == ScriptCompiler::kProduceCodeCache || |
| 19 options == ScriptCompiler::kNoCompileOptions); | 20 options == ScriptCompiler::kNoCompileOptions); |
| 20 | 21 |
| 21 // Prepare the data for the internalization phase and compilation phase, which | 22 // Prepare the data for the internalization phase and compilation phase, which |
| 22 // will happen in the main thread after parsing. | 23 // will happen in the main thread after parsing. |
| 23 Zone* zone = new Zone(); | 24 Zone* zone = new Zone(); |
| 24 ParseInfo* info = new ParseInfo(zone); | 25 ParseInfo* info = new ParseInfo(zone); |
| 25 source->zone.Reset(zone); | 26 source->zone.Reset(zone); |
| 26 source->info.Reset(info); | 27 source->info.Reset(info); |
| 27 info->set_isolate(isolate); | 28 info->set_isolate(isolate); |
| 28 info->set_source_stream(source->source_stream.get()); | 29 info->set_source_stream(source->source_stream.get()); |
| 29 info->set_source_stream_encoding(source->encoding); | 30 info->set_source_stream_encoding(source->encoding); |
| 30 info->set_hash_seed(isolate->heap()->HashSeed()); | 31 info->set_hash_seed(isolate->heap()->HashSeed()); |
| 31 info->set_global(); | 32 info->set_global(); |
| 32 info->set_unicode_cache(&source_->unicode_cache); | 33 info->set_unicode_cache(&source_->unicode_cache); |
| 33 | 34 |
| 34 bool disable_lazy = Compiler::DebuggerWantsEagerCompilation(isolate); | 35 bool disable_lazy = isolate->debug()->RequiresEagerCompilation(); |
| 35 if (disable_lazy && options == ScriptCompiler::kProduceParserCache) { | 36 if (disable_lazy && options == ScriptCompiler::kProduceParserCache) { |
| 36 // Producing cached data while parsing eagerly is not supported. | 37 // Producing cached data while parsing eagerly is not supported. |
| 37 options = ScriptCompiler::kNoCompileOptions; | 38 options = ScriptCompiler::kNoCompileOptions; |
| 38 } | 39 } |
| 39 | 40 |
| 40 info->set_compile_options(options); | 41 info->set_compile_options(options); |
| 41 info->set_allow_lazy_parsing(!disable_lazy); | 42 info->set_allow_lazy_parsing(!disable_lazy); |
| 42 } | 43 } |
| 43 | 44 |
| 44 | 45 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 if (script_data != NULL) { | 67 if (script_data != NULL) { |
| 67 source_->cached_data.Reset(new ScriptCompiler::CachedData( | 68 source_->cached_data.Reset(new ScriptCompiler::CachedData( |
| 68 script_data->data(), script_data->length(), | 69 script_data->data(), script_data->length(), |
| 69 ScriptCompiler::CachedData::BufferOwned)); | 70 ScriptCompiler::CachedData::BufferOwned)); |
| 70 script_data->ReleaseDataOwnership(); | 71 script_data->ReleaseDataOwnership(); |
| 71 delete script_data; | 72 delete script_data; |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 } // namespace internal | 75 } // namespace internal |
| 75 } // namespace v8 | 76 } // namespace v8 |
| OLD | NEW |