| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 //===- subzero/src/IceBrowserCompileServer.h - Compile server ---*- C++ -*-===// | 
|  | 2 // | 
|  | 3 //                        The Subzero Code Generator | 
|  | 4 // | 
|  | 5 // This file is distributed under the University of Illinois Open Source | 
|  | 6 // License. See LICENSE.TXT for details. | 
|  | 7 // | 
|  | 8 //===----------------------------------------------------------------------===// | 
|  | 9 // | 
|  | 10 // This file declares the compile server. Given a compiler implementation, | 
|  | 11 // it dispatches compile requests to the implementation. Each request is paired | 
|  | 12 // with an abstraction of the input and output streams, which the compiler | 
|  | 13 // will acquire. | 
|  | 14 // | 
|  | 15 //===----------------------------------------------------------------------===// | 
|  | 16 | 
|  | 17 #ifndef SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H | 
|  | 18 #define SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H | 
|  | 19 | 
|  | 20 #include <thread> | 
|  | 21 | 
|  | 22 #include "IceCompileServer.h" | 
|  | 23 #include "IceDefs.h" | 
|  | 24 | 
|  | 25 namespace llvm { | 
|  | 26 class DataStreamer; | 
|  | 27 class QueueStreamer; | 
|  | 28 class raw_fd_ostream; | 
|  | 29 }; | 
|  | 30 | 
|  | 31 namespace Ice { | 
|  | 32 | 
|  | 33 // Browser variant of the compile server. | 
|  | 34 class BrowserCompileServer : public CompileServer { | 
|  | 35   BrowserCompileServer() = delete; | 
|  | 36   BrowserCompileServer(const BrowserCompileServer &) = delete; | 
|  | 37   BrowserCompileServer &operator=(const BrowserCompileServer &) = delete; | 
|  | 38 | 
|  | 39 public: | 
|  | 40   BrowserCompileServer(Compiler &Comp) | 
|  | 41       : CompileServer(Comp), OutputFD(-1), InputStream(nullptr), argc(-1), | 
|  | 42         argv(nullptr) {} | 
|  | 43 | 
|  | 44   ~BrowserCompileServer() final; | 
|  | 45 | 
|  | 46   void run() final; | 
|  | 47 | 
|  | 48   std::unique_ptr<llvm::DataStreamer> | 
|  | 49   getInputStream(const IceString &InputFilename, | 
|  | 50                  std::string &ErrorString) final; | 
|  | 51 | 
|  | 52   std::unique_ptr<llvm::raw_fd_ostream> | 
|  | 53   getOutputStream(const IceString &OutputFilename, std::error_code &EC) final; | 
|  | 54 | 
|  | 55   void takeArgs(int argc_, char **argv_) { | 
|  | 56     argc = argc_; | 
|  | 57     argv = argv_; | 
|  | 58   } | 
|  | 59 | 
|  | 60   // Call to push more bytes to the current input stream. | 
|  | 61   // Returns false on success and true on error. | 
|  | 62   bool pushInputBytes(unsigned char *Data, size_t NumBytes); | 
|  | 63 | 
|  | 64   // Notify the input stream of EOF. | 
|  | 65   void endInputStream(); | 
|  | 66 | 
|  | 67   // Set the output file descriptor to use for the current compile | 
|  | 68   // request. Must be called before getOutputStream(). | 
|  | 69   void setOutputFD(int fd) { OutputFD = fd; } | 
|  | 70 | 
|  | 71   // Start the compile thread. | 
|  | 72   void startCompileThread(); | 
|  | 73 | 
|  | 74   // Wait for the compile thread to complete. | 
|  | 75   void waitForCompileThread() { | 
|  | 76     CompileThread.join(); | 
|  | 77     InputStream = nullptr; | 
|  | 78   } | 
|  | 79 | 
|  | 80 private: | 
|  | 81   // This currently only handles a single compile request, hence one copy | 
|  | 82   // of the state. | 
|  | 83   int OutputFD; | 
|  | 84   // A borrowed reference to the current InputStream. The compiler owns | 
|  | 85   // the actual reference so the server must be careful not to access | 
|  | 86   // after the compiler is done. | 
|  | 87   llvm::QueueStreamer *InputStream; | 
|  | 88   std::thread CompileThread; | 
|  | 89   int argc; | 
|  | 90   char **argv; | 
|  | 91 }; | 
|  | 92 | 
|  | 93 } // end of namespace Ice | 
|  | 94 | 
|  | 95 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H | 
| OLD | NEW | 
|---|