blob: ef4bd93070f44cc185b124369496dd8b33dd1ca4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "go_asm.h"
#include "textflag.h"
TEXT ·IndexByte(SB), NOSPLIT, $0-40
I64Load b_base+0(FP)
I32WrapI64
I32Load8U c+24(FP)
I64Load b_len+8(FP)
I32WrapI64
Call memchr<>(SB)
I64ExtendI32S
Set R0
Get SP
I64Const $-1
Get R0
I64Load b_base+0(FP)
I64Sub
Get R0
I64Eqz $0
Select
I64Store ret+32(FP)
RET
TEXT ·IndexByteString(SB), NOSPLIT, $0-32
Get SP
I64Load s_base+0(FP)
I32WrapI64
I32Load8U c+16(FP)
I64Load s_len+8(FP)
I32WrapI64
Call memchr<>(SB)
I64ExtendI32S
Set R0
I64Const $-1
Get R0
I64Load s_base+0(FP)
I64Sub
Get R0
I64Eqz $0
Select
I64Store ret+24(FP)
RET
// initially compiled with emscripten and then modified over time.
// params:
// R0: s
// R1: c
// R2: len
// ret: index
TEXT memchr<>(SB), NOSPLIT, $0
Get R1
Set R4
Block
Block
Get R2
I32Const $0
I32Ne
Tee R3
Get R0
I32Const $3
I32And
I32Const $0
I32Ne
I32And
If
Loop
Get R0
I32Load8U $0
Get R1
I32Eq
BrIf $2
Get R2
I32Const $-1
I32Add
Tee R2
I32Const $0
I32Ne
Tee R3
Get R0
I32Const $1
I32Add
Tee R0
I32Const $3
I32And
I32Const $0
I32Ne
I32And
BrIf $0
End
End
Get R3
BrIf $0
I32Const $0
Set R1
Br $1
End
Get R0
I32Load8U $0
Get R4
Tee R3
I32Eq
If
Get R2
Set R1
Else
Get R4
I32Const $16843009
I32Mul
Set R4
Block
Block
Get R2
I32Const $3
I32GtU
If
Get R2
Set R1
Loop
Get R0
I32Load $0
Get R4
I32Xor
Tee R2
I32Const $-2139062144
I32And
I32Const $-2139062144
I32Xor
Get R2
I32Const $-16843009
I32Add
I32And
I32Eqz
If
Get R0
I32Const $4
I32Add
Set R0
Get R1
I32Const $-4
I32Add
Tee R1
I32Const $3
I32GtU
BrIf $1
Br $3
End
End
Else
Get R2
Set R1
Br $1
End
Br $1
End
Get R1
I32Eqz
If
I32Const $0
Set R1
Br $3
End
End
Loop
Get R0
I32Load8U $0
Get R3
I32Eq
BrIf $2
Get R0
I32Const $1
I32Add
Set R0
Get R1
I32Const $-1
I32Add
Tee R1
BrIf $0
I32Const $0
Set R1
End
End
End
Get R0
I32Const $0
Get R1
Select
Return
|