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 TempFile* nexe_file, | 36 LocalTempFile* 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 ErrorInfo error_info; | 124 ErrorInfo error_info; |
125 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( | 125 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( |
126 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); | 126 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); |
127 if (llc_subprocess == NULL) { | 127 if (llc_subprocess == NULL) { |
128 TranslateFailed("Compile process could not be created: " + | 128 TranslateFailed("Compile process could not be created: " + |
129 error_info.message()); | 129 error_info.message()); |
130 return; | 130 return; |
131 } | 131 } |
132 // Run LLC. | 132 // Run LLC. |
133 SrpcParams params; | 133 SrpcParams params; |
134 nacl::DescWrapper* llc_out_file = obj_file_->write_wrapper(); | 134 nacl::DescWrapper* llc_out_file = obj_file_->get_wrapper(); |
135 PluginReverseInterface* llc_reverse = | 135 PluginReverseInterface* llc_reverse = |
136 llc_subprocess->service_runtime()->rev_interface(); | 136 llc_subprocess->service_runtime()->rev_interface(); |
137 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); | 137 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); |
138 RegisterReverseInterface(llc_reverse); | 138 RegisterReverseInterface(llc_reverse); |
139 | 139 |
140 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", | 140 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", |
141 "h", | 141 "h", |
142 ¶ms, | 142 ¶ms, |
143 llc_out_file->desc())) { | 143 llc_out_file->desc())) { |
144 // StreamInit returns an error message if the RPC fails. | 144 // StreamInit returns an error message if the RPC fails. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return false; | 226 return false; |
227 } | 227 } |
228 // Run LD. | 228 // Run LD. |
229 SrpcParams params; | 229 SrpcParams params; |
230 | 230 |
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_->read_wrapper(); | 236 nacl::DescWrapper* ld_in_file = obj_file_->get_wrapper(); |
237 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); | 237 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); |
238 PluginReverseInterface* ld_reverse = | 238 PluginReverseInterface* ld_reverse = |
239 ld_subprocess->service_runtime()->rev_interface(); | 239 ld_subprocess->service_runtime()->rev_interface(); |
240 ld_reverse->AddTempQuotaManagedFile(nexe_file_->identifier()); | 240 ld_reverse->AddQuotaManagedFile(nexe_file_->identifier(), |
| 241 nexe_file_->write_file_io()); |
241 RegisterReverseInterface(ld_reverse); | 242 RegisterReverseInterface(ld_reverse); |
242 if (!ld_subprocess->InvokeSrpcMethod("RunWithDefaultCommandLine", | 243 if (!ld_subprocess->InvokeSrpcMethod("RunWithDefaultCommandLine", |
243 "hhiss", | 244 "hhiss", |
244 ¶ms, | 245 ¶ms, |
245 ld_in_file->desc(), | 246 ld_in_file->desc(), |
246 ld_out_file->desc(), | 247 ld_out_file->desc(), |
247 is_shared_library, | 248 is_shared_library, |
248 soname.c_str(), | 249 soname.c_str(), |
249 lib_dependencies.c_str())) { | 250 lib_dependencies.c_str())) { |
250 TranslateFailed("link failed."); | 251 TranslateFailed("link failed."); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 311 |
311 PnaclTranslateThread::~PnaclTranslateThread() { | 312 PnaclTranslateThread::~PnaclTranslateThread() { |
312 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); | 313 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); |
313 SetSubprocessesShouldDie(); | 314 SetSubprocessesShouldDie(); |
314 NaClThreadJoin(translate_thread_.get()); | 315 NaClThreadJoin(translate_thread_.get()); |
315 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 316 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
316 NaClMutexDtor(&subprocess_mu_); | 317 NaClMutexDtor(&subprocess_mu_); |
317 } | 318 } |
318 | 319 |
319 } // namespace plugin | 320 } // namespace plugin |
OLD | NEW |