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

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: Rebase to master 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
« no previous file with comments | « src/IceAssemblerX8664.cpp ('k') | src/IceBrowserCompileServer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /// \file
11 // 11 /// This file declares the browser-specific compile server.
12 ///
12 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
13 14
14 #ifndef SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H 15 #ifndef SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
15 #define SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H 16 #define SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
16 17
17 #include "IceClFlags.h" 18 #include "IceClFlags.h"
18 #include "IceClFlagsExtra.h" 19 #include "IceClFlagsExtra.h"
19 #include "IceCompileServer.h" 20 #include "IceCompileServer.h"
20 #include "IceDefs.h" 21 #include "IceDefs.h"
21 #include "IceELFStreamer.h" 22 #include "IceELFStreamer.h"
22 23
23 #include <atomic> 24 #include <atomic>
24 #include <thread> 25 #include <thread>
25 26
26 namespace llvm { 27 namespace llvm {
27 class QueueStreamer; 28 class QueueStreamer;
28 class raw_fd_ostream; 29 class raw_fd_ostream;
29 } // end of namespace llvm 30 } // end of namespace llvm
30 31
31 namespace Ice { 32 namespace Ice {
32 33
33 // The browser variant of the compile server. 34 /// The browser variant of the compile server.
34 // Compared to the commandline version, this version gets compile 35 /// Compared to the commandline version, this version gets compile
35 // requests over IPC. Each compile request will have a slimmed down 36 /// requests over IPC. Each compile request will have a slimmed down
36 // version of argc, argv while other flags are set to defaults that 37 /// 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 38 /// make sense in the browser case. The output file is specified via
38 // a posix FD, and input bytes are pushed to the server. 39 /// a posix FD, and input bytes are pushed to the server.
39 class BrowserCompileServer : public CompileServer { 40 class BrowserCompileServer : public CompileServer {
40 BrowserCompileServer() = delete; 41 BrowserCompileServer() = delete;
41 BrowserCompileServer(const BrowserCompileServer &) = delete; 42 BrowserCompileServer(const BrowserCompileServer &) = delete;
42 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete; 43 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete;
43 class StringStream; 44 class StringStream;
44 45
45 public: 46 public:
46 explicit BrowserCompileServer(Compiler &Comp) 47 explicit BrowserCompileServer(Compiler &Comp)
47 : CompileServer(Comp), InputStream(nullptr), HadError(false) {} 48 : CompileServer(Comp), InputStream(nullptr), HadError(false) {}
48 49
49 ~BrowserCompileServer() final; 50 ~BrowserCompileServer() final;
50 51
51 void run() final; 52 void run() final;
52 53
53 ErrorCode &getErrorCode() final; 54 ErrorCode &getErrorCode() final;
54 55
55 // Parse and set up the flags for compile jobs. 56 /// Parse and set up the flags for compile jobs.
56 void getParsedFlags(uint32_t NumThreads, int argc, char **argv); 57 void getParsedFlags(uint32_t NumThreads, int argc, char **argv);
57 58
58 // Creates the streams + context and starts the compile thread, 59 /// Creates the streams + context and starts the compile thread,
59 // handing off the streams + context. 60 /// handing off the streams + context.
60 void startCompileThread(int OutFD); 61 void startCompileThread(int OutFD);
61 62
62 // Call to push more bytes to the current input stream. 63 /// Call to push more bytes to the current input stream.
63 // Returns false on success and true on error. 64 /// Returns false on success and true on error.
64 bool pushInputBytes(const void *Data, size_t NumBytes); 65 bool pushInputBytes(const void *Data, size_t NumBytes);
65 66
66 // Notify the input stream of EOF. 67 /// Notify the input stream of EOF.
67 void endInputStream(); 68 void endInputStream();
68 69
69 // Wait for the compile thread to complete then reset the state. 70 /// Wait for the compile thread to complete then reset the state.
70 void waitForCompileThread() { 71 void waitForCompileThread() {
71 CompileThread.join(); 72 CompileThread.join();
72 if (Ctx->getErrorStatus()->value()) 73 if (Ctx->getErrorStatus()->value())
73 LastError.assign(Ctx->getErrorStatus()->value()); 74 LastError.assign(Ctx->getErrorStatus()->value());
74 // Reset some state. The InputStream is deleted by the compiler 75 // Reset some state. The InputStream is deleted by the compiler
75 // so only reset this to nullptr. Free and flush the rest 76 // so only reset this to nullptr. Free and flush the rest
76 // of the streams. 77 // of the streams.
77 InputStream = nullptr; 78 InputStream = nullptr;
78 EmitStream.reset(nullptr); 79 EmitStream.reset(nullptr);
79 ELFStream.reset(nullptr); 80 ELFStream.reset(nullptr);
80 } 81 }
81 82
82 StringStream &getErrorStream() { return *ErrorStream; } 83 StringStream &getErrorStream() { return *ErrorStream; }
83 84
84 void setFatalError(const IceString &Reason); 85 void setFatalError(const IceString &Reason);
85 86
86 private: 87 private:
87 class StringStream { 88 class StringStream {
88 public: 89 public:
89 StringStream() : StrBuf(Buffer) {} 90 StringStream() : StrBuf(Buffer) {}
90 const IceString &getContents() { return StrBuf.str(); } 91 const IceString &getContents() { return StrBuf.str(); }
91 Ostream &getStream() { return StrBuf; } 92 Ostream &getStream() { return StrBuf; }
92 93
93 private: 94 private:
94 std::string Buffer; 95 std::string Buffer;
95 llvm::raw_string_ostream StrBuf; 96 llvm::raw_string_ostream StrBuf;
96 }; 97 };
97 // This currently only handles a single compile request, hence one copy 98 /// This currently only handles a single compile request, hence one copy
98 // of the state. 99 /// of the state.
99 std::unique_ptr<GlobalContext> Ctx; 100 std::unique_ptr<GlobalContext> Ctx;
100 // A borrowed reference to the current InputStream. The compiler owns 101 /// A borrowed reference to the current InputStream. The compiler owns
101 // the actual reference so the server must be careful not to access 102 /// the actual reference so the server must be careful not to access
102 // after the compiler is done. 103 /// after the compiler is done.
103 llvm::QueueStreamer *InputStream = nullptr; 104 llvm::QueueStreamer *InputStream = nullptr;
104 std::unique_ptr<Ostream> LogStream; 105 std::unique_ptr<Ostream> LogStream;
105 std::unique_ptr<llvm::raw_fd_ostream> EmitStream; 106 std::unique_ptr<llvm::raw_fd_ostream> EmitStream;
106 std::unique_ptr<StringStream> ErrorStream; 107 std::unique_ptr<StringStream> ErrorStream;
107 std::unique_ptr<ELFStreamer> ELFStream; 108 std::unique_ptr<ELFStreamer> ELFStream;
108 ClFlags Flags; 109 ClFlags Flags;
109 ClFlagsExtra ExtraFlags; 110 ClFlagsExtra ExtraFlags;
110 std::thread CompileThread; 111 std::thread CompileThread;
111 std::atomic<bool> HadError; 112 std::atomic<bool> HadError;
112 }; 113 };
113 114
114 } // end of namespace Ice 115 } // end of namespace Ice
115 116
116 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H 117 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
OLDNEW
« no previous file with comments | « src/IceAssemblerX8664.cpp ('k') | src/IceBrowserCompileServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698