Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 | 1027 |
| 1028 virtual void Reset() { | 1028 virtual void Reset() { |
| 1029 TRACE("----- RESET -----\n"); | 1029 TRACE("----- RESET -----\n"); |
| 1030 stack_.clear(); | 1030 stack_.clear(); |
| 1031 frames_.clear(); | 1031 frames_.clear(); |
| 1032 state_ = WasmInterpreter::STOPPED; | 1032 state_ = WasmInterpreter::STOPPED; |
| 1033 trap_reason_ = kTrapCount; | 1033 trap_reason_ = kTrapCount; |
| 1034 possible_nondeterminism_ = false; | 1034 possible_nondeterminism_ = false; |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 virtual int GetFrameCount() { return static_cast<int>(frames_.size()); } | 1037 virtual int GetFrameCount() { |
| 1038 | 1038 DCHECK_GE(kMaxInt, frames_.size()); |
| 1039 virtual const WasmFrame* GetFrame(int index) { | 1039 return static_cast<int>(frames_.size()); |
| 1040 UNIMPLEMENTED(); | |
| 1041 return nullptr; | |
| 1042 } | 1040 } |
| 1043 | 1041 |
| 1044 virtual WasmFrame* GetMutableFrame(int index) { | 1042 virtual const InterpretedFrame GetFrame(int index) { |
| 1045 UNIMPLEMENTED(); | 1043 return GetMutableFrame(index); |
| 1046 return nullptr; | 1044 } |
| 1045 | |
| 1046 virtual InterpretedFrame GetMutableFrame(int index) { | |
| 1047 DCHECK_LE(0, index); | |
| 1048 DCHECK_GT(frames_.size(), index); | |
| 1049 Frame* fr = &frames_[index]; | |
|
titzer
2017/01/16 10:18:25
Might as well spell out {frame} or call it {f}.
Clemens Hammacher
2017/01/16 11:53:26
Done. It's {frame} now.
| |
| 1050 DCHECK_GE(kMaxInt, fr->ret_pc); | |
| 1051 DCHECK_GE(kMaxInt, fr->sp); | |
| 1052 DCHECK_GE(kMaxInt, fr->llimit()); | |
| 1053 return InterpretedFrame(fr->code->function, static_cast<int>(fr->ret_pc), | |
| 1054 static_cast<int>(fr->sp), | |
| 1055 static_cast<int>(fr->llimit())); | |
| 1047 } | 1056 } |
| 1048 | 1057 |
| 1049 virtual WasmVal GetReturnValue(int index) { | 1058 virtual WasmVal GetReturnValue(int index) { |
| 1050 if (state_ == WasmInterpreter::TRAPPED) return WasmVal(0xdeadbeef); | 1059 if (state_ == WasmInterpreter::TRAPPED) return WasmVal(0xdeadbeef); |
| 1051 CHECK_EQ(WasmInterpreter::FINISHED, state_); | 1060 CHECK_EQ(WasmInterpreter::FINISHED, state_); |
| 1052 CHECK_LT(static_cast<size_t>(index), stack_.size()); | 1061 CHECK_LT(static_cast<size_t>(index), stack_.size()); |
| 1053 return stack_[index]; | 1062 return stack_[index]; |
| 1054 } | 1063 } |
| 1055 | 1064 |
| 1056 virtual pc_t GetBreakpointPc() { return break_pc_; } | 1065 virtual pc_t GetBreakpointPc() { return break_pc_; } |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1830 | 1839 |
| 1831 int WasmInterpreter::GetThreadCount() { | 1840 int WasmInterpreter::GetThreadCount() { |
| 1832 return 1; // only one thread for now. | 1841 return 1; // only one thread for now. |
| 1833 } | 1842 } |
| 1834 | 1843 |
| 1835 WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) { | 1844 WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) { |
| 1836 CHECK_EQ(0, id); // only one thread for now. | 1845 CHECK_EQ(0, id); // only one thread for now. |
| 1837 return internals_->threads_[id]; | 1846 return internals_->threads_[id]; |
| 1838 } | 1847 } |
| 1839 | 1848 |
| 1840 WasmVal WasmInterpreter::GetLocalVal(const WasmFrame* frame, int index) { | |
| 1841 CHECK_GE(index, 0); | |
| 1842 UNIMPLEMENTED(); | |
| 1843 WasmVal none; | |
| 1844 none.type = kWasmStmt; | |
| 1845 return none; | |
| 1846 } | |
| 1847 | |
| 1848 WasmVal WasmInterpreter::GetExprVal(const WasmFrame* frame, int pc) { | |
| 1849 UNIMPLEMENTED(); | |
| 1850 WasmVal none; | |
| 1851 none.type = kWasmStmt; | |
| 1852 return none; | |
| 1853 } | |
| 1854 | |
| 1855 void WasmInterpreter::SetLocalVal(WasmFrame* frame, int index, WasmVal val) { | |
| 1856 UNIMPLEMENTED(); | |
| 1857 } | |
| 1858 | |
| 1859 void WasmInterpreter::SetExprVal(WasmFrame* frame, int pc, WasmVal val) { | |
| 1860 UNIMPLEMENTED(); | |
| 1861 } | |
| 1862 | |
| 1863 size_t WasmInterpreter::GetMemorySize() { | 1849 size_t WasmInterpreter::GetMemorySize() { |
| 1864 return internals_->instance_->mem_size; | 1850 return internals_->instance_->mem_size; |
| 1865 } | 1851 } |
| 1866 | 1852 |
| 1867 WasmVal WasmInterpreter::ReadMemory(size_t offset) { | 1853 WasmVal WasmInterpreter::ReadMemory(size_t offset) { |
| 1868 UNIMPLEMENTED(); | 1854 UNIMPLEMENTED(); |
| 1869 return WasmVal(); | 1855 return WasmVal(); |
| 1870 } | 1856 } |
| 1871 | 1857 |
| 1872 void WasmInterpreter::WriteMemory(size_t offset, WasmVal val) { | 1858 void WasmInterpreter::WriteMemory(size_t offset, WasmVal val) { |
| 1873 UNIMPLEMENTED(); | 1859 UNIMPLEMENTED(); |
| 1874 } | 1860 } |
| 1875 | 1861 |
| 1876 int WasmInterpreter::AddFunctionForTesting(const WasmFunction* function) { | 1862 int WasmInterpreter::AddFunctionForTesting(const WasmFunction* function) { |
| 1877 return internals_->codemap_.AddFunction(function, nullptr, nullptr); | 1863 return internals_->codemap_.AddFunction(function, nullptr, nullptr); |
| 1878 } | 1864 } |
| 1879 | 1865 |
| 1880 bool WasmInterpreter::SetFunctionCodeForTesting(const WasmFunction* function, | 1866 bool WasmInterpreter::SetFunctionCodeForTesting(const WasmFunction* function, |
| 1881 const byte* start, | 1867 const byte* start, |
| 1882 const byte* end) { | 1868 const byte* end) { |
| 1883 return internals_->codemap_.SetFunctionCode(function, start, end); | 1869 return internals_->codemap_.SetFunctionCode(function, start, end); |
| 1884 } | 1870 } |
| 1885 | 1871 |
| 1886 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( | 1872 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( |
| 1887 Zone* zone, const byte* start, const byte* end) { | 1873 Zone* zone, const byte* start, const byte* end) { |
| 1888 ControlTransfers targets(zone, nullptr, start, end); | 1874 ControlTransfers targets(zone, nullptr, start, end); |
| 1889 return targets.map_; | 1875 return targets.map_; |
| 1890 } | 1876 } |
| 1891 | 1877 |
| 1878 //============================================================================ | |
| 1879 // Implementation of the frame inspection interface. | |
| 1880 //============================================================================ | |
| 1881 int InterpretedFrame::GetParameterCount() const { | |
| 1882 UNIMPLEMENTED(); | |
| 1883 return 0; | |
| 1884 } | |
| 1885 | |
| 1886 WasmVal InterpretedFrame::GetLocalVal(int index) const { | |
| 1887 CHECK_GE(index, 0); | |
| 1888 UNIMPLEMENTED(); | |
| 1889 WasmVal none; | |
| 1890 none.type = kWasmStmt; | |
| 1891 return none; | |
| 1892 } | |
| 1893 | |
| 1894 WasmVal InterpretedFrame::GetExprVal(int pc) const { | |
| 1895 UNIMPLEMENTED(); | |
| 1896 WasmVal none; | |
| 1897 none.type = kWasmStmt; | |
| 1898 return none; | |
| 1899 } | |
| 1900 | |
| 1901 void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); } | |
| 1902 | |
| 1903 void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); } | |
| 1904 | |
| 1892 } // namespace wasm | 1905 } // namespace wasm |
| 1893 } // namespace internal | 1906 } // namespace internal |
| 1894 } // namespace v8 | 1907 } // namespace v8 |
| OLD | NEW |