OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "components/nacl/renderer/plugin/pnacl_translate_thread.h" | 5 #include "components/nacl/renderer/plugin/pnacl_translate_thread.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "components/nacl/renderer/plugin/plugin.h" | 10 #include "components/nacl/renderer/plugin/plugin.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 compile_out_files.push_back(invalid_desc_wrapper_); | 171 compile_out_files.push_back(invalid_desc_wrapper_); |
172 | 172 |
173 PLUGIN_PRINTF( | 173 PLUGIN_PRINTF( |
174 ("DoTranslate using subzero: %d\n", pnacl_options_->use_subzero)); | 174 ("DoTranslate using subzero: %d\n", pnacl_options_->use_subzero)); |
175 | 175 |
176 pp::Core* core = pp::Module::Get()->core(); | 176 pp::Core* core = pp::Module::Get()->core(); |
177 int64_t compiler_load_start_time = NaClGetTimeOfDayMicroseconds(); | 177 int64_t compiler_load_start_time = NaClGetTimeOfDayMicroseconds(); |
178 PnaclResources::ResourceType compiler_type = pnacl_options_->use_subzero | 178 PnaclResources::ResourceType compiler_type = pnacl_options_->use_subzero |
179 ? PnaclResources::SUBZERO | 179 ? PnaclResources::SUBZERO |
180 : PnaclResources::LLC; | 180 : PnaclResources::LLC; |
181 // On success, ownership of file_info is transferred. | 181 // Ownership of file_info is transferred here. |
182 PP_NaClFileInfo file_info = resources_->TakeFileInfo(compiler_type); | 182 PP_NaClFileInfo file_info = resources_->TakeFileInfo(compiler_type); |
183 const std::string& url = resources_->GetUrl(compiler_type); | 183 const std::string& url = resources_->GetUrl(compiler_type); |
184 NaClSubprocess* compiler_subprocess = | 184 NaClSubprocess* compiler_subprocess = |
185 plugin_->LoadHelperNaClModule(url, file_info, &error_info); | 185 plugin_->LoadHelperNaClModule(url, file_info, &error_info); |
186 if (compiler_subprocess == NULL) { | 186 if (compiler_subprocess == NULL) { |
187 if (file_info.handle != PP_kInvalidFileHandle) | |
188 CloseFileHandle(file_info.handle); | |
189 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP, | 187 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP, |
190 "Compile process could not be created: " + | 188 "Compile process could not be created: " + |
191 error_info.message()); | 189 error_info.message()); |
192 return; | 190 return; |
193 } | 191 } |
194 int64_t compiler_load_time_total = | 192 int64_t compiler_load_time_total = |
195 NaClGetTimeOfDayMicroseconds() - compiler_load_start_time; | 193 NaClGetTimeOfDayMicroseconds() - compiler_load_start_time; |
196 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler", | 194 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler", |
197 compiler_load_time_total); | 195 compiler_load_time_total); |
198 GetNaClInterface()->LogTranslateTime( | 196 GetNaClInterface()->LogTranslateTime( |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return false; | 343 return false; |
346 } | 344 } |
347 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); | 345 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); |
348 } | 346 } |
349 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) | 347 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) |
350 ld_in_files.push_back(invalid_desc_wrapper_); | 348 ld_in_files.push_back(invalid_desc_wrapper_); |
351 | 349 |
352 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); | 350 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); |
353 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); | 351 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); |
354 PP_NaClFileInfo ld_file_info = resources_->TakeFileInfo(PnaclResources::LD); | 352 PP_NaClFileInfo ld_file_info = resources_->TakeFileInfo(PnaclResources::LD); |
355 // On success, ownership of ld_file_info is transferred. | 353 // Ownership of ld_file_info is transferred here. |
356 nacl::scoped_ptr<NaClSubprocess> ld_subprocess(plugin_->LoadHelperNaClModule( | 354 nacl::scoped_ptr<NaClSubprocess> ld_subprocess(plugin_->LoadHelperNaClModule( |
357 resources_->GetUrl(PnaclResources::LD), ld_file_info, &error_info)); | 355 resources_->GetUrl(PnaclResources::LD), ld_file_info, &error_info)); |
358 if (ld_subprocess.get() == NULL) { | 356 if (ld_subprocess.get() == NULL) { |
359 if (ld_file_info.handle != PP_kInvalidFileHandle) | |
360 CloseFileHandle(ld_file_info.handle); | |
361 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, | 357 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, |
362 "Link process could not be created: " + | 358 "Link process could not be created: " + |
363 error_info.message()); | 359 error_info.message()); |
364 return false; | 360 return false; |
365 } | 361 } |
366 GetNaClInterface()->LogTranslateTime( | 362 GetNaClInterface()->LogTranslateTime( |
367 "NaCl.Perf.PNaClLoadTime.LoadLinker", | 363 "NaCl.Perf.PNaClLoadTime.LoadLinker", |
368 NaClGetTimeOfDayMicroseconds() - ld_start_time); | 364 NaClGetTimeOfDayMicroseconds() - ld_start_time); |
369 { | 365 { |
370 nacl::MutexLocker ml(&subprocess_mu_); | 366 nacl::MutexLocker ml(&subprocess_mu_); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 AbortSubprocesses(); | 458 AbortSubprocesses(); |
463 if (translate_thread_ != NULL) | 459 if (translate_thread_ != NULL) |
464 NaClThreadJoin(translate_thread_.get()); | 460 NaClThreadJoin(translate_thread_.get()); |
465 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 461 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
466 NaClCondVarDtor(&buffer_cond_); | 462 NaClCondVarDtor(&buffer_cond_); |
467 NaClMutexDtor(&cond_mu_); | 463 NaClMutexDtor(&cond_mu_); |
468 NaClMutexDtor(&subprocess_mu_); | 464 NaClMutexDtor(&subprocess_mu_); |
469 } | 465 } |
470 | 466 |
471 } // namespace plugin | 467 } // namespace plugin |
OLD | NEW |