Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 1 | //===- subzero/src/main.cpp - Entry point for bitcode translation ---------===// |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 9 | /// |
| 10 | /// \file |
Jim Stichnoth | 92a6e5b | 2015-12-02 16:52:44 -0800 | [diff] [blame] | 11 | /// \brief Defines the entry point for translating PNaCl bitcode into native |
Andrew Scull | 57e1268 | 2015-09-16 11:30:19 -0700 | [diff] [blame] | 12 | /// code. |
Andrew Scull | 9612d32 | 2015-07-06 14:53:25 -0700 | [diff] [blame] | 13 | /// |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 16 | #include "IceBrowserCompileServer.h" |
Reed Kotler | 43e8ab3 | 2015-12-07 14:31:01 -0800 | [diff] [blame] | 17 | #include "IceBuildDefs.h" |
Jan Voung | 44c3a80 | 2015-03-27 16:29:08 -0700 | [diff] [blame] | 18 | #include "IceCompileServer.h" |
Karl Schimpf | b262c5e | 2014-10-27 14:41:57 -0700 | [diff] [blame] | 19 | |
John Porto | 36d6aa6 | 2016-02-26 07:19:59 -0800 | [diff] [blame] | 20 | #ifdef __pnacl__ |
| 21 | #include <malloc.h> |
| 22 | #endif // __pnacl__ |
| 23 | |
Reed Kotler | 10665a2 | 2015-12-10 13:57:32 -0800 | [diff] [blame] | 24 | /// Depending on whether we are building the compiler for the browser or |
| 25 | /// standalone, we will end up creating a Ice::BrowserCompileServer or |
| 26 | /// Ice::CLCompileServer object. Method |
| 27 | /// Ice::CompileServer::runAndReturnErrorCode is used for the invocation. |
| 28 | /// There are no real commandline arguments in the browser case. They are |
| 29 | /// supplied via IPC so argc, and argv are not used in that case. |
| 30 | /// We can only compile the Ice::BrowserCompileServer object with the PNaCl |
| 31 | /// compiler toolchain, when building Subzero as a sandboxed translator. |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 32 | int main(int argc, char **argv) { |
John Porto | 36d6aa6 | 2016-02-26 07:19:59 -0800 | [diff] [blame] | 33 | #ifdef __pnacl__ |
| 34 | #define M_GRANULARITY (-2) |
| 35 | // PNaCl's default malloc implementation grabs small chunks of memory with |
| 36 | // mmap at a time, hence causing significant slowdowns. This call ensures that |
| 37 | // mmap is used to allocate 16MB at a time, to amortize the system call cost. |
| 38 | mallopt(M_GRANULARITY, 16 * 1024 * 1024); |
| 39 | #undef M_GRANULARITY |
| 40 | #endif // __pnacl__ |
| 41 | |
Reed Kotler | 43e8ab3 | 2015-12-07 14:31:01 -0800 | [diff] [blame] | 42 | if (Ice::BuildDefs::browser()) { |
Reed Kotler | 43e8ab3 | 2015-12-07 14:31:01 -0800 | [diff] [blame] | 43 | assert(argc == 1); |
| 44 | return Ice::BrowserCompileServer().runAndReturnErrorCode(); |
| 45 | } |
| 46 | return Ice::CLCompileServer(argc, argv).runAndReturnErrorCode(); |
Jim Stichnoth | f7c9a14 | 2014-04-29 10:52:43 -0700 | [diff] [blame] | 47 | } |