|
844 | 844 | (unreachable)
|
845 | 845 | )
|
846 | 846 | )
|
| 847 | + |
| 848 | +(module |
| 849 | + ;; We will optimize the descriptor type, so we must take care not to leave |
| 850 | + ;; invalid allocations of its described type. |
| 851 | + (rec |
| 852 | + ;; YESTNH: (rec |
| 853 | + ;; YESTNH-NEXT: (type $struct (descriptor $uninstantiated (struct))) |
| 854 | + ;; NO_TNH: (rec |
| 855 | + ;; NO_TNH-NEXT: (type $struct (descriptor $uninstantiated (struct))) |
| 856 | + (type $struct (descriptor $uninstantiated (struct))) |
| 857 | + ;; YESTNH: (type $uninstantiated (sub (describes $struct (struct)))) |
| 858 | + ;; NO_TNH: (type $uninstantiated (sub (describes $struct (struct)))) |
| 859 | + (type $uninstantiated (sub (describes $struct (struct)))) |
| 860 | + ;; YESTNH: (type $other (descriptor $instantiated (struct))) |
| 861 | + ;; NO_TNH: (type $other (descriptor $instantiated (struct))) |
| 862 | + (type $other (descriptor $instantiated (struct))) |
| 863 | + ;; YESTNH: (type $instantiated (sub $uninstantiated (describes $other (struct)))) |
| 864 | + ;; NO_TNH: (type $instantiated (sub $uninstantiated (describes $other (struct)))) |
| 865 | + (type $instantiated (sub $uninstantiated (describes $other (struct)))) |
| 866 | + ) |
| 867 | + |
| 868 | + ;; YESTNH: (type $4 (func (result (ref $struct)))) |
| 869 | + |
| 870 | + ;; YESTNH: (type $5 (func)) |
| 871 | + |
| 872 | + ;; YESTNH: (import "" "" (func $effect (type $5))) |
| 873 | + ;; NO_TNH: (type $4 (func (result (ref $struct)))) |
| 874 | + |
| 875 | + ;; NO_TNH: (type $5 (func)) |
| 876 | + |
| 877 | + ;; NO_TNH: (import "" "" (func $effect (type $5))) |
| 878 | + (import "" "" (func $effect)) |
| 879 | + |
| 880 | + ;; YESTNH: (global $instantiated (ref $instantiated) (struct.new_default $instantiated)) |
| 881 | + ;; NO_TNH: (global $instantiated (ref $instantiated) (struct.new_default $instantiated)) |
| 882 | + (global $instantiated (ref $instantiated) (struct.new $instantiated)) |
| 883 | + |
| 884 | + ;; YESTNH: (global $fake-desc (ref null (exact $instantiated)) (ref.null none)) |
| 885 | + ;; NO_TNH: (global $fake-desc (ref null (exact $uninstantiated)) (ref.null none)) |
| 886 | + (global $fake-desc (ref null (exact $uninstantiated)) (ref.null none)) |
| 887 | + |
| 888 | + ;; YESTNH: (global $impossible (ref $struct) (struct.new_default $struct |
| 889 | + ;; YESTNH-NEXT: (ref.null none) |
| 890 | + ;; YESTNH-NEXT: )) |
| 891 | + ;; NO_TNH: (global $impossible (ref $struct) (struct.new_default $struct |
| 892 | + ;; NO_TNH-NEXT: (global.get $fake-desc) |
| 893 | + ;; NO_TNH-NEXT: )) |
| 894 | + (global $impossible (ref $struct) |
| 895 | + (struct.new $struct |
| 896 | + (global.get $fake-desc) |
| 897 | + ) |
| 898 | + ) |
| 899 | + |
| 900 | + ;; YESTNH: (func $impossible (type $4) (result (ref $struct)) |
| 901 | + ;; YESTNH-NEXT: (unreachable) |
| 902 | + ;; YESTNH-NEXT: ) |
| 903 | + ;; NO_TNH: (func $impossible (type $4) (result (ref $struct)) |
| 904 | + ;; NO_TNH-NEXT: (struct.new_default $struct |
| 905 | + ;; NO_TNH-NEXT: (global.get $fake-desc) |
| 906 | + ;; NO_TNH-NEXT: ) |
| 907 | + ;; NO_TNH-NEXT: ) |
| 908 | + (func $impossible (result (ref $struct)) |
| 909 | + (struct.new $struct |
| 910 | + (global.get $fake-desc) |
| 911 | + ) |
| 912 | + ) |
| 913 | + |
| 914 | + ;; YESTNH: (func $impossible-effect (type $4) (result (ref $struct)) |
| 915 | + ;; YESTNH-NEXT: (drop |
| 916 | + ;; YESTNH-NEXT: (block (result (ref null (exact $instantiated))) |
| 917 | + ;; YESTNH-NEXT: (call $effect) |
| 918 | + ;; YESTNH-NEXT: (global.get $fake-desc) |
| 919 | + ;; YESTNH-NEXT: ) |
| 920 | + ;; YESTNH-NEXT: ) |
| 921 | + ;; YESTNH-NEXT: (unreachable) |
| 922 | + ;; YESTNH-NEXT: ) |
| 923 | + ;; NO_TNH: (func $impossible-effect (type $4) (result (ref $struct)) |
| 924 | + ;; NO_TNH-NEXT: (struct.new_default $struct |
| 925 | + ;; NO_TNH-NEXT: (block (result (ref null (exact $uninstantiated))) |
| 926 | + ;; NO_TNH-NEXT: (call $effect) |
| 927 | + ;; NO_TNH-NEXT: (global.get $fake-desc) |
| 928 | + ;; NO_TNH-NEXT: ) |
| 929 | + ;; NO_TNH-NEXT: ) |
| 930 | + ;; NO_TNH-NEXT: ) |
| 931 | + (func $impossible-effect (result (ref $struct)) |
| 932 | + (struct.new $struct |
| 933 | + (block (result (ref null (exact $uninstantiated))) |
| 934 | + (call $effect) |
| 935 | + (global.get $fake-desc) |
| 936 | + ) |
| 937 | + ) |
| 938 | + ) |
| 939 | +) |
| 940 | + |
| 941 | +(module |
| 942 | + ;; Same, but now we're optimizing the descriptor to bottom, so we don't need |
| 943 | + ;; to do any preoptimization to ensure validity. We optimize anyway because |
| 944 | + ;; we can. |
| 945 | + (rec |
| 946 | + ;; YESTNH: (rec |
| 947 | + ;; YESTNH-NEXT: (type $struct (descriptor $uninstantiated (struct))) |
| 948 | + ;; NO_TNH: (rec |
| 949 | + ;; NO_TNH-NEXT: (type $struct (descriptor $uninstantiated (struct))) |
| 950 | + (type $struct (descriptor $uninstantiated (struct))) |
| 951 | + ;; YESTNH: (type $uninstantiated (describes $struct (struct))) |
| 952 | + ;; NO_TNH: (type $uninstantiated (describes $struct (struct))) |
| 953 | + (type $uninstantiated (describes $struct (struct))) |
| 954 | + ) |
| 955 | + |
| 956 | + ;; YESTNH: (type $2 (func (result (ref $struct)))) |
| 957 | + |
| 958 | + ;; YESTNH: (type $3 (func)) |
| 959 | + |
| 960 | + ;; YESTNH: (import "" "" (func $effect (type $3))) |
| 961 | + ;; NO_TNH: (type $2 (func (result (ref $struct)))) |
| 962 | + |
| 963 | + ;; NO_TNH: (type $3 (func)) |
| 964 | + |
| 965 | + ;; NO_TNH: (import "" "" (func $effect (type $3))) |
| 966 | + (import "" "" (func $effect)) |
| 967 | + |
| 968 | + ;; YESTNH: (global $fake-desc nullref (ref.null none)) |
| 969 | + ;; NO_TNH: (global $fake-desc nullref (ref.null none)) |
| 970 | + (global $fake-desc (ref null (exact $uninstantiated)) (ref.null none)) |
| 971 | + |
| 972 | + ;; YESTNH: (global $impossible (ref $struct) (struct.new_default $struct |
| 973 | + ;; YESTNH-NEXT: (ref.null none) |
| 974 | + ;; YESTNH-NEXT: )) |
| 975 | + ;; NO_TNH: (global $impossible (ref $struct) (struct.new_default $struct |
| 976 | + ;; NO_TNH-NEXT: (ref.null none) |
| 977 | + ;; NO_TNH-NEXT: )) |
| 978 | + (global $impossible (ref $struct) |
| 979 | + (struct.new $struct |
| 980 | + (global.get $fake-desc) |
| 981 | + ) |
| 982 | + ) |
| 983 | + |
| 984 | + ;; YESTNH: (func $impossible (type $2) (result (ref $struct)) |
| 985 | + ;; YESTNH-NEXT: (unreachable) |
| 986 | + ;; YESTNH-NEXT: ) |
| 987 | + ;; NO_TNH: (func $impossible (type $2) (result (ref $struct)) |
| 988 | + ;; NO_TNH-NEXT: (unreachable) |
| 989 | + ;; NO_TNH-NEXT: ) |
| 990 | + (func $impossible (result (ref $struct)) |
| 991 | + (struct.new $struct |
| 992 | + (global.get $fake-desc) |
| 993 | + ) |
| 994 | + ) |
| 995 | + |
| 996 | + ;; YESTNH: (func $impossible-effect (type $2) (result (ref $struct)) |
| 997 | + ;; YESTNH-NEXT: (drop |
| 998 | + ;; YESTNH-NEXT: (block (result nullref) |
| 999 | + ;; YESTNH-NEXT: (call $effect) |
| 1000 | + ;; YESTNH-NEXT: (global.get $fake-desc) |
| 1001 | + ;; YESTNH-NEXT: ) |
| 1002 | + ;; YESTNH-NEXT: ) |
| 1003 | + ;; YESTNH-NEXT: (unreachable) |
| 1004 | + ;; YESTNH-NEXT: ) |
| 1005 | + ;; NO_TNH: (func $impossible-effect (type $2) (result (ref $struct)) |
| 1006 | + ;; NO_TNH-NEXT: (drop |
| 1007 | + ;; NO_TNH-NEXT: (block (result nullref) |
| 1008 | + ;; NO_TNH-NEXT: (call $effect) |
| 1009 | + ;; NO_TNH-NEXT: (global.get $fake-desc) |
| 1010 | + ;; NO_TNH-NEXT: ) |
| 1011 | + ;; NO_TNH-NEXT: ) |
| 1012 | + ;; NO_TNH-NEXT: (unreachable) |
| 1013 | + ;; NO_TNH-NEXT: ) |
| 1014 | + (func $impossible-effect (result (ref $struct)) |
| 1015 | + (struct.new $struct |
| 1016 | + (block (result (ref null (exact $uninstantiated))) |
| 1017 | + (call $effect) |
| 1018 | + (global.get $fake-desc) |
| 1019 | + ) |
| 1020 | + ) |
| 1021 | + ) |
| 1022 | +) |
0 commit comments