| 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_streaming_translate_thread.h" | 5 #include "native_client/src/trusted/plugin/pnacl_streaming_translate_thread.h" |
| 6 | 6 |
| 7 #include "native_client/src/include/nacl_scoped_ptr.h" | 7 #include "native_client/src/include/nacl_scoped_ptr.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" |
| 11 #include "native_client/src/trusted/plugin/temporary_file.h" |
| 11 | 12 |
| 12 namespace plugin { | 13 namespace plugin { |
| 13 | 14 |
| 14 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { | 15 PnaclStreamingTranslateThread::PnaclStreamingTranslateThread() : done_(false) { |
| 15 NaClXMutexCtor(&cond_mu_); | 16 NaClXMutexCtor(&cond_mu_); |
| 16 NaClXCondVarCtor(&buffer_cond_); | 17 NaClXCondVarCtor(&buffer_cond_); |
| 17 } | 18 } |
| 18 | 19 |
| 19 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} | 20 PnaclStreamingTranslateThread::~PnaclStreamingTranslateThread() {} |
| 20 | 21 |
| 21 void PnaclStreamingTranslateThread::RunTranslate( | 22 void PnaclStreamingTranslateThread::RunTranslate( |
| 22 const pp::CompletionCallback& finish_callback, | 23 const pp::CompletionCallback& finish_callback, |
| 23 const Manifest* manifest, | 24 const Manifest* manifest, |
| 24 const Manifest* ld_manifest, | 25 const Manifest* ld_manifest, |
| 25 LocalTempFile* obj_file, | 26 TempFile* obj_file, |
| 26 LocalTempFile* nexe_file, | 27 LocalTempFile* nexe_file, |
| 27 ErrorInfo* error_info, | 28 ErrorInfo* error_info, |
| 28 PnaclResources* resources, | 29 PnaclResources* resources, |
| 29 Plugin* plugin) { | 30 Plugin* plugin) { |
| 30 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); | 31 PLUGIN_PRINTF(("PnaclStreamingTranslateThread::RunTranslate)\n")); |
| 31 manifest_ = manifest; | 32 manifest_ = manifest; |
| 32 ld_manifest_ = ld_manifest; | 33 ld_manifest_ = ld_manifest; |
| 33 obj_file_ = obj_file; | 34 obj_file_ = obj_file; |
| 34 nexe_file_ = nexe_file; | 35 nexe_file_ = nexe_file; |
| 35 coordinator_error_info_ = error_info; | 36 coordinator_error_info_ = error_info; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 ErrorInfo error_info; | 92 ErrorInfo error_info; |
| 92 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( | 93 nacl::scoped_ptr<NaClSubprocess> llc_subprocess( |
| 93 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); | 94 StartSubprocess(PnaclUrls::GetLlcUrl(), manifest_, &error_info)); |
| 94 if (llc_subprocess == NULL) { | 95 if (llc_subprocess == NULL) { |
| 95 TranslateFailed("Compile process could not be created: " + | 96 TranslateFailed("Compile process could not be created: " + |
| 96 error_info.message()); | 97 error_info.message()); |
| 97 return; | 98 return; |
| 98 } | 99 } |
| 99 // Run LLC. | 100 // Run LLC. |
| 100 SrpcParams params; | 101 SrpcParams params; |
| 101 nacl::DescWrapper* llc_out_file = obj_file_->write_wrapper(); | 102 nacl::DescWrapper* llc_out_file = obj_file_->get_wrapper(); |
| 102 PluginReverseInterface* llc_reverse = | 103 PluginReverseInterface* llc_reverse = |
| 103 llc_subprocess->service_runtime()->rev_interface(); | 104 llc_subprocess->service_runtime()->rev_interface(); |
| 104 llc_reverse->AddQuotaManagedFile(obj_file_->identifier(), | 105 llc_reverse->AddTempQuotaManagedFile(obj_file_->identifier()); |
| 105 obj_file_->write_file_io()); | |
| 106 | 106 |
| 107 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", | 107 if (!llc_subprocess->InvokeSrpcMethod("StreamInit", |
| 108 "h", | 108 "h", |
| 109 ¶ms, | 109 ¶ms, |
| 110 llc_out_file->desc())) { | 110 llc_out_file->desc())) { |
| 111 // StreamInit returns an error message if the RPC fails. | 111 // StreamInit returns an error message if the RPC fails. |
| 112 TranslateFailed(nacl::string("Stream init failed: ") + | 112 TranslateFailed(nacl::string("Stream init failed: ") + |
| 113 nacl::string(params.outs()[0]->arrays.str)); | 113 nacl::string(params.outs()[0]->arrays.str)); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 | 177 |
| 178 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { | 178 void PnaclStreamingTranslateThread::SetSubprocessesShouldDie() { |
| 179 PnaclTranslateThread::SetSubprocessesShouldDie(); | 179 PnaclTranslateThread::SetSubprocessesShouldDie(); |
| 180 nacl::MutexLocker ml(&cond_mu_); | 180 nacl::MutexLocker ml(&cond_mu_); |
| 181 done_ = true; | 181 done_ = true; |
| 182 NaClXCondVarSignal(&buffer_cond_); | 182 NaClXCondVarSignal(&buffer_cond_); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace plugin | 185 } // namespace plugin |
| OLD | NEW |