Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ASM_CONSTS keys to be non-contiguous #9740

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -2225,10 +2225,11 @@ def emscript_wasm_backend(infile, outfile, memfile, compiler_engine,

asm_consts, asm_const_funcs = create_asm_consts_wasm(forwarded_json, metadata)
em_js_funcs = create_em_js(forwarded_json, metadata)
asm_const_pairs = ['%s: %s' % (key, value) for key, value in asm_consts]
asm_const_map = 'var ASM_CONSTS = {\n ' + ', \n '.join(asm_const_pairs) + '\n};\n'
pre = pre.replace(
'// === Body ===',
('// === Body ===\n\nvar ASM_CONSTS = [' +
',\n '.join(asm_consts) + '];\n' +
('// === Body ===\n\n' + asm_const_map +
asstr('\n'.join(asm_const_funcs)) +
'\n'.join(em_js_funcs) + '\n'))
pre = apply_table(pre)
Expand Down Expand Up @@ -2342,7 +2343,7 @@ def debug_copy(src, dst):


def create_asm_consts_wasm(forwarded_json, metadata):
asm_consts = [0] * len(metadata['asmConsts'])
asm_consts = {}
all_sigs = []
for k, v in metadata['asmConsts'].items():
const, sigs, call_types = v
Expand Down Expand Up @@ -2417,6 +2418,8 @@ def create_asm_consts_wasm(forwarded_json, metadata):
var args = readAsmConstArgs(sigPtr, argbuf);
return ASM_CONSTS[code].apply(null, args);
}''' % (const_name, preamble))
asm_consts = [(key, value) for key, value in asm_consts.items()]
asm_consts.sort()
return asm_consts, asm_const_funcs


Expand Down
4 changes: 2 additions & 2 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -8684,8 +8684,8 @@ def test_js_optimizer_parse_error(self):
var ASM_CONSTS = [function() { var x = !<->5.; }];
^
''', '''
var ASM_CONSTS = [function() {var x = !<->5.;}];
^
0: function() {var x = !<->5.;}
sbc100 marked this conversation as resolved.
Show resolved Hide resolved
^
sbc100 marked this conversation as resolved.
Show resolved Hide resolved
'''), stderr)

def test_EM_ASM_ES6(self):
Expand Down