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

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

Issue 2648383007: [wasm] Decoding the names section should stop if there is a problem with locals. (Closed)
Patch Set: Created 3 years, 11 months 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 | « no previous file | src/wasm/module-decoder.cc » ('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_DECODER_H_ 5 #ifndef V8_WASM_DECODER_H_
6 #define V8_WASM_DECODER_H_ 6 #define V8_WASM_DECODER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 while (pc_ < end) { 375 while (pc_ < end) {
376 b = *pc_++; 376 b = *pc_++;
377 TRACE("%02x ", b); 377 TRACE("%02x ", b);
378 result = result | (static_cast<IntType>(b & 0x7F) << shift); 378 result = result | (static_cast<IntType>(b & 0x7F) << shift);
379 shift += 7; 379 shift += 7;
380 if ((b & 0x80) == 0) break; 380 if ((b & 0x80) == 0) break;
381 } 381 }
382 382
383 int length = static_cast<int>(pc_ - pos); 383 int length = static_cast<int>(pc_ - pos);
384 if (pc_ == end && (b & 0x80)) { 384 if (pc_ == end && (b & 0x80)) {
385 TRACE("\n");
385 error(pc_ - 1, "varint too large"); 386 error(pc_ - 1, "varint too large");
386 } else if (length == 0) { 387 } else if (length == 0) {
388 TRACE("\n");
387 error(pc_, "varint of length 0"); 389 error(pc_, "varint of length 0");
388 } else if (is_signed) { 390 } else if (is_signed) {
389 if (length < kMaxLength) { 391 if (length < kMaxLength) {
390 int sign_ext_shift = 8 * sizeof(IntType) - shift; 392 int sign_ext_shift = 8 * sizeof(IntType) - shift;
391 // Perform sign extension. 393 // Perform sign extension.
392 result = (result << sign_ext_shift) >> sign_ext_shift; 394 result = (result << sign_ext_shift) >> sign_ext_shift;
393 } 395 }
394 TRACE("= %" PRIi64 "\n", static_cast<int64_t>(result)); 396 TRACE("= %" PRIi64 "\n", static_cast<int64_t>(result));
395 } else { 397 } else {
396 TRACE("= %" PRIu64 "\n", static_cast<uint64_t>(result)); 398 TRACE("= %" PRIu64 "\n", static_cast<uint64_t>(result));
397 } 399 }
398 return result; 400 return result;
399 } 401 }
400 return traceOffEnd<uint32_t>(); 402 return traceOffEnd<uint32_t>();
401 } 403 }
402 }; 404 };
403 405
404 #undef TRACE 406 #undef TRACE
405 } // namespace wasm 407 } // namespace wasm
406 } // namespace internal 408 } // namespace internal
407 } // namespace v8 409 } // namespace v8
408 410
409 #endif // V8_WASM_DECODER_H_ 411 #endif // V8_WASM_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | src/wasm/module-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698