summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h45
1 files changed, 1 insertions, 44 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index d7fde5913..fe740d56a 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -28,14 +28,11 @@
#include "ir/import-utils.h"
#include "ir/module-utils.h"
#include "parsing.h"
-#include "support/debug.h"
#include "wasm-builder.h"
#include "wasm-traversal.h"
#include "wasm-validator.h"
#include "wasm.h"
-#define DEBUG_TYPE "binary"
-
namespace wasm {
enum {
@@ -158,18 +155,15 @@ public:
BufferWithRandomAccess() = default;
BufferWithRandomAccess& operator<<(int8_t x) {
- BYN_TRACE("writeInt8: " << (int)(uint8_t)x << " (at " << size() << ")\n");
push_back(x);
return *this;
}
BufferWithRandomAccess& operator<<(int16_t x) {
- BYN_TRACE("writeInt16: " << x << " (at " << size() << ")\n");
push_back(x & 0xff);
push_back(x >> 8);
return *this;
}
BufferWithRandomAccess& operator<<(int32_t x) {
- BYN_TRACE("writeInt32: " << x << " (at " << size() << ")\n");
push_back(x & 0xff);
x >>= 8;
push_back(x & 0xff);
@@ -180,7 +174,6 @@ public:
return *this;
}
BufferWithRandomAccess& operator<<(int64_t x) {
- BYN_TRACE("writeInt64: " << x << " (at " << size() << ")\n");
push_back(x & 0xff);
x >>= 8;
push_back(x & 0xff);
@@ -199,47 +192,19 @@ public:
return *this;
}
BufferWithRandomAccess& operator<<(U32LEB x) {
- [[maybe_unused]] size_t before = -1;
- BYN_DEBUG(before = size(); std::cerr << "writeU32LEB: " << x.value
- << " (at " << before << ")"
- << std::endl;);
x.write(this);
- BYN_DEBUG(for (size_t i = before; i < size(); i++) {
- std::cerr << " " << (int)at(i) << " (at " << i << ")\n";
- });
return *this;
}
BufferWithRandomAccess& operator<<(U64LEB x) {
- [[maybe_unused]] size_t before = -1;
- BYN_DEBUG(before = size(); std::cerr << "writeU64LEB: " << x.value
- << " (at " << before << ")"
- << std::endl;);
x.write(this);
- BYN_DEBUG(for (size_t i = before; i < size(); i++) {
- std::cerr << " " << (int)at(i) << " (at " << i << ")\n";
- });
return *this;
}
BufferWithRandomAccess& operator<<(S32LEB x) {
- [[maybe_unused]] size_t before = -1;
- BYN_DEBUG(before = size(); std::cerr << "writeS32LEB: " << x.value
- << " (at " << before << ")"
- << std::endl;);
x.write(this);
- BYN_DEBUG(for (size_t i = before; i < size(); i++) {
- std::cerr << " " << (int)at(i) << " (at " << i << ")\n";
- });
return *this;
}
BufferWithRandomAccess& operator<<(S64LEB x) {
- [[maybe_unused]] size_t before = -1;
- BYN_DEBUG(before = size(); std::cerr << "writeS64LEB: " << x.value
- << " (at " << before << ")"
- << std::endl;);
x.write(this);
- BYN_DEBUG(for (size_t i = before; i < size(); i++) {
- std::cerr << " " << (int)at(i) << " (at " << i << ")\n";
- });
return *this;
}
@@ -249,21 +214,17 @@ public:
BufferWithRandomAccess& operator<<(uint64_t x) { return *this << (int64_t)x; }
BufferWithRandomAccess& operator<<(float x) {
- BYN_TRACE("writeFloat32: " << x << " (at " << size() << ")\n");
return *this << Literal(x).reinterpreti32();
}
BufferWithRandomAccess& operator<<(double x) {
- BYN_TRACE("writeFloat64: " << x << " (at " << size() << ")\n");
return *this << Literal(x).reinterpreti64();
}
void writeAt(size_t i, uint16_t x) {
- BYN_TRACE("backpatchInt16: " << x << " (at " << i << ")\n");
(*this)[i] = x & 0xff;
(*this)[i + 1] = x >> 8;
}
void writeAt(size_t i, uint32_t x) {
- BYN_TRACE("backpatchInt32: " << x << " (at " << i << ")\n");
(*this)[i] = x & 0xff;
x >>= 8;
(*this)[i + 1] = x & 0xff;
@@ -276,16 +237,12 @@ public:
// writes out an LEB to an arbitrary location. this writes the LEB as a full
// 5 bytes, the fixed amount that can easily be set aside ahead of time
void writeAtFullFixedSize(size_t i, U32LEB x) {
- BYN_TRACE("backpatchU32LEB: " << x.value << " (at " << i << ")\n");
// fill all 5 bytes, we have to do this when backpatching
x.writeAt(this, i, MaxLEB32Bytes);
}
// writes out an LEB of normal size
// returns how many bytes were written
- size_t writeAt(size_t i, U32LEB x) {
- BYN_TRACE("writeAtU32LEB: " << x.value << " (at " << i << ")\n");
- return x.writeAt(this, i);
- }
+ size_t writeAt(size_t i, U32LEB x) { return x.writeAt(this, i); }
template<typename T> void writeTo(T& o) {
for (auto c : *this) {