Skip to content

Commit cd0e759

Browse files
committed
get glue phase to emit i64 stuff for fastcomp
1 parent edd3875 commit cd0e759

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

emscripten.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -804,19 +804,20 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
804804

805805
if DEBUG: logging.debug('emscript: js compiler glue')
806806

807+
# Settings changes
808+
assert settings['TARGET_LE32'] == 1
809+
settings['TARGET_LE32'] = 2
810+
if 'i64Add' in metadata['declares']: # TODO: others, once we split them up
811+
settings['PRECISE_I64_MATH'] = 2
812+
metadata['declares'] = filter(lambda i64_func: i64_func not in ['getHigh32', 'setHigh32', '__muldsi3', '__divdi3', '__remdi3', '__udivdi3', '__uremdi3'], metadata['declares']) # FIXME: do these one by one as normal js lib funcs
813+
807814
# Integrate info from backend
808815
settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] = list(
809816
set(settings['DEFAULT_LIBRARY_FUNCS_TO_INCLUDE'] + map(shared.JS.to_nice_ident, metadata['declares'])).difference(
810817
map(lambda x: x[1:], metadata['implementedFunctions'])
811818
)
812819
) + map(lambda x: x[1:], metadata['externs'])
813820

814-
# Settings changes
815-
assert settings['TARGET_LE32'] == 1
816-
settings['TARGET_LE32'] = 2
817-
if '_i64Add' in metadata['declares']: # TODO: others, once we split them up
818-
settings['PRECISE_I64_MATH'] = 2
819-
820821
# Save settings to a file to work around v8 issue 1579
821822
settings_file = temp_files.get('.txt').name
822823
def save_settings():
@@ -887,18 +888,14 @@ def save_settings():
887888
#if DEBUG: outfile.write('// funcs\n')
888889

889890
if settings.get('ASM_JS'):
890-
#print >> sys.stderr, '<<<<<<', post, '>>>>>>'
891-
post_funcs = '' #, post_rest = post.split('// EMSCRIPTEN_END_FUNCS\n')
892-
#post = post_rest
893-
894891
# Move preAsms to their right place
895892
def move_preasm(m):
896893
contents = m.groups(0)[0]
897894
outfile.write(contents + '\n')
898895
return ''
899-
post_funcs = re.sub(r'/\* PRE_ASM \*/(.*)\n', lambda m: move_preasm(m), post_funcs)
896+
funcs_js[1] = re.sub(r'/\* PRE_ASM \*/(.*)\n', lambda m: move_preasm(m), funcs_js[1])
900897

901-
funcs_js += ['\n' + post_funcs + '// EMSCRIPTEN_END_FUNCS\n']
898+
funcs_js += ['\n// EMSCRIPTEN_END_FUNCS\n']
902899

903900
simple = os.environ.get('EMCC_SIMPLE_ASM')
904901
class Counter:

src/jsifier.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1859,10 +1859,10 @@ function JSify(data, functionsOnly, givenFunctions) {
18591859
// first row are utilities called from generated code, second are needed from fastLong
18601860
['i64Add', 'i64Subtract', 'bitshift64Shl', 'bitshift64Lshr', 'bitshift64Ashr',
18611861
'llvm_ctlz_i32', 'llvm_cttz_i32'].forEach(function(func) {
1862-
if (!Functions.libraryFunctions[func]) {
1862+
if (!Functions.libraryFunctions[func] || phase == 'glue') { // TODO: one-by-one in fastcomp glue mode
18631863
print(processLibraryFunction(LibraryManager.library[func], func)); // must be first to be close to generated code
18641864
Functions.implementedFunctions['_' + func] = LibraryManager.library[func + '__sig'];
1865-
Functions.libraryFunctions[func] = 1;
1865+
Functions.libraryFunctions[func] = phase == 'glue' ? 2 : 1; // XXX
18661866
// limited dependency handling
18671867
var deps = LibraryManager.library[func + '__deps'];
18681868
if (deps) {

0 commit comments

Comments
 (0)