Commit 905d38f5 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Ensure off-thread allocations are pretenured

Squash a couple of remaining places where compilation finalization was
allocating new-space objects.

Bug: chromium:1011762
Change-Id: Ie0462eed422016f860146724a06dd2f1963bd88e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2110019
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66807}
parent 3fb75906
......@@ -654,7 +654,7 @@ Handle<DescriptorArray> FactoryBase<Impl>::NewDescriptorArray(
DCHECK_LT(0, number_of_all_descriptors);
int size = DescriptorArray::SizeFor(number_of_all_descriptors);
HeapObject obj = AllocateRawWithImmortalMap(
size, AllocationType::kYoung, read_only_roots().descriptor_array_map());
size, allocation, read_only_roots().descriptor_array_map());
DescriptorArray array = DescriptorArray::cast(obj);
array.Initialize(read_only_roots().empty_enum_cache(),
read_only_roots().undefined_value(), number_of_descriptors,
......
......@@ -874,7 +874,7 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
case State::kError:
return MaybeHandle<BigInt>();
case State::kZero:
return BigInt::Zero(this->isolate());
return BigInt::Zero(this->isolate(), allocation_type());
case State::kDone:
return BigInt::Finalize<Isolate>(result_, this->negative());
case State::kEmpty:
......@@ -891,13 +891,9 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
// Optimization opportunity: Would it makes sense to scan for trailing
// junk before allocating the result?
int charcount = this->length() - this->cursor();
// For literals, we pretenure the allocated BigInt, since it's about
// to be stored in the interpreter's constants array.
AllocationType allocation = behavior_ == Behavior::kLiteral
? AllocationType::kOld
: AllocationType::kYoung;
MaybeHandle<FreshlyAllocatedBigInt> maybe = BigInt::AllocateFor(
this->isolate(), this->radix(), charcount, kDontThrow, allocation);
MaybeHandle<FreshlyAllocatedBigInt> maybe =
BigInt::AllocateFor(this->isolate(), this->radix(), charcount,
kDontThrow, allocation_type());
if (!maybe.ToHandle(&result_)) {
this->set_state(State::kError);
}
......@@ -908,6 +904,13 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
static_cast<uintptr_t>(part));
}
AllocationType allocation_type() {
// For literals, we pretenure the allocated BigInt, since it's about
// to be stored in the interpreter's constants array.
return behavior_ == Behavior::kLiteral ? AllocationType::kOld
: AllocationType::kYoung;
}
private:
Handle<FreshlyAllocatedBigInt> result_;
Behavior behavior_;
......
......@@ -61,9 +61,12 @@ class MutableBigInt : public FreshlyAllocatedBigInt {
static Handle<MutableBigInt> Copy(Isolate* isolate,
Handle<BigIntBase> source);
template <typename LocalIsolate>
static Handle<BigInt> Zero(LocalIsolate* isolate) {
static Handle<BigInt> Zero(
LocalIsolate* isolate,
AllocationType allocation = AllocationType::kYoung) {
// TODO(jkummerow): Consider caching a canonical zero-BigInt.
return MakeImmutable<LocalIsolate>(New(isolate, 0).ToHandleChecked());
return MakeImmutable<LocalIsolate>(
New(isolate, 0, allocation).ToHandleChecked());
}
static Handle<MutableBigInt> Cast(Handle<FreshlyAllocatedBigInt> bigint) {
......@@ -412,12 +415,13 @@ void MutableBigInt::Canonicalize(MutableBigInt result) {
}
template <typename LocalIsolate>
Handle<BigInt> BigInt::Zero(LocalIsolate* isolate) {
return MutableBigInt::Zero(isolate);
Handle<BigInt> BigInt::Zero(LocalIsolate* isolate, AllocationType allocation) {
return MutableBigInt::Zero(isolate, allocation);
}
template Handle<BigInt> BigInt::Zero<Isolate>(Isolate* isolate);
template Handle<BigInt> BigInt::Zero<Isolate>(Isolate* isolate,
AllocationType allocation);
template Handle<BigInt> BigInt::Zero<OffThreadIsolate>(
OffThreadIsolate* isolate);
OffThreadIsolate* isolate, AllocationType allocation);
Handle<BigInt> BigInt::UnaryMinus(Isolate* isolate, Handle<BigInt> x) {
// Special case: There is no -0n.
......
......@@ -245,7 +245,8 @@ class BigInt : public BigIntBase {
// Special functions for StringToBigIntHelper:
template <typename LocalIsolate>
static Handle<BigInt> Zero(LocalIsolate* isolate);
static Handle<BigInt> Zero(LocalIsolate* isolate, AllocationType allocation =
AllocationType::kYoung);
template <typename LocalIsolate>
static MaybeHandle<FreshlyAllocatedBigInt> AllocateFor(
LocalIsolate* isolate, int radix, int charcount, ShouldThrow should_throw,
......
......@@ -301,17 +301,20 @@ class ObjectDescriptor {
AllocationType::kOld);
} else {
descriptor_array_template_ = DescriptorArray::Allocate(
isolate, 0, property_count_ + property_slack_);
isolate, 0, property_count_ + property_slack_,
AllocationType::kOld);
}
}
elements_dictionary_template_ =
element_count_ || computed_count_
? NumberDictionary::New(isolate, element_count_ + computed_count_)
? NumberDictionary::New(isolate, element_count_ + computed_count_,
AllocationType::kOld)
: factory->empty_slow_element_dictionary();
computed_properties_ = computed_count_
? factory->NewFixedArray(computed_count_)
: factory->empty_fixed_array();
computed_properties_ =
computed_count_
? factory->NewFixedArray(computed_count_, AllocationType::kOld)
: factory->empty_fixed_array();
temp_handle_ = handle(Smi::zero(), isolate);
}
......@@ -570,8 +573,8 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
static_desc.Finalize(isolate);
instance_desc.Finalize(isolate);
Handle<ClassBoilerplate> class_boilerplate =
Handle<ClassBoilerplate>::cast(factory->NewFixedArray(kBoileplateLength));
Handle<ClassBoilerplate> class_boilerplate = Handle<ClassBoilerplate>::cast(
factory->NewFixedArray(kBoileplateLength, AllocationType::kOld));
class_boilerplate->set_flags(0);
class_boilerplate->set_install_class_name_accessor(
......
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