File tree 12 files changed +231
-79
lines changed
12 files changed +231
-79
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ trap 'rm -f sqlite3.tmp' EXIT
12
12
" $WASI_SDK /clang" --target=wasm32-wasi -std=c23 -g0 -O2 \
13
13
-Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
14
14
-o sqlite3.wasm " $ROOT /sqlite3/main.c" \
15
- -I" $ROOT /sqlite3" \
15
+ -I" $ROOT /sqlite3/libc " -I " $ROOT /sqlite3 " \
16
16
-mexec-model=reactor \
17
17
-msimd128 -mmutable-globals -mmultivalue \
18
18
-mbulk-memory -mreference-types \
Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ cd -P -- "$(dirname -- "$0")"
6
6
ROOT=../../
7
7
BINARYEN=" $ROOT /tools/binaryen/bin"
8
8
WASI_SDK=" $ROOT /tools/wasi-sdk/bin"
9
- SRCS=" ${1:- .. / strings .c} "
9
+ SRCS=" ${1:- libc .c} "
10
10
" ../tools.sh"
11
11
12
- trap ' rm -f libc.tmp' EXIT
12
+ trap ' rm -f libc.c libc.tmp' EXIT
13
+ echo ' #include <string.h>' > libc.c
13
14
14
15
" $WASI_SDK /clang" --target=wasm32-wasi -std=c23 -g0 -O2 \
15
- -o libc.wasm " $SRCS " \
16
+ -o libc.wasm -I. " $SRCS " \
16
17
-mexec-model=reactor \
17
18
-msimd128 -mmutable-globals -mmultivalue \
18
19
-mbulk-memory -mreference-types \
Original file line number Diff line number Diff line change 849
849
(func $strspn (param $0 i32 ) (param $1 i32 ) (result i32 )
850
850
(local $2 i32 )
851
851
(local $3 i32 )
852
+ (local $4 v128 )
853
+ (local $scratch i32 )
852
854
(if
853
855
(i32.eqz
854
- (local.tee $2
856
+ (local.tee $3
855
857
(i32.load8_u
856
858
(local.get $1 )
857
859
)
863
865
)
864
866
)
865
867
)
866
- (v128.store
867
- (i32.const 65520 )
868
- (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000 )
869
- )
870
- (v128.store
871
- (i32.const 65504 )
872
- (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000 )
873
- )
874
- (local.set $1
875
- (i32.add
876
- (local.get $1 )
877
- (i32.const 1 )
878
- )
879
- )
880
- (loop $label
881
- (i32.store
882
- (local.tee $3
883
- (i32.add
884
- (i32.and
885
- (i32.shr_u
886
- (local.get $2 )
887
- (i32.const 3 )
868
+ (block $block1
869
+ (if
870
+ (i32.eqz
871
+ (i32.load8_u offset = 1
872
+ (local.get $1 )
873
+ )
874
+ )
875
+ (then
876
+ (block $block
877
+ (br_if $block
878
+ (i32.gt_u
879
+ (local.tee $1
880
+ (local.get $0 )
881
+ )
882
+ (local.tee $2
883
+ (i32.sub
884
+ (i32.shl
885
+ (memory.size )
886
+ (i32.const 16 )
887
+ )
888
+ (i32.const 16 )
889
+ )
890
+ )
891
+ )
892
+ )
893
+ (local.set $4
894
+ (i8x16.splat
895
+ (local.get $3 )
896
+ )
897
+ )
898
+ (loop $label
899
+ (br_if $block
900
+ (i32.eqz
901
+ (i8x16.all_true
902
+ (i8x16.eq
903
+ (v128.load align = 1
904
+ (local.get $1 )
905
+ )
906
+ (local.get $4 )
907
+ )
908
+ )
909
+ )
910
+ )
911
+ (br_if $label
912
+ (i32.le_u
913
+ (local.tee $1
914
+ (i32.add
915
+ (local.get $1 )
916
+ (i32.const 16 )
917
+ )
918
+ )
919
+ (local.get $2 )
920
+ )
888
921
)
889
- (i32.const 28 )
890
922
)
891
- (i32.const 65504 )
892
923
)
893
- )
894
- (i32.or
895
- (i32.load
896
- (local.get $3 )
924
+ (local.set $2
925
+ (i32.add
926
+ (i32.xor
927
+ (local.get $0 )
928
+ (i32.const -1 )
929
+ )
930
+ (local.get $1 )
931
+ )
897
932
)
898
- (i32.shl
899
- (i32.const 1 )
900
- (local.get $2 )
933
+ (loop $label1
934
+ (local.set $2
935
+ (i32.add
936
+ (local.get $2 )
937
+ (i32.const 1 )
938
+ )
939
+ )
940
+ (br_if $label1
941
+ (i32.eq
942
+ (block (result i32 )
943
+ (local.set $scratch
944
+ (i32.load8_u
945
+ (local.get $1 )
946
+ )
947
+ )
948
+ (local.set $1
949
+ (i32.add
950
+ (local.get $1 )
951
+ (i32.const 1 )
952
+ )
953
+ )
954
+ (local.get $scratch )
955
+ )
956
+ (local.get $3 )
957
+ )
958
+ )
901
959
)
960
+ (br $block1 )
902
961
)
903
962
)
904
- (local.set $2
905
- (i32.load8_u
906
- (local.get $1 )
907
- )
963
+ (v128.store
964
+ (i32.const 65520 )
965
+ (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000 )
966
+ )
967
+ (v128.store
968
+ (i32.const 65504 )
969
+ (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000 )
908
970
)
909
971
(local.set $1
910
972
(i32.add
911
973
(local.get $1 )
912
974
(i32.const 1 )
913
975
)
914
976
)
915
- (br_if $label
916
- (local.get $2 )
917
- )
918
- )
919
- (if
920
- (local.tee $2
921
- (i32.load8_u
922
- (local.tee $1
923
- (local.get $0 )
977
+ (loop $label2
978
+ (i32.store
979
+ (local.tee $2
980
+ (i32.add
981
+ (i32.and
982
+ (i32.shr_u
983
+ (local.get $3 )
984
+ (i32.const 3 )
985
+ )
986
+ (i32.const 28 )
987
+ )
988
+ (i32.const 65504 )
989
+ )
990
+ )
991
+ (i32.or
992
+ (i32.load
993
+ (local.get $2 )
994
+ )
995
+ (i32.shl
996
+ (i32.const 1 )
997
+ (local.get $3 )
998
+ )
999
+ )
1000
+ )
1001
+ (local.set $3
1002
+ (i32.load8_u
1003
+ (local.get $1 )
924
1004
)
925
1005
)
1006
+ (local.set $1
1007
+ (i32.add
1008
+ (local.get $1 )
1009
+ (i32.const 1 )
1010
+ )
1011
+ )
1012
+ (br_if $label2
1013
+ (local.get $3 )
1014
+ )
926
1015
)
927
- (then
928
- (loop $label1
1016
+ (local.set $2
1017
+ (local.get $0 )
1018
+ )
1019
+ (block $block2
1020
+ (br_if $block2
1021
+ (i32.eqz
1022
+ (local.tee $3
1023
+ (i32.load8_u
1024
+ (local.get $0 )
1025
+ )
1026
+ )
1027
+ )
1028
+ )
1029
+ (local.set $1
1030
+ (local.get $0 )
1031
+ )
1032
+ (loop $label3
929
1033
(if
930
1034
(i32.eqz
931
1035
(i32.and
934
1038
(i32.add
935
1039
(i32.and
936
1040
(i32.shr_u
937
- (local.get $2 )
1041
+ (local.get $3 )
938
1042
(i32.const 3 )
939
1043
)
940
1044
(i32.const 28 )
941
1045
)
942
1046
(i32.const 65504 )
943
1047
)
944
1048
)
945
- (local.get $2 )
1049
+ (local.get $3 )
946
1050
)
947
1051
(i32.const 1 )
948
1052
)
949
1053
)
950
1054
(then
951
- (return
952
- (i32.sub
953
- (local.get $1 )
954
- (local.get $0 )
955
- )
1055
+ (local.set $2
1056
+ (local.get $1 )
956
1057
)
1058
+ (br $block2 )
957
1059
)
958
1060
)
959
- (local.set $2
1061
+ (local.set $3
960
1062
(i32.load8_u offset = 1
961
1063
(local.get $1 )
962
1064
)
963
1065
)
964
1066
(local.set $1
965
- (i32.add
966
- (local.get $1 )
967
- (i32.const 1 )
1067
+ (local.tee $2
1068
+ (i32.add
1069
+ (local.get $1 )
1070
+ (i32.const 1 )
1071
+ )
968
1072
)
969
1073
)
970
- (br_if $label1
971
- (local.get $2 )
1074
+ (br_if $label3
1075
+ (local.get $3 )
972
1076
)
973
1077
)
974
1078
)
1079
+ (local.set $2
1080
+ (i32.sub
1081
+ (local.get $2 )
1082
+ (local.get $0 )
1083
+ )
1084
+ )
975
1085
)
976
- (i32.sub
977
- (local.get $1 )
978
- (local.get $0 )
979
- )
1086
+ (local.get $2 )
980
1087
)
981
1088
(func $strcspn (param $0 i32 ) (param $1 i32 ) (result i32 )
982
1089
(local $2 i32 )
You can’t perform that action at this time.
0 commit comments