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

Side by Side Diff: src/main.cpp

Issue 1781213002: Add malloc/new profiling on linux (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Refactoring Created 4 years, 9 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
« src/LinuxMallocProfiling.cpp ('K') | « src/LinuxMallocProfiling.cpp ('k') | no next file » | 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/main.cpp - Entry point for bitcode translation ---------===// 1 //===- subzero/src/main.cpp - Entry point for bitcode translation ---------===//
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 /// \brief Defines the entry point for translating PNaCl bitcode into native 11 /// \brief Defines the entry point for translating PNaCl bitcode into native
12 /// code. 12 /// code.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "IceBrowserCompileServer.h" 16 #include "IceBrowserCompileServer.h"
17 #include "IceBuildDefs.h" 17 #include "IceBuildDefs.h"
18 #include "IceCompileServer.h" 18 #include "IceCompileServer.h"
19 #ifdef ALLOW_LINUX_MALLOC_PROFILE
20 #include "LinuxMallocProfiling.h"
21 #endif // ALLOW_LINUX_MALLOC_PROFILE
19 22
20 #ifdef __pnacl__ 23 #ifdef __pnacl__
21 #include <malloc.h> 24 #include <malloc.h>
22 #endif // __pnacl__ 25 #endif // __pnacl__
23 26
24 /// Depending on whether we are building the compiler for the browser or 27 /// Depending on whether we are building the compiler for the browser or
25 /// standalone, we will end up creating a Ice::BrowserCompileServer or 28 /// standalone, we will end up creating a Ice::BrowserCompileServer or
26 /// Ice::CLCompileServer object. Method 29 /// Ice::CLCompileServer object. Method
27 /// Ice::CompileServer::runAndReturnErrorCode is used for the invocation. 30 /// Ice::CompileServer::runAndReturnErrorCode is used for the invocation.
28 /// There are no real commandline arguments in the browser case. They are 31 /// 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. 32 /// 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 33 /// We can only compile the Ice::BrowserCompileServer object with the PNaCl
31 /// compiler toolchain, when building Subzero as a sandboxed translator. 34 /// compiler toolchain, when building Subzero as a sandboxed translator.
32 int main(int argc, char **argv) { 35 int main(int argc, char **argv) {
36 #ifdef ALLOW_LINUX_MALLOC_PROFILE
37 Ice::LinuxMallocProfiling::Start();
38 #endif // ALLOW_LINUX_MALLOC_PROFILE
33 #ifdef __pnacl__ 39 #ifdef __pnacl__
34 #define M_GRANULARITY (-2) 40 #define M_GRANULARITY (-2)
35 // PNaCl's default malloc implementation grabs small chunks of memory with 41 // PNaCl's default malloc implementation grabs small chunks of memory with
36 // mmap at a time, hence causing significant slowdowns. This call ensures that 42 // 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. 43 // mmap is used to allocate 16MB at a time, to amortize the system call cost.
38 mallopt(M_GRANULARITY, 16 * 1024 * 1024); 44 mallopt(M_GRANULARITY, 16 * 1024 * 1024);
39 #undef M_GRANULARITY 45 #undef M_GRANULARITY
40 #endif // __pnacl__ 46 #endif // __pnacl__
41 47
42 if (Ice::BuildDefs::browser()) { 48 if (Ice::BuildDefs::browser()) {
43 assert(argc == 1); 49 assert(argc == 1);
44 return Ice::BrowserCompileServer().runAndReturnErrorCode(); 50 return Ice::BrowserCompileServer().runAndReturnErrorCode();
45 } 51 }
46 return Ice::CLCompileServer(argc, argv).runAndReturnErrorCode(); 52 int error = Ice::CLCompileServer(argc, argv).runAndReturnErrorCode();
Jim Stichnoth 2016/03/12 00:12:58 s/error/Error/
sehr 2016/03/15 00:36:46 Done.
53 #ifdef ALLOW_LINUX_MALLOC_PROFILE
54 Ice::LinuxMallocProfiling::End();
55 #endif // ALLOW_LINUX_MALLOC_PROFILE
56 return error;
47 } 57 }
OLDNEW
« src/LinuxMallocProfiling.cpp ('K') | « src/LinuxMallocProfiling.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698