OLD | NEW |
---|---|
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 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 void getIRTInterfaces() { | 35 void getIRTInterfaces() { |
36 size_t QueryResult = | 36 size_t QueryResult = |
37 nacl_interface_query(NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1, | 37 nacl_interface_query(NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1, |
38 &gIRTFuncs, sizeof(gIRTFuncs)); | 38 &gIRTFuncs, sizeof(gIRTFuncs)); |
39 if (QueryResult != sizeof(gIRTFuncs)) | 39 if (QueryResult != sizeof(gIRTFuncs)) |
40 llvm::report_fatal_error("Failed to get translator compile IRT interface"); | 40 llvm::report_fatal_error("Failed to get translator compile IRT interface"); |
41 } | 41 } |
42 | 42 |
43 char *onInitCallback(uint32_t NumThreads, int *ObjFileFDs, | 43 char *onInitCallback(uint32_t NumThreads, int *ObjFileFDs, |
44 size_t ObjFileFDCount, char **argv, size_t argc) { | 44 size_t ObjFileFDCount, char **CLArgs, size_t CLArgsLen) { |
45 if (ObjFileFDCount < 1) { | 45 if (ObjFileFDCount < 1) { |
46 std::string Buffer; | 46 std::string Buffer; |
47 llvm::raw_string_ostream StrBuf(Buffer); | 47 llvm::raw_string_ostream StrBuf(Buffer); |
48 StrBuf << "Invalid number of FDs for onInitCallback " << ObjFileFDCount | 48 StrBuf << "Invalid number of FDs for onInitCallback " << ObjFileFDCount |
49 << "\n"; | 49 << "\n"; |
50 return strdup(StrBuf.str().c_str()); | 50 return strdup(StrBuf.str().c_str()); |
51 } | 51 } |
52 int ObjFileFD = ObjFileFDs[0]; | 52 int ObjFileFD = ObjFileFDs[0]; |
53 if (ObjFileFD < 0) { | 53 if (ObjFileFD < 0) { |
54 std::string Buffer; | 54 std::string Buffer; |
55 llvm::raw_string_ostream StrBuf(Buffer); | 55 llvm::raw_string_ostream StrBuf(Buffer); |
56 StrBuf << "Invalid FD given for onInitCallback " << ObjFileFD << "\n"; | 56 StrBuf << "Invalid FD given for onInitCallback " << ObjFileFD << "\n"; |
57 return strdup(StrBuf.str().c_str()); | 57 return strdup(StrBuf.str().c_str()); |
58 } | 58 } |
59 // NOTE: argv is owned by the caller, but we parse here before returning. | 59 // CLArgs is almost an "argv", but is missing the argv[0] program name. |
60 gCompileServer->getParsedFlags(NumThreads, argc, argv); | 60 std::vector<char *> Argv; |
Mircea Trofin
2015/03/31 17:24:04
you could just
std::vector<char *> Argv(CLArgsLen
Jim Stichnoth
2015/03/31 17:26:44
True, but then the push_back() calls have to be re
jvoung (off chromium)
2015/03/31 20:41:16
Hmm, I'll stick with reserve() then. Another optio
| |
61 char ProgramName[] = "pnacl-sz.nexe"; | |
62 Argv.reserve(CLArgsLen + 1); | |
63 Argv.push_back(ProgramName); | |
64 for (size_t i = 0; i < CLArgsLen; ++i) { | |
65 Argv.push_back(CLArgs[i]); | |
66 } | |
67 // NOTE: strings pointed to by argv are owned by the caller, but we parse | |
68 // here before returning and don't store them. | |
69 gCompileServer->getParsedFlags(NumThreads, Argv.size(), Argv.data()); | |
61 gCompileServer->startCompileThread(ObjFileFD); | 70 gCompileServer->startCompileThread(ObjFileFD); |
62 return nullptr; | 71 return nullptr; |
63 } | 72 } |
64 | 73 |
65 int onDataCallback(const void *Data, size_t NumBytes) { | 74 int onDataCallback(const void *Data, size_t NumBytes) { |
66 return gCompileServer->pushInputBytes(Data, NumBytes) ? 1 : 0; | 75 return gCompileServer->pushInputBytes(Data, NumBytes) ? 1 : 0; |
67 } | 76 } |
68 | 77 |
69 char *onEndCallback() { | 78 char *onEndCallback() { |
70 gCompileServer->endInputStream(); | 79 gCompileServer->endInputStream(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 this->getCompiler().run(ExtraFlags, *Ctx.get(), | 150 this->getCompiler().run(ExtraFlags, *Ctx.get(), |
142 // Retain original reference, but the compiler | 151 // Retain original reference, but the compiler |
143 // (LLVM's MemoryObject) wants to handle deletion. | 152 // (LLVM's MemoryObject) wants to handle deletion. |
144 std::unique_ptr<llvm::DataStreamer>(InputStream)); | 153 std::unique_ptr<llvm::DataStreamer>(InputStream)); |
145 }); | 154 }); |
146 } | 155 } |
147 | 156 |
148 } // end of namespace Ice | 157 } // end of namespace Ice |
149 | 158 |
150 #endif // PNACL_BROWSER_TRANSLATOR | 159 #endif // PNACL_BROWSER_TRANSLATOR |
OLD | NEW |