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 15 matching lines...) Expand all Loading... |
26 uint32_t BodySize() const; | 26 uint32_t BodySize() const; |
27 uint32_t NameSize() const; | 27 uint32_t NameSize() const; |
28 void Serialize(byte* buffer, byte** header, byte** body) const; | 28 void Serialize(byte* buffer, byte** header, byte** body) const; |
29 | 29 |
30 private: | 30 private: |
31 WasmFunctionEncoder(Zone* zone, LocalType return_type, bool exported, | 31 WasmFunctionEncoder(Zone* zone, LocalType return_type, bool exported, |
32 bool external); | 32 bool external); |
33 friend class WasmFunctionBuilder; | 33 friend class WasmFunctionBuilder; |
34 uint16_t signature_index_; | 34 uint16_t signature_index_; |
35 ZoneVector<LocalType> params_; | 35 ZoneVector<LocalType> params_; |
36 uint16_t local_int32_count_; | 36 uint16_t local_i32_count_; |
37 uint16_t local_int64_count_; | 37 uint16_t local_i64_count_; |
38 uint16_t local_float32_count_; | 38 uint16_t local_f32_count_; |
39 uint16_t local_float64_count_; | 39 uint16_t local_f64_count_; |
40 bool exported_; | 40 bool exported_; |
41 bool external_; | 41 bool external_; |
42 ZoneVector<uint8_t> body_; | 42 ZoneVector<uint8_t> body_; |
43 ZoneVector<char> name_; | 43 ZoneVector<char> name_; |
44 | 44 |
45 bool HasLocals() const { | 45 bool HasLocals() const { |
46 return (local_int32_count_ + local_int64_count_ + local_float32_count_ + | 46 return (local_i32_count_ + local_i64_count_ + local_f32_count_ + |
47 local_float64_count_) > 0; | 47 local_f64_count_) > 0; |
48 } | 48 } |
49 | 49 |
50 bool HasName() const { return exported_ && name_.size() > 0; } | 50 bool HasName() const { return exported_ && name_.size() > 0; } |
51 }; | 51 }; |
52 | 52 |
53 class WasmFunctionBuilder : public ZoneObject { | 53 class WasmFunctionBuilder : public ZoneObject { |
54 public: | 54 public: |
55 uint16_t AddParam(LocalType type); | 55 uint16_t AddParam(LocalType type); |
56 uint16_t AddLocal(LocalType type); | 56 uint16_t AddLocal(LocalType type); |
57 void ReturnType(LocalType type); | 57 void ReturnType(LocalType type); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ZoneVector<std::pair<MachineType, bool>> globals_; | 147 ZoneVector<std::pair<MachineType, bool>> globals_; |
148 SignatureMap signature_map_; | 148 SignatureMap signature_map_; |
149 }; | 149 }; |
150 | 150 |
151 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); | 151 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); |
152 } // namespace wasm | 152 } // namespace wasm |
153 } // namespace internal | 153 } // namespace internal |
154 } // namespace v8 | 154 } // namespace v8 |
155 | 155 |
156 #endif // V8_WASM_ENCODER_H_ | 156 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |