| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/compiler-dispatcher/compiler-dispatcher-job.h" | 5 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
| 6 | 6 |
| 7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
| 8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/global-handles.h" | 10 #include "src/global-handles.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 if (parse_info_->literal() == nullptr) { | 136 if (parse_info_->literal() == nullptr) { |
| 137 status_ = CompileJobStatus::kFailed; | 137 status_ = CompileJobStatus::kFailed; |
| 138 } else { | 138 } else { |
| 139 status_ = CompileJobStatus::kReadyToAnalyse; | 139 status_ = CompileJobStatus::kReadyToAnalyse; |
| 140 } | 140 } |
| 141 | 141 |
| 142 DeferredHandleScope scope(isolate_); | 142 DeferredHandleScope scope(isolate_); |
| 143 { | 143 { |
| 144 // Create a canonical handle scope before internalizing parsed values if | |
| 145 // compiling bytecode. This is required for off-thread bytecode generation. | |
| 146 std::unique_ptr<CanonicalHandleScope> canonical; | |
| 147 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_)); | |
| 148 | |
| 149 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_); | 144 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_); |
| 150 Handle<Script> script(Script::cast(shared->script()), isolate_); | 145 Handle<Script> script(Script::cast(shared->script()), isolate_); |
| 151 | 146 |
| 152 parse_info_->set_script(script); | 147 parse_info_->set_script(script); |
| 153 parse_info_->set_context(handle(function_->context(), isolate_)); | 148 parse_info_->set_context(handle(function_->context(), isolate_)); |
| 154 parse_info_->set_shared_info(handle(function_->shared(), isolate_)); | 149 parse_info_->set_shared_info(handle(function_->shared(), isolate_)); |
| 155 | 150 |
| 156 // Do the parsing tasks which need to be done on the main thread. This will | 151 // Do the parsing tasks which need to be done on the main thread. This will |
| 157 // also handle parse errors. | 152 // also handle parse errors. |
| 158 parser_->Internalize(isolate_, script, parse_info_->literal() == nullptr); | 153 parser_->Internalize(isolate_, script, parse_info_->literal() == nullptr); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 169 return status_ != CompileJobStatus::kFailed; | 164 return status_ != CompileJobStatus::kFailed; |
| 170 } | 165 } |
| 171 | 166 |
| 172 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() { | 167 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() { |
| 173 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); | 168 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); |
| 174 DCHECK(status() == CompileJobStatus::kReadyToAnalyse); | 169 DCHECK(status() == CompileJobStatus::kReadyToAnalyse); |
| 175 | 170 |
| 176 compile_info_.reset(new CompilationInfo(parse_info_.get(), function_)); | 171 compile_info_.reset(new CompilationInfo(parse_info_.get(), function_)); |
| 177 | 172 |
| 178 DeferredHandleScope scope(isolate_); | 173 DeferredHandleScope scope(isolate_); |
| 179 { | 174 if (Compiler::Analyze(parse_info_.get())) { |
| 180 // Create a canonical handle scope before ast numbering if compiling | 175 compile_job_.reset( |
| 181 // bytecode. This is required for off-thread bytecode generation. | 176 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get())); |
| 182 std::unique_ptr<CanonicalHandleScope> canonical; | |
| 183 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_)); | |
| 184 | |
| 185 if (Compiler::Analyze(parse_info_.get())) { | |
| 186 compile_job_.reset( | |
| 187 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get())); | |
| 188 } | |
| 189 } | 177 } |
| 190 compile_info_->set_deferred_handles(scope.Detach()); | 178 compile_info_->set_deferred_handles(scope.Detach()); |
| 191 | 179 |
| 192 if (!compile_job_.get()) { | 180 if (!compile_job_.get()) { |
| 193 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); | 181 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); |
| 194 status_ = CompileJobStatus::kFailed; | 182 status_ = CompileJobStatus::kFailed; |
| 195 return false; | 183 return false; |
| 196 } | 184 } |
| 197 | 185 |
| 198 can_compile_on_background_thread_ = | 186 can_compile_on_background_thread_ = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (!source_.is_null()) { | 245 if (!source_.is_null()) { |
| 258 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); | 246 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); |
| 259 source_ = Handle<String>::null(); | 247 source_ = Handle<String>::null(); |
| 260 } | 248 } |
| 261 | 249 |
| 262 status_ = CompileJobStatus::kInitial; | 250 status_ = CompileJobStatus::kInitial; |
| 263 } | 251 } |
| 264 | 252 |
| 265 } // namespace internal | 253 } // namespace internal |
| 266 } // namespace v8 | 254 } // namespace v8 |
| OLD | NEW |