@@ -493,14 +493,13 @@ def emscript(infile, outfile, memfile, temp_files, DEBUG):
493
493
494
494
report_missing_symbols (set ([asmjs_mangle (f ) for f in exports ]), pre )
495
495
496
- asm_consts , asm_const_funcs = create_asm_consts_wasm (forwarded_json , metadata )
496
+ asm_consts = create_asm_consts_wasm (forwarded_json , metadata )
497
497
em_js_funcs = create_em_js (forwarded_json , metadata )
498
498
asm_const_pairs = ['%s: %s' % (key , value ) for key , value in asm_consts ]
499
499
asm_const_map = 'var ASM_CONSTS = {\n ' + ', \n ' .join (asm_const_pairs ) + '\n };\n '
500
500
pre = pre .replace (
501
501
'// === Body ===' ,
502
502
('// === Body ===\n \n ' + asm_const_map +
503
- asstr ('\n ' .join (asm_const_funcs )) +
504
503
'\n ' .join (em_js_funcs ) + '\n ' ))
505
504
pre = apply_table (pre )
506
505
outfile .write (pre )
@@ -585,6 +584,7 @@ def finalize_wasm(temp_files, infile, outfile, memfile, DEBUG):
585
584
args .append ('--pass-arg=legalize-js-interface-export-originals' )
586
585
if shared .Settings .DEBUG_LEVEL >= 3 :
587
586
args .append ('--dwarf' )
587
+ args .append ('--minimize-wasm-changes' )
588
588
stdout = building .run_binaryen_command ('wasm-emscripten-finalize' ,
589
589
infile = base_wasm ,
590
590
outfile = wasm ,
@@ -606,7 +606,6 @@ def finalize_wasm(temp_files, infile, outfile, memfile, DEBUG):
606
606
607
607
def create_asm_consts_wasm (forwarded_json , metadata ):
608
608
asm_consts = {}
609
- all_sigs = []
610
609
for k , v in metadata ['asmConsts' ].items ():
611
610
const , sigs , call_types = v
612
611
const = asstr (const )
@@ -621,47 +620,9 @@ def create_asm_consts_wasm(forwarded_json, metadata):
621
620
args .append ('$' + str (i ))
622
621
const = 'function(' + ', ' .join (args ) + ') {' + const + '}'
623
622
asm_consts [int (k )] = const
624
- for sig , call_type in zip (sigs , call_types ):
625
- all_sigs .append ((sig , call_type ))
626
-
627
- asm_const_funcs = []
628
-
629
- for sig , call_type in set (all_sigs ):
630
- const_name = '_emscripten_asm_const_' + call_type + sig
631
- forwarded_json ['Functions' ]['libraryFunctions' ][const_name ] = 1
632
-
633
- preamble = ''
634
- if shared .Settings .USE_PTHREADS :
635
- sync_proxy = call_type == 'sync_on_main_thread_'
636
- async_proxy = call_type == 'async_on_main_thread_'
637
- proxied = sync_proxy or async_proxy
638
- if proxied :
639
- # In proxied function calls, positive integers 1, 2, 3, ... denote pointers
640
- # to regular C compiled functions. Negative integers -1, -2, -3, ... denote
641
- # indices to EM_ASM() blocks, so remap the EM_ASM() indices from 0, 1, 2,
642
- # ... over to the negative integers starting at -1.
643
- preamble += ('\n if (ENVIRONMENT_IS_PTHREAD) { ' +
644
- proxy_debug_print (sync_proxy ) +
645
- 'return _emscripten_proxy_to_main_thread_js.apply(null, ' +
646
- '[-1 - code, ' + str (int (sync_proxy )) + '].concat(args)) }' )
647
-
648
- if shared .Settings .RELOCATABLE :
649
- preamble += '\n code -= %s;\n ' % shared .Settings .GLOBAL_BASE
650
-
651
- # EM_ASM functions are variadic, receiving the actual arguments as a buffer
652
- # in memory. the last parameter (argBuf) points to that data. We need to
653
- # alwayd un-variadify that, as in the async case this is a stack allocation
654
- # that LLVM made, which may go away before the main thread gets the message.
655
- # the readAsmConstArgs helper does so.
656
- asm_const_funcs .append (r'''
657
- function %s(code, sigPtr, argbuf) {
658
- var args = readAsmConstArgs(sigPtr, argbuf);
659
- %s
660
- return ASM_CONSTS[code].apply(null, args);
661
- }''' % (const_name , preamble ))
662
623
asm_consts = [(key , value ) for key , value in asm_consts .items ()]
663
624
asm_consts .sort ()
664
- return asm_consts , asm_const_funcs
625
+ return asm_consts
665
626
666
627
667
628
def create_em_js (forwarded_json , metadata ):
@@ -815,13 +776,9 @@ def create_sending_wasm(invoke_funcs, forwarded_json, metadata):
815
776
if shared .Settings .SAFE_HEAP :
816
777
basic_funcs += ['segfault' , 'alignfault' ]
817
778
818
- em_asm_sigs = [zip (sigs , call_types ) for _ , sigs , call_types in metadata ['asmConsts' ].values ()]
819
- # flatten em_asm_sigs
820
- em_asm_sigs = [sig for sigs in em_asm_sigs for sig in sigs ]
821
- em_asm_funcs = ['_emscripten_asm_const_' + call_type + sig for sig , call_type in em_asm_sigs ]
822
779
em_js_funcs = list (metadata ['emJsFuncs' ].keys ())
823
780
declared_items = ['_' + item for item in metadata ['declares' ]]
824
- send_items = set (basic_funcs + invoke_funcs + em_asm_funcs + em_js_funcs + declared_items )
781
+ send_items = set (basic_funcs + invoke_funcs + em_js_funcs + declared_items )
825
782
826
783
def fix_import_name (g ):
827
784
if g .startswith ('Math_' ):
0 commit comments