| Index: src/wasm/encoder.h
|
| diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h
|
| index 869a09c01121e13892a7da89884686afce2eb936..0f2118dd013cad493078f70eb74ff2e075fe26a8 100644
|
| --- a/src/wasm/encoder.h
|
| +++ b/src/wasm/encoder.h
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "src/base/smart-pointers.h"
|
|
|
| +#include "src/wasm/wasm-macro-gen.h"
|
| #include "src/wasm/wasm-module.h"
|
| #include "src/wasm/wasm-opcodes.h"
|
| #include "src/wasm/wasm-result.h"
|
| @@ -28,14 +29,10 @@ class WasmFunctionEncoder : public ZoneObject {
|
| void Serialize(byte* buffer, byte** header, byte** body) const;
|
|
|
| private:
|
| - WasmFunctionEncoder(Zone* zone, LocalType return_type, bool exported);
|
| + WasmFunctionEncoder(Zone* zone, LocalDeclEncoder locals, bool exported);
|
| friend class WasmFunctionBuilder;
|
| - uint16_t signature_index_;
|
| - ZoneVector<LocalType> params_;
|
| - uint16_t local_i32_count_;
|
| - uint16_t local_i64_count_;
|
| - uint16_t local_f32_count_;
|
| - uint16_t local_f64_count_;
|
| + uint32_t signature_index_;
|
| + LocalDeclEncoder locals_;
|
| bool exported_;
|
| ZoneVector<uint8_t> body_;
|
| ZoneVector<char> name_;
|
| @@ -45,13 +42,10 @@ class WasmFunctionEncoder : public ZoneObject {
|
|
|
| class WasmFunctionBuilder : public ZoneObject {
|
| public:
|
| - uint16_t AddParam(LocalType type);
|
| - uint16_t AddLocal(LocalType type);
|
| - void ReturnType(LocalType type);
|
| + void SetSignature(FunctionSig* sig);
|
| + uint32_t AddLocal(LocalType type);
|
| void EmitVarInt(uint32_t val);
|
| void EmitCode(const byte* code, uint32_t code_size);
|
| - void EmitCode(const byte* code, uint32_t code_size,
|
| - const uint32_t* local_indices, uint32_t indices_size);
|
| void Emit(WasmOpcode opcode);
|
| void EmitGetLocal(uint32_t index);
|
| void EmitSetLocal(uint32_t index);
|
| @@ -59,8 +53,6 @@ class WasmFunctionBuilder : public ZoneObject {
|
| void EmitWithU8(WasmOpcode opcode, const byte immediate);
|
| void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2);
|
| void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate);
|
| - uint32_t EmitEditableVarIntImmediate();
|
| - void EditVarIntImmediate(uint32_t offset, const uint32_t immediate);
|
| void Exported(uint8_t flag);
|
| void SetName(const char* name, int name_length);
|
| WasmFunctionEncoder* Build(Zone* zone, WasmModuleBuilder* mb) const;
|
| @@ -68,15 +60,11 @@ class WasmFunctionBuilder : public ZoneObject {
|
| private:
|
| explicit WasmFunctionBuilder(Zone* zone);
|
| friend class WasmModuleBuilder;
|
| - LocalType return_type_;
|
| - struct Type;
|
| - ZoneVector<Type> locals_;
|
| + LocalDeclEncoder locals_;
|
| uint8_t exported_;
|
| ZoneVector<uint8_t> body_;
|
| - ZoneVector<uint32_t> local_indices_;
|
| ZoneVector<char> name_;
|
| - uint16_t AddVar(LocalType type, bool param);
|
| - void IndexVars(WasmFunctionEncoder* e, uint16_t* var_index) const;
|
| + void IndexVars(WasmFunctionEncoder* e, uint32_t* var_index) const;
|
| };
|
|
|
| class WasmDataSegmentEncoder : public ZoneObject {
|
| @@ -122,7 +110,7 @@ class WasmModuleWriter : public ZoneObject {
|
| ZoneVector<WasmFunctionEncoder*> functions_;
|
| ZoneVector<WasmDataSegmentEncoder*> data_segments_;
|
| ZoneVector<FunctionSig*> signatures_;
|
| - ZoneVector<uint16_t> indirect_functions_;
|
| + ZoneVector<uint32_t> indirect_functions_;
|
| ZoneVector<std::pair<MachineType, bool>> globals_;
|
| int start_function_index_;
|
| };
|
| @@ -135,15 +123,15 @@ class WasmModuleBuilder : public ZoneObject {
|
| WasmFunctionBuilder* FunctionAt(size_t index);
|
| void AddDataSegment(WasmDataSegmentEncoder* data);
|
| uint32_t AddSignature(FunctionSig* sig);
|
| - void AddIndirectFunction(uint16_t index);
|
| - void MarkStartFunction(uint16_t index);
|
| + void AddIndirectFunction(uint32_t index);
|
| + void MarkStartFunction(uint32_t index);
|
| uint32_t AddImport(const char* name, int name_length, FunctionSig* sig);
|
| WasmModuleWriter* Build(Zone* zone);
|
|
|
| struct CompareFunctionSigs {
|
| bool operator()(FunctionSig* a, FunctionSig* b) const;
|
| };
|
| - typedef ZoneMap<FunctionSig*, uint16_t, CompareFunctionSigs> SignatureMap;
|
| + typedef ZoneMap<FunctionSig*, uint32_t, CompareFunctionSigs> SignatureMap;
|
|
|
| private:
|
| Zone* zone_;
|
| @@ -151,7 +139,7 @@ class WasmModuleBuilder : public ZoneObject {
|
| ZoneVector<WasmFunctionImport> imports_;
|
| ZoneVector<WasmFunctionBuilder*> functions_;
|
| ZoneVector<WasmDataSegmentEncoder*> data_segments_;
|
| - ZoneVector<uint16_t> indirect_functions_;
|
| + ZoneVector<uint32_t> indirect_functions_;
|
| ZoneVector<std::pair<MachineType, bool>> globals_;
|
| SignatureMap signature_map_;
|
| int start_function_index_;
|
|
|