OLD | NEW |
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const char* name; | 163 const char* name; |
164 int name_length; | 164 int name_length; |
165 }; | 165 }; |
166 | 166 |
167 class WasmModuleBuilder : public ZoneObject { | 167 class WasmModuleBuilder : public ZoneObject { |
168 public: | 168 public: |
169 explicit WasmModuleBuilder(Zone* zone); | 169 explicit WasmModuleBuilder(Zone* zone); |
170 | 170 |
171 // Building methods. | 171 // Building methods. |
172 uint32_t AddFunction(); | 172 uint32_t AddFunction(); |
173 uint32_t AddGlobal(MachineType type, bool exported); | 173 uint32_t AddGlobal(LocalType type, bool exported); |
174 WasmFunctionBuilder* FunctionAt(size_t index); | 174 WasmFunctionBuilder* FunctionAt(size_t index); |
175 void AddDataSegment(WasmDataSegmentEncoder* data); | 175 void AddDataSegment(WasmDataSegmentEncoder* data); |
176 uint32_t AddSignature(FunctionSig* sig); | 176 uint32_t AddSignature(FunctionSig* sig); |
177 void AddIndirectFunction(uint32_t index); | 177 void AddIndirectFunction(uint32_t index); |
178 void MarkStartFunction(uint32_t index); | 178 void MarkStartFunction(uint32_t index); |
179 uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); | 179 uint32_t AddImport(const char* name, int name_length, FunctionSig* sig); |
180 | 180 |
181 // Writing methods. | 181 // Writing methods. |
182 void WriteTo(ZoneBuffer& buffer) const; | 182 void WriteTo(ZoneBuffer& buffer) const; |
183 | 183 |
184 struct CompareFunctionSigs { | 184 struct CompareFunctionSigs { |
185 bool operator()(FunctionSig* a, FunctionSig* b) const; | 185 bool operator()(FunctionSig* a, FunctionSig* b) const; |
186 }; | 186 }; |
187 typedef ZoneMap<FunctionSig*, uint32_t, CompareFunctionSigs> SignatureMap; | 187 typedef ZoneMap<FunctionSig*, uint32_t, CompareFunctionSigs> SignatureMap; |
188 | 188 |
189 Zone* zone() { return zone_; } | 189 Zone* zone() { return zone_; } |
190 | 190 |
191 private: | 191 private: |
192 Zone* zone_; | 192 Zone* zone_; |
193 ZoneVector<FunctionSig*> signatures_; | 193 ZoneVector<FunctionSig*> signatures_; |
194 ZoneVector<WasmFunctionImport> imports_; | 194 ZoneVector<WasmFunctionImport> imports_; |
195 ZoneVector<WasmFunctionBuilder*> functions_; | 195 ZoneVector<WasmFunctionBuilder*> functions_; |
196 ZoneVector<WasmDataSegmentEncoder*> data_segments_; | 196 ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
197 ZoneVector<uint32_t> indirect_functions_; | 197 ZoneVector<uint32_t> indirect_functions_; |
198 ZoneVector<std::pair<MachineType, bool>> globals_; | 198 ZoneVector<std::pair<LocalType, bool>> globals_; |
199 SignatureMap signature_map_; | 199 SignatureMap signature_map_; |
200 int start_function_index_; | 200 int start_function_index_; |
201 }; | 201 }; |
202 | 202 |
203 } // namespace wasm | 203 } // namespace wasm |
204 } // namespace internal | 204 } // namespace internal |
205 } // namespace v8 | 205 } // namespace v8 |
206 | 206 |
207 #endif // V8_WASM_ENCODER_H_ | 207 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |