[ext-code-space][arm64] Increase max code range size to 256Mb
... when external code space is enabled. Since we are using near jump/call instruction only for [tail]calling builtins, we can increase the code range as long as we can guarantee that the remapped builtins are always reachable. We can do that by remapping embedded builtins into the middle of the code range. Bug: v8:11880, v8:12689 Change-Id: I69901634586df3c35618ea7bd5311102e4675f6c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3669107 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/main@{#80810}
This commit is contained in:
parent
010e15a7e3
commit
3ba66cd26a
@ -304,7 +304,8 @@ constexpr bool kPlatformRequiresCodeRange = true;
|
||||
constexpr size_t kMaximalCodeRangeSize = 512 * MB;
|
||||
constexpr size_t kMinExpectedOSPageSize = 64 * KB; // OS page on PPC Linux
|
||||
#elif V8_TARGET_ARCH_ARM64
|
||||
constexpr size_t kMaximalCodeRangeSize = 128 * MB;
|
||||
constexpr size_t kMaximalCodeRangeSize =
|
||||
V8_EXTERNAL_CODE_SPACE_BOOL ? 256 * MB : 128 * MB;
|
||||
constexpr size_t kMinExpectedOSPageSize = 4 * KB; // OS page.
|
||||
#else
|
||||
constexpr size_t kMaximalCodeRangeSize =
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/lazy-instance.h"
|
||||
#include "src/codegen/constants-arch.h"
|
||||
#include "src/common/globals.h"
|
||||
#include "src/flags/flags.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
@ -204,8 +205,13 @@ uint8_t* CodeRange::RemapEmbeddedBuiltins(Isolate* isolate,
|
||||
size_t allocate_code_size =
|
||||
RoundUp(embedded_blob_code_size, kAllocatePageSize);
|
||||
|
||||
// Allocate the re-embedded code blob in the end.
|
||||
void* hint = reinterpret_cast<void*>(code_region.end() - allocate_code_size);
|
||||
// Allocate the re-embedded code blob in such a way that it will be reachable
|
||||
// by PC-relative addressing from biggest possible region.
|
||||
const size_t max_pc_relative_code_range = kMaxPCRelativeCodeRangeInMB * MB;
|
||||
size_t hint_offset =
|
||||
std::min(max_pc_relative_code_range, code_region.size()) -
|
||||
allocate_code_size;
|
||||
void* hint = reinterpret_cast<void*>(code_region.begin() + hint_offset);
|
||||
|
||||
embedded_blob_code_copy =
|
||||
reinterpret_cast<uint8_t*>(page_allocator()->AllocatePages(
|
||||
@ -216,6 +222,25 @@ uint8_t* CodeRange::RemapEmbeddedBuiltins(Isolate* isolate,
|
||||
V8::FatalProcessOutOfMemory(
|
||||
isolate, "Can't allocate space for re-embedded builtins");
|
||||
}
|
||||
CHECK_EQ(embedded_blob_code_copy, hint);
|
||||
|
||||
if (code_region.size() > max_pc_relative_code_range) {
|
||||
// The re-embedded code blob might not be reachable from the end part of
|
||||
// the code range, so ensure that code pages will never be allocated in
|
||||
// the "unreachable" area.
|
||||
Address unreachable_start =
|
||||
reinterpret_cast<Address>(embedded_blob_code_copy) +
|
||||
max_pc_relative_code_range;
|
||||
|
||||
if (code_region.contains(unreachable_start)) {
|
||||
size_t unreachable_size = code_region.end() - unreachable_start;
|
||||
|
||||
void* result = page_allocator()->AllocatePages(
|
||||
reinterpret_cast<void*>(unreachable_start), unreachable_size,
|
||||
kAllocatePageSize, PageAllocator::kNoAccess);
|
||||
CHECK_EQ(reinterpret_cast<Address>(result), unreachable_start);
|
||||
}
|
||||
}
|
||||
|
||||
size_t code_size = RoundUp(embedded_blob_code_size, kCommitPageSize);
|
||||
if constexpr (base::OS::IsRemapPageSupported()) {
|
||||
|
Loading…
Reference in New Issue
Block a user