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

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

Issue 2799753003: [wasm] Fix typing of loop labels in br_table (Closed)
Patch Set: Created 3 years, 8 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/cctest/wasm/test-run-wasm.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 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/base/platform/elapsed-timer.h" 7 #include "src/base/platform/elapsed-timer.h"
8 #include "src/bit-vector.h" 8 #include "src/bit-vector.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 error(pos, "improper branch in br_table"); 981 error(pos, "improper branch in br_table");
982 break; 982 break;
983 } 983 }
984 ssa_env_ = Split(copy); 984 ssa_env_ = Split(copy);
985 ssa_env_->control = (i == operand.table_count) 985 ssa_env_->control = (i == operand.table_count)
986 ? BUILD(IfDefault, sw) 986 ? BUILD(IfDefault, sw)
987 : BUILD(IfValue, i, sw); 987 : BUILD(IfValue, i, sw);
988 BreakTo(target); 988 BreakTo(target);
989 989
990 // Check that label types match up. 990 // Check that label types match up.
991 static MergeValues loop_dummy = {0, {nullptr}};
991 Control* c = &control_[control_.size() - target - 1]; 992 Control* c = &control_[control_.size() - target - 1];
993 MergeValues* current = c->is_loop() ? &loop_dummy : &c->merge;
992 if (i == 0) { 994 if (i == 0) {
993 merge = &c->merge; 995 merge = current;
994 } else if (merge->arity != c->merge.arity) { 996 } else if (merge->arity != current->arity) {
995 errorf(pos, 997 errorf(pos,
996 "inconsistent arity in br_table target %d" 998 "inconsistent arity in br_table target %d"
997 " (previous was %u, this one %u)", 999 " (previous was %u, this one %u)",
998 i, merge->arity, c->merge.arity); 1000 i, merge->arity, current->arity);
999 } else if (control_.back().unreachable) { 1001 } else if (control_.back().unreachable) {
1000 for (uint32_t j = 0; ok() && j < merge->arity; ++j) { 1002 for (uint32_t j = 0; ok() && j < merge->arity; ++j) {
1001 if ((*merge)[j].type != c->merge[j].type) { 1003 if ((*merge)[j].type != (*current)[j].type) {
1002 errorf(pos, 1004 errorf(pos,
1003 "type error in br_table target %d operand %d" 1005 "type error in br_table target %d operand %d"
1004 " (previous expected %s, this one %s)", 1006 " (previous expected %s, this one %s)",
1005 i, j, WasmOpcodes::TypeName((*merge)[j].type), 1007 i, j, WasmOpcodes::TypeName((*merge)[j].type),
1006 WasmOpcodes::TypeName(c->merge[j].type)); 1008 WasmOpcodes::TypeName((*current)[j].type));
1007 } 1009 }
1008 } 1010 }
1009 } 1011 }
1010 } 1012 }
1011 if (failed()) break; 1013 if (failed()) break;
1012 } else { 1014 } else {
1013 // Only a default target. Do the equivalent of br. 1015 // Only a default target. Do the equivalent of br.
1014 const byte* pos = iterator.pc(); 1016 const byte* pos = iterator.pc();
1015 uint32_t target = iterator.next(); 1017 uint32_t target = iterator.next();
1016 if (target >= control_.size()) { 1018 if (target >= control_.size()) {
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2174 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2173 const byte* start, const byte* end) { 2175 const byte* start, const byte* end) {
2174 Decoder decoder(start, end); 2176 Decoder decoder(start, end);
2175 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, 2177 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,
2176 static_cast<int>(num_locals), zone); 2178 static_cast<int>(num_locals), zone);
2177 } 2179 }
2178 2180
2179 } // namespace wasm 2181 } // namespace wasm
2180 } // namespace internal 2182 } // namespace internal
2181 } // namespace v8 2183 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698