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_AST_DECODER_H_ | 5 #ifndef V8_WASM_AST_DECODER_H_ |
6 #define V8_WASM_AST_DECODER_H_ | 6 #define V8_WASM_AST_DECODER_H_ |
7 | 7 |
8 #include "src/signature.h" | 8 #include "src/signature.h" |
9 #include "src/wasm/decoder.h" | 9 #include "src/wasm/decoder.h" |
10 #include "src/wasm/wasm-opcodes.h" | 10 #include "src/wasm/wasm-opcodes.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 inline uint32_t read_entry(Decoder* decoder, unsigned i) { | 227 inline uint32_t read_entry(Decoder* decoder, unsigned i) { |
228 DCHECK(i <= table_count); | 228 DCHECK(i <= table_count); |
229 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; | 229 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0; |
230 } | 230 } |
231 }; | 231 }; |
232 | 232 |
233 // A helper to iterate over a branch table. | 233 // A helper to iterate over a branch table. |
234 class BranchTableIterator { | 234 class BranchTableIterator { |
235 public: | 235 public: |
236 unsigned cur_index() { return index_; } | 236 unsigned cur_index() { return index_; } |
237 bool has_next() { return index_ <= table_count_; } | 237 bool has_next() { return decoder_->ok() && index_ <= table_count_; } |
titzer
2016/10/13 13:46:10
Does this obviate the previous fix?
ahaas
2016/10/13 13:53:44
This change does not prevent any crashes, it just
| |
238 uint32_t next() { | 238 uint32_t next() { |
239 DCHECK(has_next()); | 239 DCHECK(has_next()); |
240 index_++; | 240 index_++; |
241 unsigned length = 0; | 241 unsigned length = 0; |
242 uint32_t result = | 242 uint32_t result = |
243 decoder_->checked_read_u32v(pc_, 0, &length, "branch table entry"); | 243 decoder_->checked_read_u32v(pc_, 0, &length, "branch table entry"); |
244 pc_ += length; | 244 pc_ += length; |
245 return result; | 245 return result; |
246 } | 246 } |
247 // length, including the length of the {BranchTableOperand}, but not the | 247 // length, including the length of the {BranchTableOperand}, but not the |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 } | 413 } |
414 | 414 |
415 bool has_next() { return pc_ < end_; } | 415 bool has_next() { return pc_ < end_; } |
416 }; | 416 }; |
417 | 417 |
418 } // namespace wasm | 418 } // namespace wasm |
419 } // namespace internal | 419 } // namespace internal |
420 } // namespace v8 | 420 } // namespace v8 |
421 | 421 |
422 #endif // V8_WASM_AST_DECODER_H_ | 422 #endif // V8_WASM_AST_DECODER_H_ |
OLD | NEW |