Commit 2bfa1c37 authored by ishell@chromium.org's avatar ishell@chromium.org Committed by V8 LUCI CQ

[builtins] Allocate builtins PGO data in old space

... to please mksnapshot which expects the new space to be empty.

Bug: v8:10470
Change-Id: I7d5b62db138ef2e334581a8697d137cd13291d7c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3827877
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82440}
parent 924be695
......@@ -151,8 +151,8 @@ MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(
// iteration.
Handle<ArrayList> list(isolate_->heap()->basic_block_profiling_data(),
isolate_);
Handle<ArrayList> new_list =
ArrayList::Add(isolate_, list, on_heap_profiler_data);
Handle<ArrayList> new_list = ArrayList::Add(
isolate_, list, on_heap_profiler_data, AllocationType::kOld);
isolate_->heap()->SetBasicBlockProfilingData(new_list);
}
......@@ -2237,11 +2237,6 @@ Handle<FixedArray> Factory::CopyFixedArrayWithMap(Handle<FixedArray> array,
return CopyArrayWithMap(array, map);
}
Handle<FixedArray> Factory::CopyFixedArrayAndGrow(Handle<FixedArray> array,
int grow_by) {
return CopyArrayAndGrow(array, grow_by, AllocationType::kYoung);
}
Handle<WeakArrayList> Factory::NewUninitializedWeakArrayList(
int capacity, AllocationType allocation) {
DCHECK_LE(0, capacity);
......@@ -2266,6 +2261,12 @@ Handle<WeakArrayList> Factory::NewWeakArrayList(int capacity,
return result;
}
Handle<FixedArray> Factory::CopyFixedArrayAndGrow(Handle<FixedArray> array,
int grow_by,
AllocationType allocation) {
return CopyArrayAndGrow(array, grow_by, allocation);
}
Handle<WeakFixedArray> Factory::CopyWeakFixedArrayAndGrow(
Handle<WeakFixedArray> src, int grow_by) {
DCHECK(!src->IsTransitionArray()); // Compacted by GC, this code doesn't work
......
......@@ -496,8 +496,9 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
Handle<Map> map);
Handle<FixedArray> CopyFixedArrayAndGrow(Handle<FixedArray> array,
int grow_by);
Handle<FixedArray> CopyFixedArrayAndGrow(
Handle<FixedArray> array, int grow_by,
AllocationType allocation = AllocationType::kYoung);
Handle<WeakArrayList> NewWeakArrayList(
int capacity, AllocationType allocation = AllocationType::kYoung);
......
......@@ -458,9 +458,9 @@ class WeakArrayList::Iterator {
// underlying FixedArray starting at kFirstIndex.
class ArrayList : public TorqueGeneratedArrayList<ArrayList, FixedArray> {
public:
V8_EXPORT_PRIVATE static Handle<ArrayList> Add(Isolate* isolate,
Handle<ArrayList> array,
Handle<Object> obj);
V8_EXPORT_PRIVATE static Handle<ArrayList> Add(
Isolate* isolate, Handle<ArrayList> array, Handle<Object> obj,
AllocationType allocation = AllocationType::kYoung);
V8_EXPORT_PRIVATE static Handle<ArrayList> Add(Isolate* isolate,
Handle<ArrayList> array,
Handle<Object> obj1,
......@@ -505,8 +505,9 @@ class ArrayList : public TorqueGeneratedArrayList<ArrayList, FixedArray> {
DECL_VERIFIER(ArrayList)
private:
static Handle<ArrayList> EnsureSpace(Isolate* isolate,
Handle<ArrayList> array, int length);
static Handle<ArrayList> EnsureSpace(
Isolate* isolate, Handle<ArrayList> array, int length,
AllocationType allocation = AllocationType::kYoung);
TQ_OBJECT_CONSTRUCTORS(ArrayList)
};
......
......@@ -4034,9 +4034,10 @@ void FixedArray::CopyTo(int pos, FixedArray dest, int dest_pos, int len) const {
// static
Handle<ArrayList> ArrayList::Add(Isolate* isolate, Handle<ArrayList> array,
Handle<Object> obj) {
Handle<Object> obj,
AllocationType allocation) {
int length = array->Length();
array = EnsureSpace(isolate, array, length + 1);
array = EnsureSpace(isolate, array, length + 1, allocation);
// Check that GC didn't remove elements from the array.
DCHECK_EQ(array->Length(), length);
{
......@@ -4101,14 +4102,15 @@ Handle<FixedArray> ArrayList::Elements(Isolate* isolate,
namespace {
Handle<FixedArray> EnsureSpaceInFixedArray(Isolate* isolate,
Handle<FixedArray> array,
int length) {
Handle<FixedArray> array, int length,
AllocationType allocation) {
int capacity = array->length();
if (capacity < length) {
int new_capacity = length;
new_capacity = new_capacity + std::max(new_capacity / 2, 2);
int grow_by = new_capacity - capacity;
array = isolate->factory()->CopyFixedArrayAndGrow(array, grow_by);
array =
isolate->factory()->CopyFixedArrayAndGrow(array, grow_by, allocation);
}
return array;
}
......@@ -4117,10 +4119,11 @@ Handle<FixedArray> EnsureSpaceInFixedArray(Isolate* isolate,
// static
Handle<ArrayList> ArrayList::EnsureSpace(Isolate* isolate,
Handle<ArrayList> array, int length) {
Handle<ArrayList> array, int length,
AllocationType allocation) {
DCHECK_LT(0, length);
auto new_array = Handle<ArrayList>::cast(
EnsureSpaceInFixedArray(isolate, array, kFirstIndex + length));
auto new_array = Handle<ArrayList>::cast(EnsureSpaceInFixedArray(
isolate, array, kFirstIndex + length, allocation));
DCHECK_EQ(array->Length(), new_array->Length());
return new_array;
}
......@@ -4402,8 +4405,9 @@ Handle<RegExpMatchInfo> RegExpMatchInfo::ReserveCaptures(
int capture_register_count =
JSRegExp::RegistersForCaptureCount(capture_count);
const int required_length = kFirstCaptureIndex + capture_register_count;
Handle<RegExpMatchInfo> result = Handle<RegExpMatchInfo>::cast(
EnsureSpaceInFixedArray(isolate, match_info, required_length));
Handle<RegExpMatchInfo> result =
Handle<RegExpMatchInfo>::cast(EnsureSpaceInFixedArray(
isolate, match_info, required_length, AllocationType::kYoung));
result->SetNumberOfCaptureRegisters(capture_register_count);
return result;
}
......
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