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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <iterator> | 9 #include <iterator> |
10 #include <sstream> | 10 #include <sstream> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/time/time.h" |
13 #include "components/nacl/renderer/plugin/plugin.h" | 14 #include "components/nacl/renderer/plugin/plugin.h" |
14 #include "components/nacl/renderer/plugin/plugin_error.h" | 15 #include "components/nacl/renderer/plugin/plugin_error.h" |
15 #include "components/nacl/renderer/plugin/utility.h" | 16 #include "components/nacl/renderer/plugin/utility.h" |
16 #include "content/public/common/sandbox_init.h" | 17 #include "content/public/common/sandbox_init.h" |
17 #include "ppapi/c/ppb_file_io.h" | 18 #include "ppapi/c/ppb_file_io.h" |
18 #include "ppapi/cpp/var.h" | 19 #include "ppapi/cpp/var.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 20 #include "ppapi/proxy/ppapi_messages.h" |
20 | 21 |
21 namespace plugin { | 22 namespace plugin { |
22 namespace { | 23 namespace { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 std::vector<ppapi::proxy::SerializedHandle> compiler_output_files; | 208 std::vector<ppapi::proxy::SerializedHandle> compiler_output_files; |
208 for (base::File& obj_file : *obj_files_) { | 209 for (base::File& obj_file : *obj_files_) { |
209 compiler_output_files.push_back( | 210 compiler_output_files.push_back( |
210 GetHandleForSubprocess(&obj_file, PP_FILEOPENFLAG_WRITE, | 211 GetHandleForSubprocess(&obj_file, PP_FILEOPENFLAG_WRITE, |
211 compiler_channel_peer_pid_)); | 212 compiler_channel_peer_pid_)); |
212 } | 213 } |
213 | 214 |
214 PLUGIN_PRINTF(("DoCompile using subzero: %d\n", pnacl_options_->use_subzero)); | 215 PLUGIN_PRINTF(("DoCompile using subzero: %d\n", pnacl_options_->use_subzero)); |
215 | 216 |
216 pp::Core* core = pp::Module::Get()->core(); | 217 pp::Core* core = pp::Module::Get()->core(); |
217 int64_t do_compile_start_time = NaClGetTimeOfDayMicroseconds(); | 218 base::TimeTicks do_compile_start_time = base::TimeTicks::Now(); |
218 | 219 |
219 std::vector<std::string> args; | 220 std::vector<std::string> args; |
220 if (pnacl_options_->use_subzero) { | 221 if (pnacl_options_->use_subzero) { |
221 GetSubzeroCommandLine(&args, pnacl_options_->opt_level, | 222 GetSubzeroCommandLine(&args, pnacl_options_->opt_level, |
222 PP_ToBool(pnacl_options_->is_debug), | 223 PP_ToBool(pnacl_options_->is_debug), |
223 architecture_attributes_); | 224 architecture_attributes_); |
224 } else { | 225 } else { |
225 GetLlcCommandLine(&args, obj_files_->size(), | 226 GetLlcCommandLine(&args, obj_files_->size(), |
226 pnacl_options_->opt_level, | 227 pnacl_options_->opt_level, |
227 PP_ToBool(pnacl_options_->is_debug), | 228 PP_ToBool(pnacl_options_->is_debug), |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, | 294 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, |
294 "Compile stream end failed: " | 295 "Compile stream end failed: " |
295 "reply not received from PNaCl translator " | 296 "reply not received from PNaCl translator " |
296 "(it probably crashed)"); | 297 "(it probably crashed)"); |
297 return; | 298 return; |
298 } | 299 } |
299 if (!success) { | 300 if (!success) { |
300 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, error_str); | 301 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, error_str); |
301 return; | 302 return; |
302 } | 303 } |
303 compile_time_ = NaClGetTimeOfDayMicroseconds() - do_compile_start_time; | 304 compile_time_ = |
| 305 (base::TimeTicks::Now() - do_compile_start_time).InMicroseconds(); |
304 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime", | 306 GetNaClInterface()->LogTranslateTime("NaCl.Perf.PNaClLoadTime.CompileTime", |
305 compile_time_); | 307 compile_time_); |
306 GetNaClInterface()->LogTranslateTime( | 308 GetNaClInterface()->LogTranslateTime( |
307 pnacl_options_->use_subzero | 309 pnacl_options_->use_subzero |
308 ? "NaCl.Perf.PNaClLoadTime.CompileTime.Subzero" | 310 ? "NaCl.Perf.PNaClLoadTime.CompileTime.Subzero" |
309 : "NaCl.Perf.PNaClLoadTime.CompileTime.LLC", | 311 : "NaCl.Perf.PNaClLoadTime.CompileTime.LLC", |
310 compile_time_); | 312 compile_time_); |
311 | 313 |
312 // Shut down the compiler subprocess. | 314 // Shut down the compiler subprocess. |
313 { | 315 { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 ppapi::proxy::SerializedHandle nexe_file = | 348 ppapi::proxy::SerializedHandle nexe_file = |
347 GetHandleForSubprocess(nexe_file_, PP_FILEOPENFLAG_WRITE, | 349 GetHandleForSubprocess(nexe_file_, PP_FILEOPENFLAG_WRITE, |
348 ld_channel_peer_pid_); | 350 ld_channel_peer_pid_); |
349 std::vector<ppapi::proxy::SerializedHandle> ld_input_files; | 351 std::vector<ppapi::proxy::SerializedHandle> ld_input_files; |
350 for (base::File& obj_file : *obj_files_) { | 352 for (base::File& obj_file : *obj_files_) { |
351 ld_input_files.push_back( | 353 ld_input_files.push_back( |
352 GetHandleForSubprocess(&obj_file, PP_FILEOPENFLAG_READ, | 354 GetHandleForSubprocess(&obj_file, PP_FILEOPENFLAG_READ, |
353 ld_channel_peer_pid_)); | 355 ld_channel_peer_pid_)); |
354 } | 356 } |
355 | 357 |
356 int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); | 358 base::TimeTicks link_start_time = base::TimeTicks::Now(); |
357 bool success = false; | 359 bool success = false; |
358 bool sent = ld_channel_filter_->Send( | 360 bool sent = ld_channel_filter_->Send( |
359 new PpapiMsg_PnaclTranslatorLink(ld_input_files, nexe_file, &success)); | 361 new PpapiMsg_PnaclTranslatorLink(ld_input_files, nexe_file, &success)); |
360 if (!sent) { | 362 if (!sent) { |
361 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, | 363 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, |
362 "link failed: reply not received from linker."); | 364 "link failed: reply not received from linker."); |
363 return; | 365 return; |
364 } | 366 } |
365 if (!success) { | 367 if (!success) { |
366 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, | 368 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, |
367 "link failed: linker returned failure status."); | 369 "link failed: linker returned failure status."); |
368 return; | 370 return; |
369 } | 371 } |
370 | 372 |
371 GetNaClInterface()->LogTranslateTime( | 373 GetNaClInterface()->LogTranslateTime( |
372 "NaCl.Perf.PNaClLoadTime.LinkTime", | 374 "NaCl.Perf.PNaClLoadTime.LinkTime", |
373 NaClGetTimeOfDayMicroseconds() - link_start_time); | 375 (base::TimeTicks::Now() - link_start_time).InMicroseconds()); |
374 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", | 376 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", |
375 this)); | 377 this)); |
376 | 378 |
377 // Shut down the ld subprocess. | 379 // Shut down the ld subprocess. |
378 { | 380 { |
379 base::AutoLock lock(subprocess_mu_); | 381 base::AutoLock lock(subprocess_mu_); |
380 ld_subprocess_active_ = false; | 382 ld_subprocess_active_ = false; |
381 ld_subprocess_->Shutdown(); | 383 ld_subprocess_->Shutdown(); |
382 } | 384 } |
383 | 385 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 428 |
427 PnaclTranslateThread::~PnaclTranslateThread() { | 429 PnaclTranslateThread::~PnaclTranslateThread() { |
428 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); | 430 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); |
429 AbortSubprocesses(); | 431 AbortSubprocesses(); |
430 if (translate_thread_) | 432 if (translate_thread_) |
431 translate_thread_->Join(); | 433 translate_thread_->Join(); |
432 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 434 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
433 } | 435 } |
434 | 436 |
435 } // namespace plugin | 437 } // namespace plugin |
OLD | NEW |