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

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

Issue 2345593003: [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix test failures and TSAN races. Created 4 years, 2 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 | « src/wasm/ast-decoder.cc ('k') | src/wasm/encoder.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_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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } else { 201 } else {
202 TRACE("= %u\n", result); 202 TRACE("= %u\n", result);
203 } 203 }
204 return result; 204 return result;
205 } 205 }
206 return traceOffEnd<uint32_t>(); 206 return traceOffEnd<uint32_t>();
207 } 207 }
208 208
209 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}. 209 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}.
210 void consume_bytes(int size) { 210 void consume_bytes(int size) {
211 TRACE(" +%d %-20s: %d bytes\n", static_cast<int>(pc_ - start_), "skip",
212 size);
211 if (checkAvailable(size)) { 213 if (checkAvailable(size)) {
212 pc_ += size; 214 pc_ += size;
213 } else { 215 } else {
216 pc_ = limit_;
217 }
218 }
219
220 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}.
221 void consume_bytes(uint32_t size, const char* name = "skip") {
222 TRACE(" +%d %-20s: %d bytes\n", static_cast<int>(pc_ - start_), name,
223 size);
224 if (checkAvailable(size)) {
225 pc_ += size;
226 } else {
214 pc_ = limit_; 227 pc_ = limit_;
215 } 228 }
216 } 229 }
217 230
218 // Check that at least {size} bytes exist between {pc_} and {limit_}. 231 // Check that at least {size} bytes exist between {pc_} and {limit_}.
219 bool checkAvailable(int size) { 232 bool checkAvailable(int size) {
220 intptr_t pc_overflow_value = std::numeric_limits<intptr_t>::max() - size; 233 intptr_t pc_overflow_value = std::numeric_limits<intptr_t>::max() - size;
221 if (size < 0 || (intptr_t)pc_ > pc_overflow_value) { 234 if (size < 0 || (intptr_t)pc_ > pc_overflow_value) {
222 error(pc_, nullptr, "reading %d bytes would underflow/overflow", size); 235 error(pc_, nullptr, "reading %d bytes would underflow/overflow", size);
223 return false; 236 return false;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return result; 384 return result;
372 } 385 }
373 }; 386 };
374 387
375 #undef TRACE 388 #undef TRACE
376 } // namespace wasm 389 } // namespace wasm
377 } // namespace internal 390 } // namespace internal
378 } // namespace v8 391 } // namespace v8
379 392
380 #endif // V8_WASM_DECODER_H_ 393 #endif // V8_WASM_DECODER_H_
OLDNEW
« no previous file with comments | « src/wasm/ast-decoder.cc ('k') | src/wasm/encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698