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

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

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-debug.cc ('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/zone-containers.h" 9 #include "src/zone/zone-containers.h"
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } \ 73 } \
74 template <> \ 74 template <> \
75 inline ctype WasmVal::to() { \ 75 inline ctype WasmVal::to() { \
76 CHECK_EQ(localtype, type); \ 76 CHECK_EQ(localtype, type); \
77 return val.field; \ 77 return val.field; \
78 } 78 }
79 FOREACH_UNION_MEMBER(DECLARE_CAST) 79 FOREACH_UNION_MEMBER(DECLARE_CAST)
80 #undef DECLARE_CAST 80 #undef DECLARE_CAST
81 81
82 // Representation of frames within the interpreter. 82 // Representation of frames within the interpreter.
83 class WasmFrame { 83 class InterpretedFrame {
84 public: 84 public:
85 const WasmFunction* function() const { return function_; } 85 const WasmFunction* function() const { return function_; }
86 int pc() const { 86 int pc() const { return pc_; }
87 // TODO(wasm): Remove USE once we actually use them. 87
88 USE(fp_); 88 //==========================================================================
89 USE(sp_); 89 // Stack frame inspection.
90 return pc_; 90 //==========================================================================
91 } 91 int GetParameterCount() const;
92 WasmVal GetLocalVal(int index) const;
93 WasmVal GetExprVal(int pc) const;
94 void SetLocalVal(int index, WasmVal val);
95 void SetExprVal(int pc, WasmVal val);
92 96
93 private: 97 private:
94 friend class WasmInterpreter; 98 friend class WasmInterpreter;
95 99
96 WasmFrame(const WasmFunction* function, int pc, int fp, int sp) 100 InterpretedFrame(const WasmFunction* function, int pc, int fp, int sp)
97 : function_(function), pc_(pc), fp_(fp), sp_(sp) {} 101 : function_(function), pc_(pc), fp_(fp), sp_(sp) {}
98 102
99 const WasmFunction* function_; 103 const WasmFunction* function_;
100 int pc_; 104 int pc_;
101 int fp_; 105 int fp_;
102 int sp_; 106 int sp_;
103 }; 107 };
104 108
105 // An interpreter capable of executing WASM. 109 // An interpreter capable of executing WASM.
106 class V8_EXPORT_PRIVATE WasmInterpreter { 110 class V8_EXPORT_PRIVATE WasmInterpreter {
(...skipping 20 matching lines...) Expand all
127 State state(); 131 State state();
128 void PushFrame(const WasmFunction* function, WasmVal* args); 132 void PushFrame(const WasmFunction* function, WasmVal* args);
129 State Run(); 133 State Run();
130 State Step(); 134 State Step();
131 void Pause(); 135 void Pause();
132 void Reset(); 136 void Reset();
133 137
134 // Stack inspection and modification. 138 // Stack inspection and modification.
135 pc_t GetBreakpointPc(); 139 pc_t GetBreakpointPc();
136 int GetFrameCount(); 140 int GetFrameCount();
137 const WasmFrame* GetFrame(int index); 141 const InterpretedFrame GetFrame(int index);
138 WasmFrame* GetMutableFrame(int index); 142 InterpretedFrame GetMutableFrame(int index);
139 WasmVal GetReturnValue(int index = 0); 143 WasmVal GetReturnValue(int index = 0);
140 // Returns true if the thread executed an instruction which may produce 144 // Returns true if the thread executed an instruction which may produce
141 // nondeterministic results, e.g. float div, float sqrt, and float mul, 145 // nondeterministic results, e.g. float div, float sqrt, and float mul,
142 // where the sign bit of a NaN is nondeterministic. 146 // where the sign bit of a NaN is nondeterministic.
143 bool PossibleNondeterminism(); 147 bool PossibleNondeterminism();
144 148
145 // Thread-specific breakpoints. 149 // Thread-specific breakpoints.
146 // TODO(wasm): Implement this once we support multiple threads. 150 // TODO(wasm): Implement this once we support multiple threads.
147 // bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled); 151 // bool SetBreakpoint(const WasmFunction* function, int pc, bool enabled);
148 // bool GetBreakpoint(const WasmFunction* function, int pc); 152 // bool GetBreakpoint(const WasmFunction* function, int pc);
(...skipping 18 matching lines...) Expand all
167 // Enable or disable tracing for {function}. Return the previous state. 171 // Enable or disable tracing for {function}. Return the previous state.
168 bool SetTracing(const WasmFunction* function, bool enabled); 172 bool SetTracing(const WasmFunction* function, bool enabled);
169 173
170 //========================================================================== 174 //==========================================================================
171 // Thread iteration and inspection. 175 // Thread iteration and inspection.
172 //========================================================================== 176 //==========================================================================
173 int GetThreadCount(); 177 int GetThreadCount();
174 Thread* GetThread(int id); 178 Thread* GetThread(int id);
175 179
176 //========================================================================== 180 //==========================================================================
177 // Stack frame inspection.
178 //==========================================================================
179 WasmVal GetLocalVal(const WasmFrame* frame, int index);
180 WasmVal GetExprVal(const WasmFrame* frame, int pc);
181 void SetLocalVal(WasmFrame* frame, int index, WasmVal val);
182 void SetExprVal(WasmFrame* frame, int pc, WasmVal val);
183
184 //==========================================================================
185 // Memory access. 181 // Memory access.
186 //========================================================================== 182 //==========================================================================
187 size_t GetMemorySize(); 183 size_t GetMemorySize();
188 WasmVal ReadMemory(size_t offset); 184 WasmVal ReadMemory(size_t offset);
189 void WriteMemory(size_t offset, WasmVal val); 185 void WriteMemory(size_t offset, WasmVal val);
190 186
191 //========================================================================== 187 //==========================================================================
192 // Testing functionality. 188 // Testing functionality.
193 //========================================================================== 189 //==========================================================================
194 // Manually adds a function to this interpreter, returning the index of the 190 // Manually adds a function to this interpreter, returning the index of the
(...skipping 12 matching lines...) Expand all
207 private: 203 private:
208 Zone zone_; 204 Zone zone_;
209 WasmInterpreterInternals* internals_; 205 WasmInterpreterInternals* internals_;
210 }; 206 };
211 207
212 } // namespace wasm 208 } // namespace wasm
213 } // namespace internal 209 } // namespace internal
214 } // namespace v8 210 } // namespace v8
215 211
216 #endif // V8_WASM_INTERPRETER_H_ 212 #endif // V8_WASM_INTERPRETER_H_
OLDNEW
« no previous file with comments | « src/wasm/wasm-debug.cc ('k') | src/wasm/wasm-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698