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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 } | 194 } |
195 PLUGIN_PRINTF(("PnaclTranslateThread done with chunks\n")); | 195 PLUGIN_PRINTF(("PnaclTranslateThread done with chunks\n")); |
196 // Finish llc. | 196 // Finish llc. |
197 if(!llc_subprocess_->InvokeSrpcMethod("StreamEnd", | 197 if(!llc_subprocess_->InvokeSrpcMethod("StreamEnd", |
198 "", | 198 "", |
199 ¶ms)) { | 199 ¶ms)) { |
200 PLUGIN_PRINTF(("PnaclTranslateThread StreamEnd failed\n")); | 200 PLUGIN_PRINTF(("PnaclTranslateThread StreamEnd failed\n")); |
201 if (llc_subprocess_->srpc_client()->GetLastError() == | 201 if (llc_subprocess_->srpc_client()->GetLastError() == |
202 NACL_SRPC_RESULT_APP_ERROR) { | 202 NACL_SRPC_RESULT_APP_ERROR) { |
203 // The error string is only present if the error was sent back from llc | 203 // The error string is only present if the error was sent back from llc. |
| 204 // TODO(jvoung,dschuff): Be able to distinguish between things like: |
| 205 // - Out of memory. |
| 206 // - Bitcode doesn't match ABI. |
204 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, | 207 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, |
205 params.outs()[3]->arrays.str); | 208 params.outs()[3]->arrays.str); |
206 } else { | 209 } else { |
207 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, | 210 TranslateFailed(ERROR_PNACL_LLC_INTERNAL, |
208 "Compile StreamEnd internal error"); | 211 "Compile StreamEnd internal error"); |
209 } | 212 } |
210 return; | 213 return; |
211 } | 214 } |
212 // LLC returns values that are used to determine how linking is done. | 215 // LLC returns values that are used to determine how linking is done. |
213 int is_shared_library = (params.outs()[0]->u.ival != 0); | 216 int is_shared_library = (params.outs()[0]->u.ival != 0); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 267 } |
265 // Run LD. | 268 // Run LD. |
266 if (!ld_subprocess_->InvokeSrpcMethod("RunWithDefaultCommandLine", | 269 if (!ld_subprocess_->InvokeSrpcMethod("RunWithDefaultCommandLine", |
267 "hhiss", | 270 "hhiss", |
268 ¶ms, | 271 ¶ms, |
269 ld_in_file->desc(), | 272 ld_in_file->desc(), |
270 ld_out_file->desc(), | 273 ld_out_file->desc(), |
271 is_shared_library, | 274 is_shared_library, |
272 soname.c_str(), | 275 soname.c_str(), |
273 lib_dependencies.c_str())) { | 276 lib_dependencies.c_str())) { |
| 277 // TODO(jvoung,dschuff): Be able to distinguish between things like: |
| 278 // - Out of memory. |
| 279 // - Nexe has undefined symbols. |
274 TranslateFailed(ERROR_PNACL_LD_INTERNAL, | 280 TranslateFailed(ERROR_PNACL_LD_INTERNAL, |
275 "link failed."); | 281 "link failed."); |
276 return false; | 282 return false; |
277 } | 283 } |
278 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", | 284 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", |
279 this)); | 285 this)); |
280 // Shut down the ld subprocess. | 286 // Shut down the ld subprocess. |
281 NaClXMutexLock(&subprocess_mu_); | 287 NaClXMutexLock(&subprocess_mu_); |
282 ld_subprocess_active_ = false; | 288 ld_subprocess_active_ = false; |
283 ld_subprocess_.reset(NULL); | 289 ld_subprocess_.reset(NULL); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); | 330 PLUGIN_PRINTF(("~PnaclTranslateThread (translate_thread=%p)\n", this)); |
325 AbortSubprocesses(); | 331 AbortSubprocesses(); |
326 NaClThreadJoin(translate_thread_.get()); | 332 NaClThreadJoin(translate_thread_.get()); |
327 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); | 333 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); |
328 NaClCondVarDtor(&buffer_cond_); | 334 NaClCondVarDtor(&buffer_cond_); |
329 NaClMutexDtor(&cond_mu_); | 335 NaClMutexDtor(&cond_mu_); |
330 NaClMutexDtor(&subprocess_mu_); | 336 NaClMutexDtor(&subprocess_mu_); |
331 } | 337 } |
332 | 338 |
333 } // namespace plugin | 339 } // namespace plugin |
OLD | NEW |