Commit c693e005 authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[Heap] Remove more unnecessary allocation flags

Discussing with Toon, we've decided that these flags are no longer needed.

Bug: v8:9714
Change-Id: Ic5ae8b4c0b2f470fad915ada8fec753a5d7e50ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1801844
Commit-Queue: Victor Gomes <victorgomes@google.com>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@google.com>
Cr-Commit-Position: refs/heads/master@{#63765}
parent 9d2591a6
......@@ -575,16 +575,15 @@ Handle<ObjectBoilerplateDescription> Factory::NewObjectBoilerplateDescription(
return description;
}
Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int length,
AllocationType allocation) {
Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int length) {
if (length == 0) return empty_fixed_array();
if (length < 0 || length > FixedDoubleArray::kMaxLength) {
isolate()->heap()->FatalProcessOutOfMemory("invalid array length");
}
int size = FixedDoubleArray::SizeFor(length);
Map map = *fixed_double_array_map();
HeapObject result =
AllocateRawWithImmortalMap(size, allocation, map, kDoubleAligned);
HeapObject result = AllocateRawWithImmortalMap(size, AllocationType::kYoung,
map, kDoubleAligned);
Handle<FixedDoubleArray> array(FixedDoubleArray::cast(result), isolate());
array->set_length(length);
return array;
......@@ -592,8 +591,7 @@ Handle<FixedArrayBase> Factory::NewFixedDoubleArray(int length,
Handle<FixedArrayBase> Factory::NewFixedDoubleArrayWithHoles(int length) {
DCHECK_LE(0, length);
Handle<FixedArrayBase> array =
NewFixedDoubleArray(length, AllocationType::kYoung);
Handle<FixedArrayBase> array = NewFixedDoubleArray(length);
if (length > 0) {
Handle<FixedDoubleArray>::cast(array)->FillWithHoles(0, length);
}
......@@ -1845,15 +1843,13 @@ Handle<PropertyCell> Factory::NewPropertyCell(Handle<Name> name,
}
Handle<DescriptorArray> Factory::NewDescriptorArray(int number_of_descriptors,
int slack,
AllocationType allocation) {
DCHECK(Heap::IsRegularObjectAllocation(allocation));
int slack) {
int number_of_all_descriptors = number_of_descriptors + slack;
// Zero-length case must be handled outside.
DCHECK_LT(0, number_of_all_descriptors);
int size = DescriptorArray::SizeFor(number_of_all_descriptors);
HeapObject obj =
isolate()->heap()->AllocateRawWithRetryOrFail(size, allocation);
isolate()->heap()->AllocateRawWithRetryOrFail(size, AllocationType::kOld);
obj.set_map_after_allocation(*descriptor_array_map(), SKIP_WRITE_BARRIER);
DescriptorArray array = DescriptorArray::cast(obj);
array.Initialize(*empty_enum_cache(), *undefined_value(),
......@@ -2095,9 +2091,8 @@ Handle<FixedArray> Factory::CopyFixedArrayWithMap(Handle<FixedArray> array,
}
Handle<FixedArray> Factory::CopyFixedArrayAndGrow(Handle<FixedArray> array,
int grow_by,
AllocationType allocation) {
return CopyArrayAndGrow(array, grow_by, allocation);
int grow_by) {
return CopyArrayAndGrow(array, grow_by, AllocationType::kYoung);
}
Handle<WeakFixedArray> Factory::CopyWeakFixedArrayAndGrow(
......@@ -2175,8 +2170,8 @@ Handle<FixedDoubleArray> Factory::CopyFixedDoubleArray(
Handle<FixedDoubleArray> array) {
int len = array->length();
if (len == 0) return array;
Handle<FixedDoubleArray> result = Handle<FixedDoubleArray>::cast(
NewFixedDoubleArray(len, AllocationType::kYoung));
Handle<FixedDoubleArray> result =
Handle<FixedDoubleArray>::cast(NewFixedDoubleArray(len));
Heap::CopyBlock(
result->address() + FixedDoubleArray::kLengthOffset,
array->address() + FixedDoubleArray::kLengthOffset,
......
......@@ -177,8 +177,7 @@ class V8_EXPORT_PRIVATE Factory {
// Allocate a new uninitialized fixed double array.
// The function returns a pre-allocated empty fixed array for length = 0,
// so the return type must be the general fixed array class.
Handle<FixedArrayBase> NewFixedDoubleArray(
int length, AllocationType allocation = AllocationType::kYoung);
Handle<FixedArrayBase> NewFixedDoubleArray(int length);
// Allocate a new fixed double array with hole values.
Handle<FixedArrayBase> NewFixedDoubleArrayWithHoles(int size);
......@@ -482,9 +481,8 @@ class V8_EXPORT_PRIVATE Factory {
Handle<FeedbackCell> NewOneClosureCell(Handle<HeapObject> value);
Handle<FeedbackCell> NewManyClosuresCell(Handle<HeapObject> value);
Handle<DescriptorArray> NewDescriptorArray(
int number_of_entries, int slack = 0,
AllocationType allocation = AllocationType::kYoung);
Handle<DescriptorArray> NewDescriptorArray(int number_of_entries,
int slack = 0);
Handle<TransitionArray> NewTransitionArray(int number_of_transitions,
int slack = 0);
......@@ -521,9 +519,8 @@ class V8_EXPORT_PRIVATE Factory {
Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
Handle<Map> map);
Handle<FixedArray> CopyFixedArrayAndGrow(
Handle<FixedArray> array, int grow_by,
AllocationType allocation = AllocationType::kYoung);
Handle<FixedArray> CopyFixedArrayAndGrow(Handle<FixedArray> array,
int grow_by);
Handle<WeakFixedArray> CopyWeakFixedArrayAndGrow(Handle<WeakFixedArray> array,
int grow_by);
......
......@@ -16,9 +16,8 @@ namespace internal {
void MathRandom::InitializeContext(Isolate* isolate,
Handle<Context> native_context) {
Handle<FixedDoubleArray> cache =
Handle<FixedDoubleArray>::cast(isolate->factory()->NewFixedDoubleArray(
kCacheSize, AllocationType::kOld));
Handle<FixedDoubleArray> cache = Handle<FixedDoubleArray>::cast(
isolate->factory()->NewFixedDoubleArray(kCacheSize));
for (int i = 0; i < kCacheSize; i++) cache->set(i, 0);
native_context->set_math_random_cache(*cache);
Handle<PodArray<State>> pod =
......
......@@ -120,9 +120,9 @@ class DescriptorArray : public HeapObject {
// Allocates a DescriptorArray, but returns the singleton
// empty descriptor array object if number_of_descriptors is 0.
V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(
Isolate* isolate, int nof_descriptors, int slack,
AllocationType allocation = AllocationType::kYoung);
V8_EXPORT_PRIVATE static Handle<DescriptorArray> Allocate(Isolate* isolate,
int nof_descriptors,
int slack);
void Initialize(EnumCache enum_cache, HeapObject undefined_value,
int nof_descriptors, int slack);
......
......@@ -3354,8 +3354,8 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
}
// Allocate the instance descriptor.
Handle<DescriptorArray> descriptors = DescriptorArray::Allocate(
isolate, instance_descriptor_length, 0, AllocationType::kOld);
Handle<DescriptorArray> descriptors =
DescriptorArray::Allocate(isolate, instance_descriptor_length, 0);
int number_of_allocated_fields =
number_of_fields + unused_property_fields - inobject_props;
......
......@@ -4146,12 +4146,10 @@ Handle<FrameArray> FrameArray::EnsureSpace(Isolate* isolate,
Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate,
int nof_descriptors,
int slack,
AllocationType allocation) {
int slack) {
return nof_descriptors + slack == 0
? isolate->factory()->empty_descriptor_array()
: isolate->factory()->NewDescriptorArray(nof_descriptors, slack,
allocation);
: isolate->factory()->NewDescriptorArray(nof_descriptors, slack);
}
void DescriptorArray::Initialize(EnumCache enum_cache,
......
......@@ -635,8 +635,8 @@ Handle<Code> WasmDebugInfo::GetCWasmEntry(Handle<WasmDebugInfo> debug_info,
if (index == -1) {
index = static_cast<int32_t>(map->FindOrInsert(*sig));
if (index == entries->length()) {
entries = isolate->factory()->CopyFixedArrayAndGrow(
entries, entries->length(), AllocationType::kOld);
entries =
isolate->factory()->CopyFixedArrayAndGrow(entries, entries->length());
debug_info->set_c_wasm_entries(*entries);
}
DCHECK(entries->get(index).IsUndefined(isolate));
......
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