| 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_DECODER_H_ | 5 #ifndef V8_WASM_DECODER_H_ |
| 6 #define V8_WASM_DECODER_H_ | 6 #define V8_WASM_DECODER_H_ |
| 7 | 7 |
| 8 #include "src/base/smart-pointers.h" | 8 #include "src/base/smart-pointers.h" |
| 9 #include "src/flags.h" | 9 #include "src/flags.h" |
| 10 #include "src/signature.h" | 10 #include "src/signature.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 b = *pc_++; | 218 b = *pc_++; |
| 219 TRACE("%02x ", b); | 219 TRACE("%02x ", b); |
| 220 result = result | ((b & 0x7F) << shift); | 220 result = result | ((b & 0x7F) << shift); |
| 221 if ((b & 0x80) == 0) break; | 221 if ((b & 0x80) == 0) break; |
| 222 shift += 7; | 222 shift += 7; |
| 223 } | 223 } |
| 224 | 224 |
| 225 *length = static_cast<int>(pc_ - pos); | 225 *length = static_cast<int>(pc_ - pos); |
| 226 if (pc_ == end && (b & 0x80)) { | 226 if (pc_ == end && (b & 0x80)) { |
| 227 error(pc_ - 1, "varint too large"); | 227 error(pc_ - 1, "varint too large"); |
| 228 } else if (*length == 0) { |
| 229 error(pc_, "varint of length 0"); |
| 228 } else { | 230 } else { |
| 229 TRACE("= %u\n", result); | 231 TRACE("= %u\n", result); |
| 230 } | 232 } |
| 231 return result; | 233 return result; |
| 232 } | 234 } |
| 233 return traceOffEnd<uint32_t>(); | 235 return traceOffEnd<uint32_t>(); |
| 234 } | 236 } |
| 235 | 237 |
| 236 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}. | 238 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}. |
| 237 void consume_bytes(int size) { | 239 void consume_bytes(int size) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return result; | 397 return result; |
| 396 } | 398 } |
| 397 }; | 399 }; |
| 398 | 400 |
| 399 #undef TRACE | 401 #undef TRACE |
| 400 } // namespace wasm | 402 } // namespace wasm |
| 401 } // namespace internal | 403 } // namespace internal |
| 402 } // namespace v8 | 404 } // namespace v8 |
| 403 | 405 |
| 404 #endif // V8_WASM_DECODER_H_ | 406 #endif // V8_WASM_DECODER_H_ |
| OLD | NEW |