Commit ae340e19 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[cleanup] Remove right trimming from class boilerplate allocation

During class boilerplate allocation, we were overestimating the number
of computed properties before allocating the computed property array,
and the array after. But, we can reasonably easily get an exact size
for the computed properties array, and avoid the right trimming
entirely.

This will simplify off-thread class boilerplate allocation, where the
off-thread heap doesn't currently implement right trimming.

Bug: chromium:1011762
Change-Id: Icf450340aa4e215c2063f4dd964ca7b80ef033c3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2083029
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66538}
parent cdec094f
......@@ -299,11 +299,9 @@ class ObjectDescriptor {
? NumberDictionary::New(isolate, element_count_ + computed_count_)
: factory->empty_slow_element_dictionary();
computed_properties_ =
computed_count_
? factory->NewFixedArray(computed_count_ *
ClassBoilerplate::kFullComputedEntrySize)
: factory->empty_fixed_array();
computed_properties_ = computed_count_
? factory->NewFixedArray(computed_count_)
: factory->empty_fixed_array();
temp_handle_ = handle(Smi::zero(), isolate);
}
......@@ -366,10 +364,9 @@ class ObjectDescriptor {
void Finalize(Isolate* isolate) {
if (HasDictionaryProperties()) {
DCHECK_EQ(current_computed_index_, computed_properties_->length());
properties_dictionary_template_->set_next_enumeration_index(
next_enumeration_index_);
computed_properties_ = FixedArray::ShrinkOrEmpty(
isolate, computed_properties_, current_computed_index_);
} else {
DCHECK(descriptor_array_template_->IsSortedNoDuplicates());
}
......@@ -420,7 +417,9 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
ObjectDescriptor& desc =
property->is_static() ? static_desc : instance_desc;
if (property->is_computed_name()) {
desc.IncComputedCount();
if (property->kind() != ClassLiteral::Property::FIELD) {
desc.IncComputedCount();
}
} else {
if (property->key()->AsLiteral()->IsPropertyName()) {
desc.IncPropertiesCount();
......
......@@ -144,8 +144,6 @@ class ClassBoilerplate : public FixedArray {
kBoileplateLength // last element
};
static const int kFullComputedEntrySize = 2;
private:
DECL_INT_ACCESSORS(flags)
......
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