| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 void EmitCode(const byte* code, uint32_t code_size); | 125 void EmitCode(const byte* code, uint32_t code_size); |
| 126 void Emit(WasmOpcode opcode); | 126 void Emit(WasmOpcode opcode); |
| 127 void EmitGetLocal(uint32_t index); | 127 void EmitGetLocal(uint32_t index); |
| 128 void EmitSetLocal(uint32_t index); | 128 void EmitSetLocal(uint32_t index); |
| 129 void EmitTeeLocal(uint32_t index); | 129 void EmitTeeLocal(uint32_t index); |
| 130 void EmitI32Const(int32_t val); | 130 void EmitI32Const(int32_t val); |
| 131 void EmitWithU8(WasmOpcode opcode, const byte immediate); | 131 void EmitWithU8(WasmOpcode opcode, const byte immediate); |
| 132 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); | 132 void EmitWithU8U8(WasmOpcode opcode, const byte imm1, const byte imm2); |
| 133 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); | 133 void EmitWithVarInt(WasmOpcode opcode, uint32_t immediate); |
| 134 void EmitDirectCallIndex(uint32_t index); | 134 void EmitDirectCallIndex(uint32_t index); |
| 135 void Export(); | |
| 136 void ExportAs(Vector<const char> name); | 135 void ExportAs(Vector<const char> name); |
| 137 void SetName(Vector<const char> name); | 136 void SetName(Vector<const char> name); |
| 138 void AddAsmWasmOffset(int asm_position); | 137 void AddAsmWasmOffset(int asm_position); |
| 139 | 138 |
| 140 void WriteSignature(ZoneBuffer& buffer) const; | 139 void WriteSignature(ZoneBuffer& buffer) const; |
| 141 void WriteExport(ZoneBuffer& buffer) const; | 140 void WriteExports(ZoneBuffer& buffer) const; |
| 142 void WriteBody(ZoneBuffer& buffer) const; | 141 void WriteBody(ZoneBuffer& buffer) const; |
| 143 void WriteAsmWasmOffsetTable(ZoneBuffer& buffer) const; | 142 void WriteAsmWasmOffsetTable(ZoneBuffer& buffer) const; |
| 144 | 143 |
| 145 bool exported() { return exported_; } | |
| 146 uint32_t func_index() { return func_index_; } | 144 uint32_t func_index() { return func_index_; } |
| 147 FunctionSig* signature(); | 145 FunctionSig* signature(); |
| 148 | 146 |
| 149 private: | 147 private: |
| 150 explicit WasmFunctionBuilder(WasmModuleBuilder* builder); | 148 explicit WasmFunctionBuilder(WasmModuleBuilder* builder); |
| 151 friend class WasmModuleBuilder; | 149 friend class WasmModuleBuilder; |
| 152 friend class WasmTemporary; | 150 friend class WasmTemporary; |
| 153 | 151 |
| 154 struct DirectCallIndex { | 152 struct DirectCallIndex { |
| 155 size_t offset; | 153 size_t offset; |
| 156 uint32_t direct_index; | 154 uint32_t direct_index; |
| 157 }; | 155 }; |
| 158 | 156 |
| 159 WasmModuleBuilder* builder_; | 157 WasmModuleBuilder* builder_; |
| 160 LocalDeclEncoder locals_; | 158 LocalDeclEncoder locals_; |
| 161 uint32_t signature_index_; | 159 uint32_t signature_index_; |
| 162 bool exported_; | |
| 163 uint32_t func_index_; | 160 uint32_t func_index_; |
| 164 ZoneVector<uint8_t> body_; | 161 ZoneVector<uint8_t> body_; |
| 165 ZoneVector<char> name_; | 162 ZoneVector<char> name_; |
| 166 ZoneVector<char> exported_name_; | 163 ZoneVector<ZoneVector<char>> exported_names_; |
| 167 ZoneVector<uint32_t> i32_temps_; | 164 ZoneVector<uint32_t> i32_temps_; |
| 168 ZoneVector<uint32_t> i64_temps_; | 165 ZoneVector<uint32_t> i64_temps_; |
| 169 ZoneVector<uint32_t> f32_temps_; | 166 ZoneVector<uint32_t> f32_temps_; |
| 170 ZoneVector<uint32_t> f64_temps_; | 167 ZoneVector<uint32_t> f64_temps_; |
| 171 ZoneVector<DirectCallIndex> direct_calls_; | 168 ZoneVector<DirectCallIndex> direct_calls_; |
| 172 | 169 |
| 173 // Delta-encoded mapping from wasm bytes to asm.js source positions. | 170 // Delta-encoded mapping from wasm bytes to asm.js source positions. |
| 174 ZoneBuffer asm_offsets_; | 171 ZoneBuffer asm_offsets_; |
| 175 uint32_t last_asm_byte_offset_ = 0; | 172 uint32_t last_asm_byte_offset_ = 0; |
| 176 uint32_t last_asm_source_position_ = 0; | 173 uint32_t last_asm_source_position_ = 0; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 279 |
| 283 inline FunctionSig* WasmFunctionBuilder::signature() { | 280 inline FunctionSig* WasmFunctionBuilder::signature() { |
| 284 return builder_->signatures_[signature_index_]; | 281 return builder_->signatures_[signature_index_]; |
| 285 } | 282 } |
| 286 | 283 |
| 287 } // namespace wasm | 284 } // namespace wasm |
| 288 } // namespace internal | 285 } // namespace internal |
| 289 } // namespace v8 | 286 } // namespace v8 |
| 290 | 287 |
| 291 #endif // V8_WASM_WASM_MODULE_BUILDER_H_ | 288 #endif // V8_WASM_WASM_MODULE_BUILDER_H_ |
| OLD | NEW |