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 24 matching lines...) Expand all Loading... |
35 ZoneVector<LocalType> params_; | 35 ZoneVector<LocalType> params_; |
36 uint16_t local_i32_count_; | 36 uint16_t local_i32_count_; |
37 uint16_t local_i64_count_; | 37 uint16_t local_i64_count_; |
38 uint16_t local_f32_count_; | 38 uint16_t local_f32_count_; |
39 uint16_t local_f64_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 { | |
46 return (local_i32_count_ + local_i64_count_ + local_f32_count_ + | |
47 local_f64_count_) > 0; | |
48 } | |
49 | |
50 bool HasName() const { return (exported_ || external_) && name_.size() > 0; } | 45 bool HasName() const { return (exported_ || external_) && name_.size() > 0; } |
51 }; | 46 }; |
52 | 47 |
53 class WasmFunctionBuilder : public ZoneObject { | 48 class WasmFunctionBuilder : public ZoneObject { |
54 public: | 49 public: |
55 uint16_t AddParam(LocalType type); | 50 uint16_t AddParam(LocalType type); |
56 uint16_t AddLocal(LocalType type); | 51 uint16_t AddLocal(LocalType type); |
57 void ReturnType(LocalType type); | 52 void ReturnType(LocalType type); |
58 void EmitCode(const byte* code, uint32_t code_size); | 53 void EmitCode(const byte* code, uint32_t code_size); |
59 void EmitCode(const byte* code, uint32_t code_size, | 54 void EmitCode(const byte* code, uint32_t code_size, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 SignatureMap signature_map_; | 145 SignatureMap signature_map_; |
151 int start_function_index_; | 146 int start_function_index_; |
152 }; | 147 }; |
153 | 148 |
154 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); | 149 std::vector<uint8_t> UnsignedLEB128From(uint32_t result); |
155 } // namespace wasm | 150 } // namespace wasm |
156 } // namespace internal | 151 } // namespace internal |
157 } // namespace v8 | 152 } // namespace v8 |
158 | 153 |
159 #endif // V8_WASM_ENCODER_H_ | 154 #endif // V8_WASM_ENCODER_H_ |
OLD | NEW |