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_coordinator.h" | 5 #include "components/nacl/renderer/plugin/pnacl_coordinator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 | 365 |
366 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( | 366 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( |
367 int64_t bytes_compiled) { | 367 int64_t bytes_compiled) { |
368 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, | 368 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, |
369 bytes_compiled); | 369 bytes_compiled); |
370 } | 370 } |
371 | 371 |
372 void PnaclCoordinator::LoadCompiler() { | 372 void PnaclCoordinator::LoadCompiler() { |
373 PLUGIN_PRINTF(("PnaclCoordinator::LoadCompiler")); | 373 PLUGIN_PRINTF(("PnaclCoordinator::LoadCompiler")); |
374 int64_t compiler_load_start_time = NaClGetTimeOfDayMicroseconds(); | 374 base::TimeTicks compiler_load_start_time = base::TimeTicks::Now(); |
375 pp::CompletionCallback load_finished = callback_factory_.NewCallback( | 375 pp::CompletionCallback load_finished = callback_factory_.NewCallback( |
376 &PnaclCoordinator::RunCompile, compiler_load_start_time); | 376 &PnaclCoordinator::RunCompile, compiler_load_start_time); |
377 PnaclResources::ResourceType compiler_type = pnacl_options_.use_subzero | 377 PnaclResources::ResourceType compiler_type = pnacl_options_.use_subzero |
378 ? PnaclResources::SUBZERO | 378 ? PnaclResources::SUBZERO |
379 : PnaclResources::LLC; | 379 : PnaclResources::LLC; |
380 // Transfer file_info ownership to the sel_ldr launcher. | 380 // Transfer file_info ownership to the sel_ldr launcher. |
381 PP_NaClFileInfo file_info = resources_->TakeFileInfo(compiler_type); | 381 PP_NaClFileInfo file_info = resources_->TakeFileInfo(compiler_type); |
382 const std::string& url = resources_->GetUrl(compiler_type); | 382 const std::string& url = resources_->GetUrl(compiler_type); |
383 plugin_->LoadHelperNaClModule(url, file_info, &compiler_subprocess_, | 383 plugin_->LoadHelperNaClModule(url, file_info, &compiler_subprocess_, |
384 load_finished); | 384 load_finished); |
385 } | 385 } |
386 | 386 |
387 void PnaclCoordinator::RunCompile(int32_t pp_error, | 387 void PnaclCoordinator::RunCompile(int32_t pp_error, |
388 int64_t compiler_load_start_time) { | 388 base::TimeTicks compiler_load_start_time) { |
389 PLUGIN_PRINTF( | 389 PLUGIN_PRINTF( |
390 ("PnaclCoordinator::RunCompile (pp_error=%" NACL_PRId32 ")\n", pp_error)); | 390 ("PnaclCoordinator::RunCompile (pp_error=%" NACL_PRId32 ")\n", pp_error)); |
391 if (pp_error != PP_OK) { | 391 if (pp_error != PP_OK) { |
392 ReportNonPpapiError( | 392 ReportNonPpapiError( |
393 PP_NACL_ERROR_PNACL_LLC_SETUP, | 393 PP_NACL_ERROR_PNACL_LLC_SETUP, |
394 "PnaclCoordinator: Compiler process could not be created."); | 394 "PnaclCoordinator: Compiler process could not be created."); |
395 return; | 395 return; |
396 } | 396 } |
397 int64_t compiler_load_time_total = | 397 int64_t compiler_load_time_total = |
398 NaClGetTimeOfDayMicroseconds() - compiler_load_start_time; | 398 (base::TimeTicks::Now() - compiler_load_start_time).InMicroseconds(); |
399 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler", | 399 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.LoadCompiler", |
400 compiler_load_time_total); | 400 compiler_load_time_total); |
401 GetNaClInterface()->LogTranslateTime( | 401 GetNaClInterface()->LogTranslateTime( |
402 pnacl_options_.use_subzero | 402 pnacl_options_.use_subzero |
403 ? "NaCl.Perf.PNaClLoadTime.LoadCompiler.Subzero" | 403 ? "NaCl.Perf.PNaClLoadTime.LoadCompiler.Subzero" |
404 : "NaCl.Perf.PNaClLoadTime.LoadCompiler.LLC", | 404 : "NaCl.Perf.PNaClLoadTime.LoadCompiler.LLC", |
405 compiler_load_time_total); | 405 compiler_load_time_total); |
406 | 406 |
407 // Invoke llc followed by ld off the main thread. This allows use of | 407 // Invoke llc followed by ld off the main thread. This allows use of |
408 // blocking RPCs that would otherwise block the JavaScript main thread. | 408 // blocking RPCs that would otherwise block the JavaScript main thread. |
(...skipping 12 matching lines...) Expand all Loading... |
421 void PnaclCoordinator::LoadLinker(int32_t pp_error) { | 421 void PnaclCoordinator::LoadLinker(int32_t pp_error) { |
422 PLUGIN_PRINTF( | 422 PLUGIN_PRINTF( |
423 ("PnaclCoordinator::LoadLinker (pp_error=%" NACL_PRId32 ")\n", pp_error)); | 423 ("PnaclCoordinator::LoadLinker (pp_error=%" NACL_PRId32 ")\n", pp_error)); |
424 // Errors in the previous step would have skipped to TranslateFinished | 424 // Errors in the previous step would have skipped to TranslateFinished |
425 // so we only expect PP_OK here. | 425 // so we only expect PP_OK here. |
426 DCHECK(pp_error == PP_OK); | 426 DCHECK(pp_error == PP_OK); |
427 if (pp_error != PP_OK) { | 427 if (pp_error != PP_OK) { |
428 return; | 428 return; |
429 } | 429 } |
430 ErrorInfo error_info; | 430 ErrorInfo error_info; |
431 int64_t ld_load_start_time = NaClGetTimeOfDayMicroseconds(); | 431 base::TimeTicks ld_load_start_time = base::TimeTicks::Now(); |
432 pp::CompletionCallback load_finished = callback_factory_.NewCallback( | 432 pp::CompletionCallback load_finished = callback_factory_.NewCallback( |
433 &PnaclCoordinator::RunLink, ld_load_start_time); | 433 &PnaclCoordinator::RunLink, ld_load_start_time); |
434 // Transfer file_info ownership to the sel_ldr launcher. | 434 // Transfer file_info ownership to the sel_ldr launcher. |
435 PP_NaClFileInfo ld_file_info = resources_->TakeFileInfo(PnaclResources::LD); | 435 PP_NaClFileInfo ld_file_info = resources_->TakeFileInfo(PnaclResources::LD); |
436 plugin_->LoadHelperNaClModule(resources_->GetUrl(PnaclResources::LD), | 436 plugin_->LoadHelperNaClModule(resources_->GetUrl(PnaclResources::LD), |
437 ld_file_info, &ld_subprocess_, load_finished); | 437 ld_file_info, &ld_subprocess_, load_finished); |
438 } | 438 } |
439 | 439 |
440 void PnaclCoordinator::RunLink(int32_t pp_error, int64_t ld_load_start_time) { | 440 void PnaclCoordinator::RunLink(int32_t pp_error, |
| 441 base::TimeTicks ld_load_start_time) { |
441 PLUGIN_PRINTF( | 442 PLUGIN_PRINTF( |
442 ("PnaclCoordinator::RunLink (pp_error=%" NACL_PRId32 ")\n", pp_error)); | 443 ("PnaclCoordinator::RunLink (pp_error=%" NACL_PRId32 ")\n", pp_error)); |
443 if (pp_error != PP_OK) { | 444 if (pp_error != PP_OK) { |
444 ReportNonPpapiError( | 445 ReportNonPpapiError( |
445 PP_NACL_ERROR_PNACL_LD_SETUP, | 446 PP_NACL_ERROR_PNACL_LD_SETUP, |
446 "PnaclCoordinator: Linker process could not be created."); | 447 "PnaclCoordinator: Linker process could not be created."); |
447 return; | 448 return; |
448 } | 449 } |
449 GetNaClInterface()->LogTranslateTime( | 450 GetNaClInterface()->LogTranslateTime( |
450 "NaCl.Perf.PNaClLoadTime.LoadLinker", | 451 "NaCl.Perf.PNaClLoadTime.LoadLinker", |
451 NaClGetTimeOfDayMicroseconds() - ld_load_start_time); | 452 (base::TimeTicks::Now() - ld_load_start_time).InMicroseconds()); |
452 translate_thread_->RunLink(); | 453 translate_thread_->RunLink(); |
453 } | 454 } |
454 | 455 |
455 } // namespace plugin | 456 } // namespace plugin |
OLD | NEW |