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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ZoneVector<char> name_; | 43 ZoneVector<char> name_; |
44 | 44 |
45 bool HasName() const { return (exported_ || external_) && name_.size() > 0; } | 45 bool HasName() const { return (exported_ || external_) && name_.size() > 0; } |
46 }; | 46 }; |
47 | 47 |
48 class WasmFunctionBuilder : public ZoneObject { | 48 class WasmFunctionBuilder : public ZoneObject { |
49 public: | 49 public: |
50 uint16_t AddParam(LocalType type); | 50 uint16_t AddParam(LocalType type); |
51 uint16_t AddLocal(LocalType type); | 51 uint16_t AddLocal(LocalType type); |
52 void ReturnType(LocalType type); | 52 void ReturnType(LocalType type); |
| 53 void EmitVarInt(uint32_t val); |
53 void EmitCode(const byte* code, uint32_t code_size); | 54 void EmitCode(const byte* code, uint32_t code_size); |
54 void EmitCode(const byte* code, uint32_t code_size, | 55 void EmitCode(const byte* code, uint32_t code_size, |
55 const uint32_t* local_indices, uint32_t indices_size); | 56 const uint32_t* local_indices, uint32_t indices_size); |
56 void Emit(WasmOpcode opcode); | 57 void Emit(WasmOpcode opcode); |
57 void EmitGetLocal(uint32_t index); | 58 void EmitGetLocal(uint32_t index); |
58 void EmitSetLocal(uint32_t index); | 59 void EmitSetLocal(uint32_t index); |
59 void EmitWithU8(WasmOpcode opcode, const byte immediate); | 60 void EmitWithU8(WasmOpcode opcode, const byte immediate); |
60 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); | 61 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); |
61 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); | 62 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); |
62 uint32_t EmitEditableVarIntImmediate(); | 63 uint32_t EmitEditableVarIntImmediate(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 Zone* zone_; | 144 Zone* zone_; |
144 ZoneVector<FunctionSig*> signatures_; | 145 ZoneVector<FunctionSig*> signatures_; |
145 ZoneVector<WasmFunctionBuilder*> functions_; | 146 ZoneVector<WasmFunctionBuilder*> functions_; |
146 ZoneVector<WasmDataSegmentEncoder*> data_segments_; | 147 ZoneVector<WasmDataSegmentEncoder*> data_segments_; |
147 ZoneVector<uint16_t> indirect_functions_; | 148 ZoneVector<uint16_t> indirect_functions_; |
148 ZoneVector<std::pair<MachineType, bool>> globals_; | 149 ZoneVector<std::pair<MachineType, bool>> globals_; |
149 SignatureMap signature_map_; | 150 SignatureMap signature_map_; |
150 int start_function_index_; | 151 int start_function_index_; |
151 }; | 152 }; |
152 | 153 |
153 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); | |
154 } // namespace wasm | 154 } // namespace wasm |
155 } // namespace internal | 155 } // namespace internal |
156 } // namespace v8 | 156 } // namespace v8 |
157 | 157 |
158 #endif // V8_WASM_ENCODER_H_ | 158 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |