Chromium Code Reviews| Index: src/wasm/encoder.h |
| diff --git a/src/wasm/encoder.h b/src/wasm/encoder.h |
| index 8f0fd49bdd58031b45ec83cb0043ca06115a509e..f24a847700ff52ceb3121a0b3dcdd86e82d8d61d 100644 |
| --- a/src/wasm/encoder.h |
| +++ b/src/wasm/encoder.h |
| @@ -121,19 +121,22 @@ class WasmFunctionBuilder : public ZoneObject { |
| void Emit(WasmOpcode opcode); |
| void EmitGetLocal(uint32_t index); |
| void EmitSetLocal(uint32_t index); |
| + void EmitTeeLocal(uint32_t index); |
| void EmitI32Const(int32_t val); |
| void EmitWithU8(WasmOpcode opcode, const byte immediate); |
| void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); |
| void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); |
| void SetExported(); |
| void SetName(const char* name, int name_length); |
| - bool exported() { return exported_; } |
| - // Writing methods. |
| void WriteSignature(ZoneBuffer& buffer) const; |
| - void WriteExport(ZoneBuffer& buffer, uint32_t func_index) const; |
| + void WriteExport(ZoneBuffer& buffer) const; |
| void WriteBody(ZoneBuffer& buffer) const; |
| + bool exported() { return exported_; } |
| + uint32_t func_index() { return func_index_; } |
| + FunctionSig* signature(); |
| + |
| private: |
| explicit WasmFunctionBuilder(WasmModuleBuilder* builder); |
| friend class WasmModuleBuilder; |
| @@ -142,6 +145,7 @@ class WasmFunctionBuilder : public ZoneObject { |
| LocalDeclEncoder locals_; |
| uint32_t signature_index_; |
| bool exported_; |
| + uint32_t func_index_; |
| ZoneVector<uint8_t> body_; |
| ZoneVector<char> name_; |
| ZoneVector<uint32_t> i32_temps_; |
| @@ -212,14 +216,17 @@ class WasmModuleBuilder : public ZoneObject { |
| explicit WasmModuleBuilder(Zone* zone); |
| // Building methods. |
| - uint32_t AddFunction(); |
| - uint32_t AddGlobal(LocalType type, bool exported); |
| - WasmFunctionBuilder* FunctionAt(size_t index); |
| + uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
| + void SetImportName(uint32_t index, const char* name, int name_length) { |
| + imports_[index].name = name; |
| + imports_[index].name_length = name_length; |
| + } |
| + WasmFunctionBuilder* AddFunction(FunctionSig* sig = nullptr); |
|
bradnelson
2016/09/23 11:36:01
So I'll need to add a list of fixups per callsite
titzer
2016/09/23 12:07:30
Do you mean a list of fixups per imported function
bradn
2016/09/23 15:18:43
Oddly phrased.
I mean to say each callsite in ever
|
| + uint32_t AddGlobal(LocalType type, bool exported, bool mutability = true); |
| void AddDataSegment(WasmDataSegmentEncoder* data); |
| uint32_t AddSignature(FunctionSig* sig); |
| void AddIndirectFunction(uint32_t index); |
| - void MarkStartFunction(uint32_t index); |
| - uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
| + void MarkStartFunction(WasmFunctionBuilder* builder); |
| // Writing methods. |
| void WriteTo(ZoneBuffer& buffer) const; |
| @@ -231,18 +238,25 @@ class WasmModuleBuilder : public ZoneObject { |
| Zone* zone() { return zone_; } |
| + FunctionSig* GetSignature(uint32_t index) { return signatures_[index]; } |
| + |
| private: |
| + friend class WasmFunctionBuilder; |
| Zone* zone_; |
| ZoneVector<FunctionSig*> signatures_; |
| ZoneVector<WasmFunctionImport> imports_; |
| ZoneVector<WasmFunctionBuilder*> functions_; |
| ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
| ZoneVector<uint32_t> indirect_functions_; |
| - ZoneVector<std::pair<LocalType, bool>> globals_; |
| + ZoneVector<std::tuple<LocalType, bool, bool>> globals_; |
| SignatureMap signature_map_; |
| int start_function_index_; |
| }; |
| +inline FunctionSig* WasmFunctionBuilder::signature() { |
| + return builder_->signatures_[signature_index_]; |
| +} |
| + |
| } // namespace wasm |
| } // namespace internal |
| } // namespace v8 |