diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-01-25 18:40:31 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-01-25 18:40:31 -0800 |
commit | d57236a76b95d15f77d98db827a567c40d87f173 (patch) | |
tree | 0871454cfc4f78dc8daadf533b22fbbf8b8eea46 | |
parent | 55ea32242febfd83841d39d1b53d6e2f190db67c (diff) | |
parent | 01e21e541251d271d28e92b2c6b28a8290994470 (diff) |
Merge branch 'master' into llvmopts
-rwxr-xr-x | emar | 4 | ||||
-rw-r--r-- | src/intertyper.js | 4 | ||||
-rw-r--r-- | src/jsifier.js | 18 | ||||
-rw-r--r-- | src/parseTools.js | 3 | ||||
-rw-r--r-- | src/preamble.js | 2 | ||||
-rw-r--r-- | src/preamble_sharedlib.js | 1 | ||||
-rw-r--r-- | system/include/libc/ifaddrs.h | 64 | ||||
-rw-r--r-- | system/include/net/if.h | 26 | ||||
-rw-r--r-- | system/include/sys/io.h | 14 | ||||
-rwxr-xr-x | tests/runner.py | 16 |
10 files changed, 138 insertions, 14 deletions
@@ -12,11 +12,11 @@ from tools import shared DEBUG = os.environ.get('EMCC_DEBUG') -newargs = [shared.EMLD] + sys.argv[3:] + ['-o='+sys.argv[2]] +newargs = [shared.LLVM_LINK] + sys.argv[3:] + ['-o='+sys.argv[2]] if DEBUG: print >> sys.stderr, 'emar:', sys.argv, ' ==> ', newargs if len(newargs) > 2: - os.execvp(shared.EMLD, newargs) + os.execvp(shared.LLVM_LINK, newargs) diff --git a/src/intertyper.js b/src/intertyper.js index d295a872..ae9794b8 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -83,10 +83,12 @@ function intertyper(data, sidePass, baseLineNums) { var global = /([@%\w\d\.\" ]+) = .*/.exec(line); var globalIdent = toNiceIdent(global[1]); var testAlias = /[@%\w\d\.\" ]+ = alias .*/.exec(line); + var testString = /^[^"]+c\"[^"]+"/.exec(line); Variables.globals[globalIdent] = { name: globalIdent, alias: !!testAlias, - impl: VAR_EMULATED + impl: VAR_EMULATED, + isString : !!testString }; unparsedGlobals.lines.push(line); } else { diff --git a/src/jsifier.js b/src/jsifier.js index 846cb4c1..7bff588c 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -247,7 +247,8 @@ function JSify(data, functionsOnly, givenFunctions) { substrate.addActor('GlobalVariable', { processItem: function(item) { function needsPostSet(value) { - return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW'; + return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW' + || value.substr(0, 13) === 'STRING_TABLE.'; } item.intertype = 'GlobalVariableStub'; @@ -264,7 +265,9 @@ function JSify(data, functionsOnly, givenFunctions) { // they would shadow similarly-named globals in the parent. item.JS = ''; } else { - item.JS = 'var ' + item.ident + ';'; + if (!(item.ident in Variables.globals) || !Variables.globals[item.ident].isString) { + item.JS = 'var ' + item.ident + ';'; + } } var constant = null; if (item.external) { @@ -313,7 +316,16 @@ function JSify(data, functionsOnly, givenFunctions) { // allocations in a shared library. constant = makePointer(constant, null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', item.type); - var js = item.ident + '=' + constant + ';'; + var js; + + // Strings are held in STRING_TABLE, to not clutter up the main namespace (in some cases we have + // many many strings, possibly exceeding the js engine limit on global vars). + if (Variables.globals[item.ident].isString) { + js = 'STRING_TABLE.' + item.ident + '=' + constant + ';'; + } else { + js = item.ident + '=' + constant + ';'; + } + // Special case: class vtables. We make sure they are null-terminated, to allow easy runtime operations if (item.ident.substr(0, 5) == '__ZTV') { js += '\n' + makePointer('[0]', null, BUILD_AS_SHARED_LIB ? 'ALLOC_NORMAL' : 'ALLOC_STATIC', ['void*']) + ';'; diff --git a/src/parseTools.js b/src/parseTools.js index d956ccfb..49e5b411 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1439,6 +1439,9 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { } } else if (param.intertype == 'value') { ret = param.ident; + if (ret in Variables.globals && Variables.globals[ret].isString) { + ret = "STRING_TABLE." + ret; + } if (param.type == 'i64' && I64_MODE == 1) { ret = parseI64Constant(ret); } diff --git a/src/preamble.js b/src/preamble.js index 051bb8d4..94add7f4 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -771,6 +771,8 @@ function intArrayToString(array) { } Module['intArrayToString'] = intArrayToString; +var STRING_TABLE = []; + {{{ unSign }}} {{{ reSign }}} diff --git a/src/preamble_sharedlib.js b/src/preamble_sharedlib.js index 2a071f6b..af204e2f 100644 --- a/src/preamble_sharedlib.js +++ b/src/preamble_sharedlib.js @@ -16,6 +16,7 @@ function callRuntimeCallbacks(callbacks) { } var __ATINIT__ = []; // functions called during startup +var STRING_TABLE = []; function initRuntime() { callRuntimeCallbacks(__ATINIT__); diff --git a/system/include/libc/ifaddrs.h b/system/include/libc/ifaddrs.h new file mode 100644 index 00000000..f96d57e3 --- /dev/null +++ b/system/include/libc/ifaddrs.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 1995, 1999 + * Berkeley Software Design, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp + */ + +#ifndef _IFADDRS_H_ +#define _IFADDRS_H_ + +#include <sys/socket.h> + +struct ifaddrs { + struct ifaddrs *ifa_next; + char *ifa_name; + unsigned int ifa_flags; + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + struct sockaddr *ifa_dstaddr; + void *ifa_data; +}; + +/* + * This may have been defined in <net/if.h>. Note that if <net/if.h> is + * to be included it must be included before this header file. + */ +#ifndef ifa_broadaddr +#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ +#endif + +struct ifmaddrs { + struct ifmaddrs *ifma_next; + struct sockaddr *ifma_name; + struct sockaddr *ifma_addr; + struct sockaddr *ifma_lladdr; +}; + +#include <sys/cdefs.h> + +extern int getifaddrs(struct ifaddrs **); +extern void freeifaddrs(struct ifaddrs *); +extern int getifmaddrs(struct ifmaddrs **); +extern void freeifmaddrs(struct ifmaddrs *); + +#endif + diff --git a/system/include/net/if.h b/system/include/net/if.h new file mode 100644 index 00000000..9a4badf3 --- /dev/null +++ b/system/include/net/if.h @@ -0,0 +1,26 @@ + +#ifndef _NET_IF_H +#define _NET_IF_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct if_nameindex { + unsigned if_index; + char *if_name; +}; + +#define IF_NAMESIZE abort(0); + +unsigned if_nametoindex(const char *a); +char *if_indextoname(unsigned int a, char *b); +struct if_nameindex *if_nameindex(); +void if_freenameindex(struct if_nameindex *a); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/system/include/sys/io.h b/system/include/sys/io.h new file mode 100644 index 00000000..8caea237 --- /dev/null +++ b/system/include/sys/io.h @@ -0,0 +1,14 @@ + +#ifndef _SYS_IO_H +#define _SYS_IO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/tests/runner.py b/tests/runner.py index c886afd4..eb96160e 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -4155,7 +4155,7 @@ def process(filename): def get_freetype(self): Settings.INIT_STACK = 1 # TODO: Investigate why this is necessary - return self.get_library('freetype', os.path.join('objs', '.libs', 'libfreetype.a.bc')) + return self.get_library('freetype', os.path.join('objs', '.libs', 'libfreetype.a')) def test_freetype(self): if Settings.QUANTUM_SIZE == 1: return self.skip('TODO: Figure out and try to fix') @@ -4234,7 +4234,7 @@ def process(filename): self.do_run(open(path_from_root('tests', 'zlib', 'example.c'), 'r').read(), open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(), - libraries=[self.get_library('zlib', os.path.join('libz.a.bc'), make_args=['libz.a'])], + libraries=[self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a'])], includes=[path_from_root('tests', 'zlib')], force_c=True) @@ -4251,9 +4251,9 @@ def process(filename): self.do_run(open(path_from_root('tests', 'bullet', 'Demos', 'HelloWorld', 'HelloWorld.cpp'), 'r').read(), [open(path_from_root('tests', 'bullet', 'output.txt'), 'r').read(), # different roundings open(path_from_root('tests', 'bullet', 'output2.txt'), 'r').read()], - libraries=[self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletCollision.a.bc'), - os.path.join('src', '.libs', 'libBulletDynamics.a.bc'), - os.path.join('src', '.libs', 'libLinearMath.a.bc')], + libraries=[self.get_library('bullet', [os.path.join('src', '.libs', 'libBulletCollision.a'), + os.path.join('src', '.libs', 'libBulletDynamics.a'), + os.path.join('src', '.libs', 'libLinearMath.a')], configure_args=['--disable-demos','--disable-dependency-tracking'])], includes=[path_from_root('tests', 'bullet', 'src')], js_engines=[SPIDERMONKEY_ENGINE]) # V8 issue 1407 @@ -4299,9 +4299,9 @@ def process(filename): poppler = self.get_library('poppler', [os.path.join('poppler', '.libs', 'libpoppler.so.13.0.0'), - os.path.join('goo', '.libs', 'libgoo.a.bc'), - os.path.join('fofi', '.libs', 'libfofi.a.bc'), - os.path.join('splash', '.libs', 'libsplash.a.bc'), + os.path.join('goo', '.libs', 'libgoo.a'), + os.path.join('fofi', '.libs', 'libfofi.a'), + os.path.join('splash', '.libs', 'libsplash.a'), os.path.join('utils', 'pdftoppm.o'), os.path.join('utils', 'parseargs.o')], configure_args=['--disable-libjpeg', '--disable-libpng', '--disable-poppler-qt', '--disable-poppler-qt4', '--disable-cms']) |