| 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 "native_client/src/trusted/plugin/pnacl_translate_thread.h" | 5 #include "native_client/src/trusted/plugin/pnacl_translate_thread.h" |
| 6 | 6 |
| 7 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" | 7 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" |
| 8 #include "native_client/src/trusted/plugin/plugin.h" | 8 #include "native_client/src/trusted/plugin/plugin.h" |
| 9 #include "native_client/src/trusted/plugin/plugin_error.h" | 9 #include "native_client/src/trusted/plugin/plugin_error.h" |
| 10 #include "native_client/src/trusted/plugin/pnacl_resources.h" | 10 #include "native_client/src/trusted/plugin/pnacl_resources.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 void PnaclTranslateThread::RunTranslate( | 34 void PnaclTranslateThread::RunTranslate( |
| 35 const pp::CompletionCallback& finish_callback, | 35 const pp::CompletionCallback& finish_callback, |
| 36 const Manifest* manifest, | 36 const Manifest* manifest, |
| 37 const Manifest* ld_manifest, | 37 const Manifest* ld_manifest, |
| 38 TempFile* obj_file, | 38 TempFile* obj_file, |
| 39 TempFile* nexe_file, | 39 TempFile* nexe_file, |
| 40 ErrorInfo* error_info, | 40 ErrorInfo* error_info, |
| 41 PnaclResources* resources, | 41 PnaclResources* resources, |
| 42 PnaclOptions* pnacl_options, |
| 42 PnaclCoordinator* coordinator, | 43 PnaclCoordinator* coordinator, |
| 43 Plugin* plugin) { | 44 Plugin* plugin) { |
| 44 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); | 45 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); |
| 45 manifest_ = manifest; | 46 manifest_ = manifest; |
| 46 ld_manifest_ = ld_manifest; | 47 ld_manifest_ = ld_manifest; |
| 47 obj_file_ = obj_file; | 48 obj_file_ = obj_file; |
| 48 nexe_file_ = nexe_file; | 49 nexe_file_ = nexe_file; |
| 49 coordinator_error_info_ = error_info; | 50 coordinator_error_info_ = error_info; |
| 50 resources_ = resources; | 51 resources_ = resources; |
| 52 pnacl_options_ = pnacl_options; |
| 51 coordinator_ = coordinator; | 53 coordinator_ = coordinator; |
| 52 plugin_ = plugin; | 54 plugin_ = plugin; |
| 53 | 55 |
| 54 // Invoke llc followed by ld off the main thread. This allows use of | 56 // Invoke llc followed by ld off the main thread. This allows use of |
| 55 // blocking RPCs that would otherwise block the JavaScript main thread. | 57 // blocking RPCs that would otherwise block the JavaScript main thread. |
| 56 report_translate_finished_ = finish_callback; | 58 report_translate_finished_ = finish_callback; |
| 57 translate_thread_.reset(new NaClThread); | 59 translate_thread_.reset(new NaClThread); |
| 58 if (translate_thread_ == NULL) { | 60 if (translate_thread_ == NULL) { |
| 59 TranslateFailed(ERROR_PNACL_THREAD_CREATE, | 61 TranslateFailed(ERROR_PNACL_THREAD_CREATE, |
| 60 "could not allocate thread struct."); | 62 "could not allocate thread struct."); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 llc_subprocess_active_ = true; | 148 llc_subprocess_active_ = true; |
| 147 time_stats_.pnacl_llc_load_time = | 149 time_stats_.pnacl_llc_load_time = |
| 148 (NaClGetTimeOfDayMicroseconds() - llc_start_time); | 150 (NaClGetTimeOfDayMicroseconds() - llc_start_time); |
| 149 // Run LLC. | 151 // Run LLC. |
| 150 PluginReverseInterface* llc_reverse = | 152 PluginReverseInterface* llc_reverse = |
| 151 llc_subprocess_->service_runtime()->rev_interface(); | 153 llc_subprocess_->service_runtime()->rev_interface(); |
| 152 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); | 154 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); |
| 153 } | 155 } |
| 154 | 156 |
| 155 int64_t compile_start_time = NaClGetTimeOfDayMicroseconds(); | 157 int64_t compile_start_time = NaClGetTimeOfDayMicroseconds(); |
| 156 if (!llc_subprocess_->InvokeSrpcMethod("StreamInit", | 158 bool init_success; |
| 157 "h", | 159 if (pnacl_options_->HasDefaultOpts()) { |
| 158 ¶ms, | 160 PLUGIN_PRINTF(("PnaclCoordinator: StreamInit with default options\n")); |
| 159 llc_out_file->desc())) { | 161 init_success = llc_subprocess_->InvokeSrpcMethod("StreamInit", |
| 162 "h", |
| 163 ¶ms, |
| 164 llc_out_file->desc()); |
| 165 } else { |
| 166 std::vector<char> options = pnacl_options_->GetOptCommandline(); |
| 167 init_success = llc_subprocess_->InvokeSrpcMethod( |
| 168 "StreamInitWithOverrides", |
| 169 "hC", |
| 170 ¶ms, |
| 171 llc_out_file->desc(), |
| 172 &options[0], |
| 173 options.size()); |
| 174 } |
| 175 |
| 176 if (!init_success) { |
| 160 if (llc_subprocess_->srpc_client()->GetLastError() == | 177 if (llc_subprocess_->srpc_client()->GetLastError() == |
| 161 NACL_SRPC_RESULT_APP_ERROR) { | 178 NACL_SRPC_RESULT_APP_ERROR) { |
| 162 // The error message is only present if the error was returned from llc | 179 // The error message is only present if the error was returned from llc |
| 163 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, | 180 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, |
| 164 nacl::string("Stream init failed: ") + | 181 nacl::string("Stream init failed: ") + |
| 165 nacl::string(params.outs()[0]->arrays.str)); | 182 nacl::string(params.outs()[0]->arrays.str)); |
| 166 } else { | 183 } else { |
| 167 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, | 184 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, |
| 168 "Stream init internal error"); | 185 "Stream init internal error"); |
| 169 } | 186 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); | 363 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); |
| 347 AbortSubprocesses(); | 364 AbortSubprocesses(); |
| 348 NaClThreadJoin(translate_thread_.get()); | 365 NaClThreadJoin(translate_thread_.get()); |
| 349 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 366 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
| 350 NaClCondVarDtor(&buffer_cond_); | 367 NaClCondVarDtor(&buffer_cond_); |
| 351 NaClMutexDtor(&cond_mu_); | 368 NaClMutexDtor(&cond_mu_); |
| 352 NaClMutexDtor(&subprocess_mu_); | 369 NaClMutexDtor(&subprocess_mu_); |
| 353 } | 370 } |
| 354 | 371 |
| 355 } // namespace plugin | 372 } // namespace plugin |
| OLD | NEW |