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 #ifndef V8_WASM_INTERPRETER_H_ | 5 #ifndef V8_WASM_INTERPRETER_H_ |
6 #define V8_WASM_INTERPRETER_H_ | 6 #define V8_WASM_INTERPRETER_H_ |
7 | 7 |
8 #include "src/wasm/wasm-opcodes.h" | 8 #include "src/wasm/wasm-opcodes.h" |
9 #include "src/zone/zone-containers.h" | 9 #include "src/zone/zone-containers.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 } | 69 } |
70 FOREACH_UNION_MEMBER(DECLARE_CAST) | 70 FOREACH_UNION_MEMBER(DECLARE_CAST) |
71 #undef DECLARE_CAST | 71 #undef DECLARE_CAST |
72 | 72 |
73 template <> | 73 template <> |
74 inline void WasmVal::to() { | 74 inline void WasmVal::to() { |
75 CHECK_EQ(kWasmStmt, type); | 75 CHECK_EQ(kWasmStmt, type); |
76 } | 76 } |
77 | 77 |
78 // Representation of frames within the interpreter. | 78 // Representation of frames within the interpreter. |
79 class WasmFrame { | 79 class InterpretedFrame { |
80 public: | 80 public: |
81 const WasmFunction* function() const { return function_; } | 81 const WasmFunction* function() const { return function_; } |
82 int pc() const { return pc_; } | 82 int pc() const { return pc_; } |
83 | 83 |
84 //========================================================================== | |
titzer
2017/01/16 10:18:25
These methods are not going to be possible to impl
Clemens Hammacher
2017/01/16 11:53:26
Yes, I was aware of that. I planned to include a p
| |
85 // Stack frame inspection. | |
86 //========================================================================== | |
87 int GetParameterCount() const; | |
88 WasmVal GetLocalVal(int index) const; | |
89 WasmVal GetExprVal(int pc) const; | |
90 void SetLocalVal(int index, WasmVal val); | |
91 void SetExprVal(int pc, WasmVal val); | |
92 | |
84 private: | 93 private: |
85 friend class WasmInterpreter; | 94 friend class ThreadImpl; |
86 | 95 |
87 WasmFrame(const WasmFunction* function, int pc, int fp, int sp) | 96 InterpretedFrame(const WasmFunction* function, int pc, int fp, int sp) |
88 : function_(function), pc_(pc), fp_(fp), sp_(sp) {} | 97 : function_(function), pc_(pc), fp_(fp), sp_(sp) {} |
89 | 98 |
90 const WasmFunction* function_; | 99 const WasmFunction* function_; |
91 int pc_; | 100 int pc_; |
92 int fp_; | 101 int fp_; |
93 int sp_; | 102 int sp_; |
94 }; | 103 }; |
95 | 104 |
96 // An interpreter capable of executing WASM. | 105 // An interpreter capable of executing WASM. |
97 class V8_EXPORT_PRIVATE WasmInterpreter { | 106 class V8_EXPORT_PRIVATE WasmInterpreter { |
(...skipping 17 matching lines...) Expand all Loading... | |
115 virtual void PushFrame(const WasmFunction* function, WasmVal* args) = 0; | 124 virtual void PushFrame(const WasmFunction* function, WasmVal* args) = 0; |
116 virtual State Run() = 0; | 125 virtual State Run() = 0; |
117 virtual State Step() = 0; | 126 virtual State Step() = 0; |
118 virtual void Pause() = 0; | 127 virtual void Pause() = 0; |
119 virtual void Reset() = 0; | 128 virtual void Reset() = 0; |
120 virtual ~Thread() {} | 129 virtual ~Thread() {} |
121 | 130 |
122 // Stack inspection and modification. | 131 // Stack inspection and modification. |
123 virtual pc_t GetBreakpointPc() = 0; | 132 virtual pc_t GetBreakpointPc() = 0; |
124 virtual int GetFrameCount() = 0; | 133 virtual int GetFrameCount() = 0; |
125 virtual const WasmFrame* GetFrame(int index) = 0; | 134 virtual const InterpretedFrame GetFrame(int index) = 0; |
126 virtual WasmFrame* GetMutableFrame(int index) = 0; | 135 virtual InterpretedFrame GetMutableFrame(int index) = 0; |
127 virtual WasmVal GetReturnValue(int index = 0) = 0; | 136 virtual WasmVal GetReturnValue(int index = 0) = 0; |
128 // Returns true if the thread executed an instruction which may produce | 137 // Returns true if the thread executed an instruction which may produce |
129 // nondeterministic results, e.g. float div, float sqrt, and float mul, | 138 // nondeterministic results, e.g. float div, float sqrt, and float mul, |
130 // where the sign bit of a NaN is nondeterministic. | 139 // where the sign bit of a NaN is nondeterministic. |
131 virtual bool PossibleNondeterminism() = 0; | 140 virtual bool PossibleNondeterminism() = 0; |
132 | 141 |
133 // Thread-specific breakpoints. | 142 // Thread-specific breakpoints. |
134 bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); | 143 bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); |
135 bool GetBreakpoint(const WasmFunction* function, int pc); | 144 bool GetBreakpoint(const WasmFunction* function, int pc); |
136 }; | 145 }; |
(...skipping 17 matching lines...) Expand all Loading... | |
154 // Enable or disable tracing for {function}. Return the previous state. | 163 // Enable or disable tracing for {function}. Return the previous state. |
155 bool SetTracing(const WasmFunction* function, bool enabled); | 164 bool SetTracing(const WasmFunction* function, bool enabled); |
156 | 165 |
157 //========================================================================== | 166 //========================================================================== |
158 // Thread iteration and inspection. | 167 // Thread iteration and inspection. |
159 //========================================================================== | 168 //========================================================================== |
160 int GetThreadCount(); | 169 int GetThreadCount(); |
161 Thread* GetThread(int id); | 170 Thread* GetThread(int id); |
162 | 171 |
163 //========================================================================== | 172 //========================================================================== |
164 // Stack frame inspection. | |
165 //========================================================================== | |
166 WasmVal GetLocalVal(const WasmFrame* frame, int index); | |
167 WasmVal GetExprVal(const WasmFrame* frame, int pc); | |
168 void SetLocalVal(WasmFrame* frame, int index, WasmVal val); | |
169 void SetExprVal(WasmFrame* frame, int pc, WasmVal val); | |
170 | |
171 //========================================================================== | |
172 // Memory access. | 173 // Memory access. |
173 //========================================================================== | 174 //========================================================================== |
174 size_t GetMemorySize(); | 175 size_t GetMemorySize(); |
175 WasmVal ReadMemory(size_t offset); | 176 WasmVal ReadMemory(size_t offset); |
176 void WriteMemory(size_t offset, WasmVal val); | 177 void WriteMemory(size_t offset, WasmVal val); |
177 | 178 |
178 //========================================================================== | 179 //========================================================================== |
179 // Testing functionality. | 180 // Testing functionality. |
180 //========================================================================== | 181 //========================================================================== |
181 // Manually adds a function to this interpreter, returning the index of the | 182 // Manually adds a function to this interpreter, returning the index of the |
(...skipping 12 matching lines...) Expand all Loading... | |
194 private: | 195 private: |
195 Zone zone_; | 196 Zone zone_; |
196 WasmInterpreterInternals* internals_; | 197 WasmInterpreterInternals* internals_; |
197 }; | 198 }; |
198 | 199 |
199 } // namespace wasm | 200 } // namespace wasm |
200 } // namespace internal | 201 } // namespace internal |
201 } // namespace v8 | 202 } // namespace v8 |
202 | 203 |
203 #endif // V8_WASM_INTERPRETER_H_ | 204 #endif // V8_WASM_INTERPRETER_H_ |
OLD | NEW |