memory initializer in fastcomp

This commit is contained in:
Alon Zakai 2013-11-20 17:29:52 -08:00
Родитель 22b996181d
Коммит 93ff9b23ee
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -779,8 +779,10 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
funcs = backend_output[start_funcs+len(start_funcs_marker):end_funcs]
metadata_raw = backend_output[metadata_split+len(metadata_split_marker):]
metadata = json.loads(metadata_raw)
mem_init = backend_output[end_funcs+len(end_funcs_marker):metadata_split]
print >> sys.stderr, "FUNCS", funcs
print >> sys.stderr, "META", metadata
print >> sys.stderr, "meminit", mem_init
if DEBUG: logging.debug('emscript: js compiler glue')
@ -816,6 +818,12 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
#print >> sys.stderr, 'glue:', pre, '\n\n||||||||||||||||\n\n', post, '...............'
# memory initializer
pre = pre.replace('STATICTOP = STATIC_BASE + 0;', '''STATICTOP = STATIC_BASE + Runtime.alignMemory(%d);
// /* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } });
%s''' % (mem_init.count(',')+1, mem_init)) # XXX wrong size calculation!
funcs_js = [funcs]
if settings.get('ASM_JS'):
parts = pre.split('// ASM_LIBRARY FUNCTIONS\n')

Просмотреть файл

@ -1742,7 +1742,7 @@ function JSify(data, functionsOnly, givenFunctions) {
});
// write out the singleton big memory initialization value
print('/* memory initializer */ ' + makePointer(memoryInitialization, null, 'ALLOC_NONE', 'i8', 'Runtime.GLOBAL_BASE' + (SIDE_MODULE ? '+H_BASE' : ''), true));
} else {
} else if (phase !== 'glue') {
print('/* no memory initializer */'); // test purposes
}