Ignore NaCl st_blksize of 0 and buffer writes to raw_fd_ostream.
Ignore NaCl st_blksize of 0 and buffer writes to raw_fd_ostream.

The default LLVM raw_fd_ostream buffer size is based on stat'ing the
FD and then checking st_blksize. Unfortunately, in the NaCl sandboxed
build of pnacl-sz, NaCl's syscall returns st_blksize of 0 which makes
the writes unbuffered. There is a comment in "src/trusted/service_runtime/include/bits/stat.h":

  nacl_abi_blksize_t nacl_abi_st_blksize;   /* not implemented */

And the " src/trusted/desc/" implementation sets this to 0.

This results in half a million write syscalls to translate the GCC pexe,
which roughly doubles the translation time in sandboxed mode vs
unsandboxed mode.

Manually set a buffer size (Linux st_blksize seems to be about
4KB for comparison). This drops the number of write syscalls
to about 200 for translating the GCC pexe.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4091
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/969403003

bkaradzic/SwiftShader,google/swiftshader,bkaradzic/SwiftShader,google/swiftshader,google/swiftshader,bkaradzic/SwiftShader,bkaradzic/SwiftShader,bkaradzic/SwiftShader