Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: src/wasm/ast-decoder.h

Issue 2520943002: [wasm] Implement official wasm text format (Closed)
Patch Set: Address comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/v8.gyp ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/compiler-specific.h" 8 #include "src/base/compiler-specific.h"
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/signature.h" 10 #include "src/signature.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 DCHECK_EQ(kExprBrTable, decoder->checked_read_u8(pc, 0, "opcode")); 236 DCHECK_EQ(kExprBrTable, decoder->checked_read_u8(pc, 0, "opcode"));
237 start = pc + 1; 237 start = pc + 1;
238 unsigned len1 = 0; 238 unsigned len1 = 0;
239 table_count = decoder->checked_read_u32v(pc, 1, &len1, "table count"); 239 table_count = decoder->checked_read_u32v(pc, 1, &len1, "table count");
240 if (table_count > (UINT_MAX / sizeof(uint32_t)) - 1 || 240 if (table_count > (UINT_MAX / sizeof(uint32_t)) - 1 ||
241 len1 > UINT_MAX - (table_count + 1) * sizeof(uint32_t)) { 241 len1 > UINT_MAX - (table_count + 1) * sizeof(uint32_t)) {
242 decoder->error(pc, "branch table size overflow"); 242 decoder->error(pc, "branch table size overflow");
243 } 243 }
244 table = pc + 1 + len1; 244 table = pc + 1 + len1;
245 } 245 }
246 inline uint32_t read_entry(Decoder* decoder, unsigned i) {
247 DCHECK(i <= table_count);
248 return table ? decoder->read_u32(table + i * sizeof(uint32_t)) : 0;
249 }
250 }; 246 };
251 247
252 // A helper to iterate over a branch table. 248 // A helper to iterate over a branch table.
253 class BranchTableIterator { 249 class BranchTableIterator {
254 public: 250 public:
255 unsigned cur_index() { return index_; } 251 unsigned cur_index() { return index_; }
256 bool has_next() { return decoder_->ok() && index_ <= table_count_; } 252 bool has_next() { return decoder_->ok() && index_ <= table_count_; }
257 uint32_t next() { 253 uint32_t next() {
258 DCHECK(has_next()); 254 DCHECK(has_next());
259 index_++; 255 index_++;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 431 }
436 432
437 bool has_next() { return pc_ < end_; } 433 bool has_next() { return pc_ < end_; }
438 }; 434 };
439 435
440 } // namespace wasm 436 } // namespace wasm
441 } // namespace internal 437 } // namespace internal
442 } // namespace v8 438 } // namespace v8
443 439
444 #endif // V8_WASM_AST_DECODER_H_ 440 #endif // V8_WASM_AST_DECODER_H_
OLDNEW
« no previous file with comments | « src/v8.gyp ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698