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

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

Issue 2096863003: [wasm] prototype for breakpoint support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@extend-script-functionality
Patch Set: Created 4 years, 6 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-external-refs.h ('k') | src/wasm/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 #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-containers.h" 9 #include "src/zone-containers.h"
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 FOREACH_UNION_MEMBER(DECLARE_CAST) 78 FOREACH_UNION_MEMBER(DECLARE_CAST)
79 #undef DECLARE_CAST 79 #undef DECLARE_CAST
80 80
81 template <> 81 template <>
82 inline void WasmVal::to() { 82 inline void WasmVal::to() {
83 CHECK_EQ(kAstStmt, type); 83 CHECK_EQ(kAstStmt, type);
84 } 84 }
85 85
86 // Representation of frames within the interpreter. 86 // Representation of frames within the interpreter.
87 class WasmFrame { 87 class WasmInterpreterFrame {
88 public: 88 public:
89 const WasmFunction* function() const { return function_; } 89 const WasmFunction* function() const { return function_; }
90 int pc() const { return pc_; } 90 int pc() const { return pc_; }
91 91
92 private: 92 private:
93 friend class WasmInterpreter; 93 friend class WasmInterpreter;
94 friend class ThreadImpl;
94 95
95 WasmFrame(const WasmFunction* function, int pc, int fp, int sp) 96 WasmInterpreterFrame(const WasmFunction* function, int pc, int fp, int sp)
96 : function_(function), pc_(pc), fp_(fp), sp_(sp) {} 97 : function_(function), pc_(pc), fp_(fp), sp_(sp) {}
97 98
98 const WasmFunction* function_; 99 const WasmFunction* function_;
99 int pc_; 100 int pc_;
100 int fp_; 101 int fp_;
101 int sp_; 102 int sp_;
102 }; 103 };
103 104
104 // An interpreter capable of executing WASM. 105 // An interpreter capable of executing WASM.
105 class WasmInterpreter { 106 class WasmInterpreter {
(...skipping 17 matching lines...) Expand all
123 virtual void PushFrame(const WasmFunction* function, WasmVal* args) = 0; 124 virtual void PushFrame(const WasmFunction* function, WasmVal* args) = 0;
124 virtual State Run() = 0; 125 virtual State Run() = 0;
125 virtual State Step() = 0; 126 virtual State Step() = 0;
126 virtual void Pause() = 0; 127 virtual void Pause() = 0;
127 virtual void Reset() = 0; 128 virtual void Reset() = 0;
128 virtual ~Thread() {} 129 virtual ~Thread() {}
129 130
130 // Stack inspection and modification. 131 // Stack inspection and modification.
131 virtual pc_t GetBreakpointPc() = 0; 132 virtual pc_t GetBreakpointPc() = 0;
132 virtual int GetFrameCount() = 0; 133 virtual int GetFrameCount() = 0;
133 virtual const WasmFrame* GetFrame(int index) = 0; 134 virtual const WasmInterpreterFrame* GetFrame(int index) = 0;
134 virtual WasmFrame* GetMutableFrame(int index) = 0; 135 virtual WasmInterpreterFrame* GetMutableFrame(int index) = 0;
135 virtual WasmVal GetReturnValue() = 0; 136 virtual WasmVal GetReturnValue() = 0;
136 137
137 // Thread-specific breakpoints. 138 // Thread-specific breakpoints.
138 bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); 139 bool SetBreakpoint(uint32_t function_index, int pc, bool enabled);
139 bool GetBreakpoint(const WasmFunction* function, int pc); 140 bool GetBreakpoint(uint32_t function_index, int pc);
140 }; 141 };
141 142
142 WasmInterpreter(WasmModuleInstance* instance, 143 WasmInterpreter(WasmModuleInstance* instance, Zone* zone);
143 base::AccountingAllocator* allocator);
144 ~WasmInterpreter(); 144 ~WasmInterpreter();
145 145
146 //========================================================================== 146 //==========================================================================
147 // Execution controls. 147 // Execution controls.
148 //========================================================================== 148 //==========================================================================
149 void Run(); 149 void Run();
150 void Pause(); 150 void Pause();
151 151
152 // Set a breakpoint at {pc} in {function} to be {enabled}. Returns the 152 // Set a breakpoint at {pc} in {function_index} to be {enabled}. Returns the
153 // previous state of the breakpoint at {pc}. 153 // previous state of the breakpoint at {pc}.
154 bool SetBreakpoint(const WasmFunction* function, pc_t pc, bool enabled); 154 bool SetBreakpoint(uint32_t function_index, pc_t pc, bool enabled);
155 155
156 // Gets the current state of the breakpoint at {function}. 156 // Gets the current state of the breakpoint at {function_index}.
157 bool GetBreakpoint(const WasmFunction* function, pc_t pc); 157 bool GetBreakpoint(uint32_t function_index, pc_t pc);
158 158
159 // Enable or disable tracing for {function}. Return the previous state. 159 // Enable or disable tracing for {function}. Return the previous state.
160 bool SetTracing(const WasmFunction* function, bool enabled); 160 bool SetTracing(const WasmFunction* function, bool enabled);
161 161
162 //========================================================================== 162 //==========================================================================
163 // Thread iteration and inspection. 163 // Thread iteration and inspection.
164 //========================================================================== 164 //==========================================================================
165 int GetThreadCount(); 165 int GetThreadCount();
166 Thread* GetThread(int id); 166 Thread* GetThread(int id);
167 167
168 //========================================================================== 168 //==========================================================================
169 // Stack frame inspection. 169 // Stack frame inspection.
170 //========================================================================== 170 //==========================================================================
171 WasmVal GetLocalVal(const WasmFrame* frame, int index); 171 WasmVal GetLocalVal(const WasmInterpreterFrame* frame, int index);
172 WasmVal GetExprVal(const WasmFrame* frame, int pc); 172 WasmVal GetExprVal(const WasmInterpreterFrame* frame, int pc);
173 void SetLocalVal(WasmFrame* frame, int index, WasmVal val); 173 void SetLocalVal(WasmInterpreterFrame* frame, int index, WasmVal val);
174 void SetExprVal(WasmFrame* frame, int pc, WasmVal val); 174 void SetExprVal(WasmInterpreterFrame* frame, int pc, WasmVal val);
175 175
176 //========================================================================== 176 //==========================================================================
177 // Memory access. 177 // Memory access.
178 //========================================================================== 178 //==========================================================================
179 size_t GetMemorySize(); 179 size_t GetMemorySize();
180 WasmVal ReadMemory(size_t offset); 180 WasmVal ReadMemory(size_t offset);
181 void WriteMemory(size_t offset, WasmVal val); 181 void WriteMemory(size_t offset, WasmVal val);
182 182
183 //========================================================================== 183 //==========================================================================
184 // Testing functionality. 184 // Testing functionality.
185 //========================================================================== 185 //==========================================================================
186 // Manually adds a function to this interpreter, returning the index of the 186 // Manually adds a function to this interpreter, returning the index of the
187 // function. 187 // function.
188 int AddFunctionForTesting(const WasmFunction* function); 188 int AddFunctionForTesting(const WasmFunction* function);
189 // Manually adds code to the interpreter for the given function. 189 // Manually adds code to the interpreter for the given function.
190 bool SetFunctionCodeForTesting(const WasmFunction* function, 190 bool SetFunctionCodeForTesting(const WasmFunction* function,
191 const byte* start, const byte* end); 191 const byte* start, const byte* end);
192 192
193 // Computes the control targets for the given bytecode as {pc offset, sp 193 // Computes the control targets for the given bytecode as {pc offset, sp
194 // offset} 194 // offset}
195 // pairs. Used internally in the interpreter, but exposed for testing. 195 // pairs. Used internally in the interpreter, but exposed for testing.
196 static ControlTransferMap ComputeControlTransfersForTesting(Zone* zone, 196 static ControlTransferMap ComputeControlTransfersForTesting(Zone* zone,
197 const byte* start, 197 const byte* start,
198 const byte* end); 198 const byte* end);
199 199
200 private: 200 private:
201 Zone zone_; 201 Zone* zone_;
202 WasmInterpreterInternals* internals_; 202 WasmInterpreterInternals* internals_;
203 }; 203 };
204 204
205 } // namespace wasm 205 } // namespace wasm
206 } // namespace internal 206 } // namespace internal
207 } // namespace v8 207 } // namespace v8
208 208
209 #endif // V8_WASM_INTERPRETER_H_ 209 #endif // V8_WASM_INTERPRETER_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-external-refs.h ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698