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

Unified Diff: src/wasm/wasm-interpreter.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-interpreter.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-interpreter.cc
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc
index 4bb215a51ac2e7f13d7dc677def634abe16b052b..27e38605358a5b1c23d8e5e21b62211436484db4 100644
--- a/src/wasm/wasm-interpreter.cc
+++ b/src/wasm/wasm-interpreter.cc
@@ -985,16 +985,22 @@ class ThreadImpl {
possible_nondeterminism_ = false;
}
- int GetFrameCount() { return static_cast<int>(frames_.size()); }
-
- const WasmFrame* GetFrame(int index) {
- UNIMPLEMENTED();
- return nullptr;
+ int GetFrameCount() {
+ DCHECK_GE(kMaxInt, frames_.size());
+ return static_cast<int>(frames_.size());
}
- WasmFrame* GetMutableFrame(int index) {
- UNIMPLEMENTED();
- return nullptr;
+ template <typename FrameCons>
+ InterpretedFrame GetMutableFrame(int index, FrameCons frame_cons) {
+ DCHECK_LE(0, index);
+ DCHECK_GT(frames_.size(), index);
+ Frame* frame = &frames_[index];
+ DCHECK_GE(kMaxInt, frame->ret_pc);
+ DCHECK_GE(kMaxInt, frame->sp);
+ DCHECK_GE(kMaxInt, frame->llimit());
+ return frame_cons(frame->code->function, static_cast<int>(frame->ret_pc),
+ static_cast<int>(frame->sp),
+ static_cast<int>(frame->llimit()));
}
WasmVal GetReturnValue(int index) {
@@ -1747,11 +1753,16 @@ pc_t WasmInterpreter::Thread::GetBreakpointPc() {
int WasmInterpreter::Thread::GetFrameCount() {
return ToImpl(this)->GetFrameCount();
}
-const WasmFrame* WasmInterpreter::Thread::GetFrame(int index) {
- return ToImpl(this)->GetFrame(index);
+const InterpretedFrame WasmInterpreter::Thread::GetFrame(int index) {
+ return GetMutableFrame(index);
}
-WasmFrame* WasmInterpreter::Thread::GetMutableFrame(int index) {
- return ToImpl(this)->GetMutableFrame(index);
+InterpretedFrame WasmInterpreter::Thread::GetMutableFrame(int index) {
+ // We have access to the constructor of InterpretedFrame, but ThreadImpl has
+ // not. So pass it as a lambda (should all get inlined).
+ auto frame_cons = [](const WasmFunction* function, int pc, int fp, int sp) {
+ return InterpretedFrame(function, pc, fp, sp);
+ };
+ return ToImpl(this)->GetMutableFrame(index, frame_cons);
}
WasmVal WasmInterpreter::Thread::GetReturnValue(int index) {
return ToImpl(this)->GetReturnValue(index);
@@ -1844,29 +1855,6 @@ WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) {
return ToThread(&internals_->threads_[id]);
}
-WasmVal WasmInterpreter::GetLocalVal(const WasmFrame* frame, int index) {
- CHECK_GE(index, 0);
- UNIMPLEMENTED();
- WasmVal none;
- none.type = kWasmStmt;
- return none;
-}
-
-WasmVal WasmInterpreter::GetExprVal(const WasmFrame* frame, int pc) {
- UNIMPLEMENTED();
- WasmVal none;
- none.type = kWasmStmt;
- return none;
-}
-
-void WasmInterpreter::SetLocalVal(WasmFrame* frame, int index, WasmVal val) {
- UNIMPLEMENTED();
-}
-
-void WasmInterpreter::SetExprVal(WasmFrame* frame, int pc, WasmVal val) {
- UNIMPLEMENTED();
-}
-
size_t WasmInterpreter::GetMemorySize() {
return internals_->instance_->mem_size;
}
@@ -1896,6 +1884,35 @@ ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
return targets.map_;
}
+//============================================================================
+// Implementation of the frame inspection interface.
+//============================================================================
+int InterpretedFrame::GetParameterCount() const {
+ USE(fp_);
+ USE(sp_);
+ // TODO(clemensh): Return the correct number of parameters.
+ return 0;
+}
+
+WasmVal InterpretedFrame::GetLocalVal(int index) const {
+ CHECK_GE(index, 0);
+ UNIMPLEMENTED();
+ WasmVal none;
+ none.type = kWasmStmt;
+ return none;
+}
+
+WasmVal InterpretedFrame::GetExprVal(int pc) const {
+ UNIMPLEMENTED();
+ WasmVal none;
+ none.type = kWasmStmt;
+ return none;
+}
+
+void InterpretedFrame::SetLocalVal(int index, WasmVal val) { UNIMPLEMENTED(); }
+
+void InterpretedFrame::SetExprVal(int pc, WasmVal val) { UNIMPLEMENTED(); }
+
} // namespace wasm
} // namespace internal
} // namespace v8
« no previous file with comments | « src/wasm/wasm-interpreter.h ('k') | src/wasm/wasm-module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698