OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_LEB_HELPER_H_ | 5 #ifndef V8_WASM_LEB_HELPER_H_ |
6 #define V8_WASM_LEB_HELPER_H_ | 6 #define V8_WASM_LEB_HELPER_H_ |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace wasm { | 10 namespace wasm { |
11 | 11 |
| 12 static const size_t kPaddedVarInt32Size = 5; |
| 13 static const size_t kMaxVarInt32Size = 5; |
| 14 |
12 class LEBHelper { | 15 class LEBHelper { |
13 public: | 16 public: |
14 // Write a 32-bit unsigned LEB to {dest}, updating {dest} to point after | 17 // Write a 32-bit unsigned LEB to {dest}, updating {dest} to point after |
15 // the last uint8_t written. No safety checks. | 18 // the last uint8_t written. No safety checks. |
16 static void write_u32v(uint8_t** dest, uint32_t val) { | 19 static void write_u32v(uint8_t** dest, uint32_t val) { |
17 while (val >= 0x80) { | 20 while (val >= 0x80) { |
18 *((*dest)++) = static_cast<uint8_t>(0x80 | (val & 0x7F)); | 21 *((*dest)++) = static_cast<uint8_t>(0x80 | (val & 0x7F)); |
19 val >>= 7; | 22 val >>= 7; |
20 } | 23 } |
21 *((*dest)++) = static_cast<uint8_t>(val & 0x7F); | 24 *((*dest)++) = static_cast<uint8_t>(val & 0x7F); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 125 } |
123 return size; | 126 return size; |
124 } | 127 } |
125 }; | 128 }; |
126 | 129 |
127 } // namespace wasm | 130 } // namespace wasm |
128 } // namespace internal | 131 } // namespace internal |
129 } // namespace v8 | 132 } // namespace v8 |
130 | 133 |
131 #endif // V8_WASM_LEB_HELPER_H_ | 134 #endif // V8_WASM_LEB_HELPER_H_ |
OLD | NEW |