aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-16 17:20:47 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-17 10:01:04 -0800
commite138af189b10854ba16cbc99843a171c59c6d331 (patch)
tree6c50ac845e1ea403175f2036e54c9007b9129513
parent3c4f29d187ce68f6e0b21a59eb8399a7c6e6eb16 (diff)
remove current memory initialization chunking via .concat(..)
-rwxr-xr-xemcc4
-rw-r--r--src/parseTools.js23
-rw-r--r--tools/shared.py2
3 files changed, 4 insertions, 25 deletions
diff --git a/emcc b/emcc
index c295a76e..4ad0706a 100755
--- a/emcc
+++ b/emcc
@@ -1913,9 +1913,7 @@ try:
shared.try_delete(memfile)
def repl(m):
# handle chunking of the memory initializer
- s = re.sub('[\[\]\n\(\)\. ]', '', m.groups(0)[0])
- s = s.replace('concat', ',')
- if s[-1] == ',': s = s[:-1]
+ s = m.groups(0)[0][1:-1]
open(memfile, 'wb').write(''.join(map(lambda x: chr(int(x or '0')), s.split(','))))
if DEBUG:
# Copy into temp dir as well, so can be run there too
diff --git a/src/parseTools.js b/src/parseTools.js
index 036ccfc1..a564f2e3 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1789,31 +1789,12 @@ function makePointer(slab, pos, allocator, type, ptr, finalMemoryInitialization)
types = 'i8';
}
- // JS engines sometimes say array initializers are too large. Work around that by chunking and calling concat to combine at runtime
- var chunkSize = JS_CHUNK_SIZE;
- function chunkify(array) {
- // break very large slabs into parts
- var ret = '';
- var index = 0;
- while (index < array.length) {
- ret = (ret ? ret + '.concat(' : '') + '[' + array.slice(index, index + chunkSize).map(JSON.stringify) + ']' + (ret ? ')\n' : '');
- index += chunkSize;
- }
- return ret;
- }
- if (typeof slab == 'object' && slab.length > chunkSize) {
- slab = chunkify(slab);
- }
if (typeof types == 'object') {
while (types.length < slab.length) types.push(0);
}
- if (typeof types != 'string' && types.length > chunkSize) {
- types = chunkify(types);
- } else {
- types = JSON.stringify(types);
- }
+ types = JSON.stringify(types);
if (typeof slab == 'object') slab = '[' + slab.join(',') + ']';
- return 'allocate(' + slab + ', ' + types + (allocator ? ', ' + allocator : '') + (allocator == 'ALLOC_NONE' ? ', ' + ptr : '') + ')';
+ return 'allocate(' + slab + ', ' + types + (allocator ? ', ' + allocator : '') + (allocator == 'ALLOC_NONE' ? ', ' + ptr : '') + ');';
}
function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
diff --git a/tools/shared.py b/tools/shared.py
index bb50350d..781a7ee7 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1568,7 +1568,7 @@ JCache = cache.JCache(Cache)
chunkify = cache.chunkify
class JS:
- memory_initializer_pattern = '/\* memory initializer \*/ allocate\(([\d,\.concat\(\)\[\]\\n ]+)"i8", ALLOC_NONE, ([\dRuntime\.GLOBAL_BASEH+]+)\)'
+ memory_initializer_pattern = '/\* memory initializer \*/ allocate\((\[[\d, ]+\]), "i8", ALLOC_NONE, ([\d+Runtime\.GLOBAL_BASEH]+)\);'
no_memory_initializer_pattern = '/\* no memory initializer \*/'
memory_staticbump_pattern = 'STATICTOP = STATIC_BASE \+ (\d+);'