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

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2650293003: [wasm] Interpreter: Don't pause on invalid position (Closed)
Patch Set: Rebase Created 3 years, 10 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-interpreter.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/wasm/wasm-interpreter.h" 5 #include "src/wasm/wasm-interpreter.h"
6 6
7 #include "src/utils.h" 7 #include "src/utils.h"
8 #include "src/wasm/decoder.h" 8 #include "src/wasm/decoder.h"
9 #include "src/wasm/function-body-decoder.h" 9 #include "src/wasm/function-body-decoder.h"
10 #include "src/wasm/wasm-external-refs.h" 10 #include "src/wasm/wasm-external-refs.h"
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 stack_.resize(stack_.size() - pop_count); 1176 stack_.resize(stack_.size() - pop_count);
1177 } 1177 }
1178 1178
1179 void Execute(InterpreterCode* code, pc_t pc, int max) { 1179 void Execute(InterpreterCode* code, pc_t pc, int max) {
1180 Decoder decoder(code->start, code->end); 1180 Decoder decoder(code->start, code->end);
1181 pc_t limit = code->end - code->start; 1181 pc_t limit = code->end - code->start;
1182 while (--max >= 0) { 1182 while (--max >= 0) {
1183 #define PAUSE_IF_BREAK_FLAG(flag) \ 1183 #define PAUSE_IF_BREAK_FLAG(flag) \
1184 if (V8_UNLIKELY(break_flags_ & WasmInterpreter::BreakFlag::flag)) max = 0; 1184 if (V8_UNLIKELY(break_flags_ & WasmInterpreter::BreakFlag::flag)) max = 0;
1185 1185
1186 if (pc >= limit) { 1186 DCHECK_GT(limit, pc);
1187 // Fell off end of code; do an implicit return.
1188 TRACE("@%-3zu: ImplicitReturn\n", pc);
1189 if (!DoReturn(&code, &pc, &limit, code->function->sig->return_count()))
1190 return;
1191 decoder.Reset(code->start, code->end);
1192 PAUSE_IF_BREAK_FLAG(AfterReturn);
1193 continue;
1194 }
1195 1187
1196 const char* skip = " "; 1188 const char* skip = " ";
1197 int len = 1; 1189 int len = 1;
1198 byte opcode = code->start[pc]; 1190 byte opcode = code->start[pc];
1199 byte orig = opcode; 1191 byte orig = opcode;
1200 if (V8_UNLIKELY(opcode == kInternalBreakpoint)) { 1192 if (V8_UNLIKELY(opcode == kInternalBreakpoint)) {
1201 orig = code->orig_start[pc]; 1193 orig = code->orig_start[pc];
1202 if (SkipBreakpoint(code, pc)) { 1194 if (SkipBreakpoint(code, pc)) {
1203 // skip breakpoint by switching on original code. 1195 // skip breakpoint by switching on original code.
1204 skip = "[skip] "; 1196 skip = "[skip] ";
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 FOREACH_OTHER_UNOP_NAN(EXECUTE_OTHER_UNOP_NAN) 1620 FOREACH_OTHER_UNOP_NAN(EXECUTE_OTHER_UNOP_NAN)
1629 #undef EXECUTE_OTHER_UNOP_NAN 1621 #undef EXECUTE_OTHER_UNOP_NAN
1630 1622
1631 default: 1623 default:
1632 V8_Fatal(__FILE__, __LINE__, "Unknown or unimplemented opcode #%d:%s", 1624 V8_Fatal(__FILE__, __LINE__, "Unknown or unimplemented opcode #%d:%s",
1633 code->start[pc], OpcodeName(code->start[pc])); 1625 code->start[pc], OpcodeName(code->start[pc]));
1634 UNREACHABLE(); 1626 UNREACHABLE();
1635 } 1627 }
1636 1628
1637 pc += len; 1629 pc += len;
1630 if (pc == limit) {
1631 // Fell off end of code; do an implicit return.
1632 TRACE("@%-3zu: ImplicitReturn\n", pc);
1633 if (!DoReturn(&code, &pc, &limit, code->function->sig->return_count()))
1634 return;
1635 decoder.Reset(code->start, code->end);
1636 PAUSE_IF_BREAK_FLAG(AfterReturn);
1637 }
1638 } 1638 }
1639 // Set break_pc_, even though we might have stopped because max was reached. 1639 // Set break_pc_, even though we might have stopped because max was reached.
1640 // We don't want to stop after executing zero instructions next time. 1640 // We don't want to stop after executing zero instructions next time.
1641 break_pc_ = pc; 1641 break_pc_ = pc;
1642 state_ = WasmInterpreter::PAUSED; 1642 state_ = WasmInterpreter::PAUSED;
1643 CommitPc(pc); 1643 CommitPc(pc);
1644 } 1644 }
1645 1645
1646 WasmVal Pop() { 1646 WasmVal Pop() {
1647 DCHECK_GT(stack_.size(), 0); 1647 DCHECK_GT(stack_.size(), 0);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 return none; 1922 return none;
1923 } 1923 }
1924 1924
1925 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); } 1925 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); }
1926 1926
1927 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); } 1927 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); }
1928 1928
1929 } // namespace wasm 1929 } // namespace wasm
1930 } // namespace internal 1930 } // namespace internal
1931 } // namespace v8 1931 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/wasm/test-run-wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698