Commit 63be6dde authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[baseline] Update EstimateInstructionSize

Adds a minimum estimated size.

Data suggests that estimated instruction size (+ relocation info size)
is linear to bytecode array length. This CL adds a constant for this
equation. The ratio remains the same.

This is important, because we want to increase success rate of
estimation when compiling on-heap.

When off-heap, we round up the assembler buffer to 4kB, so this CL
will only impact JS functions with more than 585 bytecodes, i.e, the
new added constant will be negligible.

Note: Relocation info (for Sparkplug) is usually so small that it is
not useful to have a separate zone for this.

Bug: v8:11872
Change-Id: I789e72f80b970d1f541965e7ae808b61c8174326
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3069155
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76144}
parent 639e8563
......@@ -241,8 +241,10 @@ namespace {
// than pre-allocating a large enough buffer.
#ifdef V8_TARGET_ARCH_IA32
const int kAverageBytecodeToInstructionRatio = 5;
const int kMinimumEstimatedInstructionSize = 200;
#else
const int kAverageBytecodeToInstructionRatio = 7;
const int kMinimumEstimatedInstructionSize = 300;
#endif
std::unique_ptr<AssemblerBuffer> AllocateBuffer(
Isolate* isolate, Handle<BytecodeArray> bytecodes,
......@@ -258,9 +260,6 @@ std::unique_ptr<AssemblerBuffer> AllocateBuffer(
if (code_location == BaselineCompiler::kOnHeap &&
Code::SizeFor(estimated_size) <
heap->MaxRegularHeapObjectSize(AllocationType::kCode)) {
// TODO(victorgomes): We're currently underestimating the size of the
// buffer, since we don't know how big the reloc info will be. We could
// use a separate zone vector for the RelocInfo.
return NewOnHeapAssemblerBuffer(isolate, estimated_size);
}
return NewAssemblerBuffer(RoundUp(estimated_size, 4 * KB));
......@@ -328,7 +327,8 @@ MaybeHandle<Code> BaselineCompiler::Build(Isolate* isolate) {
}
int BaselineCompiler::EstimateInstructionSize(BytecodeArray bytecode) {
return bytecode.length() * kAverageBytecodeToInstructionRatio;
return bytecode.length() * kAverageBytecodeToInstructionRatio +
kMinimumEstimatedInstructionSize;
}
interpreter::Register BaselineCompiler::RegisterOperand(int operand_index) {
......
......@@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax --no-always-opt --opt
// Flags: --no-stress-flush-code
// Flags: --no-stress-incremental-marking
// Flags: --no-baseline-batch-compilation
var source =
`
......
......@@ -4,8 +4,8 @@
// Flags: --sparkplug --no-always-sparkplug --sparkplug-filter="test*"
// Flags: --allow-natives-syntax --expose-gc --no-always-opt
// Flags: --baseline-batch-compilation --baseline-batch-compilation-threshold=200
// Flags: --scale-factor-for-feedback-allocation=4
// Flags: --baseline-batch-compilation --baseline-batch-compilation-threshold=500
// Flags: --scale-factor-for-feedback-allocation=2
// Flags to drive Fuzzers into the right direction
// TODO(v8:11853): Remove these flags once fuzzers handle flag implications
......
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