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

Side by Side Diff: src/wasm/function-body-decoder.cc

Issue 2638383004: [wasm] Fix checking of unreachable code (clear stack after unreachable). (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 | test/mjsunit/wasm/unreachable-validation.js » ('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 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 } 1234 }
1235 } 1235 }
1236 PrintF("\n"); 1236 PrintF("\n");
1237 } 1237 }
1238 #endif 1238 #endif
1239 pc_ += len; 1239 pc_ += len;
1240 } // end decode loop 1240 } // end decode loop
1241 if (pc_ > end_ && ok()) error("Beyond end of code"); 1241 if (pc_ > end_ && ok()) error("Beyond end of code");
1242 } 1242 }
1243 1243
1244 void EndControl() { ssa_env_->Kill(SsaEnv::kControlEnd); } 1244 void EndControl() {
1245 ssa_env_->Kill(SsaEnv::kControlEnd);
1246 if (control_.empty()) {
rossberg 2017/01/19 12:55:11 I suppose you could avoid spurious case distinctio
1247 stack_.clear();
1248 } else {
1249 DCHECK_LE(control_.back().stack_depth, stack_.size());
1250 stack_.resize(control_.back().stack_depth);
1251 }
1252 }
1245 1253
1246 void SetBlockType(Control* c, BlockTypeOperand& operand) { 1254 void SetBlockType(Control* c, BlockTypeOperand& operand) {
1247 c->merge.arity = operand.arity; 1255 c->merge.arity = operand.arity;
1248 if (c->merge.arity == 1) { 1256 if (c->merge.arity == 1) {
1249 c->merge.vals.first = {pc_, nullptr, operand.read_entry(0)}; 1257 c->merge.vals.first = {pc_, nullptr, operand.read_entry(0)};
1250 } else if (c->merge.arity > 1) { 1258 } else if (c->merge.arity > 1) {
1251 c->merge.vals.array = zone_->NewArray<Value>(c->merge.arity); 1259 c->merge.vals.array = zone_->NewArray<Value>(c->merge.arity);
1252 for (unsigned i = 0; i < c->merge.arity; i++) { 1260 for (unsigned i = 0; i < c->merge.arity; i++) {
1253 c->merge.vals.array[i] = {pc_, nullptr, operand.read_entry(i)}; 1261 c->merge.vals.array[i] = {pc_, nullptr, operand.read_entry(i)};
1254 } 1262 }
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2012 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2005 const byte* start, const byte* end) { 2013 const byte* start, const byte* end) {
2006 Decoder decoder(start, end); 2014 Decoder decoder(start, end);
2007 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, 2015 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,
2008 static_cast<int>(num_locals), zone); 2016 static_cast<int>(num_locals), zone);
2009 } 2017 }
2010 2018
2011 } // namespace wasm 2019 } // namespace wasm
2012 } // namespace internal 2020 } // namespace internal
2013 } // namespace v8 2021 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/wasm/unreachable-validation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698