aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-04 14:32:21 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-04 14:32:21 -0700
commit93aa89e9e9d8ffe93393bb19e61cf98b5ec298db (patch)
treefd1b53f1314384fe106a5aa99690433d65d14d07 /emscripten.py
parentcce94969bdda8d209dddd69ad68cf883ab085333 (diff)
split function table indexings into 4 Uint8 when in the singleton global allocation
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py
index c6a08e6a..a42fe116 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -308,7 +308,12 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
indexing = forwarded_json['Functions']['indexedFunctions']
def indexize(js):
- return re.sub(r"'{{ FI_([\w\d_$]+) }}'", lambda m: str(indexing.get(m.groups(0)[0]) or 0), js)
+ # In the global initial allocation, we need to split up into Uint8 format
+ def split_32(x):
+ x = int(x)
+ return '%d,%d,%d,%d' % (x&255, (x >> 8)&255, (x >> 16)&255, (x >> 24)&255)
+ ret = re.sub(r"\"'{{ FI_([\w\d_$]+) }}'\",0,0,0", lambda m: split_32(indexing.get(m.groups(0)[0]) or 0), js)
+ return re.sub(r"'{{ FI_([\w\d_$]+) }}'", lambda m: str(indexing.get(m.groups(0)[0]) or 0), ret)
blockaddrs = forwarded_json['Functions']['blockAddresses']
def blockaddrsize(js):