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

Side by Side Diff: src/wasm/encoder.h

Issue 1583603002: Add __init__ function to all modules created in asm-to-wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@refactor
Patch Set: Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/wasm/asm-wasm-builder.cc ('k') | src/wasm/encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_WASM_ENCODER_H_ 5 #ifndef V8_WASM_ENCODER_H_
6 #define V8_WASM_ENCODER_H_ 6 #define V8_WASM_ENCODER_H_
7 7
8 #include "src/signature.h" 8 #include "src/signature.h"
9 #include "src/zone-containers.h" 9 #include "src/zone-containers.h"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void EmitCode(const byte* code, uint32_t code_size); 58 void EmitCode(const byte* code, uint32_t code_size);
59 void EmitCode(const byte* code, uint32_t code_size, 59 void EmitCode(const byte* code, uint32_t code_size,
60 const uint32_t* local_indices, uint32_t indices_size); 60 const uint32_t* local_indices, uint32_t indices_size);
61 void Emit(WasmOpcode opcode); 61 void Emit(WasmOpcode opcode);
62 void EmitWithU8(WasmOpcode opcode, const byte immediate); 62 void EmitWithU8(WasmOpcode opcode, const byte immediate);
63 void EmitWithLocal(WasmOpcode opcode); 63 void EmitWithLocal(WasmOpcode opcode);
64 uint32_t EmitEditableImmediate(const byte immediate); 64 uint32_t EmitEditableImmediate(const byte immediate);
65 void EditImmediate(uint32_t offset, const byte immediate); 65 void EditImmediate(uint32_t offset, const byte immediate);
66 void Exported(uint8_t flag); 66 void Exported(uint8_t flag);
67 void External(uint8_t flag); 67 void External(uint8_t flag);
68 void SetName(const unsigned char* name, int name_length);
68 WasmFunctionEncoder* Build(Zone* zone, WasmModuleBuilder* mb) const; 69 WasmFunctionEncoder* Build(Zone* zone, WasmModuleBuilder* mb) const;
69 70
70 private: 71 private:
71 WasmFunctionBuilder(Zone* zone, const unsigned char* name, int name_length); 72 explicit WasmFunctionBuilder(Zone* zone);
72 friend class WasmModuleBuilder; 73 friend class WasmModuleBuilder;
73 LocalType return_type_; 74 LocalType return_type_;
74 struct Type; 75 struct Type;
75 ZoneVector<Type> locals_; 76 ZoneVector<Type> locals_;
76 uint8_t exported_; 77 uint8_t exported_;
77 uint8_t external_; 78 uint8_t external_;
78 ZoneVector<uint8_t> body_; 79 ZoneVector<uint8_t> body_;
79 ZoneVector<uint32_t> local_indices_; 80 ZoneVector<uint32_t> local_indices_;
80 ZoneVector<char> name_; 81 ZoneVector<char> name_;
81 uint16_t AddVar(LocalType type, bool param); 82 uint16_t AddVar(LocalType type, bool param);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ZoneVector<WasmFunctionEncoder*> functions_; 119 ZoneVector<WasmFunctionEncoder*> functions_;
119 ZoneVector<WasmDataSegmentEncoder*> data_segments_; 120 ZoneVector<WasmDataSegmentEncoder*> data_segments_;
120 ZoneVector<FunctionSig*> signatures_; 121 ZoneVector<FunctionSig*> signatures_;
121 ZoneVector<uint16_t> indirect_functions_; 122 ZoneVector<uint16_t> indirect_functions_;
122 ZoneVector<std::pair<MachineType, bool>> globals_; 123 ZoneVector<std::pair<MachineType, bool>> globals_;
123 }; 124 };
124 125
125 class WasmModuleBuilder : public ZoneObject { 126 class WasmModuleBuilder : public ZoneObject {
126 public: 127 public:
127 explicit WasmModuleBuilder(Zone* zone); 128 explicit WasmModuleBuilder(Zone* zone);
128 uint16_t AddFunction(const unsigned char* name = nullptr, 129 uint16_t AddFunction();
129 int name_length = 0);
130 uint32_t AddGlobal(MachineType type, bool exported); 130 uint32_t AddGlobal(MachineType type, bool exported);
131 WasmFunctionBuilder* FunctionAt(size_t index); 131 WasmFunctionBuilder* FunctionAt(size_t index);
132 void AddDataSegment(WasmDataSegmentEncoder* data); 132 void AddDataSegment(WasmDataSegmentEncoder* data);
133 uint16_t AddSignature(FunctionSig* sig); 133 uint16_t AddSignature(FunctionSig* sig);
134 void AddIndirectFunction(uint16_t index); 134 void AddIndirectFunction(uint16_t index);
135 WasmModuleWriter* Build(Zone* zone); 135 WasmModuleWriter* Build(Zone* zone);
136 136
137 private: 137 private:
138 struct CompareFunctionSigs { 138 struct CompareFunctionSigs {
139 int operator()(FunctionSig* a, FunctionSig* b) const; 139 int operator()(FunctionSig* a, FunctionSig* b) const;
140 }; 140 };
141 typedef ZoneMap<FunctionSig*, uint16_t, CompareFunctionSigs> SignatureMap; 141 typedef ZoneMap<FunctionSig*, uint16_t, CompareFunctionSigs> SignatureMap;
142 142
143 Zone* zone_; 143 Zone* zone_;
144 ZoneVector<FunctionSig*> signatures_; 144 ZoneVector<FunctionSig*> signatures_;
145 ZoneVector<WasmFunctionBuilder*> functions_; 145 ZoneVector<WasmFunctionBuilder*> functions_;
146 ZoneVector<WasmDataSegmentEncoder*> data_segments_; 146 ZoneVector<WasmDataSegmentEncoder*> data_segments_;
147 ZoneVector<uint16_t> indirect_functions_; 147 ZoneVector<uint16_t> indirect_functions_;
148 ZoneVector<std::pair<MachineType, bool>> globals_; 148 ZoneVector<std::pair<MachineType, bool>> globals_;
149 SignatureMap signature_map_; 149 SignatureMap signature_map_;
150 }; 150 };
151 151
152 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); 152 std::vector<uint8_t> UnsignedLEB128From(uint32_t result);
153 } // namespace wasm 153 } // namespace wasm
154 } // namespace internal 154 } // namespace internal
155 } // namespace v8 155 } // namespace v8
156 156
157 #endif // V8_WASM_ENCODER_H_ 157 #endif // V8_WASM_ENCODER_H_
OLDNEW
« 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