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/pnacl_resources.h" | 9 #include "native_client/src/trusted/plugin/pnacl_resources.h" |
10 #include "native_client/src/trusted/plugin/srpc_params.h" | 10 #include "native_client/src/trusted/plugin/srpc_params.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 NaClXMutexCtor(&subprocess_mu_); | 26 NaClXMutexCtor(&subprocess_mu_); |
27 NaClXMutexCtor(&cond_mu_); | 27 NaClXMutexCtor(&cond_mu_); |
28 NaClXCondVarCtor(&buffer_cond_); | 28 NaClXCondVarCtor(&buffer_cond_); |
29 } | 29 } |
30 | 30 |
31 void PnaclTranslateThread::RunTranslate( | 31 void PnaclTranslateThread::RunTranslate( |
32 const pp::CompletionCallback& finish_callback, | 32 const pp::CompletionCallback& finish_callback, |
33 const Manifest* manifest, | 33 const Manifest* manifest, |
34 const Manifest* ld_manifest, | 34 const Manifest* ld_manifest, |
35 TempFile* obj_file, | 35 TempFile* obj_file, |
36 LocalTempFile* nexe_file, | 36 TempFile* nexe_file, |
37 ErrorInfo* error_info, | 37 ErrorInfo* error_info, |
38 PnaclResources* resources, | 38 PnaclResources* resources, |
39 Plugin* plugin) { | 39 Plugin* plugin) { |
40 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); | 40 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); |
41 manifest_ = manifest; | 41 manifest_ = manifest; |
42 ld_manifest_ = ld_manifest; | 42 ld_manifest_ = ld_manifest; |
43 obj_file_ = obj_file; | 43 obj_file_ = obj_file; |
44 nexe_file_ = nexe_file; | 44 nexe_file_ = nexe_file; |
45 coordinator_error_info_ = error_info; | 45 coordinator_error_info_ = error_info; |
46 resources_ = resources; | 46 resources_ = resources; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 void WINAPI PnaclTranslateThread::DoTranslateThread(void* arg) { | 117 void WINAPI PnaclTranslateThread::DoTranslateThread(void* arg) { |
118 PnaclTranslateThread* translator = | 118 PnaclTranslateThread* translator = |
119 reinterpret_cast<PnaclTranslateThread*>(arg); | 119 reinterpret_cast<PnaclTranslateThread*>(arg); |
120 translator->DoTranslate(); | 120 translator->DoTranslate(); |
121 } | 121 } |
122 | 122 |
123 void PnaclTranslateThread::DoTranslate() { | 123 void PnaclTranslateThread::DoTranslate() { |
124 ErrorInfo error_info; | 124 ErrorInfo error_info; |
125 SrpcParams params; | 125 SrpcParams params; |
126 nacl::DescWrapper* llc_out_file = obj_file_->get_wrapper(); | 126 nacl::DescWrapper* llc_out_file = obj_file_->write_wrapper(); |
127 | 127 |
128 { | 128 { |
129 nacl::MutexLocker ml(&subprocess_mu_); | 129 nacl::MutexLocker ml(&subprocess_mu_); |
130 llc_subprocess_.reset( | 130 llc_subprocess_.reset( |
131 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); | 131 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); |
132 if (llc_subprocess_ == NULL) { | 132 if (llc_subprocess_ == NULL) { |
133 TranslateFailed("Compile process could not be created: " + | 133 TranslateFailed("Compile process could not be created: " + |
134 error_info.message()); | 134 error_info.message()); |
135 return; | 135 return; |
136 } | 136 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 const nacl::string& soname, | 226 const nacl::string& soname, |
227 const nacl::string& lib_dependencies | 227 const nacl::string& lib_dependencies |
228 ) { | 228 ) { |
229 ErrorInfo error_info; | 229 ErrorInfo error_info; |
230 SrpcParams params; | 230 SrpcParams params; |
231 // Reset object file for reading first. | 231 // Reset object file for reading first. |
232 if (!obj_file_->Reset()) { | 232 if (!obj_file_->Reset()) { |
233 TranslateFailed("Link process could not reset object file"); | 233 TranslateFailed("Link process could not reset object file"); |
234 return false; | 234 return false; |
235 } | 235 } |
236 nacl::DescWrapper* ld_in_file = obj_file_->get_wrapper(); | 236 nacl::DescWrapper* ld_in_file = obj_file_->read_wrapper(); |
237 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); | 237 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); |
238 | 238 |
239 { | 239 { |
240 // Create LD process | 240 // Create LD process |
241 nacl::MutexLocker ml(&subprocess_mu_); | 241 nacl::MutexLocker ml(&subprocess_mu_); |
242 ld_subprocess_.reset( | 242 ld_subprocess_.reset( |
243 StartSubprocess(PnaclUrls::GetLdUrl(), ld_manifest_, &error_info)); | 243 StartSubprocess(PnaclUrls::GetLdUrl(), ld_manifest_, &error_info)); |
244 if (ld_subprocess_ == NULL) { | 244 if (ld_subprocess_ == NULL) { |
245 TranslateFailed("Link process could not be created: " + | 245 TranslateFailed("Link process could not be created: " + |
246 error_info.message()); | 246 error_info.message()); |
247 return false; | 247 return false; |
248 } | 248 } |
249 ld_subprocess_active_ = true; | 249 ld_subprocess_active_ = true; |
250 PluginReverseInterface* ld_reverse = | 250 PluginReverseInterface* ld_reverse = |
251 ld_subprocess_->service_runtime()->rev_interface(); | 251 ld_subprocess_->service_runtime()->rev_interface(); |
252 ld_reverse->AddQuotaManagedFile(nexe_file_->identifier(), | 252 ld_reverse->AddTempQuotaManagedFile(nexe_file_->identifier()); |
253 nexe_file_->write_file_io()); | |
254 } | 253 } |
255 // Run LD. | 254 // Run LD. |
256 if (!ld_subprocess_->InvokeSrpcMethod("RunWithDefaultCommandLine", | 255 if (!ld_subprocess_->InvokeSrpcMethod("RunWithDefaultCommandLine", |
257 "hhiss", | 256 "hhiss", |
258 ¶ms, | 257 ¶ms, |
259 ld_in_file->desc(), | 258 ld_in_file->desc(), |
260 ld_out_file->desc(), | 259 ld_out_file->desc(), |
261 is_shared_library, | 260 is_shared_library, |
262 soname.c_str(), | 261 soname.c_str(), |
263 lib_dependencies.c_str())) { | 262 lib_dependencies.c_str())) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); | 310 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); |
312 AbortSubprocesses(); | 311 AbortSubprocesses(); |
313 NaClThreadJoin(translate_thread_.get()); | 312 NaClThreadJoin(translate_thread_.get()); |
314 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 313 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
315 NaClCondVarDtor(&buffer_cond_); | 314 NaClCondVarDtor(&buffer_cond_); |
316 NaClMutexDtor(&cond_mu_); | 315 NaClMutexDtor(&cond_mu_); |
317 NaClMutexDtor(&subprocess_mu_); | 316 NaClMutexDtor(&subprocess_mu_); |
318 } | 317 } |
319 | 318 |
320 } // namespace plugin | 319 } // namespace plugin |
OLD | NEW |