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

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

Issue 331973002: Pepper: Move more UMA stuff out of trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix for dmichael 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
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 NaClSubprocess* llc_subprocess = plugin_->LoadHelperNaClModule( 167 NaClSubprocess* llc_subprocess = plugin_->LoadHelperNaClModule(
168 resources_->GetLlcUrl(), llc_file_handle, &error_info); 168 resources_->GetLlcUrl(), llc_file_handle, &error_info);
169 if (llc_subprocess == NULL) { 169 if (llc_subprocess == NULL) {
170 if (llc_file_handle != PP_kInvalidFileHandle) 170 if (llc_file_handle != PP_kInvalidFileHandle)
171 CloseFileHandle(llc_file_handle); 171 CloseFileHandle(llc_file_handle);
172 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP, 172 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP,
173 "Compile process could not be created: " + 173 "Compile process could not be created: " +
174 error_info.message()); 174 error_info.message());
175 return; 175 return;
176 } 176 }
177 core->CallOnMainThread(0, 177 GetNaClInterface()->LogTranslateTime(
178 coordinator_->GetUMATimeCallback( 178 "NaCl.Perf.PNaClLoadTime.LoadCompiler",
179 "NaCl.Perf.PNaClLoadTime.LoadCompiler", 179 NaClGetTimeOfDayMicroseconds() - llc_start_time);
180 NaClGetTimeOfDayMicroseconds() - llc_start_time),
181 PP_OK);
182 180
183 { 181 {
184 nacl::MutexLocker ml(&subprocess_mu_); 182 nacl::MutexLocker ml(&subprocess_mu_);
185 // If we received a call to AbortSubprocesses() before we had a chance to 183 // If we received a call to AbortSubprocesses() before we had a chance to
186 // set llc_subprocess_, shut down and clean up the subprocess started here. 184 // set llc_subprocess_, shut down and clean up the subprocess started here.
187 if (subprocesses_aborted_) { 185 if (subprocesses_aborted_) {
188 llc_subprocess->service_runtime()->Shutdown(); 186 llc_subprocess->service_runtime()->Shutdown();
189 delete llc_subprocess; 187 delete llc_subprocess;
190 return; 188 return;
191 } 189 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // The error string is only present if the error was sent back from llc. 292 // The error string is only present if the error was sent back from llc.
295 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 293 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
296 params.outs()[3]->arrays.str); 294 params.outs()[3]->arrays.str);
297 } else { 295 } else {
298 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 296 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
299 "Compile StreamEnd internal error"); 297 "Compile StreamEnd internal error");
300 } 298 }
301 return; 299 return;
302 } 300 }
303 compile_time_ = NaClGetTimeOfDayMicroseconds() - compile_start_time; 301 compile_time_ = NaClGetTimeOfDayMicroseconds() - compile_start_time;
304 core->CallOnMainThread(0, 302 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime",
305 coordinator_->GetUMATimeCallback( 303 compile_time_);
306 "NaCl.Perf.PNaClLoadTime.CompileTime",
307 compile_time_),
308 PP_OK);
309 304
310 // Shut down the llc subprocess. 305 // Shut down the llc subprocess.
311 NaClXMutexLock(&subprocess_mu_); 306 NaClXMutexLock(&subprocess_mu_);
312 llc_subprocess_active_ = false; 307 llc_subprocess_active_ = false;
313 llc_subprocess_.reset(NULL); 308 llc_subprocess_.reset(NULL);
314 NaClXMutexUnlock(&subprocess_mu_); 309 NaClXMutexUnlock(&subprocess_mu_);
315 310
316 if(!RunLdSubprocess()) { 311 if(!RunLdSubprocess()) {
317 return; 312 return;
318 } 313 }
(...skipping 12 matching lines...) Expand all
331 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, 326 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
332 "Link process could not reset object file"); 327 "Link process could not reset object file");
333 return false; 328 return false;
334 } 329 }
335 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); 330 ld_in_files.push_back((*obj_files_)[i]->read_wrapper());
336 } 331 }
337 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) 332 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++)
338 ld_in_files.push_back(invalid_desc_wrapper_); 333 ld_in_files.push_back(invalid_desc_wrapper_);
339 334
340 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); 335 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper();
341 pp::Core* core = pp::Module::Get()->core();
342 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); 336 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds();
343 PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle(); 337 PP_FileHandle ld_file_handle = resources_->TakeLdFileHandle();
344 // On success, ownership of ld_file_handle is transferred. 338 // On success, ownership of ld_file_handle is transferred.
345 nacl::scoped_ptr<NaClSubprocess> ld_subprocess( 339 nacl::scoped_ptr<NaClSubprocess> ld_subprocess(
346 plugin_->LoadHelperNaClModule(resources_->GetLlcUrl(), 340 plugin_->LoadHelperNaClModule(resources_->GetLlcUrl(),
347 ld_file_handle, 341 ld_file_handle,
348 &error_info)); 342 &error_info));
349 if (ld_subprocess.get() == NULL) { 343 if (ld_subprocess.get() == NULL) {
350 if (ld_file_handle != PP_kInvalidFileHandle) 344 if (ld_file_handle != PP_kInvalidFileHandle)
351 CloseFileHandle(ld_file_handle); 345 CloseFileHandle(ld_file_handle);
352 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, 346 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
353 "Link process could not be created: " + 347 "Link process could not be created: " +
354 error_info.message()); 348 error_info.message());
355 return false; 349 return false;
356 } 350 }
357 core->CallOnMainThread(0, 351 GetNaClInterface()->LogTranslateTime(
358 coordinator_->GetUMATimeCallback( 352 "NaCl.Perf.PNaClLoadTime.LoadLinker",
359 "NaCl.Perf.PNaClLoadTime.LoadLinker", 353 NaClGetTimeOfDayMicroseconds() - ld_start_time);
360 NaClGetTimeOfDayMicroseconds() - ld_start_time),
361 PP_OK);
362
363 { 354 {
364 nacl::MutexLocker ml(&subprocess_mu_); 355 nacl::MutexLocker ml(&subprocess_mu_);
365 // If we received a call to AbortSubprocesses() before we had a chance to 356 // If we received a call to AbortSubprocesses() before we had a chance to
366 // set llc_subprocess_, shut down and clean up the subprocess started here. 357 // set llc_subprocess_, shut down and clean up the subprocess started here.
367 if (subprocesses_aborted_) { 358 if (subprocesses_aborted_) {
368 ld_subprocess->service_runtime()->Shutdown(); 359 ld_subprocess->service_runtime()->Shutdown();
369 return false; 360 return false;
370 } 361 }
371 DCHECK(ld_subprocess_.get() == NULL); 362 DCHECK(ld_subprocess_.get() == NULL);
372 ld_subprocess_.swap(ld_subprocess); 363 ld_subprocess_.swap(ld_subprocess);
(...skipping 22 matching lines...) Expand all
395 ld_in_files[12]->desc(), 386 ld_in_files[12]->desc(),
396 ld_in_files[13]->desc(), 387 ld_in_files[13]->desc(),
397 ld_in_files[14]->desc(), 388 ld_in_files[14]->desc(),
398 ld_in_files[15]->desc(), 389 ld_in_files[15]->desc(),
399 ld_out_file->desc()); 390 ld_out_file->desc());
400 if (!success) { 391 if (!success) {
401 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, 392 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL,
402 "link failed."); 393 "link failed.");
403 return false; 394 return false;
404 } 395 }
405 core->CallOnMainThread(0, 396 GetNaClInterface()->LogTranslateTime(
406 coordinator_->GetUMATimeCallback( 397 "NaCl.Perf.PNaClLoadTime.LinkTime",
407 "NaCl.Perf.PNaClLoadTime.LinkTime", 398 NaClGetTimeOfDayMicroseconds() - link_start_time);
408 NaClGetTimeOfDayMicroseconds() - link_start_time),
409 PP_OK);
410 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", 399 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n",
411 this)); 400 this));
412 // Shut down the ld subprocess. 401 // Shut down the ld subprocess.
413 NaClXMutexLock(&subprocess_mu_); 402 NaClXMutexLock(&subprocess_mu_);
414 ld_subprocess_active_ = false; 403 ld_subprocess_active_ = false;
415 ld_subprocess_.reset(NULL); 404 ld_subprocess_.reset(NULL);
416 NaClXMutexUnlock(&subprocess_mu_); 405 NaClXMutexUnlock(&subprocess_mu_);
417 return true; 406 return true;
418 } 407 }
419 408
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 AbortSubprocesses(); 447 AbortSubprocesses();
459 if (translate_thread_ != NULL) 448 if (translate_thread_ != NULL)
460 NaClThreadJoin(translate_thread_.get()); 449 NaClThreadJoin(translate_thread_.get());
461 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); 450 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n"));
462 NaClCondVarDtor(&buffer_cond_); 451 NaClCondVarDtor(&buffer_cond_);
463 NaClMutexDtor(&cond_mu_); 452 NaClMutexDtor(&cond_mu_);
464 NaClMutexDtor(&subprocess_mu_); 453 NaClMutexDtor(&subprocess_mu_);
465 } 454 }
466 455
467 } // namespace plugin 456 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698