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 "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
10 #include "ppapi/cpp/var.h" | 10 #include "ppapi/cpp/var.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 "Link process could not reset object file"); | 332 "Link process could not reset object file"); |
333 return false; | 333 return false; |
334 } | 334 } |
335 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); | 335 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); |
336 } | 336 } |
337 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) | 337 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) |
338 ld_in_files.push_back(invalid_desc_wrapper_); | 338 ld_in_files.push_back(invalid_desc_wrapper_); |
339 | 339 |
340 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); | 340 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); |
341 pp::Core* core = pp::Module::Get()->core(); | 341 pp::Core* core = pp::Module::Get()->core(); |
342 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); | |
343 PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle(); | |
344 // On success, ownership of ld_file_handle is transferred. | |
345 NaClSubprocess* ld_subprocess = plugin_->LoadHelperNaClModule( | |
bbudge
2014/06/02 16:58:04
Why not make ld_subprocess a nacl::scoped_ptr? We'
| |
346 resources_->GetLlcUrl(), ld_file_handle, &error_info); | |
347 if (ld_subprocess == NULL) { | |
348 if (ld_file_handle != PP_kInvalidFileHandle) | |
349 CloseFileHandle(ld_file_handle); | |
350 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, | |
351 "Link process could not be created: " + | |
352 error_info.message()); | |
353 return false; | |
354 } | |
355 core->CallOnMainThread(0, | |
356 coordinator_->GetUMATimeCallback( | |
357 "NaCl.Perf.PNaClLoadTime.LoadLinker", | |
358 NaClGetTimeOfDayMicroseconds() - ld_start_time), | |
359 PP_OK); | |
360 | |
342 { | 361 { |
343 // Create LD process | |
344 nacl::MutexLocker ml(&subprocess_mu_); | 362 nacl::MutexLocker ml(&subprocess_mu_); |
345 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); | 363 // If we received a call to AbortSubprocesses() before we had a chance to |
346 PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle(); | 364 // set llc_subprocess_, shut down and clean up the subprocess started here. |
347 | 365 if (subprocesses_aborted_) { |
348 // On success, ownership of ld_file_handle is transferred. | 366 ld_subprocess->service_runtime()->Shutdown(); |
349 ld_subprocess_.reset(plugin_->LoadHelperNaClModule( | 367 delete ld_subprocess; |
350 resources_->GetLdUrl(), ld_file_handle, &error_info)); | |
351 if (ld_subprocess_ == NULL) { | |
352 if (ld_file_handle != PP_kInvalidFileHandle) | |
353 CloseFileHandle(ld_file_handle); | |
354 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, | |
355 "Link process could not be created: " + | |
356 error_info.message()); | |
357 return false; | 368 return false; |
358 } | 369 } |
370 ld_subprocess_.reset(ld_subprocess); | |
371 ld_subprocess = NULL; | |
bbudge
2014/06/02 16:58:04
This seems unnecessary, since it's a local and we'
| |
359 ld_subprocess_active_ = true; | 372 ld_subprocess_active_ = true; |
360 core->CallOnMainThread(0, | |
361 coordinator_->GetUMATimeCallback( | |
362 "NaCl.Perf.PNaClLoadTime.LoadLinker", | |
363 NaClGetTimeOfDayMicroseconds() - ld_start_time), | |
364 PP_OK); | |
365 } | 373 } |
366 | 374 |
367 int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); | 375 int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); |
368 // Run LD. | 376 // Run LD. |
369 bool success = ld_subprocess_->InvokeSrpcMethod( | 377 bool success = ld_subprocess_->InvokeSrpcMethod( |
370 "RunWithSplit", | 378 "RunWithSplit", |
371 "ihhhhhhhhhhhhhhhhh", | 379 "ihhhhhhhhhhhhhhhhh", |
372 ¶ms, | 380 ¶ms, |
373 static_cast<int>(obj_files_->size()), | 381 static_cast<int>(obj_files_->size()), |
374 ld_in_files[0]->desc(), | 382 ld_in_files[0]->desc(), |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 AbortSubprocesses(); | 457 AbortSubprocesses(); |
450 if (translate_thread_ != NULL) | 458 if (translate_thread_ != NULL) |
451 NaClThreadJoin(translate_thread_.get()); | 459 NaClThreadJoin(translate_thread_.get()); |
452 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 460 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
453 NaClCondVarDtor(&buffer_cond_); | 461 NaClCondVarDtor(&buffer_cond_); |
454 NaClMutexDtor(&cond_mu_); | 462 NaClMutexDtor(&cond_mu_); |
455 NaClMutexDtor(&subprocess_mu_); | 463 NaClMutexDtor(&subprocess_mu_); |
456 } | 464 } |
457 | 465 |
458 } // namespace plugin | 466 } // namespace plugin |
OLD | NEW |