Commit 506aeae9 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[heap] Allocate code close to the binary

Calls >4gb may have pretty bad performance on 64bit processors that use
32bits to encode branch prediction. By passing in a function in the
binary as a hint to mmap it's more likely we'll be given an address
close to the binary. This may significantly improve performance on many
types of 64bit cores, especially those without hyperthreading.

Change-Id: Ia1f712a3a029e10cb0c6a0d1e2c4919bbb2854f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2726500
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73093}
parent 5defb206
......@@ -23,11 +23,15 @@ namespace internal {
static base::LazyInstance<CodeRangeAddressHint>::type code_range_address_hint =
LAZY_INSTANCE_INITIALIZER;
namespace {
void FunctionInStaticBinaryForAddressHint() {}
} // namespace
Address CodeRangeAddressHint::GetAddressHint(size_t code_range_size) {
base::MutexGuard guard(&mutex_);
auto it = recently_freed_.find(code_range_size);
if (it == recently_freed_.end() || it->second.empty()) {
return reinterpret_cast<Address>(GetRandomMmapAddr());
return FUNCTION_ADDR(&FunctionInStaticBinaryForAddressHint);
}
Address result = it->second.back();
it->second.pop_back();
......
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