diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-11-29 16:43:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:20 -0800 |
commit | 9cbdfde1937770d866fcf44b8158c71c025b0900 (patch) | |
tree | ba61542603a7c2123ae7d539663e4c07db3ec674 /src | |
parent | 3ce1d7793a6bfb81e7e86e2c2796c9745f18ff75 (diff) |
pre-allocate stdin, stdout, stderr, so their values remain constant just like normal LLVM constants
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/library.js b/src/library.js index de2b448e..ddfbd5db 100644 --- a/src/library.js +++ b/src/library.js @@ -20,9 +20,10 @@ LibraryManager.library = { // File system base. // ========================================================================== - stdin: 0, - stdout: 0, - stderr: 0, + // keep this low in memory, because we flatten arrays with them in them + stdin: 'allocate(1, "i32*", ALLOC_STACK)', + stdout: 'allocate(1, "i32*", ALLOC_STACK)', + stderr: 'allocate(1, "i32*", ALLOC_STACK)', _impure_ptr: 0, $FS__deps: ['$ERRNO_CODES', '__setErrNo', 'stdin', 'stdout', 'stderr', '_impure_ptr'], @@ -572,10 +573,10 @@ LibraryManager.library = { eof: false, ungotten: [] }; - // Allocate these on the stack (and never free, we are called from ATINIT or earlier), to keep their locations low - _stdin = allocate([1], 'void*', ALLOC_STACK); - _stdout = allocate([2], 'void*', ALLOC_STACK); - _stderr = allocate([3], 'void*', ALLOC_STACK); + assert(Math.max(_stdin, _stdout, _stderr) < 128); // make sure these are low, we flatten arrays with these + {{{ makeSetValue('_stdin', 0, 1, 'void*') }}}; + {{{ makeSetValue('_stdout', 0, 2, 'void*') }}}; + {{{ makeSetValue('_stderr', 0, 3, 'void*') }}}; // Other system paths FS.createPath('/', 'dev/shm/tmp', true, true); // temp files |