| 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 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 | 9 |
| 10 BackgroundParsingTask::BackgroundParsingTask( | 10 BackgroundParsingTask::BackgroundParsingTask( |
| 11 StreamedSource* source, ScriptCompiler::CompileOptions options, | 11 StreamedSource* source, ScriptCompiler::CompileOptions options, |
| 12 int stack_size, Isolate* isolate) | 12 int stack_size, Isolate* isolate) |
| 13 : source_(source), options_(options), stack_size_(stack_size) { | 13 : source_(source), options_(options), stack_size_(stack_size) { |
| 14 // Prepare the data for the internalization phase and compilation phase, which | 14 // Prepare the data for the internalization phase and compilation phase, which |
| 15 // will happen in the main thread after parsing. | 15 // will happen in the main thread after parsing. |
| 16 source->info.Reset(new i::CompilationInfoWithZone(source->source_stream.get(), | 16 source->info.Reset(new i::CompilationInfoWithZone(source->source_stream.get(), |
| 17 source->encoding, isolate)); | 17 source->encoding, isolate)); |
| 18 source->info->MarkAsGlobal(); | 18 source->info->MarkAsGlobal(); |
| 19 | 19 |
| 20 // We don't set the context to the CompilationInfo yet, because the background | 20 // We don't set the context to the CompilationInfo yet, because the background |
| 21 // thread cannot do anything with it anyway. We set it just before compilation | 21 // thread cannot do anything with it anyway. We set it just before compilation |
| 22 // on the foreground thread. | 22 // on the foreground thread. |
| 23 DCHECK(options == ScriptCompiler::kProduceParserCache || | 23 DCHECK(options == ScriptCompiler::kProduceParserCache || |
| 24 options == ScriptCompiler::kProduceCodeCache || | 24 options == ScriptCompiler::kProduceCodeCache || |
| 25 options == ScriptCompiler::kNoCompileOptions); | 25 options == ScriptCompiler::kNoCompileOptions); |
| 26 source->allow_lazy = | 26 source->allow_lazy = |
| 27 !i::Compiler::DebuggerWantsEagerCompilation(source->info.get()); | 27 !i::Compiler::DebuggerWantsEagerCompilation(source->info.get()); |
| 28 |
| 29 if (!source->allow_lazy && options_ == ScriptCompiler::kProduceParserCache) { |
| 30 // Producing cached data while parsing eagerly is not supported. |
| 31 options_ = ScriptCompiler::kNoCompileOptions; |
| 32 } |
| 28 source->hash_seed = isolate->heap()->HashSeed(); | 33 source->hash_seed = isolate->heap()->HashSeed(); |
| 29 } | 34 } |
| 30 | 35 |
| 31 | 36 |
| 32 void BackgroundParsingTask::Run() { | 37 void BackgroundParsingTask::Run() { |
| 33 DisallowHeapAllocation no_allocation; | 38 DisallowHeapAllocation no_allocation; |
| 34 DisallowHandleAllocation no_handles; | 39 DisallowHandleAllocation no_handles; |
| 35 DisallowHandleDereference no_deref; | 40 DisallowHandleDereference no_deref; |
| 36 | 41 |
| 37 ScriptData* script_data = NULL; | 42 ScriptData* script_data = NULL; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 53 if (script_data != NULL) { | 58 if (script_data != NULL) { |
| 54 source_->cached_data.Reset(new ScriptCompiler::CachedData( | 59 source_->cached_data.Reset(new ScriptCompiler::CachedData( |
| 55 script_data->data(), script_data->length(), | 60 script_data->data(), script_data->length(), |
| 56 ScriptCompiler::CachedData::BufferOwned)); | 61 ScriptCompiler::CachedData::BufferOwned)); |
| 57 script_data->ReleaseDataOwnership(); | 62 script_data->ReleaseDataOwnership(); |
| 58 delete script_data; | 63 delete script_data; |
| 59 } | 64 } |
| 60 } | 65 } |
| 61 } | 66 } |
| 62 } // namespace v8::internal | 67 } // namespace v8::internal |
| OLD | NEW |