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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // +---------------Run()-----------+ | 113 // +---------------Run()-----------+ |
114 // V | | 114 // V | |
115 // STOPPED ---Run()--> RUNNING ------Pause()-----+-> PAUSED <------+ | 115 // STOPPED ---Run()--> RUNNING ------Pause()-----+-> PAUSED <------+ |
116 // | | | / | | | 116 // | | | / | | |
117 // | | +---- Breakpoint ---+ +-- Step() --+ | 117 // | | +---- Breakpoint ---+ +-- Step() --+ |
118 // | | | 118 // | | |
119 // | +------------ Trap --------------> TRAPPED | 119 // | +------------ Trap --------------> TRAPPED |
120 // +------------- Finish -------------> FINISHED | 120 // +------------- Finish -------------> FINISHED |
121 enum State { STOPPED, RUNNING, PAUSED, FINISHED, TRAPPED }; | 121 enum State { STOPPED, RUNNING, PAUSED, FINISHED, TRAPPED }; |
122 | 122 |
| 123 // Tells a thread to pause after certain instructions. |
| 124 enum BreakFlag : uint8_t { |
| 125 None = 0, |
| 126 AfterReturn = 1 << 0, |
| 127 AfterCall = 1 << 1 |
| 128 }; |
| 129 |
123 // Representation of a thread in the interpreter. | 130 // Representation of a thread in the interpreter. |
124 class V8_EXPORT_PRIVATE Thread { | 131 class V8_EXPORT_PRIVATE Thread { |
125 // Don't instante Threads; they will be allocated as ThreadImpl in the | 132 // Don't instante Threads; they will be allocated as ThreadImpl in the |
126 // interpreter implementation. | 133 // interpreter implementation. |
127 Thread() = delete; | 134 Thread() = delete; |
128 | 135 |
129 public: | 136 public: |
130 // Execution control. | 137 // Execution control. |
131 State state(); | 138 State state(); |
132 void PushFrame(const WasmFunction* function, WasmVal* args); | 139 void PushFrame(const WasmFunction* function, WasmVal* args); |
(...skipping 10 matching lines...) Expand all Loading... |
143 WasmVal GetReturnValue(int index = 0); | 150 WasmVal GetReturnValue(int index = 0); |
144 // Returns true if the thread executed an instruction which may produce | 151 // Returns true if the thread executed an instruction which may produce |
145 // nondeterministic results, e.g. float div, float sqrt, and float mul, | 152 // nondeterministic results, e.g. float div, float sqrt, and float mul, |
146 // where the sign bit of a NaN is nondeterministic. | 153 // where the sign bit of a NaN is nondeterministic. |
147 bool PossibleNondeterminism(); | 154 bool PossibleNondeterminism(); |
148 | 155 |
149 // Thread-specific breakpoints. | 156 // Thread-specific breakpoints. |
150 // TODO(wasm): Implement this once we support multiple threads. | 157 // TODO(wasm): Implement this once we support multiple threads. |
151 // bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); | 158 // bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); |
152 // bool GetBreakpoint(const WasmFunction* function, int pc); | 159 // bool GetBreakpoint(const WasmFunction* function, int pc); |
| 160 |
| 161 void AddBreakFlags(uint8_t flags); |
| 162 void ClearBreakFlags(); |
153 }; | 163 }; |
154 | 164 |
155 WasmInterpreter(const ModuleBytesEnv& env, AccountingAllocator* allocator); | 165 WasmInterpreter(const ModuleBytesEnv& env, AccountingAllocator* allocator); |
156 ~WasmInterpreter(); | 166 ~WasmInterpreter(); |
157 | 167 |
158 //========================================================================== | 168 //========================================================================== |
159 // Execution controls. | 169 // Execution controls. |
160 //========================================================================== | 170 //========================================================================== |
161 void Run(); | 171 void Run(); |
162 void Pause(); | 172 void Pause(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 private: | 213 private: |
204 Zone zone_; | 214 Zone zone_; |
205 WasmInterpreterInternals* internals_; | 215 WasmInterpreterInternals* internals_; |
206 }; | 216 }; |
207 | 217 |
208 } // namespace wasm | 218 } // namespace wasm |
209 } // namespace internal | 219 } // namespace internal |
210 } // namespace v8 | 220 } // namespace v8 |
211 | 221 |
212 #endif // V8_WASM_INTERPRETER_H_ | 222 #endif // V8_WASM_INTERPRETER_H_ |
OLD | NEW |