Index: src/wasm/encoder.cc |
diff --git a/src/wasm/encoder.cc b/src/wasm/encoder.cc |
index 863739b4037c20fe22b12f69fa1c07ddd5fd6bc2..24ca158e7f0e77ba2d4d2e964fa216e5fc13e254 100644 |
--- a/src/wasm/encoder.cc |
+++ b/src/wasm/encoder.cc |
@@ -39,13 +39,11 @@ void EmitUint8(byte** b, uint8_t x) { |
*b += 1; |
} |
- |
void EmitUint16(byte** b, uint16_t x) { |
WriteUnalignedUInt16(*b, x); |
*b += 2; |
} |
- |
void EmitUint32(byte** b, uint32_t x) { |
WriteUnalignedUInt32(*b, x); |
*b += 4; |
@@ -102,7 +100,6 @@ struct WasmFunctionBuilder::Type { |
LocalType type_; |
}; |
- |
WasmFunctionBuilder::WasmFunctionBuilder(Zone* zone) |
: return_type_(kAstI32), |
locals_(zone), |
@@ -125,21 +122,17 @@ uint16_t WasmFunctionBuilder::AddParam(LocalType type) { |
return AddVar(type, true); |
} |
- |
uint16_t WasmFunctionBuilder::AddLocal(LocalType type) { |
return AddVar(type, false); |
} |
- |
uint16_t WasmFunctionBuilder::AddVar(LocalType type, bool param) { |
locals_.push_back({param, type}); |
return static_cast<uint16_t>(locals_.size() - 1); |
} |
- |
void WasmFunctionBuilder::ReturnType(LocalType type) { return_type_ = type; } |
- |
void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size) { |
EmitCode(code, code_size, nullptr, 0); |
} |
@@ -166,12 +159,10 @@ void WasmFunctionBuilder::EmitCode(const byte* code, uint32_t code_size, |
} |
} |
- |
void WasmFunctionBuilder::Emit(WasmOpcode opcode) { |
body_.push_back(static_cast<byte>(opcode)); |
} |
- |
void WasmFunctionBuilder::EmitWithU8(WasmOpcode opcode, const byte immediate) { |
body_.push_back(static_cast<byte>(opcode)); |
body_.push_back(immediate); |
@@ -229,10 +220,8 @@ void WasmFunctionBuilder::EditVarIntImmediate(uint32_t offset, |
v8::internal::wasm::EmitVarInt(&p, immediate); |
} |
- |
void WasmFunctionBuilder::Exported(uint8_t flag) { exported_ = flag; } |
- |
void WasmFunctionBuilder::External(uint8_t flag) { external_ = flag; } |
void WasmFunctionBuilder::SetName(const unsigned char* name, int name_length) { |
@@ -244,7 +233,6 @@ void WasmFunctionBuilder::SetName(const unsigned char* name, int name_length) { |
} |
} |
- |
WasmFunctionEncoder* WasmFunctionBuilder::Build(Zone* zone, |
WasmModuleBuilder* mb) const { |
WasmFunctionEncoder* e = |
@@ -296,7 +284,6 @@ WasmFunctionEncoder* WasmFunctionBuilder::Build(Zone* zone, |
return e; |
} |
- |
void WasmFunctionBuilder::IndexVars(WasmFunctionEncoder* e, |
uint16_t* var_index) const { |
uint16_t param = 0; |
@@ -342,7 +329,6 @@ void WasmFunctionBuilder::IndexVars(WasmFunctionEncoder* e, |
} |
} |
- |
WasmFunctionEncoder::WasmFunctionEncoder(Zone* zone, LocalType return_type, |
bool exported, bool external) |
: params_(zone), |
@@ -351,7 +337,6 @@ WasmFunctionEncoder::WasmFunctionEncoder(Zone* zone, LocalType return_type, |
body_(zone), |
name_(zone) {} |
- |
uint32_t WasmFunctionEncoder::HeaderSize() const { |
uint32_t size = 3; |
if (!external_) size += 2; |
@@ -363,7 +348,6 @@ uint32_t WasmFunctionEncoder::HeaderSize() const { |
return size; |
} |
- |
uint32_t WasmFunctionEncoder::BodySize(void) const { |
// TODO(titzer): embed a LocalDeclEncoder in the WasmFunctionEncoder |
LocalDeclEncoder local_decl; |
@@ -376,12 +360,10 @@ uint32_t WasmFunctionEncoder::BodySize(void) const { |
: static_cast<uint32_t>(body_.size() + local_decl.Size()); |
} |
- |
uint32_t WasmFunctionEncoder::NameSize() const { |
return HasName() ? static_cast<uint32_t>(name_.size()) : 0; |
} |
- |
void WasmFunctionEncoder::Serialize(byte* buffer, byte** header, |
byte** body) const { |
uint8_t decl_bits = (exported_ ? kDeclFunctionExport : 0) | |
@@ -398,7 +380,6 @@ void WasmFunctionEncoder::Serialize(byte* buffer, byte** header, |
} |
} |
- |
if (!external_) { |
// TODO(titzer): embed a LocalDeclEncoder in the WasmFunctionEncoder |
LocalDeclEncoder local_decl; |
@@ -416,7 +397,6 @@ void WasmFunctionEncoder::Serialize(byte* buffer, byte** header, |
} |
} |
- |
WasmDataSegmentEncoder::WasmDataSegmentEncoder(Zone* zone, const byte* data, |
uint32_t size, uint32_t dest) |
: data_(zone), dest_(dest) { |
@@ -425,18 +405,15 @@ WasmDataSegmentEncoder::WasmDataSegmentEncoder(Zone* zone, const byte* data, |
} |
} |
- |
uint32_t WasmDataSegmentEncoder::HeaderSize() const { |
static const int kDataSegmentSize = 13; |
return kDataSegmentSize; |
} |
- |
uint32_t WasmDataSegmentEncoder::BodySize() const { |
return static_cast<uint32_t>(data_.size()); |
} |
- |
void WasmDataSegmentEncoder::Serialize(byte* buffer, byte** header, |
byte** body) const { |
EmitVarInt(header, dest_); |
@@ -461,7 +438,6 @@ uint16_t WasmModuleBuilder::AddFunction() { |
return static_cast<uint16_t>(functions_.size() - 1); |
} |
- |
WasmFunctionBuilder* WasmModuleBuilder::FunctionAt(size_t index) { |
if (functions_.size() > index) { |
return functions_.at(index); |
@@ -470,12 +446,10 @@ WasmFunctionBuilder* WasmModuleBuilder::FunctionAt(size_t index) { |
} |
} |
- |
void WasmModuleBuilder::AddDataSegment(WasmDataSegmentEncoder* data) { |
data_segments_.push_back(data); |
} |
- |
bool WasmModuleBuilder::CompareFunctionSigs::operator()(FunctionSig* a, |
FunctionSig* b) const { |
if (a->return_count() < b->return_count()) return true; |
@@ -493,7 +467,6 @@ bool WasmModuleBuilder::CompareFunctionSigs::operator()(FunctionSig* a, |
return false; |
} |
- |
uint16_t WasmModuleBuilder::AddSignature(FunctionSig* sig) { |
SignatureMap::iterator pos = signature_map_.find(sig); |
if (pos != signature_map_.end()) { |
@@ -506,7 +479,6 @@ uint16_t WasmModuleBuilder::AddSignature(FunctionSig* sig) { |
} |
} |
- |
void WasmModuleBuilder::AddIndirectFunction(uint16_t index) { |
indirect_functions_.push_back(index); |
} |
@@ -536,13 +508,11 @@ WasmModuleWriter* WasmModuleBuilder::Build(Zone* zone) { |
return writer; |
} |
- |
uint32_t WasmModuleBuilder::AddGlobal(MachineType type, bool exported) { |
globals_.push_back(std::make_pair(type, exported)); |
return static_cast<uint32_t>(globals_.size() - 1); |
} |
- |
WasmModuleWriter::WasmModuleWriter(Zone* zone) |
: functions_(zone), |
data_segments_(zone), |