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

Side by Side Diff: src/IceCompileServer.cpp

Issue 1215463014: Modify how textual bitcode is injected into pnacl-sz. (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/IceCompileServer.cpp - Compile server ------------------===// 1 //===- subzero/src/IceCompileServer.cpp - 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 /// \file 10 /// \file
11 /// This file defines the basic commandline-based compile server. 11 /// This file defines the basic commandline-based compile server.
12 /// 12 ///
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "IceCompileServer.h" 15 #include "IceCompileServer.h"
16 16
17 #include "IceClFlags.h" 17 #include "IceClFlags.h"
18 #include "IceClFlagsExtra.h" 18 #include "IceClFlagsExtra.h"
19 #include "IceELFStreamer.h" 19 #include "IceELFStreamer.h"
20 #include "IceGlobalContext.h" 20 #include "IceGlobalContext.h"
21 21
22 #pragma clang diagnostic push 22 #pragma clang diagnostic push
23 #pragma clang diagnostic ignored "-Wunused-parameter" 23 #pragma clang diagnostic ignored "-Wunused-parameter"
24 // Include code to handle converting textual bitcode records to binary (for 24 // Include code to handle converting textual bitcode records to binary (for
Karl 2015/07/21 21:07:01 Removed comment, no longer dependent on ACCEPT_TEX
25 // INPUT_IS_TEXTUAL_BITCODE). 25 // ACCEPT_TEXTUAL_PNACL_BITCODE).
26 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h" 26 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h"
27 #include "llvm/Support/FileSystem.h" 27 #include "llvm/Support/FileSystem.h"
28 #include "llvm/Support/raw_os_ostream.h" 28 #include "llvm/Support/raw_os_ostream.h"
29 #include "llvm/Support/Signals.h" 29 #include "llvm/Support/Signals.h"
30 #include "llvm/Support/SourceMgr.h" 30 #include "llvm/Support/SourceMgr.h"
31 #include "llvm/Support/StreamingMemoryObject.h" 31 #include "llvm/Support/StreamingMemoryObject.h"
32 #pragma clang diagnostic pop 32 #pragma clang diagnostic pop
33 33
34 #include <fstream> 34 #include <fstream>
35 #include <iostream> 35 #include <iostream>
36 #include <thread> 36 #include <thread>
37 37
38 namespace Ice { 38 namespace Ice {
39 39
40 namespace { 40 namespace {
41 41
42 static_assert(!(BuildDefs::textualBitcode() && PNACL_BROWSER_TRANSLATOR), 42 static_assert(!(BuildDefs::textualBitcode() && PNACL_BROWSER_TRANSLATOR),
43 "Can not define INPUT_IS_TEXTUAL_BITCODE when building browswer " 43 "Can not accept textual bitcode when building "
44 "translator"); 44 "browswer translator");
jvoung (off chromium) 2015/07/07 21:40:17 browswer -> browser
Karl 2015/07/21 21:07:01 Removed static_assert since it is no longer depend
45 45
46 // Define a SmallVector backed buffer as a data stream, so that it 46 // Define a SmallVector backed buffer as a data stream, so that it
47 // can hold the generated binary version of the textual bitcode in the 47 // can hold the generated binary version of the textual bitcode in the
48 // input file. 48 // input file.
49 class TextDataStreamer : public llvm::DataStreamer { 49 class TextDataStreamer : public llvm::DataStreamer {
50 public: 50 public:
51 TextDataStreamer() = default; 51 TextDataStreamer() = default;
52 ~TextDataStreamer() final = default; 52 ~TextDataStreamer() final = default;
53 static TextDataStreamer *create(const IceString &Filename, std::string *Err); 53 static TextDataStreamer *create(const IceString &Filename, std::string *Err);
54 size_t GetBytes(unsigned char *Buf, size_t Len) final; 54 size_t GetBytes(unsigned char *Buf, size_t Len) final;
55 55
56 private: 56 private:
57 llvm::SmallVector<char, 1024> BitcodeBuffer; 57 llvm::SmallVector<char, 1024> BitcodeBuffer;
58 size_t Cursor = 0; 58 size_t Cursor = 0;
59 }; 59 };
60 60
61 TextDataStreamer *TextDataStreamer::create(const IceString &Filename, 61 TextDataStreamer *TextDataStreamer::create(const IceString &Filename,
62 std::string *Err) { 62 std::string *Err) {
63 TextDataStreamer *Streamer = new TextDataStreamer(); 63 TextDataStreamer *Streamer = new TextDataStreamer();
64 llvm::raw_string_ostream ErrStrm(*Err); 64 llvm::raw_string_ostream ErrStrm(*Err);
65 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode( 65 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode(
66 Filename, Streamer->BitcodeBuffer, &ErrStrm)) { 66 Filename, Streamer->BitcodeBuffer, &ErrStrm)) {
67 ErrStrm << EC.message(); // << "\n"; 67 ErrStrm << EC.message(); // << "\n";
jvoung (off chromium) 2015/07/07 21:40:17 why comment out the "// << "\n";"?, and the // Err
Karl 2015/07/21 21:07:01 I removed the '<< "\n"' because the caller expects
68 ErrStrm.flush(); 68 ErrStrm.flush();
69 delete Streamer; 69 delete Streamer;
70 return nullptr; 70 return nullptr;
71 } 71 }
72 // ErrStrm.flush(); 72 // ErrStrm.flush();
73 return Streamer; 73 return Streamer;
74 } 74 }
75 75
76 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) { 76 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) {
77 if (Cursor >= BitcodeBuffer.size()) 77 if (Cursor >= BitcodeBuffer.size())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 }); 172 });
173 CompileThread.join(); 173 CompileThread.join();
174 } else { 174 } else {
175 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); 175 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream));
176 } 176 }
177 transferErrorCode(getReturnValue( 177 transferErrorCode(getReturnValue(
178 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); 178 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value())));
179 } 179 }
180 180
181 } // end of namespace Ice 181 } // end of namespace Ice
OLDNEW
« src/IceBuildDefs.h ('K') | « src/IceBuildDefs.h ('k') | src/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698