Commit 5c05acf7 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][debug] Remove interpreter frame inspection

The interpreter is still used for testing, but frame inspection is not
wired any more. Hence this CL removes it.

R=thibaudm@chromium.org

Bug: v8:10389
Change-Id: If93928dd3996a19c1251a93d843034574d4c43ce
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2215165Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67964}
parent 458c07a7
......@@ -233,35 +233,6 @@ class InterpreterHandle {
return true;
}
std::vector<std::pair<uint32_t, int>> GetInterpretedStack(
Address frame_pointer) {
DCHECK_EQ(1, interpreter()->GetThreadCount());
WasmInterpreter::Thread* thread = interpreter()->GetThread(0);
std::pair<uint32_t, uint32_t> frame_range =
GetActivationFrameRange(thread, frame_pointer);
std::vector<std::pair<uint32_t, int>> stack;
stack.reserve(frame_range.second - frame_range.first);
for (uint32_t fp = frame_range.first; fp < frame_range.second; ++fp) {
auto frame = thread->GetFrame(fp);
stack.emplace_back(frame->function()->func_index, frame->pc());
}
return stack;
}
int NumberOfActiveFrames(Address frame_pointer) {
if (!HasActivation(frame_pointer)) return 0;
DCHECK_EQ(1, interpreter()->GetThreadCount());
WasmInterpreter::Thread* thread = interpreter()->GetThread(0);
std::pair<uint32_t, uint32_t> frame_range =
GetActivationFrameRange(thread, frame_pointer);
return frame_range.second - frame_range.first;
}
private:
DISALLOW_COPY_AND_ASSIGN(InterpreterHandle);
};
......
......@@ -1364,7 +1364,6 @@ class ThreadImpl {
WasmValue value_;
};
friend class InterpretedFrameImpl;
friend class ReferenceStackScope;
CodeMap* codemap_;
......@@ -4029,70 +4028,6 @@ class ThreadImpl {
}
};
class InterpretedFrameImpl {
public:
InterpretedFrameImpl(ThreadImpl* thread, int index)
: thread_(thread), index_(index) {
DCHECK_LE(0, index);
}
const WasmFunction* function() const { return frame()->code->function; }
int pc() const {
DCHECK_LE(0, frame()->pc);
DCHECK_GE(kMaxInt, frame()->pc);
return static_cast<int>(frame()->pc);
}
int GetParameterCount() const {
DCHECK_GE(kMaxInt, function()->sig->parameter_count());
return static_cast<int>(function()->sig->parameter_count());
}
int GetLocalCount() const {
size_t num_locals = function()->sig->parameter_count() +
frame()->code->locals.type_list.size();
DCHECK_GE(kMaxInt, num_locals);
return static_cast<int>(num_locals);
}
int GetStackHeight() const {
bool is_top_frame =
static_cast<size_t>(index_) + 1 == thread_->frames_.size();
size_t stack_limit =
is_top_frame ? thread_->StackHeight() : thread_->frames_[index_ + 1].sp;
DCHECK_LE(frame()->sp, stack_limit);
size_t frame_size = stack_limit - frame()->sp;
DCHECK_LE(GetLocalCount(), frame_size);
return static_cast<int>(frame_size) - GetLocalCount();
}
WasmValue GetLocalValue(int index) const {
ThreadImpl::ReferenceStackScope stack_scope(thread_);
DCHECK_LE(0, index);
DCHECK_GT(GetLocalCount(), index);
return thread_->GetStackValue(static_cast<int>(frame()->sp) + index);
}
WasmValue GetStackValue(int index) const {
ThreadImpl::ReferenceStackScope stack_scope(thread_);
DCHECK_LE(0, index);
// Index must be within the number of stack values of this frame.
DCHECK_GT(GetStackHeight(), index);
return thread_->GetStackValue(static_cast<int>(frame()->sp) +
GetLocalCount() + index);
}
private:
ThreadImpl* thread_;
int index_;
ThreadImpl::Frame* frame() const {
DCHECK_GT(thread_->frames_.size(), index_);
return &thread_->frames_[index_];
}
};
namespace {
// Converters between WasmInterpreter::Thread and WasmInterpreter::ThreadImpl.
......@@ -4106,14 +4041,6 @@ ThreadImpl* ToImpl(WasmInterpreter::Thread* thread) {
return reinterpret_cast<ThreadImpl*>(thread);
}
// Same conversion for InterpretedFrame and InterpretedFrameImpl.
InterpretedFrame* ToFrame(InterpretedFrameImpl* impl) {
return reinterpret_cast<InterpretedFrame*>(impl);
}
const InterpretedFrameImpl* ToImpl(const InterpretedFrame* frame) {
return reinterpret_cast<const InterpretedFrameImpl*>(frame);
}
} // namespace
//============================================================================
......@@ -4154,11 +4081,6 @@ WasmInterpreter::Thread::RaiseException(Isolate* isolate,
int WasmInterpreter::Thread::GetFrameCount() {
return ToImpl(this)->GetFrameCount();
}
WasmInterpreter::FramePtr WasmInterpreter::Thread::GetFrame(int index) {
DCHECK_LE(0, index);
DCHECK_GT(GetFrameCount(), index);
return FramePtr(ToFrame(new InterpretedFrameImpl(ToImpl(this), index)));
}
WasmValue WasmInterpreter::Thread::GetReturnValue(int index) {
ThreadImpl* impl = ToImpl(this);
ThreadImpl::ReferenceStackScope stack_scope(impl);
......@@ -4286,32 +4208,6 @@ ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
return side_table.map_;
}
//============================================================================
// Implementation of the frame inspection interface.
//============================================================================
const WasmFunction* InterpretedFrame::function() const {
return ToImpl(this)->function();
}
int InterpretedFrame::pc() const { return ToImpl(this)->pc(); }
int InterpretedFrame::GetParameterCount() const {
return ToImpl(this)->GetParameterCount();
}
int InterpretedFrame::GetLocalCount() const {
return ToImpl(this)->GetLocalCount();
}
int InterpretedFrame::GetStackHeight() const {
return ToImpl(this)->GetStackHeight();
}
WasmValue InterpretedFrame::GetLocalValue(int index) const {
return ToImpl(this)->GetLocalValue(index);
}
WasmValue InterpretedFrame::GetStackValue(int index) const {
return ToImpl(this)->GetStackValue(index);
}
void InterpretedFrameDeleter::operator()(InterpretedFrame* ptr) {
delete ToImpl(ptr);
}
#undef TRACE
#undef LANE
#undef FOREACH_SIMPLE_BINOP
......
......@@ -41,46 +41,6 @@ struct ControlTransferEntry {
using ControlTransferMap = ZoneMap<pc_t, ControlTransferEntry>;
// Representation of frames within the interpreter.
//
// Layout of a frame:
// -----------------
// stack slot #N ‾\.
// ... | stack entries: GetStackHeight(); GetStackValue()
// stack slot #0 _/·
// local #L ‾\.
// ... | locals: GetLocalCount(); GetLocalValue()
// local #P+1 |
// param #P | ‾\.
// ... | | parameters: GetParameterCount(); GetLocalValue()
// param #0 _/· _/·
// -----------------
//
class V8_EXPORT_PRIVATE InterpretedFrame {
public:
const WasmFunction* function() const;
int pc() const;
int GetParameterCount() const;
int GetLocalCount() const;
int GetStackHeight() const;
WasmValue GetLocalValue(int index) const;
WasmValue GetStackValue(int index) const;
private:
friend class WasmInterpreter;
// Don't instante InterpretedFrames; they will be allocated as
// InterpretedFrameImpl in the interpreter implementation.
InterpretedFrame() = delete;
DISALLOW_COPY_AND_ASSIGN(InterpretedFrame);
};
// Deleter struct to delete the underlying InterpretedFrameImpl without
// violating language specifications.
struct V8_EXPORT_PRIVATE InterpretedFrameDeleter {
void operator()(InterpretedFrame* ptr);
};
// An interpreter capable of executing WebAssembly.
class V8_EXPORT_PRIVATE WasmInterpreter {
public:
......@@ -103,8 +63,6 @@ class V8_EXPORT_PRIVATE WasmInterpreter {
AfterCall = 1 << 1
};
using FramePtr = std::unique_ptr<InterpretedFrame, InterpretedFrameDeleter>;
// Representation of a thread in the interpreter.
class V8_EXPORT_PRIVATE Thread {
// Don't instante Threads; they will be allocated as ThreadImpl in the
......@@ -131,8 +89,6 @@ class V8_EXPORT_PRIVATE WasmInterpreter {
// Stack inspection and modification.
int GetFrameCount();
// The InterpretedFrame is only valid as long as the Thread is paused.
FramePtr GetFrame(int index);
WasmValue GetReturnValue(int index = 0);
TrapReason GetTrapReason();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment