28
28
#include " ir/import-utils.h"
29
29
#include " ir/module-utils.h"
30
30
#include " parsing.h"
31
- #include " support/debug.h"
32
31
#include " wasm-builder.h"
33
32
#include " wasm-traversal.h"
34
33
#include " wasm-validator.h"
35
34
#include " wasm.h"
36
35
37
- #define DEBUG_TYPE " binary"
38
-
39
36
namespace wasm {
40
37
41
38
enum {
@@ -158,18 +155,15 @@ class BufferWithRandomAccess : public std::vector<uint8_t> {
158
155
BufferWithRandomAccess () = default ;
159
156
160
157
BufferWithRandomAccess& operator <<(int8_t x) {
161
- BYN_TRACE (" writeInt8: " << (int )(uint8_t )x << " (at " << size () << " )\n " );
162
158
push_back (x);
163
159
return *this ;
164
160
}
165
161
BufferWithRandomAccess& operator <<(int16_t x) {
166
- BYN_TRACE (" writeInt16: " << x << " (at " << size () << " )\n " );
167
162
push_back (x & 0xff );
168
163
push_back (x >> 8 );
169
164
return *this ;
170
165
}
171
166
BufferWithRandomAccess& operator <<(int32_t x) {
172
- BYN_TRACE (" writeInt32: " << x << " (at " << size () << " )\n " );
173
167
push_back (x & 0xff );
174
168
x >>= 8 ;
175
169
push_back (x & 0xff );
@@ -180,7 +174,6 @@ class BufferWithRandomAccess : public std::vector<uint8_t> {
180
174
return *this ;
181
175
}
182
176
BufferWithRandomAccess& operator <<(int64_t x) {
183
- BYN_TRACE (" writeInt64: " << x << " (at " << size () << " )\n " );
184
177
push_back (x & 0xff );
185
178
x >>= 8 ;
186
179
push_back (x & 0xff );
@@ -199,47 +192,19 @@ class BufferWithRandomAccess : public std::vector<uint8_t> {
199
192
return *this ;
200
193
}
201
194
BufferWithRandomAccess& operator <<(U32LEB x) {
202
- [[maybe_unused]] size_t before = -1 ;
203
- BYN_DEBUG (before = size (); std::cerr << " writeU32LEB: " << x.value
204
- << " (at " << before << " )"
205
- << std::endl;);
206
195
x.write (this );
207
- BYN_DEBUG (for (size_t i = before; i < size (); i++) {
208
- std::cerr << " " << (int )at (i) << " (at " << i << " )\n " ;
209
- });
210
196
return *this ;
211
197
}
212
198
BufferWithRandomAccess& operator <<(U64LEB x) {
213
- [[maybe_unused]] size_t before = -1 ;
214
- BYN_DEBUG (before = size (); std::cerr << " writeU64LEB: " << x.value
215
- << " (at " << before << " )"
216
- << std::endl;);
217
199
x.write (this );
218
- BYN_DEBUG (for (size_t i = before; i < size (); i++) {
219
- std::cerr << " " << (int )at (i) << " (at " << i << " )\n " ;
220
- });
221
200
return *this ;
222
201
}
223
202
BufferWithRandomAccess& operator <<(S32LEB x) {
224
- [[maybe_unused]] size_t before = -1 ;
225
- BYN_DEBUG (before = size (); std::cerr << " writeS32LEB: " << x.value
226
- << " (at " << before << " )"
227
- << std::endl;);
228
203
x.write (this );
229
- BYN_DEBUG (for (size_t i = before; i < size (); i++) {
230
- std::cerr << " " << (int )at (i) << " (at " << i << " )\n " ;
231
- });
232
204
return *this ;
233
205
}
234
206
BufferWithRandomAccess& operator <<(S64LEB x) {
235
- [[maybe_unused]] size_t before = -1 ;
236
- BYN_DEBUG (before = size (); std::cerr << " writeS64LEB: " << x.value
237
- << " (at " << before << " )"
238
- << std::endl;);
239
207
x.write (this );
240
- BYN_DEBUG (for (size_t i = before; i < size (); i++) {
241
- std::cerr << " " << (int )at (i) << " (at " << i << " )\n " ;
242
- });
243
208
return *this ;
244
209
}
245
210
@@ -249,21 +214,17 @@ class BufferWithRandomAccess : public std::vector<uint8_t> {
249
214
BufferWithRandomAccess& operator <<(uint64_t x) { return *this << (int64_t )x; }
250
215
251
216
BufferWithRandomAccess& operator <<(float x) {
252
- BYN_TRACE (" writeFloat32: " << x << " (at " << size () << " )\n " );
253
217
return *this << Literal (x).reinterpreti32 ();
254
218
}
255
219
BufferWithRandomAccess& operator <<(double x) {
256
- BYN_TRACE (" writeFloat64: " << x << " (at " << size () << " )\n " );
257
220
return *this << Literal (x).reinterpreti64 ();
258
221
}
259
222
260
223
void writeAt (size_t i, uint16_t x) {
261
- BYN_TRACE (" backpatchInt16: " << x << " (at " << i << " )\n " );
262
224
(*this )[i] = x & 0xff ;
263
225
(*this )[i + 1 ] = x >> 8 ;
264
226
}
265
227
void writeAt (size_t i, uint32_t x) {
266
- BYN_TRACE (" backpatchInt32: " << x << " (at " << i << " )\n " );
267
228
(*this )[i] = x & 0xff ;
268
229
x >>= 8 ;
269
230
(*this )[i + 1 ] = x & 0xff ;
@@ -276,16 +237,12 @@ class BufferWithRandomAccess : public std::vector<uint8_t> {
276
237
// writes out an LEB to an arbitrary location. this writes the LEB as a full
277
238
// 5 bytes, the fixed amount that can easily be set aside ahead of time
278
239
void writeAtFullFixedSize (size_t i, U32LEB x) {
279
- BYN_TRACE (" backpatchU32LEB: " << x.value << " (at " << i << " )\n " );
280
240
// fill all 5 bytes, we have to do this when backpatching
281
241
x.writeAt (this , i, MaxLEB32Bytes);
282
242
}
283
243
// writes out an LEB of normal size
284
244
// returns how many bytes were written
285
- size_t writeAt (size_t i, U32LEB x) {
286
- BYN_TRACE (" writeAtU32LEB: " << x.value << " (at " << i << " )\n " );
287
- return x.writeAt (this , i);
288
- }
245
+ size_t writeAt (size_t i, U32LEB x) { return x.writeAt (this , i); }
289
246
290
247
template <typename T> void writeTo (T& o) {
291
248
for (auto c : *this ) {
0 commit comments