Commit 700665b6 authored by Steve Blackburn's avatar Steve Blackburn Committed by Commit Bot

Refactor code ranges for TPH

Code ranges are currently accessed from outside the heap via an
internal structure of the heap.  This change lifts the accessor
function a level higher.  This should have no cost, but will
maintain abstraction better and allow the TPH interface to work
more readily.

Bug: v8:9533
Change-Id: I154d93ce46f5137b3e3b7ecc6bed7e5b8b0343a6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2039351Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Steve Blackburn <steveblackburn@google.com>
Cr-Commit-Position: refs/heads/master@{#66152}
parent d3eabf79
...@@ -42,8 +42,7 @@ AssemblerOptions BuiltinAssemblerOptions(Isolate* isolate, ...@@ -42,8 +42,7 @@ AssemblerOptions BuiltinAssemblerOptions(Isolate* isolate,
return options; return options;
} }
const base::AddressRegion& code_range = const base::AddressRegion& code_range = isolate->heap()->code_range();
isolate->heap()->memory_allocator()->code_range();
bool pc_relative_calls_fit_in_code_range = bool pc_relative_calls_fit_in_code_range =
!code_range.is_empty() && !code_range.is_empty() &&
std::ceil(static_cast<float>(code_range.size() / MB)) <= std::ceil(static_cast<float>(code_range.size() / MB)) <=
......
...@@ -70,8 +70,7 @@ AssemblerOptions AssemblerOptions::Default(Isolate* isolate) { ...@@ -70,8 +70,7 @@ AssemblerOptions AssemblerOptions::Default(Isolate* isolate) {
#endif #endif
options.inline_offheap_trampolines &= !generating_embedded_builtin; options.inline_offheap_trampolines &= !generating_embedded_builtin;
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64
const base::AddressRegion& code_range = const base::AddressRegion& code_range = isolate->heap()->code_range();
isolate->heap()->memory_allocator()->code_range();
DCHECK_IMPLIES(code_range.begin() != kNullAddress, !code_range.is_empty()); DCHECK_IMPLIES(code_range.begin() != kNullAddress, !code_range.is_empty());
options.code_range_start = code_range.begin(); options.code_range_start = code_range.begin();
#endif #endif
......
...@@ -155,6 +155,14 @@ size_t Heap::NewSpaceAllocationCounter() { ...@@ -155,6 +155,14 @@ size_t Heap::NewSpaceAllocationCounter() {
return new_space_allocation_counter_ + new_space()->AllocatedSinceLastGC(); return new_space_allocation_counter_ + new_space()->AllocatedSinceLastGC();
} }
inline const base::AddressRegion& Heap::code_range() {
#ifdef V8_ENABLE_THIRD_PARTY_HEAP
return tp_heap_->GetCodeRange();
#else
return memory_allocator_->code_range();
#endif
}
AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type, AllocationResult Heap::AllocateRaw(int size_in_bytes, AllocationType type,
AllocationOrigin origin, AllocationOrigin origin,
AllocationAlignment alignment) { AllocationAlignment alignment) {
......
...@@ -755,6 +755,8 @@ class Heap { ...@@ -755,6 +755,8 @@ class Heap {
return array_buffer_sweeper_.get(); return array_buffer_sweeper_.get();
} }
const base::AddressRegion& code_range();
// =========================================================================== // ===========================================================================
// Root set access. ========================================================== // Root set access. ==========================================================
// =========================================================================== // ===========================================================================
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_HEAP_THIRD_PARTY_HEAP_API_H_ #define V8_HEAP_THIRD_PARTY_HEAP_API_H_
#include "include/v8.h" #include "include/v8.h"
#include "src/base/address-region.h"
#include "src/heap/heap.h" #include "src/heap/heap.h"
namespace v8 { namespace v8 {
...@@ -23,6 +24,8 @@ class Heap { ...@@ -23,6 +24,8 @@ class Heap {
Address GetObjectFromInnerPointer(Address inner_pointer); Address GetObjectFromInnerPointer(Address inner_pointer);
const base::AddressRegion& GetCodeRange();
static bool InCodeSpace(Address address); static bool InCodeSpace(Address address);
static bool InReadOnlySpace(Address address); static bool InReadOnlySpace(Address address);
......
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