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

Side by Side Diff: src/IceBrowserCompileServer.cpp

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 | « src/IceBrowserCompileServer.h ('k') | src/IceCompileServer.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.cpp - Browser compile server ---===// 1 //===- subzero/src/IceBrowserCompileServer.cpp - Browser compile server ---===//
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 defines the browser-based compile server. 10 // This file defines the browser-based compile server.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 int onDataCallback(const void *Data, size_t NumBytes) { 74 int onDataCallback(const void *Data, size_t NumBytes) {
75 return gCompileServer->pushInputBytes(Data, NumBytes) ? 1 : 0; 75 return gCompileServer->pushInputBytes(Data, NumBytes) ? 1 : 0;
76 } 76 }
77 77
78 char *onEndCallback() { 78 char *onEndCallback() {
79 gCompileServer->endInputStream(); 79 gCompileServer->endInputStream();
80 gCompileServer->waitForCompileThread(); 80 gCompileServer->waitForCompileThread();
81 // TODO(jvoung): Also return an error string, and UMA data. 81 // TODO(jvoung): Also return an error string, and UMA data.
82 // Set up a report_fatal_error handler to grab that string. 82 // Set up a report_fatal_error handler to grab that string.
83 if (gCompileServer->getErrorCode().value()) { 83 if (gCompileServer->getErrorCode().value()) {
84 return strdup("Some error occurred"); 84 const std::string Error = gCompileServer->getErrorStream().getContents();
85 return strdup(Error.empty() ? "Some error occurred" : Error.c_str());
85 } 86 }
86 return nullptr; 87 return nullptr;
87 } 88 }
88 89
89 struct nacl_irt_pnacl_compile_funcs SubzeroCallbacks { 90 struct nacl_irt_pnacl_compile_funcs SubzeroCallbacks {
90 &onInitCallback, &onDataCallback, &onEndCallback 91 &onInitCallback, &onDataCallback, &onEndCallback
91 }; 92 };
92 93
93 std::unique_ptr<llvm::raw_fd_ostream> getOutputStream(int FD) { 94 std::unique_ptr<llvm::raw_fd_ostream> getOutputStream(int FD) {
94 if (FD <= 0) 95 if (FD <= 0)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 137
137 void BrowserCompileServer::endInputStream() { InputStream->SetDone(); } 138 void BrowserCompileServer::endInputStream() { InputStream->SetDone(); }
138 139
139 void BrowserCompileServer::startCompileThread(int ObjFD) { 140 void BrowserCompileServer::startCompileThread(int ObjFD) {
140 InputStream = new llvm::QueueStreamer(); 141 InputStream = new llvm::QueueStreamer();
141 LogStream = getOutputStream(STDOUT_FILENO); 142 LogStream = getOutputStream(STDOUT_FILENO);
142 LogStream->SetUnbuffered(); 143 LogStream->SetUnbuffered();
143 EmitStream = getOutputStream(ObjFD); 144 EmitStream = getOutputStream(ObjFD);
144 EmitStream->SetBufferSize(1 << 14); 145 EmitStream->SetBufferSize(1 << 14);
146 std::unique_ptr<StringStream> ErrStrm(new StringStream());
147 ErrorStream = std::move(ErrStrm);
145 ELFStream.reset(new ELFStreamer(*EmitStream.get())); 148 ELFStream.reset(new ELFStreamer(*EmitStream.get()));
146 Ctx.reset(new GlobalContext(LogStream.get(), EmitStream.get(), 149 Ctx.reset(new GlobalContext(LogStream.get(), EmitStream.get(),
147 ELFStream.get(), Flags)); 150 &ErrorStream->getStream(), ELFStream.get(),
151 Flags));
148 CompileThread = std::thread([this]() { 152 CompileThread = std::thread([this]() {
149 Ctx->initParserThread(); 153 Ctx->initParserThread();
150 this->getCompiler().run(ExtraFlags, *Ctx.get(), 154 this->getCompiler().run(ExtraFlags, *Ctx.get(),
151 // Retain original reference, but the compiler 155 // Retain original reference, but the compiler
152 // (LLVM's MemoryObject) wants to handle deletion. 156 // (LLVM's MemoryObject) wants to handle deletion.
153 std::unique_ptr<llvm::DataStreamer>(InputStream)); 157 std::unique_ptr<llvm::DataStreamer>(InputStream));
154 }); 158 });
155 } 159 }
156 160
157 } // end of namespace Ice 161 } // end of namespace Ice
158 162
159 #endif // PNACL_BROWSER_TRANSLATOR 163 #endif // PNACL_BROWSER_TRANSLATOR
OLDNEW
« no previous file with comments | « src/IceBrowserCompileServer.h ('k') | src/IceCompileServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698