Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: components/nacl/renderer/plugin/pnacl_translate_thread.h

Issue 1005173006: Add a switch for using PNaCl Subzero and use it for -O0 translation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix takefileinfo Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 5 #ifndef COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 6 #define COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 class PnaclTranslateThread { 34 class PnaclTranslateThread {
35 public: 35 public:
36 PnaclTranslateThread(); 36 PnaclTranslateThread();
37 ~PnaclTranslateThread(); 37 ~PnaclTranslateThread();
38 38
39 // Start the translation process. It will continue to run and consume data 39 // Start the translation process. It will continue to run and consume data
40 // as it is passed in with PutBytes. 40 // as it is passed in with PutBytes.
41 void RunTranslate(const pp::CompletionCallback& finish_callback, 41 void RunTranslate(const pp::CompletionCallback& finish_callback,
42 const std::vector<TempFile*>* obj_files, 42 const std::vector<TempFile*>* obj_files,
43 int num_threads,
43 TempFile* nexe_file, 44 TempFile* nexe_file,
44 nacl::DescWrapper* invalid_desc_wrapper, 45 nacl::DescWrapper* invalid_desc_wrapper,
45 ErrorInfo* error_info, 46 ErrorInfo* error_info,
46 PnaclResources* resources, 47 PnaclResources* resources,
47 PP_PNaClOptions* pnacl_options, 48 PP_PNaClOptions* pnacl_options,
48 const std::string &architecture_attributes, 49 const std::string& architecture_attributes,
49 PnaclCoordinator* coordinator, 50 PnaclCoordinator* coordinator,
50 Plugin* plugin); 51 Plugin* plugin);
51 52
52 // Kill the llc and/or ld subprocesses. This happens by closing the command 53 // Kill the llc and/or ld subprocesses. This happens by closing the command
53 // channel on the plugin side, which causes the trusted code in the nexe to 54 // channel on the plugin side, which causes the trusted code in the nexe to
54 // exit, which will cause any pending SRPCs to error. Because this is called 55 // exit, which will cause any pending SRPCs to error. Because this is called
55 // on the main thread, the translation thread must not use the subprocess 56 // on the main thread, the translation thread must not use the subprocess
56 // objects without the lock, other than InvokeSrpcMethod, which does not 57 // objects without the lock, other than InvokeSrpcMethod, which does not
57 // race with service runtime shutdown. 58 // race with service runtime shutdown.
58 void AbortSubprocesses(); 59 void AbortSubprocesses();
(...skipping 22 matching lines...) Expand all
81 // Run the LD subprocess, returning true on success. 82 // Run the LD subprocess, returning true on success.
82 // On failure, it returns false and runs the callback. 83 // On failure, it returns false and runs the callback.
83 bool RunLdSubprocess(); 84 bool RunLdSubprocess();
84 85
85 86
86 // Callback to run when tasks are completed or an error has occurred. 87 // Callback to run when tasks are completed or an error has occurred.
87 pp::CompletionCallback report_translate_finished_; 88 pp::CompletionCallback report_translate_finished_;
88 89
89 nacl::scoped_ptr<NaClThread> translate_thread_; 90 nacl::scoped_ptr<NaClThread> translate_thread_;
90 91
91 // Used to guard llc_subprocess and ld_subprocess 92 // Used to guard compiler_subprocess and ld_subprocess
92 struct NaClMutex subprocess_mu_; 93 struct NaClMutex subprocess_mu_;
93 nacl::scoped_ptr<NaClSubprocess> llc_subprocess_; 94 nacl::scoped_ptr<NaClSubprocess> compiler_subprocess_;
94 nacl::scoped_ptr<NaClSubprocess> ld_subprocess_; 95 nacl::scoped_ptr<NaClSubprocess> ld_subprocess_;
95 // Used to ensure the subprocesses don't get shutdown more than once. 96 // Used to ensure the subprocesses don't get shutdown more than once.
96 bool llc_subprocess_active_; 97 bool compiler_subprocess_active_;
97 bool ld_subprocess_active_; 98 bool ld_subprocess_active_;
98 99
99 bool subprocesses_aborted_; 100 bool subprocesses_aborted_;
100 101
101 // Condition variable to synchronize communication with the SRPC thread. 102 // Condition variable to synchronize communication with the SRPC thread.
102 // SRPC thread waits on this condvar if data_buffers_ is empty (meaning 103 // SRPC thread waits on this condvar if data_buffers_ is empty (meaning
103 // there is no bitcode to send to the translator), and the main thread 104 // there is no bitcode to send to the translator), and the main thread
104 // appends to data_buffers_ and signals it when it receives bitcode. 105 // appends to data_buffers_ and signals it when it receives bitcode.
105 struct NaClCondVar buffer_cond_; 106 struct NaClCondVar buffer_cond_;
106 // Mutex for buffer_cond_. 107 // Mutex for buffer_cond_.
107 struct NaClMutex cond_mu_; 108 struct NaClMutex cond_mu_;
108 // Data buffers from FileDownloader are enqueued here to pass from the 109 // Data buffers from FileDownloader are enqueued here to pass from the
109 // main thread to the SRPC thread. Protected by cond_mu_ 110 // main thread to the SRPC thread. Protected by cond_mu_
110 std::deque<std::vector<char> > data_buffers_; 111 std::deque<std::vector<char> > data_buffers_;
111 // Whether all data has been downloaded and copied to translation thread. 112 // Whether all data has been downloaded and copied to translation thread.
112 // Associated with buffer_cond_ 113 // Associated with buffer_cond_
113 bool done_; 114 bool done_;
114 115
115 int64_t compile_time_; 116 int64_t compile_time_;
116 117
117 // Data about the translation files, owned by the coordinator 118 // Data about the translation files, owned by the coordinator
118 const std::vector<TempFile*>* obj_files_; 119 const std::vector<TempFile*>* obj_files_;
120 int num_threads_;
119 TempFile* nexe_file_; 121 TempFile* nexe_file_;
120 nacl::DescWrapper* invalid_desc_wrapper_; 122 nacl::DescWrapper* invalid_desc_wrapper_;
121 ErrorInfo* coordinator_error_info_; 123 ErrorInfo* coordinator_error_info_;
122 PnaclResources* resources_; 124 PnaclResources* resources_;
123 PP_PNaClOptions* pnacl_options_; 125 PP_PNaClOptions* pnacl_options_;
124 std::string architecture_attributes_; 126 std::string architecture_attributes_;
125 PnaclCoordinator* coordinator_; 127 PnaclCoordinator* coordinator_;
126 Plugin* plugin_; 128 Plugin* plugin_;
127 private: 129 private:
128 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); 130 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread);
129 }; 131 };
130 132
131 } 133 }
132 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_ 134 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_PNACL_TRANSLATE_THREAD_H_
OLDNEW
« no previous file with comments | « components/nacl/renderer/plugin/pnacl_resources.cc ('k') | components/nacl/renderer/plugin/pnacl_translate_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698