Chromium Code Reviews| Index: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
| diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
| index 9e96f0d77a7fcf153131818409d3cd5d10c3d075..d7b31485d78e9c7f5753868152ae6e251828254a 100644 |
| --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
| +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc |
| @@ -200,6 +200,10 @@ PnaclCoordinator* PnaclCoordinator::BitcodeToNative( |
| PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, ", |
| reinterpret_cast<const void*>(coordinator->manifest_.get()))); |
| + int cpus = plugin->nacl_interface()->GetNumberOfProcessors(); |
| + coordinator->split_module_count_ = std::min(4, cpus); |
|
jvoung (off chromium)
2014/02/14 00:46:49
Maybe clamp to >= 1. Looks like the unittest of im
Derek Schuff
2014/02/14 01:01:51
Done.
|
| + fprintf(stderr, "processors %d, modules %d\n", cpus, coordinator->split_module_count_); |
| + |
| // First start a network request for the pexe, to tickle the component |
| // updater's On-Demand resource throttler, and to get Last-Modified/ETag |
| // cache information. We can cancel the request later if there's |
| @@ -220,6 +224,7 @@ PnaclCoordinator::PnaclCoordinator( |
| manifest_(new PnaclManifest()), |
| pexe_url_(pexe_url), |
| pnacl_options_(pnacl_options), |
| + num_object_files_opened_(0), |
|
jvoung (off chromium)
2014/02/14 00:46:49
Initialize split_module_count_(0) or to 1 in const
Derek Schuff
2014/02/14 01:01:51
Done.
|
| is_cache_hit_(PP_FALSE), |
| error_already_reported_(false), |
| pnacl_init_time_(0), |
| @@ -248,6 +253,9 @@ PnaclCoordinator::~PnaclCoordinator() { |
| plugin_->pp_instance(), |
| PP_FALSE); |
| } |
| + for (int i = 0; i < num_object_files_opened_; i++) { |
| + delete obj_files_[i]; |
| + } |
| } |
| nacl::DescWrapper* PnaclCoordinator::ReleaseTranslatedFD() { |
| @@ -531,10 +539,13 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) { |
| } else { |
| // Open an object file first so the translator can start writing to it |
| // during streaming translation. |
| - obj_file_.reset(new TempFile(plugin_)); |
| - pp::CompletionCallback obj_cb = |
| - callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen); |
| - obj_file_->Open(obj_cb, true); |
| + for (int i = 0; i < split_module_count_; i++) { |
| + obj_files_.push_back(new TempFile(plugin_)); |
| + |
| + pp::CompletionCallback obj_cb = |
| + callback_factory_.NewCallback(&PnaclCoordinator::ObjectFileDidOpen); |
| + obj_files_[i]->Open(obj_cb, true); |
| + } |
| // Meanwhile, a miss means we know we need to stream the bitcode, so stream |
| // the rest of it now. (Calling FinishStreaming means that the downloader |
| @@ -643,11 +654,14 @@ void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { |
| "Failed to open scratch object file."); |
| return; |
| } |
| - // Open the nexe file for connecting ld and sel_ldr. |
| - // Start translation when done with this last step of setup! |
| - pp::CompletionCallback cb = |
| - callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); |
| - temp_nexe_file_->Open(cb, true); |
| + num_object_files_opened_++; |
| + if (num_object_files_opened_ == split_module_count_) { |
| + // Open the nexe file for connecting ld and sel_ldr. |
| + // Start translation when done with this last step of setup! |
| + pp::CompletionCallback cb = |
| + callback_factory_.NewCallback(&PnaclCoordinator::RunTranslate); |
| + temp_nexe_file_->Open(cb, true); |
| + } |
| } |
| void PnaclCoordinator::RunTranslate(int32_t pp_error) { |
| @@ -661,7 +675,7 @@ void PnaclCoordinator::RunTranslate(int32_t pp_error) { |
| CHECK(translate_thread_ != NULL); |
| translate_thread_->RunTranslate(report_translate_finished, |
| manifest_.get(), |
| - obj_file_.get(), |
| + &obj_files_, |
| temp_nexe_file_.get(), |
| &error_info_, |
| resources_.get(), |