Commit 0cd74947 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[turbofan] fix Turbolizer output by running FinalizeCode only once

Change-Id: I0517ac0c9b8d83809fa51a2828f91211c97f6ffc
Reviewed-on: https://chromium-review.googlesource.com/c/1424956Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58986}
parent 5043ab26
......@@ -239,6 +239,8 @@ class V8_EXPORT_PRIVATE AssemblerBase : public Malloced {
jump_optimization_info_ = jump_opt;
}
void FinalizeJumpOptimizationInfo() {}
// Overwrite a host NaN with a quiet target NaN. Used by mksnapshot for
// cross-snapshotting.
static void QuietNaN(HeapObject nan) {}
......
......@@ -305,6 +305,8 @@ void CodeGenerator::AssembleCode() {
}
}
tasm()->FinalizeJumpOptimizationInfo();
result_ = kSuccess;
}
......
......@@ -542,6 +542,7 @@ class PipelineImpl final {
void VerifyGeneratedCodeIsIdempotent();
void RunPrintAndVerify(const char* phase, bool untyped = false);
bool SelectInstructionsAndAssemble(CallDescriptor* call_descriptor);
MaybeHandle<Code> GenerateCode(CallDescriptor* call_descriptor);
void AllocateRegisters(const RegisterConfiguration* config,
CallDescriptor* call_descriptor, bool run_verifier);
......@@ -2132,12 +2133,14 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
options);
second_data.set_verify_graph(FLAG_verify_csa);
PipelineImpl second_pipeline(&second_data);
Handle<Code> code =
second_pipeline.GenerateCode(call_descriptor).ToHandleChecked();
second_pipeline.SelectInstructionsAndAssemble(call_descriptor);
Handle<Code> code;
if (jump_opt.is_optimizable()) {
jump_opt.set_optimizing();
code = pipeline.GenerateCode(call_descriptor).ToHandleChecked();
} else {
code = second_pipeline.FinalizeCode().ToHandleChecked();
}
return code;
......@@ -2755,14 +2758,21 @@ MaybeHandle<Code> PipelineImpl::FinalizeCode() {
return code;
}
MaybeHandle<Code> PipelineImpl::GenerateCode(CallDescriptor* call_descriptor) {
bool PipelineImpl::SelectInstructionsAndAssemble(
CallDescriptor* call_descriptor) {
Linkage linkage(call_descriptor);
// Perform instruction selection and register allocation.
if (!SelectInstructions(&linkage)) return MaybeHandle<Code>();
if (!SelectInstructions(&linkage)) return false;
// Generate the final machine code.
AssembleCode(&linkage);
return true;
}
MaybeHandle<Code> PipelineImpl::GenerateCode(CallDescriptor* call_descriptor) {
if (!SelectInstructionsAndAssemble(call_descriptor))
return MaybeHandle<Code>();
return FinalizeCode();
}
......
......@@ -333,7 +333,9 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
desc->unwinding_info_size = 0;
desc->unwinding_info = nullptr;
desc->code_comments_size = code_comments_size;
}
void Assembler::FinalizeJumpOptimizationInfo() {
// Collection stage
auto jump_opt = jump_optimization_info();
if (jump_opt && jump_opt->is_collecting()) {
......@@ -358,7 +360,6 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
}
}
void Assembler::Align(int m) {
DCHECK(base::bits::IsPowerOfTwo(m));
int mask = m - 1;
......
......@@ -378,6 +378,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Assembler functions are invoked in between GetCode() calls.
void GetCode(Isolate* isolate, CodeDesc* desc);
void FinalizeJumpOptimizationInfo();
// 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);
......
......@@ -460,7 +460,9 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
desc->unwinding_info_size = 0;
desc->unwinding_info = nullptr;
desc->code_comments_size = code_comments_size;
}
void Assembler::FinalizeJumpOptimizationInfo() {
// Collection stage
auto jump_opt = jump_optimization_info();
if (jump_opt && jump_opt->is_collecting()) {
......@@ -485,7 +487,6 @@ void Assembler::GetCode(Isolate* isolate, CodeDesc* desc) {
}
}
void Assembler::Align(int m) {
DCHECK(base::bits::IsPowerOfTwo(m));
int delta = (m - (pc_offset() & (m - 1))) & (m - 1);
......
......@@ -321,6 +321,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Assembler functions are invoked in between GetCode() calls.
void GetCode(Isolate* isolate, CodeDesc* desc);
void FinalizeJumpOptimizationInfo();
// 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.
......
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