Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: src/wasm/encoder.h

Issue 1980543002: [wasm] Remove renumbering of local variables from asm->wasm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm_renumber
Patch Set: Fix memory leak by using a zone Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | src/wasm/encoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | src/wasm/encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698