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

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

Issue 1743773002: WebAssembly: skip unknown sections, add names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git cl format Created 4 years, 9 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') | src/wasm/module-decoder.cc » ('J')
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 "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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 if (pc_ == end && (b & 0x80)) { 215 if (pc_ == end && (b & 0x80)) {
216 error(pc_ - 1, "varint too large"); 216 error(pc_ - 1, "varint too large");
217 } else { 217 } else {
218 TRACE("= %u\n", result); 218 TRACE("= %u\n", result);
219 } 219 }
220 return result; 220 return result;
221 } 221 }
222 return traceOffEnd<uint32_t>(); 222 return traceOffEnd<uint32_t>();
223 } 223 }
224 224
225 // Consume {size} bytes and send them to the bit bucket, advancing {pc_}.
226 void consume_bytes(size_t size) {
227 if (checkAvailable(size)) {
228 pc_ += size;
229 } else {
230 pc_ = limit_;
231 }
232 }
233
225 // Check that at least {size} bytes exist between {pc_} and {limit_}. 234 // Check that at least {size} bytes exist between {pc_} and {limit_}.
226 bool checkAvailable(int size) { 235 bool checkAvailable(size_t size) {
227 if (pc_ < start_ || (pc_ + size) > limit_) { 236 if (pc_ < start_ || (limit_ - start_) < size || limit_ < (pc_ + size)) {
228 error(pc_, nullptr, "expected %d bytes, fell off end", size); 237 error(pc_, nullptr, "expected %z bytes, fell off end", size);
229 return false; 238 return false;
230 } else { 239 } else {
231 return true; 240 return true;
232 } 241 }
233 } 242 }
234 243
235 bool RangeOk(const byte* pc, int length) { 244 bool RangeOk(const byte* pc, int length) {
236 if (pc < start_ || pc_ >= limit_) return false; 245 if (pc < start_ || pc_ >= limit_) return false;
237 if ((pc + length) >= limit_) return false; 246 if ((pc + length) >= limit_) return false;
238 return true; 247 return true;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 const byte* error_pt_; 328 const byte* error_pt_;
320 base::SmartArrayPointer<char> error_msg_; 329 base::SmartArrayPointer<char> error_msg_;
321 }; 330 };
322 331
323 #undef TRACE 332 #undef TRACE
324 } // namespace wasm 333 } // namespace wasm
325 } // namespace internal 334 } // namespace internal
326 } // namespace v8 335 } // namespace v8
327 336
328 #endif // V8_WASM_DECODER_H_ 337 #endif // V8_WASM_DECODER_H_
OLDNEW
« no previous file with comments | « no previous file | src/wasm/module-decoder.cc » ('j') | src/wasm/module-decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698