Commit f65a638e authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

Remove unneeded safepoint and handler table offset arguments

These offsets are now transported via CodeDesc.

Bug: v8:8758
Change-Id: If7485c62878bc81a55c9b4ca8ce3578dab2376ce
Reviewed-on: https://chromium-review.googlesource.com/c/1447717
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59315}
parent 0befa6d4
......@@ -121,13 +121,11 @@ Code BuildWithMacroAssembler(Isolate* isolate, int32_t builtin_index,
static constexpr bool kIsNotTurbofanned = false;
static constexpr int kStackSlots = 0;
static constexpr int kSafepointTableOffset = 0;
Handle<Code> code = isolate->factory()->NewCode(
desc, Code::BUILTIN, masm.CodeObject(), builtin_index,
MaybeHandle<ByteArray>(), DeoptimizationData::Empty(isolate), kMovable,
kIsNotTurbofanned, kStackSlots, kSafepointTableOffset,
handler_table_offset);
kIsNotTurbofanned, kStackSlots);
PostBuildProfileAndTracing(isolate, *code, s_name);
return *code;
}
......
......@@ -22,9 +22,6 @@ namespace internal {
// │ instructions │ data │ free │ reloc info │
// ├───────────────────────────────────────────┴──────┴──────────────┘
// TODO(jgruber): Remove safepoint and handler table offset parameters passed
// around for Code creation methods and rely on CodeDesc exclusively.
// TODO(jgruber): Likewise for WasmCompilationResult.
// TODO(jgruber): Change Code::safepoint_table_offset() semantics to always
// contain a real offset, and add has_safepoint_table() and
// safepoint_table_size() helpers. Likewise for other inlined metadata.
......
......@@ -403,8 +403,7 @@ MaybeHandle<Code> CodeGenerator::FinalizeCode() {
MaybeHandle<Code> maybe_code = isolate()->factory()->TryNewCode(
desc, info()->code_kind(), Handle<Object>(), info()->builtin_index(),
source_positions, deopt_data, kMovable, true,
frame()->GetTotalFrameSlotCount(), safepoints()->GetCodeOffset(),
handler_table_offset_);
frame()->GetTotalFrameSlotCount());
Handle<Code> code;
if (!maybe_code.ToHandle(&code)) {
......
......@@ -2205,8 +2205,6 @@ wasm::WasmCode* Pipeline::GenerateCodeForWasmNativeStub(
wasm::WasmCode::kAnonymousFuncIndex, code_desc,
code_generator->frame()->GetTotalFrameSlotCount(),
call_descriptor->GetTaggedParameterSlots(),
code_generator->GetSafepointTableOffset(),
code_generator->GetHandlerTableOffset(),
code_generator->GetProtectedInstructions(),
code_generator->GetSourcePositionTable(),
static_cast<wasm::WasmCode::Kind>(wasm_kind), wasm::WasmCode::kOther);
......@@ -2453,8 +2451,6 @@ void Pipeline::GenerateCodeForWasmFunction(
result->instr_buffer = instruction_buffer->ReleaseBuffer();
result->frame_slot_count = code_generator->frame()->GetTotalFrameSlotCount();
result->tagged_parameter_slots = call_descriptor->GetTaggedParameterSlots();
result->safepoint_table_offset = code_generator->GetSafepointTableOffset();
result->handler_table_offset = code_generator->GetHandlerTableOffset();
result->source_positions = code_generator->GetSourcePositionTable();
result->protected_instructions = code_generator->GetProtectedInstructions();
......@@ -2465,7 +2461,7 @@ void Pipeline::GenerateCodeForWasmFunction(
std::stringstream disassembler_stream;
Disassembler::Decode(
nullptr, &disassembler_stream, result->code_desc.buffer,
result->code_desc.buffer + result->safepoint_table_offset,
result->code_desc.buffer + result->code_desc.instr_size,
CodeReference(&result->code_desc));
for (auto const c : disassembler_stream.str()) {
json_of << AsEscapedUC16ForJSON(c);
......
......@@ -71,25 +71,19 @@ void InitializeCode(Heap* heap, Handle<Code> code, int object_size,
Handle<DeoptimizationData> deopt_data,
Handle<ByteArray> reloc_info,
Handle<CodeDataContainer> data_container,
bool is_turbofanned, int stack_slots,
int safepoint_table_offset, int handler_table_offset) {
bool is_turbofanned, int stack_slots) {
DCHECK(IsAligned(code->address(), kCodeAlignment));
DCHECK_IMPLIES(
!heap->memory_allocator()->code_range().is_empty(),
heap->memory_allocator()->code_range().contains(code->address()));
// TODO(jgruber): Remove safepoint table and handler table parameters and drop
// the 2 postfix from the local variables below.
DCHECK((safepoint_table_offset == 0 && desc.safepoint_table_size == 0) ||
(desc.safepoint_table_size > 0 &&
desc.safepoint_table_offset == safepoint_table_offset));
DCHECK((handler_table_offset == 0 && desc.handler_table_size == 0) ||
(desc.handler_table_size > 0 &&
desc.handler_table_offset == handler_table_offset));
const int safepoint_table_offset2 =
// TODO(jgruber): Simplify the meaning of relevant fields on Code objects.
// Offset fields should probably always contain a real offset; or
// alternatively, constant pool and code comment offset fields should behave
// similarly (i.e. an offset of 0 means 'empty').
const int safepoint_table_offset =
desc.safepoint_table_size == 0 ? 0 : desc.safepoint_table_offset;
const int handler_table_offset2 =
const int handler_table_offset =
desc.handler_table_size == 0 ? 0 : desc.handler_table_offset;
constexpr bool kIsNotOffHeapTrampoline = false;
......@@ -102,8 +96,8 @@ void InitializeCode(Heap* heap, Handle<Code> code, int object_size,
code->set_code_data_container(*data_container);
code->set_deoptimization_data(*deopt_data);
code->set_source_position_table(*source_position_table);
code->set_safepoint_table_offset(safepoint_table_offset2);
code->set_handler_table_offset(handler_table_offset2);
code->set_safepoint_table_offset(safepoint_table_offset);
code->set_handler_table_offset(handler_table_offset);
code->set_constant_pool_offset(desc.constant_pool_offset);
code->set_code_comments_offset(desc.code_comments_offset);
code->set_builtin_index(builtin_index);
......@@ -2732,8 +2726,7 @@ MaybeHandle<Code> Factory::TryNewCode(
const CodeDesc& desc, Code::Kind kind, Handle<Object> self_ref,
int32_t builtin_index, MaybeHandle<ByteArray> maybe_source_position_table,
MaybeHandle<DeoptimizationData> maybe_deopt_data, Movability movability,
bool is_turbofanned, int stack_slots, int safepoint_table_offset,
int handler_table_offset) {
bool is_turbofanned, int stack_slots) {
// Allocate objects needed for code initialization.
Handle<ByteArray> reloc_info = NewByteArray(
desc.reloc_size,
......@@ -2771,8 +2764,7 @@ MaybeHandle<Code> Factory::TryNewCode(
InitializeCode(heap, code, object_size, desc, kind, self_ref, builtin_index,
source_position_table, deopt_data, reloc_info,
data_container, is_turbofanned, stack_slots,
safepoint_table_offset, handler_table_offset);
data_container, is_turbofanned, stack_slots);
// Flush the instruction cache before changing the permissions.
// Note: we do this before setting permissions to ReadExecute because on
......@@ -2789,8 +2781,7 @@ Handle<Code> Factory::NewCode(
const CodeDesc& desc, Code::Kind kind, Handle<Object> self_ref,
int32_t builtin_index, MaybeHandle<ByteArray> maybe_source_position_table,
MaybeHandle<DeoptimizationData> maybe_deopt_data, Movability movability,
bool is_turbofanned, int stack_slots, int safepoint_table_offset,
int handler_table_offset) {
bool is_turbofanned, int stack_slots) {
// Allocate objects needed for code initialization.
Handle<ByteArray> reloc_info = NewByteArray(
desc.reloc_size,
......@@ -2825,8 +2816,7 @@ Handle<Code> Factory::NewCode(
InitializeCode(heap, code, object_size, desc, kind, self_ref, builtin_index,
source_position_table, deopt_data, reloc_info,
data_container, is_turbofanned, stack_slots,
safepoint_table_offset, handler_table_offset);
data_container, is_turbofanned, stack_slots);
// Flush the instruction cache before changing the permissions.
// Note: we do this before setting permissions to ReadExecute because on
......
......@@ -785,9 +785,7 @@ class V8_EXPORT_PRIVATE Factory {
MaybeHandle<DeoptimizationData> maybe_deopt_data =
MaybeHandle<DeoptimizationData>(),
Movability movability = kMovable,
bool is_turbofanned = false, int stack_slots = 0,
int safepoint_table_offset = 0,
int handler_table_offset = 0);
bool is_turbofanned = false, int stack_slots = 0);
// Like NewCode, this function allocates a new code object (fully
// initialized). It may return an empty handle if the allocation does not
......@@ -800,8 +798,7 @@ class V8_EXPORT_PRIVATE Factory {
MaybeHandle<DeoptimizationData> maybe_deopt_data =
MaybeHandle<DeoptimizationData>(),
Movability movability = kMovable, bool is_turbofanned = false,
int stack_slots = 0, int safepoint_table_offset = 0,
int handler_table_offset = 0);
int stack_slots = 0);
// Allocates a new code object and initializes it as the trampoline to the
// given off-heap entry point.
......
......@@ -2000,7 +2000,6 @@ WasmCompilationResult LiftoffCompilationUnit::ExecuteCompilation(
result.protected_instructions = compiler->GetProtectedInstructions();
result.frame_slot_count = compiler->GetTotalFrameSlotCount();
result.tagged_parameter_slots = call_descriptor->GetTaggedParameterSlots();
result.safepoint_table_offset = compiler->GetSafepointTableOffset();
DCHECK(result.succeeded());
return result;
......
......@@ -199,22 +199,9 @@ WasmCode* WasmCompilationUnit::Publish(WasmCompilationResult result,
: WasmCode::kTurbofan;
DCHECK_EQ(result.code_desc.buffer, result.instr_buffer.get());
// TODO(jgruber): Use the safepoint and handler table offsets in CodeDesc.
DCHECK((result.safepoint_table_offset == 0 &&
result.code_desc.safepoint_table_size == 0) ||
(result.code_desc.safepoint_table_size > 0 &&
result.code_desc.safepoint_table_offset ==
static_cast<int>(result.safepoint_table_offset)));
DCHECK((result.handler_table_offset == 0 &&
result.code_desc.handler_table_size == 0) ||
(result.code_desc.handler_table_size > 0 &&
result.code_desc.handler_table_offset ==
static_cast<int>(result.handler_table_offset)));
WasmCode* code = native_module->AddCode(
func_index_, result.code_desc, result.frame_slot_count,
result.tagged_parameter_slots, result.safepoint_table_offset,
result.handler_table_offset, std::move(result.protected_instructions),
result.tagged_parameter_slots, std::move(result.protected_instructions),
std::move(result.source_positions), WasmCode::kFunction, code_tier);
// TODO(clemensh): Merge this into {AddCode}?
native_module->PublishCode(code);
......
......@@ -62,8 +62,6 @@ struct WasmCompilationResult {
std::unique_ptr<uint8_t[]> instr_buffer;
uint32_t frame_slot_count = 0;
uint32_t tagged_parameter_slots = 0;
size_t safepoint_table_offset = 0;
size_t handler_table_offset = 0;
OwnedVector<byte> source_positions;
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions;
......
......@@ -589,8 +589,7 @@ WasmCode* NativeModule::AddAnonymousCode(Handle<Code> code, WasmCode::Kind kind,
WasmCode* NativeModule::AddCode(
uint32_t index, const CodeDesc& desc, uint32_t stack_slots,
uint32_t tagged_parameter_slots, size_t safepoint_table_offset,
size_t handler_table_offset,
uint32_t tagged_parameter_slots,
OwnedVector<trap_handler::ProtectedInstructionData> protected_instructions,
OwnedVector<const byte> source_pos_table, WasmCode::Kind kind,
WasmCode::Tier tier) {
......@@ -600,6 +599,13 @@ WasmCode* NativeModule::AddCode(
desc.reloc_size);
}
// TODO(jgruber): Remove this translation. It exists only because CodeDesc
// contains real offsets but WasmCode expects an offset of 0 to mean 'empty'.
const int safepoint_table_offset =
desc.safepoint_table_size == 0 ? 0 : desc.safepoint_table_offset;
const int handler_table_offset =
desc.handler_table_size == 0 ? 0 : desc.handler_table_offset;
WasmCode* ret = AddOwnedCode(
index, {desc.buffer, static_cast<size_t>(desc.instr_size)}, stack_slots,
tagged_parameter_slots, safepoint_table_offset, handler_table_offset,
......
......@@ -234,7 +234,6 @@ class V8_EXPORT_PRIVATE NativeModule final {
// code below, i.e. it can be called concurrently from background threads.
WasmCode* AddCode(uint32_t index, const CodeDesc& desc, uint32_t stack_slots,
uint32_t tagged_parameter_slots,
size_t safepoint_table_offset, size_t handler_table_offset,
OwnedVector<trap_handler::ProtectedInstructionData>
protected_instructions,
OwnedVector<const byte> source_position_table,
......
......@@ -3474,7 +3474,7 @@ TEST(Liftoff_tier_up) {
desc.buffer = buffer.get();
desc.instr_size = static_cast<int>(sub_size);
WasmCode* code = native_module->AddCode(
add.function_index(), desc, 0, 0, 0, 0, {}, OwnedVector<byte>(),
add.function_index(), desc, 0, 0, {}, OwnedVector<byte>(),
WasmCode::kFunction, WasmCode::kOther);
native_module->PublishCode(code);
......
......@@ -175,9 +175,8 @@ class WasmCodeManagerTest : public TestWithContext,
std::unique_ptr<byte[]> exec_buff(new byte[size]);
desc.buffer = exec_buff.get();
desc.instr_size = static_cast<int>(size);
return native_module->AddCode(index, desc, 0, 0, 0, 0, {},
OwnedVector<byte>(), WasmCode::kFunction,
WasmCode::kOther);
return native_module->AddCode(index, desc, 0, 0, {}, OwnedVector<byte>(),
WasmCode::kFunction, WasmCode::kOther);
}
size_t page() const { return AllocatePageSize(); }
......
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