Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc

Issue 308193004: Pepper: Narrow locking at ld subprocess start. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add DCHECK Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 nacl::scoped_ptr<NaClSubprocess> ld_subprocess(
346 plugin_->LoadHelperNaClModule(resources_->GetLlcUrl(),
347 ld_file_handle,
348 &error_info));
349 if (ld_subprocess.get() == NULL) {
350 if (ld_file_handle != PP_kInvalidFileHandle)
351 CloseFileHandle(ld_file_handle);
352 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
353 "Link process could not be created: " +
354 error_info.message());
355 return false;
356 }
357 core->CallOnMainThread(0,
358 coordinator_->GetUMATimeCallback(
359 "NaCl.Perf.PNaClLoadTime.LoadLinker",
360 NaClGetTimeOfDayMicroseconds() - ld_start_time),
361 PP_OK);
362
342 { 363 {
343 // Create LD process
344 nacl::MutexLocker ml(&subprocess_mu_); 364 nacl::MutexLocker ml(&subprocess_mu_);
345 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); 365 // If we received a call to AbortSubprocesses() before we had a chance to
346 PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle(); 366 // set llc_subprocess_, shut down and clean up the subprocess started here.
347 367 if (subprocesses_aborted_) {
348 // On success, ownership of ld_file_handle is transferred. 368 ld_subprocess->service_runtime()->Shutdown();
349 ld_subprocess_.reset(plugin_->LoadHelperNaClModule(
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; 369 return false;
358 } 370 }
371 DCHECK(ld_subprocess_.get() == NULL);
372 ld_subprocess_.swap(ld_subprocess);
359 ld_subprocess_active_ = true; 373 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 } 374 }
366 375
367 int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); 376 int64_t link_start_time = NaClGetTimeOfDayMicroseconds();
368 // Run LD. 377 // Run LD.
369 bool success = ld_subprocess_->InvokeSrpcMethod( 378 bool success = ld_subprocess_->InvokeSrpcMethod(
370 "RunWithSplit", 379 "RunWithSplit",
371 "ihhhhhhhhhhhhhhhhh", 380 "ihhhhhhhhhhhhhhhhh",
372 &params, 381 &params,
373 static_cast<int>(obj_files_->size()), 382 static_cast<int>(obj_files_->size()),
374 ld_in_files[0]->desc(), 383 ld_in_files[0]->desc(),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 AbortSubprocesses(); 458 AbortSubprocesses();
450 if (translate_thread_ != NULL) 459 if (translate_thread_ != NULL)
451 NaClThreadJoin(translate_thread_.get()); 460 NaClThreadJoin(translate_thread_.get());
452 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); 461 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n"));
453 NaClCondVarDtor(&buffer_cond_); 462 NaClCondVarDtor(&buffer_cond_);
454 NaClMutexDtor(&cond_mu_); 463 NaClMutexDtor(&cond_mu_);
455 NaClMutexDtor(&subprocess_mu_); 464 NaClMutexDtor(&subprocess_mu_);
456 } 465 }
457 466
458 } // namespace plugin 467 } // namespace plugin
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698