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_WASM_MODULE_BUILDER_H_ | 5 #ifndef V8_WASM_WASM_MODULE_BUILDER_H_ |
6 #define V8_WASM_WASM_MODULE_BUILDER_H_ | 6 #define V8_WASM_WASM_MODULE_BUILDER_H_ |
7 | 7 |
8 #include "src/signature.h" | 8 #include "src/signature.h" |
9 #include "src/zone/zone-containers.h" | 9 #include "src/zone/zone-containers.h" |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void Emit(WasmOpcode opcode); | 121 void Emit(WasmOpcode opcode); |
122 void EmitGetLocal(uint32_t index); | 122 void EmitGetLocal(uint32_t index); |
123 void EmitSetLocal(uint32_t index); | 123 void EmitSetLocal(uint32_t index); |
124 void EmitTeeLocal(uint32_t index); | 124 void EmitTeeLocal(uint32_t index); |
125 void EmitI32Const(int32_t val); | 125 void EmitI32Const(int32_t val); |
126 void EmitWithU8(WasmOpcode opcode, const byte immediate); | 126 void EmitWithU8(WasmOpcode opcode, const byte immediate); |
127 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); | 127 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); |
128 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); | 128 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); |
129 void EmitDirectCallIndex(uint32_t index); | 129 void EmitDirectCallIndex(uint32_t index); |
130 void SetExported(); | 130 void SetExported(); |
| 131 void SetExportedWithName(const char* name, int name_length); |
131 void SetName(const char* name, int name_length); | 132 void SetName(const char* name, int name_length); |
132 | 133 |
133 void WriteSignature(ZoneBuffer& buffer) const; | 134 void WriteSignature(ZoneBuffer& buffer) const; |
134 void WriteExport(ZoneBuffer& buffer) const; | 135 void WriteExport(ZoneBuffer& buffer) const; |
135 void WriteBody(ZoneBuffer& buffer) const; | 136 void WriteBody(ZoneBuffer& buffer) const; |
136 | 137 |
137 bool exported() { return exported_; } | 138 bool exported() { return exported_; } |
138 uint32_t func_index() { return func_index_; } | 139 uint32_t func_index() { return func_index_; } |
139 FunctionSig* signature(); | 140 FunctionSig* signature(); |
140 | 141 |
141 private: | 142 private: |
142 explicit WasmFunctionBuilder(WasmModuleBuilder* builder); | 143 explicit WasmFunctionBuilder(WasmModuleBuilder* builder); |
143 friend class WasmModuleBuilder; | 144 friend class WasmModuleBuilder; |
144 friend class WasmTemporary; | 145 friend class WasmTemporary; |
145 | 146 |
146 struct DirectCallIndex { | 147 struct DirectCallIndex { |
147 size_t offset; | 148 size_t offset; |
148 uint32_t direct_index; | 149 uint32_t direct_index; |
149 }; | 150 }; |
150 | 151 |
151 WasmModuleBuilder* builder_; | 152 WasmModuleBuilder* builder_; |
152 LocalDeclEncoder locals_; | 153 LocalDeclEncoder locals_; |
153 uint32_t signature_index_; | 154 uint32_t signature_index_; |
154 bool exported_; | 155 bool exported_; |
155 uint32_t func_index_; | 156 uint32_t func_index_; |
156 ZoneVector<uint8_t> body_; | 157 ZoneVector<uint8_t> body_; |
157 ZoneVector<char> name_; | 158 ZoneVector<char> name_; |
| 159 ZoneVector<char> exported_name_; |
158 ZoneVector<uint32_t> i32_temps_; | 160 ZoneVector<uint32_t> i32_temps_; |
159 ZoneVector<uint32_t> i64_temps_; | 161 ZoneVector<uint32_t> i64_temps_; |
160 ZoneVector<uint32_t> f32_temps_; | 162 ZoneVector<uint32_t> f32_temps_; |
161 ZoneVector<uint32_t> f64_temps_; | 163 ZoneVector<uint32_t> f64_temps_; |
162 ZoneVector<DirectCallIndex> direct_calls_; | 164 ZoneVector<DirectCallIndex> direct_calls_; |
163 }; | 165 }; |
164 | 166 |
165 class WasmTemporary { | 167 class WasmTemporary { |
166 public: | 168 public: |
167 WasmTemporary(WasmFunctionBuilder* builder, LocalType type) { | 169 WasmTemporary(WasmFunctionBuilder* builder, LocalType type) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 266 |
265 inline FunctionSig* WasmFunctionBuilder::signature() { | 267 inline FunctionSig* WasmFunctionBuilder::signature() { |
266 return builder_->signatures_[signature_index_]; | 268 return builder_->signatures_[signature_index_]; |
267 } | 269 } |
268 | 270 |
269 } // namespace wasm | 271 } // namespace wasm |
270 } // namespace internal | 272 } // namespace internal |
271 } // namespace v8 | 273 } // namespace v8 |
272 | 274 |
273 #endif // V8_WASM_WASM_MODULE_BUILDER_H_ | 275 #endif // V8_WASM_WASM_MODULE_BUILDER_H_ |
OLD | NEW |