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

Side by Side Diff: src/IceBrowserCompileServer.h

Issue 1052833003: First attempt to capture parser/translation errors in browser. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits and syntax errors. 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
« no previous file with comments | « no previous file | 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 // This file declares the browser-specific compile server.
(...skipping 21 matching lines...) Expand all
32 // The browser variant of the compile server. 32 // The browser variant of the compile server.
33 // Compared to the commandline version, this version gets compile 33 // Compared to the commandline version, this version gets compile
34 // requests over IPC. Each compile request will have a slimmed down 34 // requests over IPC. Each compile request will have a slimmed down
35 // version of argc, argv while other flags are set to defaults that 35 // version of argc, argv while other flags are set to defaults that
36 // make sense in the browser case. The output file is specified via 36 // make sense in the browser case. The output file is specified via
37 // a posix FD, and input bytes are pushed to the server. 37 // a posix FD, and input bytes are pushed to the server.
38 class BrowserCompileServer : public CompileServer { 38 class BrowserCompileServer : public CompileServer {
39 BrowserCompileServer() = delete; 39 BrowserCompileServer() = delete;
40 BrowserCompileServer(const BrowserCompileServer &) = delete; 40 BrowserCompileServer(const BrowserCompileServer &) = delete;
41 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete; 41 BrowserCompileServer &operator=(const BrowserCompileServer &) = delete;
42 class StringStream;
42 43
43 public: 44 public:
44 explicit BrowserCompileServer(Compiler &Comp) 45 explicit BrowserCompileServer(Compiler &Comp)
45 : CompileServer(Comp), InputStream(nullptr) {} 46 : CompileServer(Comp), InputStream(nullptr) {}
46 47
47 ~BrowserCompileServer() final; 48 ~BrowserCompileServer() final;
48 49
49 void run() final; 50 void run() final;
50 51
51 // Parse and set up the flags for compile jobs. 52 // Parse and set up the flags for compile jobs.
(...skipping 15 matching lines...) Expand all
67 CompileThread.join(); 68 CompileThread.join();
68 LastError.assign(Ctx->getErrorStatus()->value()); 69 LastError.assign(Ctx->getErrorStatus()->value());
69 // Reset some state. The InputStream is deleted by the compiler 70 // Reset some state. The InputStream is deleted by the compiler
70 // so only reset this to nullptr. Free and flush the rest 71 // so only reset this to nullptr. Free and flush the rest
71 // of the streams. 72 // of the streams.
72 InputStream = nullptr; 73 InputStream = nullptr;
73 EmitStream.reset(nullptr); 74 EmitStream.reset(nullptr);
74 ELFStream.reset(nullptr); 75 ELFStream.reset(nullptr);
75 } 76 }
76 77
78 StringStream &getErrorStream() {
79 return *ErrorStream;
80 }
81
77 private: 82 private:
83 class StringStream {
84 public:
85 StringStream() : StrBuf(Buffer) {}
86 const IceString &getContents() { return StrBuf.str(); }
87 Ostream &getStream() { return StrBuf; }
88 private:
89 std::string Buffer;
90 llvm::raw_string_ostream StrBuf;
91 };
78 // This currently only handles a single compile request, hence one copy 92 // This currently only handles a single compile request, hence one copy
79 // of the state. 93 // of the state.
80 std::unique_ptr<GlobalContext> Ctx; 94 std::unique_ptr<GlobalContext> Ctx;
81 // A borrowed reference to the current InputStream. The compiler owns 95 // A borrowed reference to the current InputStream. The compiler owns
82 // the actual reference so the server must be careful not to access 96 // the actual reference so the server must be careful not to access
83 // after the compiler is done. 97 // after the compiler is done.
84 llvm::QueueStreamer *InputStream; 98 llvm::QueueStreamer *InputStream;
85 std::unique_ptr<Ostream> LogStream; 99 std::unique_ptr<Ostream> LogStream;
86 std::unique_ptr<llvm::raw_fd_ostream> EmitStream; 100 std::unique_ptr<llvm::raw_fd_ostream> EmitStream;
101 std::unique_ptr<StringStream> ErrorStream;
87 std::unique_ptr<ELFStreamer> ELFStream; 102 std::unique_ptr<ELFStreamer> ELFStream;
88 ClFlags Flags; 103 ClFlags Flags;
89 ClFlagsExtra ExtraFlags; 104 ClFlagsExtra ExtraFlags;
90 std::thread CompileThread; 105 std::thread CompileThread;
91 }; 106 };
92 107
93 } // end of namespace Ice 108 } // end of namespace Ice
94 109
95 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H 110 #endif // SUBZERO_SRC_ICEBROWSERCOMPILESERVER_H
OLDNEW
« no previous file with comments | « no previous file | src/IceBrowserCompileServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698