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