Commit 31e9ebee authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[Liftoff] Emit and test debug side table

This adds a method to generate the debug side table via Liftoff, and
adds first tests that check that the number of entries is as expected.
These tests will be extended in a follow-up CL to test the actual
content of the debug side table.

R=mstarzinger@chromium.org

Bug: v8:10019
Change-Id: I393ffabed3408463ffba232a66e2dffd7dd74f15
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1954390
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65370}
parent 7cb7f775
......@@ -245,11 +245,13 @@ class LiftoffCompiler {
LiftoffCompiler(compiler::CallDescriptor* call_descriptor,
CompilationEnv* env, Zone* compilation_zone,
std::unique_ptr<AssemblerBuffer> buffer)
std::unique_ptr<AssemblerBuffer> buffer,
DebugSideTableBuilder* debug_sidetable_builder)
: asm_(std::move(buffer)),
descriptor_(
GetLoweredCallDescriptor(compilation_zone, call_descriptor)),
env_(env),
debug_sidetable_builder_(debug_sidetable_builder),
compilation_zone_(compilation_zone),
safepoint_table_builder_(compilation_zone_) {}
......@@ -2172,8 +2174,7 @@ class LiftoffCompiler {
compiler::CallDescriptor* const descriptor_;
CompilationEnv* const env_;
// TODO(clemensb): Provide a DebugSideTableBuilder here.
DebugSideTableBuilder* const debug_sidetable_builder_ = nullptr;
DebugSideTableBuilder* const debug_sidetable_builder_;
LiftoffBailoutReason bailout_reason_ = kSuccess;
std::vector<OutOfLineCode> out_of_line_code_;
SourcePositionTableBuilder source_position_table_builder_;
......@@ -2225,7 +2226,6 @@ WasmCompilationResult ExecuteLiftoffCompilation(AccountingAllocator* allocator,
"body_size", func_body_size);
Zone zone(allocator, "LiftoffCompilationZone");
const WasmModule* module = env ? env->module : nullptr;
auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig);
base::Optional<TimedHistogramScope> liftoff_compile_time_scope(
base::in_place, counters->liftoff_compile_time());
......@@ -2235,9 +2235,11 @@ WasmCompilationResult ExecuteLiftoffCompilation(AccountingAllocator* allocator,
// generation.
std::unique_ptr<wasm::WasmInstructionBuffer> instruction_buffer =
wasm::WasmInstructionBuffer::New(128 + code_size_estimate * 4 / 3);
DebugSideTableBuilder* const kNoDebugSideTable = nullptr;
WasmFullDecoder<Decoder::kValidate, LiftoffCompiler> decoder(
&zone, module, env->enabled_features, detected, func_body,
call_descriptor, env, &zone, instruction_buffer->CreateView());
&zone, env->module, env->enabled_features, detected, func_body,
call_descriptor, env, &zone, instruction_buffer->CreateView(),
kNoDebugSideTable);
decoder.Decode();
liftoff_compile_time_scope.reset();
LiftoffCompiler* compiler = &decoder.interface();
......@@ -2272,6 +2274,24 @@ WasmCompilationResult ExecuteLiftoffCompilation(AccountingAllocator* allocator,
return result;
}
DebugSideTable GenerateLiftoffDebugSideTable(AccountingAllocator* allocator,
CompilationEnv* env,
const FunctionBody& func_body) {
Zone zone(allocator, "LiftoffDebugSideTableZone");
auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig);
DebugSideTableBuilder debug_sidetable_builder;
WasmFeatures detected;
WasmFullDecoder<Decoder::kValidate, LiftoffCompiler> decoder(
&zone, env->module, env->enabled_features, &detected, func_body,
call_descriptor, env, &zone,
NewAssemblerBuffer(AssemblerBase::kDefaultBufferSize),
&debug_sidetable_builder);
decoder.Decode();
DCHECK(decoder.ok());
DCHECK(!decoder.interface().did_bailout());
return debug_sidetable_builder.GenerateDebugSideTable();
}
#undef __
#undef TRACE
#undef WASM_INSTANCE_OBJECT_FIELD_OFFSET
......
......@@ -16,6 +16,7 @@ class Counters;
namespace wasm {
struct CompilationEnv;
class DebugSideTable;
struct FunctionBody;
class WasmFeatures;
......@@ -55,6 +56,9 @@ V8_EXPORT_PRIVATE WasmCompilationResult ExecuteLiftoffCompilation(
AccountingAllocator*, CompilationEnv*, const FunctionBody&, int func_index,
Counters*, WasmFeatures* detected_features);
V8_EXPORT_PRIVATE DebugSideTable GenerateLiftoffDebugSideTable(
AccountingAllocator*, CompilationEnv*, const FunctionBody&);
} // namespace wasm
} // namespace internal
} // namespace v8
......
......@@ -9,6 +9,7 @@
#include <vector>
#include "src/base/logging.h"
#include "src/base/macros.h"
namespace v8 {
namespace internal {
......@@ -67,6 +68,10 @@ class DebugSideTable {
std::vector<Constant> constants_;
};
// Technically it would be fine to copy this class, but there should not be a
// reason to do so, hence mark it move only.
MOVE_ONLY_NO_DEFAULT_CONSTRUCTOR(DebugSideTable);
explicit DebugSideTable(std::vector<Entry> entries)
: entries_(std::move(entries)) {
DCHECK(
......@@ -80,6 +85,8 @@ class DebugSideTable {
return &*it;
}
size_t num_entries() const { return entries_.size(); }
private:
struct EntryPositionLess {
bool operator()(const Entry& a, const Entry& b) const {
......
This diff is collapsed.
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