@@ -775,10 +775,12 @@ class Exceptions(IntEnum):
775
775
- EMSCRIPTEN: Emscripten provides exception handling capability using JS
776
776
emulation. This causes code size increase and performance degradation.
777
777
- WASM_LEGACY: Wasm native exception handling support (legacy)
778
+ - WASM: Wasm native exception handling support
778
779
"""
779
780
NONE = auto ()
780
781
EMSCRIPTEN = auto ()
781
782
WASM_LEGACY = auto ()
783
+ WASM = auto ()
782
784
783
785
784
786
class ExceptionLibrary (Library ):
@@ -793,7 +795,9 @@ def get_cflags(self):
793
795
elif self .eh_mode == Exceptions .EMSCRIPTEN :
794
796
cflags += ['-sDISABLE_EXCEPTION_CATCHING=0' ]
795
797
elif self .eh_mode == Exceptions .WASM_LEGACY :
796
- cflags += ['-fwasm-exceptions' ]
798
+ cflags += ['-fwasm-exceptions' , '-sWASM_LEGACY_EXCEPTIONS' ]
799
+ elif self .eh_mode == Exceptions .WASM :
800
+ cflags += ['-fwasm-exceptions' , '-sWASM_LEGACY_EXCEPTIONS=0' ]
797
801
798
802
return cflags
799
803
@@ -805,19 +809,25 @@ def get_base_name(self):
805
809
name += '-noexcept'
806
810
elif self .eh_mode == Exceptions .WASM_LEGACY :
807
811
name += '-legacyexcept'
812
+ elif self .eh_mode == Exceptions .WASM :
813
+ name += '-wasmexcept'
808
814
return name
809
815
810
816
@classmethod
811
817
def variations (cls ):
812
818
combos = super ().variations ()
813
819
return ([dict (eh_mode = Exceptions .NONE , ** combo ) for combo in combos ] +
814
820
[dict (eh_mode = Exceptions .EMSCRIPTEN , ** combo ) for combo in combos ] +
815
- [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ])
821
+ [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ] +
822
+ [dict (eh_mode = Exceptions .WASM , ** combo ) for combo in combos ])
816
823
817
824
@classmethod
818
825
def get_default_variation (cls , ** kwargs ):
819
826
if settings .WASM_EXCEPTIONS :
820
- eh_mode = Exceptions .WASM_LEGACY
827
+ if settings .WASM_LEGACY_EXCEPTIONS :
828
+ eh_mode = Exceptions .WASM_LEGACY
829
+ else :
830
+ eh_mode = Exceptions .WASM
821
831
elif settings .DISABLE_EXCEPTION_CATCHING == 1 :
822
832
eh_mode = Exceptions .NONE
823
833
else :
@@ -838,6 +848,12 @@ def get_cflags(self):
838
848
'-sDISABLE_EXCEPTION_THROWING=0' ]
839
849
elif self .eh_mode == Exceptions .WASM_LEGACY :
840
850
cflags += ['-sSUPPORT_LONGJMP=wasm' ,
851
+ '-sWASM_LEGACY_EXCEPTIONS' ,
852
+ '-sDISABLE_EXCEPTION_THROWING' ,
853
+ '-D__WASM_SJLJ__' ]
854
+ elif self .eh_mode == Exceptions .WASM :
855
+ cflags += ['-sSUPPORT_LONGJMP=wasm' ,
856
+ '-sWASM_LEGACY_EXCEPTIONS=0' ,
841
857
'-sDISABLE_EXCEPTION_THROWING' ,
842
858
'-D__WASM_SJLJ__' ]
843
859
return cflags
@@ -848,18 +864,24 @@ def get_base_name(self):
848
864
# suffixes. Change the default to wasm exception later.
849
865
if self .eh_mode == Exceptions .WASM_LEGACY :
850
866
name += '-legacysjlj'
867
+ elif self .eh_mode == Exceptions .WASM :
868
+ name += '-wasmsjlj'
851
869
return name
852
870
853
871
@classmethod
854
872
def variations (cls ):
855
873
combos = super ().variations ()
856
874
return ([dict (eh_mode = Exceptions .EMSCRIPTEN , ** combo ) for combo in combos ] +
857
- [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ])
875
+ [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ] +
876
+ [dict (eh_mode = Exceptions .WASM , ** combo ) for combo in combos ])
858
877
859
878
@classmethod
860
879
def get_default_variation (cls , ** kwargs ):
861
880
if settings .SUPPORT_LONGJMP == 'wasm' :
862
- eh_mode = Exceptions .WASM_LEGACY
881
+ if settings .WASM_LEGACY_EXCEPTIONS :
882
+ eh_mode = Exceptions .WASM_LEGACY
883
+ else :
884
+ eh_mode = Exceptions .WASM
863
885
else :
864
886
eh_mode = Exceptions .EMSCRIPTEN
865
887
return super ().get_default_variation (eh_mode = eh_mode , ** kwargs )
@@ -1600,7 +1622,7 @@ def get_files(self):
1600
1622
filenames += ['cxa_noexception.cpp' ]
1601
1623
elif self .eh_mode == Exceptions .EMSCRIPTEN :
1602
1624
filenames += ['cxa_exception_emscripten.cpp' ]
1603
- elif self .eh_mode == Exceptions .WASM_LEGACY :
1625
+ elif self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
1604
1626
filenames += [
1605
1627
'cxa_exception_storage.cpp' ,
1606
1628
'cxa_exception.cpp' ,
@@ -1654,7 +1676,7 @@ class libcxx(ExceptionLibrary, MTLibrary):
1654
1676
1655
1677
def get_cflags (self ):
1656
1678
cflags = super ().get_cflags ()
1657
- if self .eh_mode == Exceptions .WASM_LEGACY :
1679
+ if self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
1658
1680
cflags .append ('-D__WASM_EXCEPTIONS__' )
1659
1681
return cflags
1660
1682
@@ -1677,7 +1699,7 @@ def __init__(self, **kwargs):
1677
1699
super ().__init__ (** kwargs )
1678
1700
1679
1701
def can_use (self ):
1680
- return super ().can_use () and self .eh_mode == Exceptions .WASM_LEGACY
1702
+ return super ().can_use () and self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM )
1681
1703
1682
1704
def get_cflags (self ):
1683
1705
cflags = super ().get_cflags ()
@@ -1688,7 +1710,7 @@ def get_cflags(self):
1688
1710
cflags .append ('-D_LIBUNWIND_HAS_NO_EXCEPTIONS' )
1689
1711
elif self .eh_mode == Exceptions .EMSCRIPTEN :
1690
1712
cflags .append ('-D__EMSCRIPTEN_EXCEPTIONS__' )
1691
- elif self .eh_mode == Exceptions .WASM_LEGACY :
1713
+ elif self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
1692
1714
cflags .append ('-D__WASM_EXCEPTIONS__' )
1693
1715
return cflags
1694
1716
0 commit comments