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/debug.h" | 6 #include "src/debug/debug.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 // Parse eagerly with ignition since we will compile eagerly. | 35 // Parse eagerly with ignition since we will compile eagerly. |
36 info->set_allow_lazy_parsing(!(i::FLAG_ignition && i::FLAG_ignition_eager)); | 36 info->set_allow_lazy_parsing(!(i::FLAG_ignition && i::FLAG_ignition_eager)); |
37 | 37 |
38 if (options == ScriptCompiler::kProduceParserCache || | 38 if (options == ScriptCompiler::kProduceParserCache || |
39 options == ScriptCompiler::kProduceCodeCache) { | 39 options == ScriptCompiler::kProduceCodeCache) { |
40 source_->info->set_cached_data(&script_data_); | 40 source_->info->set_cached_data(&script_data_); |
41 } | 41 } |
42 // Parser needs to stay alive for finalizing the parsing on the main | 42 // Parser needs to stay alive for finalizing the parsing on the main |
43 // thread. | 43 // thread. |
44 source_->parser.reset(new Parser(source_->info.get())); | 44 source_->parser.reset(new Parser(source_->info.get())); |
| 45 source_->parser->DeserializeScopeChain( |
| 46 source_->info.get(), Handle<Context>::null(), |
| 47 Scope::DeserializationMode::kDeserializeOffHeap); |
45 } | 48 } |
46 | 49 |
47 | 50 |
48 void BackgroundParsingTask::Run() { | 51 void BackgroundParsingTask::Run() { |
49 DisallowHeapAllocation no_allocation; | 52 DisallowHeapAllocation no_allocation; |
50 DisallowHandleAllocation no_handles; | 53 DisallowHandleAllocation no_handles; |
51 DisallowHandleDereference no_deref; | 54 DisallowHandleDereference no_deref; |
52 | 55 |
53 // Reset the stack limit of the parser to reflect correctly that we're on a | 56 // Reset the stack limit of the parser to reflect correctly that we're on a |
54 // background thread. | 57 // background thread. |
55 uintptr_t stack_limit = | 58 uintptr_t stack_limit = |
56 reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB; | 59 reinterpret_cast<uintptr_t>(&stack_limit) - stack_size_ * KB; |
57 source_->parser->set_stack_limit(stack_limit); | 60 source_->parser->set_stack_limit(stack_limit); |
58 | 61 |
59 // Nullify the Isolate temporarily so that the background parser doesn't | 62 // Nullify the Isolate temporarily so that the background parser doesn't |
60 // accidentally use it. | 63 // accidentally use it. |
61 Isolate* isolate = source_->info->isolate(); | 64 Isolate* isolate = source_->info->isolate(); |
62 source_->info->set_isolate(nullptr); | 65 source_->info->set_isolate(nullptr); |
63 | 66 |
64 source_->parser->DeserializeScopeChain( | |
65 source_->info.get(), Handle<Context>::null(), | |
66 Scope::DeserializationMode::kDeserializeOffHeap); | |
67 source_->parser->ParseOnBackground(source_->info.get()); | 67 source_->parser->ParseOnBackground(source_->info.get()); |
68 | 68 |
69 if (script_data_ != nullptr) { | 69 if (script_data_ != nullptr) { |
70 source_->cached_data.reset(new ScriptCompiler::CachedData( | 70 source_->cached_data.reset(new ScriptCompiler::CachedData( |
71 script_data_->data(), script_data_->length(), | 71 script_data_->data(), script_data_->length(), |
72 ScriptCompiler::CachedData::BufferOwned)); | 72 ScriptCompiler::CachedData::BufferOwned)); |
73 script_data_->ReleaseDataOwnership(); | 73 script_data_->ReleaseDataOwnership(); |
74 delete script_data_; | 74 delete script_data_; |
75 script_data_ = nullptr; | 75 script_data_ = nullptr; |
76 } | 76 } |
77 source_->info->set_isolate(isolate); | 77 source_->info->set_isolate(isolate); |
78 } | 78 } |
79 } // namespace internal | 79 } // namespace internal |
80 } // namespace v8 | 80 } // namespace v8 |
OLD | NEW |