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

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

Issue 2629823003: [wasm] Implement frame inspection for interpreted frames (Closed)
Patch Set: Rebase after Yangs revert ಠ益ಠ 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 | « src/wasm/wasm-interpreter.h ('k') | src/wasm/wasm-module.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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 978
979 void Reset() { 979 void Reset() {
980 TRACE("----- RESET -----\n"); 980 TRACE("----- RESET -----\n");
981 stack_.clear(); 981 stack_.clear();
982 frames_.clear(); 982 frames_.clear();
983 state_ = WasmInterpreter::STOPPED; 983 state_ = WasmInterpreter::STOPPED;
984 trap_reason_ = kTrapCount; 984 trap_reason_ = kTrapCount;
985 possible_nondeterminism_ = false; 985 possible_nondeterminism_ = false;
986 } 986 }
987 987
988 int GetFrameCount() { return static_cast<int>(frames_.size()); } 988 int GetFrameCount() {
989 989 DCHECK_GE(kMaxInt, frames_.size());
990 const WasmFrame* GetFrame(int index) { 990 return static_cast<int>(frames_.size());
991 UNIMPLEMENTED();
992 return nullptr;
993 } 991 }
994 992
995 WasmFrame* GetMutableFrame(int index) { 993 template <typename FrameCons>
996 UNIMPLEMENTED(); 994 InterpretedFrame GetMutableFrame(int index, FrameCons frame_cons) {
997 return nullptr; 995 DCHECK_LE(0, index);
996 DCHECK_GT(frames_.size(), index);
997 Frame* frame = &frames_[index];
998 DCHECK_GE(kMaxInt, frame->ret_pc);
999 DCHECK_GE(kMaxInt, frame->sp);
1000 DCHECK_GE(kMaxInt, frame->llimit());
1001 return frame_cons(frame->code->function, static_cast<int>(frame->ret_pc),
1002 static_cast<int>(frame->sp),
1003 static_cast<int>(frame->llimit()));
998 } 1004 }
999 1005
1000 WasmVal GetReturnValue(int index) { 1006 WasmVal GetReturnValue(int index) {
1001 if (state_ == WasmInterpreter::TRAPPED) return WasmVal(0xdeadbeef); 1007 if (state_ == WasmInterpreter::TRAPPED) return WasmVal(0xdeadbeef);
1002 CHECK_EQ(WasmInterpreter::FINISHED, state_); 1008 CHECK_EQ(WasmInterpreter::FINISHED, state_);
1003 CHECK_LT(static_cast<size_t>(index), stack_.size()); 1009 CHECK_LT(static_cast<size_t>(index), stack_.size());
1004 return stack_[index]; 1010 return stack_[index];
1005 } 1011 }
1006 1012
1007 pc_t GetBreakpointPc() { return break_pc_; } 1013 pc_t GetBreakpointPc() { return break_pc_; }
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1740 return ToImpl(this)->Step(); 1746 return ToImpl(this)->Step();
1741 } 1747 }
1742 void WasmInterpreter::Thread::Pause() { return ToImpl(this)->Pause(); } 1748 void WasmInterpreter::Thread::Pause() { return ToImpl(this)->Pause(); }
1743 void WasmInterpreter::Thread::Reset() { return ToImpl(this)->Reset(); } 1749 void WasmInterpreter::Thread::Reset() { return ToImpl(this)->Reset(); }
1744 pc_t WasmInterpreter::Thread::GetBreakpointPc() { 1750 pc_t WasmInterpreter::Thread::GetBreakpointPc() {
1745 return ToImpl(this)->GetBreakpointPc(); 1751 return ToImpl(this)->GetBreakpointPc();
1746 } 1752 }
1747 int WasmInterpreter::Thread::GetFrameCount() { 1753 int WasmInterpreter::Thread::GetFrameCount() {
1748 return ToImpl(this)->GetFrameCount(); 1754 return ToImpl(this)->GetFrameCount();
1749 } 1755 }
1750 const WasmFrame* WasmInterpreter::Thread::GetFrame(int index) { 1756 const InterpretedFrame WasmInterpreter::Thread::GetFrame(int index) {
1751 return ToImpl(this)->GetFrame(index); 1757 return GetMutableFrame(index);
1752 } 1758 }
1753 WasmFrame* WasmInterpreter::Thread::GetMutableFrame(int index) { 1759 InterpretedFrame WasmInterpreter::Thread::GetMutableFrame(int index) {
1754 return ToImpl(this)->GetMutableFrame(index); 1760 // We have access to the constructor of InterpretedFrame, but ThreadImpl has
1761 // not. So pass it as a lambda (should all get inlined).
1762 auto frame_cons = [](const WasmFunction* function, int pc, int fp, int sp) {
1763 return InterpretedFrame(function, pc, fp, sp);
1764 };
1765 return ToImpl(this)->GetMutableFrame(index, frame_cons);
1755 } 1766 }
1756 WasmVal WasmInterpreter::Thread::GetReturnValue(int index) { 1767 WasmVal WasmInterpreter::Thread::GetReturnValue(int index) {
1757 return ToImpl(this)->GetReturnValue(index); 1768 return ToImpl(this)->GetReturnValue(index);
1758 } 1769 }
1759 bool WasmInterpreter::Thread::PossibleNondeterminism() { 1770 bool WasmInterpreter::Thread::PossibleNondeterminism() {
1760 return ToImpl(this)->PossibleNondeterminism(); 1771 return ToImpl(this)->PossibleNondeterminism();
1761 } 1772 }
1762 1773
1763 //============================================================================ 1774 //============================================================================
1764 // The implementation details of the interpreter. 1775 // The implementation details of the interpreter.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 1848
1838 int WasmInterpreter::GetThreadCount() { 1849 int WasmInterpreter::GetThreadCount() {
1839 return 1; // only one thread for now. 1850 return 1; // only one thread for now.
1840 } 1851 }
1841 1852
1842 WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) { 1853 WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) {
1843 CHECK_EQ(0, id); // only one thread for now. 1854 CHECK_EQ(0, id); // only one thread for now.
1844 return ToThread(&internals_->threads_[id]); 1855 return ToThread(&internals_->threads_[id]);
1845 } 1856 }
1846 1857
1847 WasmVal WasmInterpreter::GetLocalVal(const WasmFrame* frame, int index) {
1848 CHECK_GE(index, 0);
1849 UNIMPLEMENTED();
1850 WasmVal none;
1851 none.type = kWasmStmt;
1852 return none;
1853 }
1854
1855 WasmVal WasmInterpreter::GetExprVal(const WasmFrame* frame, int pc) {
1856 UNIMPLEMENTED();
1857 WasmVal none;
1858 none.type = kWasmStmt;
1859 return none;
1860 }
1861
1862 void WasmInterpreter::SetLocalVal(WasmFrame* frame, int index, WasmVal val) {
1863 UNIMPLEMENTED();
1864 }
1865
1866 void WasmInterpreter::SetExprVal(WasmFrame* frame, int pc, WasmVal val) {
1867 UNIMPLEMENTED();
1868 }
1869
1870 size_t WasmInterpreter::GetMemorySize() { 1858 size_t WasmInterpreter::GetMemorySize() {
1871 return internals_->instance_->mem_size; 1859 return internals_->instance_->mem_size;
1872 } 1860 }
1873 1861
1874 WasmVal WasmInterpreter::ReadMemory(size_t offset) { 1862 WasmVal WasmInterpreter::ReadMemory(size_t offset) {
1875 UNIMPLEMENTED(); 1863 UNIMPLEMENTED();
1876 return WasmVal(); 1864 return WasmVal();
1877 } 1865 }
1878 1866
1879 void WasmInterpreter::WriteMemory(size_t offset, WasmVal val) { 1867 void WasmInterpreter::WriteMemory(size_t offset, WasmVal val) {
1880 UNIMPLEMENTED(); 1868 UNIMPLEMENTED();
1881 } 1869 }
1882 1870
1883 int WasmInterpreter::AddFunctionForTesting(const WasmFunction* function) { 1871 int WasmInterpreter::AddFunctionForTesting(const WasmFunction* function) {
1884 return internals_->codemap_.AddFunction(function, nullptr, nullptr); 1872 return internals_->codemap_.AddFunction(function, nullptr, nullptr);
1885 } 1873 }
1886 1874
1887 bool WasmInterpreter::SetFunctionCodeForTesting(const WasmFunction* function, 1875 bool WasmInterpreter::SetFunctionCodeForTesting(const WasmFunction* function,
1888 const byte* start, 1876 const byte* start,
1889 const byte* end) { 1877 const byte* end) {
1890 return internals_->codemap_.SetFunctionCode(function, start, end); 1878 return internals_->codemap_.SetFunctionCode(function, start, end);
1891 } 1879 }
1892 1880
1893 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1881 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1894 Zone* zone, const byte* start, const byte* end) { 1882 Zone* zone, const byte* start, const byte* end) {
1895 ControlTransfers targets(zone, nullptr, start, end); 1883 ControlTransfers targets(zone, nullptr, start, end);
1896 return targets.map_; 1884 return targets.map_;
1897 } 1885 }
1898 1886
1887 //============================================================================
1888 // Implementation of the frame inspection interface.
1889 //============================================================================
1890 int InterpretedFrame::GetParameterCount() const {
1891 USE(fp_);
1892 USE(sp_);
1893 // TODO(clemensh): Return the correct number of parameters.
1894 return 0;
1895 }
1896
1897 WasmVal InterpretedFrame::GetLocalVal(int index) const {
1898 CHECK_GE(index, 0);
1899 UNIMPLEMENTED();
1900 WasmVal none;
1901 none.type = kWasmStmt;
1902 return none;
1903 }
1904
1905 WasmVal InterpretedFrame::GetExprVal(int pc) const {
1906 UNIMPLEMENTED();
1907 WasmVal none;
1908 none.type = kWasmStmt;
1909 return none;
1910 }
1911
1912 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); }
1913
1914 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); }
1915
1899 } // namespace wasm 1916 } // namespace wasm
1900 } // namespace internal 1917 } // namespace internal
1901 } // namespace v8 1918 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-interpreter.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698