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

Side by Side Diff: src/IceBrowserCompileServer.h

Issue 1216963007: Doxygenize the documentation comments (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 5 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 //===- subzero/src/IceBrowserCompileServer.h - Browser server ---*- C++ -*-===// 1 //===- subzero/src/IceBrowserCompileServer.h - Browser server ---*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares the browser-specific compile server. 10 // This file declares the browser-specific compile server.
(...skipping 12 matching lines...) Expand all
23 #include <atomic> 23 #include <atomic>
24 #include <thread> 24 #include <thread>
25 25
26 namespace llvm { 26 namespace llvm {
27 class QueueStreamer; 27 class QueueStreamer;
28 class raw_fd_ostream; 28 class raw_fd_ostream;
29 } // end of namespace llvm 29 } // end of namespace llvm
30 30
31 namespace Ice { 31 namespace Ice {
32 32
33 // The browser variant of the compile server. 33 /// The browser variant of the compile server.
34 // Compared to the commandline version, this version gets compile 34 /// Compared to the commandline version, this version gets compile
35 // requests over IPC. Each compile request will have a slimmed down 35 /// requests over IPC. Each compile request will have a slimmed down
36 // version of argc, argv while other flags are set to defaults that 36 /// version of argc, argv while other flags are set to defaults that
37 // make sense in the browser case. The output file is specified via 37 /// make sense in the browser case. The output file is specified via
38 // a posix FD, and input bytes are pushed to the server. 38 /// a posix FD, and input bytes are pushed to the server.
39 class BrowserCompileServer : public CompileServer { 39 class BrowserCompileServer : public CompileServer {
40 BrowserCompileServer() = delete; 40 BrowserCompileServer() = delete;
41 BrowserCompileServer(const BrowserCompileServer &) = delete; 41 BrowserCompileServer(const BrowserCompileServer &) = delete;
42 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete; 42 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete;
43 class StringStream; 43 class StringStream;
44 44
45 public: 45 public:
46 explicit BrowserCompileServer(Compiler &Comp) 46 explicit BrowserCompileServer(Compiler &Comp)
47 : CompileServer(Comp), InputStream(nullptr), HadError(false) {} 47 : CompileServer(Comp), InputStream(nullptr), HadError(false) {}
48 48
49 ~BrowserCompileServer() final; 49 ~BrowserCompileServer() final;
50 50
51 void run() final; 51 void run() final;
52 52
53 ErrorCode &getErrorCode() final; 53 ErrorCode &getErrorCode() final;
54 54
55 // Parse and set up the flags for compile jobs. 55 /// Parse and set up the flags for compile jobs.
56 void getParsedFlags(uint32_t NumThreads, int argc, char **argv); 56 void getParsedFlags(uint32_t NumThreads, int argc, char **argv);
57 57
58 // Creates the streams + context and starts the compile thread, 58 /// Creates the streams + context and starts the compile thread,
59 // handing off the streams + context. 59 /// handing off the streams + context.
60 void startCompileThread(int OutFD); 60 void startCompileThread(int OutFD);
61 61
62 // Call to push more bytes to the current input stream. 62 /// Call to push more bytes to the current input stream.
63 // Returns false on success and true on error. 63 /// Returns false on success and true on error.
64 bool pushInputBytes(const void *Data, size_t NumBytes); 64 bool pushInputBytes(const void *Data, size_t NumBytes);
65 65
66 // Notify the input stream of EOF. 66 /// Notify the input stream of EOF.
67 void endInputStream(); 67 void endInputStream();
68 68
69 // Wait for the compile thread to complete then reset the state. 69 /// Wait for the compile thread to complete then reset the state.
70 void waitForCompileThread() { 70 void waitForCompileThread() {
71 CompileThread.join(); 71 CompileThread.join();
72 if (Ctx->getErrorStatus()->value()) 72 if (Ctx->getErrorStatus()->value())
73 LastError.assign(Ctx->getErrorStatus()->value()); 73 LastError.assign(Ctx->getErrorStatus()->value());
74 // Reset some state. The InputStream is deleted by the compiler 74 // Reset some state. The InputStream is deleted by the compiler
75 // so only reset this to nullptr. Free and flush the rest 75 // so only reset this to nullptr. Free and flush the rest
76 // of the streams. 76 // of the streams.
77 InputStream = nullptr; 77 InputStream = nullptr;
78 EmitStream.reset(nullptr); 78 EmitStream.reset(nullptr);
79 ELFStream.reset(nullptr); 79 ELFStream.reset(nullptr);
80 } 80 }
81 81
82 StringStream &getErrorStream() { return *ErrorStream; } 82 StringStream &getErrorStream() { return *ErrorStream; }
83 83
84 void setFatalError(const IceString &Reason); 84 void setFatalError(const IceString &Reason);
85 85
86 private: 86 private:
87 class StringStream { 87 class StringStream {
88 public: 88 public:
89 StringStream() : StrBuf(Buffer) {} 89 StringStream() : StrBuf(Buffer) {}
90 const IceString &getContents() { return StrBuf.str(); } 90 const IceString &getContents() { return StrBuf.str(); }
91 Ostream &getStream() { return StrBuf; } 91 Ostream &getStream() { return StrBuf; }
92 92
93 private: 93 private:
94 std::string Buffer; 94 std::string Buffer;
95 llvm::raw_string_ostream StrBuf; 95 llvm::raw_string_ostream StrBuf;
96 }; 96 };
97 // This currently only handles a single compile request, hence one copy 97 /// This currently only handles a single compile request, hence one copy
98 // of the state. 98 /// of the state.
99 std::unique_ptr<GlobalContext> Ctx; 99 std::unique_ptr<GlobalContext> Ctx;
100 // A borrowed reference to the current InputStream. The compiler owns 100 /// A borrowed reference to the current InputStream. The compiler owns
101 // the actual reference so the server must be careful not to access 101 /// the actual reference so the server must be careful not to access
102 // after the compiler is done. 102 /// after the compiler is done.
103 llvm::QueueStreamer *InputStream = nullptr; 103 llvm::QueueStreamer *InputStream = nullptr;
104 std::unique_ptr<Ostream> LogStream; 104 std::unique_ptr<Ostream> LogStream;
105 std::unique_ptr<llvm::raw_fd_ostream> EmitStream; 105 std::unique_ptr<llvm::raw_fd_ostream> EmitStream;
106 std::unique_ptr<StringStream> ErrorStream; 106 std::unique_ptr<StringStream> ErrorStream;
107 std::unique_ptr<ELFStreamer> ELFStream; 107 std::unique_ptr<ELFStreamer> ELFStream;
108 ClFlags Flags; 108 ClFlags Flags;
109 ClFlagsExtra ExtraFlags; 109 ClFlagsExtra ExtraFlags;
110 std::thread CompileThread; 110 std::thread CompileThread;
111 std::atomic<bool> HadError; 111 std::atomic<bool> HadError;
112 }; 112 };
113 113
114 } // end of namespace Ice 114 } // end of namespace Ice
115 115
116 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H 116 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698