Commit 975bc15b authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[ppc] Emit the constant pool after handler table generation

This basically adjusts reality to match our expectations. Methods based
on Code::kConstantPoolOffset expected the constant pool to be located
immediately following the handler table and before the code comments
section, while it was actually emitted before the jump table. We did
not notice earlier since this is only relevant on ppc.

Bug: v8:8758
Change-Id: I189af491fe133a7dc480ff4056372ba7a27faa81
Reviewed-on: https://chromium-review.googlesource.com/c/1445880
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#59299}
parent 4b3e4448
......@@ -1101,6 +1101,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope);
};
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Record a deoptimization reason that can be used by a log or cpu profiler.
// Use --trace-deopt to enable.
void RecordDeoptReason(DeoptimizeReason reason, SourcePosition position,
......
......@@ -2513,6 +2513,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(BlockConstPoolScope);
};
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Check if is time to emit a constant pool.
void CheckConstPool(bool force_emit, bool require_jump);
......
......@@ -130,6 +130,10 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall(
return kSuccess;
}
void CodeGenerator::MaybeEmitOutOfLineConstantPool() {
tasm()->MaybeEmitOutOfLineConstantPool();
}
void CodeGenerator::AssembleCode() {
OptimizedCompilationInfo* info = this->info();
......@@ -277,6 +281,10 @@ void CodeGenerator::AssembleCode() {
if (result_ != kSuccess) return;
}
// TODO(jgruber): Move all inlined metadata generation into a new,
// architecture-independent version of FinishCode. Currently, this includes
// the safepoint table, handler table, constant pool, and code comments, in
// that order.
FinishCode();
// Emit the jump tables.
......@@ -289,8 +297,8 @@ void CodeGenerator::AssembleCode() {
}
// The PerfJitLogger logs code up until here, excluding the safepoint
// table. Resolve the unwinding info now so it is aware of the same code size
// as reported by perf.
// table. Resolve the unwinding info now so it is aware of the same code
// size as reported by perf.
unwinding_info_writer_.Finish(tasm()->pc_offset());
safepoints()->Emit(tasm(), frame()->GetTotalFrameSlotCount());
......@@ -305,6 +313,7 @@ void CodeGenerator::AssembleCode() {
}
}
tasm()->MaybeEmitOutOfLineConstantPool();
tasm()->FinalizeJumpOptimizationInfo();
result_ = kSuccess;
......
......@@ -309,6 +309,7 @@ class CodeGenerator final : public GapResolver::Assembler {
int first_unused_stack_slot);
void FinishCode();
void MaybeEmitOutOfLineConstantPool();
// ===========================================================================
// ============== Architecture-specific gap resolver methods. ================
......
......@@ -2470,7 +2470,7 @@ void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
__ Ret();
}
void CodeGenerator::FinishCode() { __ EmitConstantPool(); }
void CodeGenerator::FinishCode() {}
void CodeGenerator::AssembleMove(InstructionOperand* source,
InstructionOperand* destination) {
......
......@@ -389,6 +389,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void FinalizeJumpOptimizationInfo();
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Read/Modify the code target in the branch/call instruction at pc.
// The isolate argument is unused (and may be nullptr) when skipping flushing.
inline static Address target_address_at(Address pc, Address constant_pool);
......
......@@ -164,6 +164,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Assembler functions are invoked in between GetCode() calls.
void GetCode(Isolate* isolate, CodeDesc* desc);
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Label operations & relative jumps (PPUM Appendix D).
//
// Takes a branch opcode (cc) and a label (L) and generates
......
......@@ -162,6 +162,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Assembler functions are invoked in between GetCode() calls.
void GetCode(Isolate* isolate, CodeDesc* desc);
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Label operations & relative jumps (PPUM Appendix D).
//
// Takes a branch opcode (cc) and a label (L) and generates
......
......@@ -201,6 +201,8 @@ class Assembler : public AssemblerBase {
GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable);
}
void MaybeEmitOutOfLineConstantPool() { EmitConstantPool(); }
// Label operations & relative jumps (PPUM Appendix D)
//
// Takes a branch opcode (cc) and a label (L) and generates
......
......@@ -240,6 +240,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
GetCode(isolate, desc, kNoSafepointTable, kNoHandlerTable);
}
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Label operations & relative jumps (PPUM Appendix D)
//
// Takes a branch opcode (cc) and a label (L) and generates
......
......@@ -444,6 +444,7 @@ class LiftoffCompiler {
__ GetTotalFrameSlotCount());
__ FinishCode();
safepoint_table_builder_.Emit(&asm_, __ GetTotalFrameSlotCount());
__ MaybeEmitOutOfLineConstantPool();
// The previous calls may have also generated a bailout.
DidAssemblerBailout(decoder);
}
......
......@@ -346,6 +346,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
void FinalizeJumpOptimizationInfo();
// Unused on this architecture.
void MaybeEmitOutOfLineConstantPool() {}
// Read/Modify the code target in the relative branch/call instruction at pc.
// On the x64 architecture, we use relative jumps with a 32-bit displacement
// to jump to other Code objects in the Code space in the heap.
......
......@@ -1109,6 +1109,8 @@ class CodeGeneratorTester {
generator_->FinishCode();
generator_->safepoints()->Emit(generator_->tasm(),
frame_.GetTotalFrameSlotCount());
generator_->MaybeEmitOutOfLineConstantPool();
return generator_->FinalizeCode().ToHandleChecked();
}
......
......@@ -24,13 +24,20 @@ TEST(CodeLayoutWithoutUnwindingInfo) {
CodeDesc code_desc;
code_desc.buffer = buffer;
code_desc.buffer_size = buffer_size;
code_desc.constant_pool_size = 0;
code_desc.instr_size = buffer_size;
code_desc.safepoint_table_offset = buffer_size;
code_desc.safepoint_table_size = 0;
code_desc.handler_table_offset = buffer_size;
code_desc.handler_table_size = 0;
code_desc.constant_pool_offset = buffer_size;
code_desc.constant_pool_size = 0;
code_desc.code_comments_offset = buffer_size;
code_desc.code_comments_size = 0;
code_desc.reloc_offset = buffer_size;
code_desc.reloc_size = 0;
code_desc.origin = nullptr;
code_desc.unwinding_info = nullptr;
code_desc.unwinding_info_size = 0;
code_desc.code_comments_size = 0;
code_desc.origin = nullptr;
Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
code_desc, Code::STUB, Handle<Object>::null());
......@@ -63,13 +70,20 @@ TEST(CodeLayoutWithUnwindingInfo) {
CodeDesc code_desc;
code_desc.buffer = buffer;
code_desc.buffer_size = buffer_size;
code_desc.constant_pool_size = 0;
code_desc.instr_size = buffer_size;
code_desc.safepoint_table_offset = buffer_size;
code_desc.safepoint_table_size = 0;
code_desc.handler_table_offset = buffer_size;
code_desc.handler_table_size = 0;
code_desc.constant_pool_offset = buffer_size;
code_desc.constant_pool_size = 0;
code_desc.code_comments_offset = buffer_size;
code_desc.code_comments_size = 0;
code_desc.reloc_offset = buffer_size;
code_desc.reloc_size = 0;
code_desc.origin = nullptr;
code_desc.unwinding_info = unwinding_info;
code_desc.unwinding_info_size = unwinding_info_size;
code_desc.code_comments_size = 0;
code_desc.origin = nullptr;
Handle<Code> code = CcTest::i_isolate()->factory()->NewCode(
code_desc, Code::STUB, Handle<Object>::null());
......
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