Commit 2a09af7e authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[heap] Make Heap::MaxRegularHeapObjectSize an inlineable constexpr

Bug: v8:11263
Change-Id: Ia86ae814434aed9795f98d80e987a1ed10fa9a1f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2821540Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73991}
parent c331839a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "src/compiler/access-builder.h" #include "src/compiler/access-builder.h"
#include "src/compiler/allocation-builder.h" #include "src/compiler/allocation-builder.h"
#include "src/heap/heap-inl.h"
#include "src/objects/arguments-inl.h" #include "src/objects/arguments-inl.h"
#include "src/objects/map-inl.h" #include "src/objects/map-inl.h"
...@@ -14,6 +15,16 @@ namespace v8 { ...@@ -14,6 +15,16 @@ namespace v8 {
namespace internal { namespace internal {
namespace compiler { namespace compiler {
void AllocationBuilder::Allocate(int size, AllocationType allocation,
Type type) {
DCHECK_LE(size, Heap::MaxRegularHeapObjectSize(allocation));
effect_ = graph()->NewNode(
common()->BeginRegion(RegionObservability::kNotObservable), effect_);
allocation_ = graph()->NewNode(simplified()->Allocate(type, allocation),
jsgraph()->Constant(size), effect_, control_);
effect_ = allocation_;
}
void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) { void AllocationBuilder::AllocateContext(int variadic_part_length, MapRef map) {
DCHECK(base::IsInRange(map.instance_type(), FIRST_CONTEXT_TYPE, DCHECK(base::IsInRange(map.instance_type(), FIRST_CONTEXT_TYPE,
LAST_CONTEXT_TYPE)); LAST_CONTEXT_TYPE));
......
...@@ -25,16 +25,9 @@ class AllocationBuilder final { ...@@ -25,16 +25,9 @@ class AllocationBuilder final {
control_(control) {} control_(control) {}
// Primitive allocation of static size. // Primitive allocation of static size.
void Allocate(int size, AllocationType allocation = AllocationType::kYoung, inline void Allocate(int size,
Type type = Type::Any()) { AllocationType allocation = AllocationType::kYoung,
DCHECK_LE(size, Heap::MaxRegularHeapObjectSize(allocation)); Type type = Type::Any());
effect_ = graph()->NewNode(
common()->BeginRegion(RegionObservability::kNotObservable), effect_);
allocation_ =
graph()->NewNode(simplified()->Allocate(type, allocation),
jsgraph()->Constant(size), effect_, control_);
effect_ = allocation_;
}
// Primitive store into a field. // Primitive store into a field.
void Store(const FieldAccess& access, Node* value) { void Store(const FieldAccess& access, Node* value) {
......
...@@ -85,6 +85,15 @@ BytecodeFlushMode Heap::GetBytecodeFlushMode(Isolate* isolate) { ...@@ -85,6 +85,15 @@ BytecodeFlushMode Heap::GetBytecodeFlushMode(Isolate* isolate) {
return BytecodeFlushMode::kDoNotFlushBytecode; return BytecodeFlushMode::kDoNotFlushBytecode;
} }
// static
constexpr int Heap::MaxRegularHeapObjectSize(AllocationType allocation) {
if (!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
(allocation == AllocationType::kCode)) {
return MemoryChunkLayout::MaxRegularCodeObjectSize();
}
return kMaxRegularHeapObjectSize;
}
Isolate* Heap::isolate() { Isolate* Heap::isolate() {
return reinterpret_cast<Isolate*>( return reinterpret_cast<Isolate*>(
reinterpret_cast<intptr_t>(this) - reinterpret_cast<intptr_t>(this) -
......
...@@ -4851,15 +4851,6 @@ bool Heap::AllocationLimitOvershotByLargeMargin() { ...@@ -4851,15 +4851,6 @@ bool Heap::AllocationLimitOvershotByLargeMargin() {
return v8_overshoot >= v8_margin || global_overshoot >= global_margin; return v8_overshoot >= v8_margin || global_overshoot >= global_margin;
} }
// static
int Heap::MaxRegularHeapObjectSize(AllocationType allocation) {
if (!V8_ENABLE_THIRD_PARTY_HEAP_BOOL &&
(allocation == AllocationType::kCode)) {
return MemoryChunkLayout::MaxRegularCodeObjectSize();
}
return kMaxRegularHeapObjectSize;
}
bool Heap::ShouldOptimizeForLoadTime() { bool Heap::ShouldOptimizeForLoadTime() {
return isolate()->rail_mode() == PERFORMANCE_LOAD && return isolate()->rail_mode() == PERFORMANCE_LOAD &&
!AllocationLimitOvershotByLargeMargin() && !AllocationLimitOvershotByLargeMargin() &&
......
...@@ -1390,7 +1390,7 @@ class Heap { ...@@ -1390,7 +1390,7 @@ class Heap {
// which the size of the allocatable space per V8 page may depend on the OS // which the size of the allocatable space per V8 page may depend on the OS
// page size at runtime. You may use kMaxRegularHeapObjectSize as a constant // page size at runtime. You may use kMaxRegularHeapObjectSize as a constant
// instead if you know the allocation isn't in the code spaces. // instead if you know the allocation isn't in the code spaces.
V8_EXPORT_PRIVATE static int MaxRegularHeapObjectSize( V8_EXPORT_PRIVATE static constexpr int MaxRegularHeapObjectSize(
AllocationType allocation); AllocationType allocation);
// =========================================================================== // ===========================================================================
......
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