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( ...@@ -654,7 +654,7 @@ Handle<DescriptorArray> FactoryBase<Impl>::NewDescriptorArray(
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 = AllocateRawWithImmortalMap( 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); DescriptorArray array = DescriptorArray::cast(obj);
array.Initialize(read_only_roots().empty_enum_cache(), array.Initialize(read_only_roots().empty_enum_cache(),
read_only_roots().undefined_value(), number_of_descriptors, read_only_roots().undefined_value(), number_of_descriptors,
......
...@@ -874,7 +874,7 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> { ...@@ -874,7 +874,7 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
case State::kError: case State::kError:
return MaybeHandle<BigInt>(); return MaybeHandle<BigInt>();
case State::kZero: case State::kZero:
return BigInt::Zero(this->isolate()); return BigInt::Zero(this->isolate(), allocation_type());
case State::kDone: case State::kDone:
return BigInt::Finalize<Isolate>(result_, this->negative()); return BigInt::Finalize<Isolate>(result_, this->negative());
case State::kEmpty: case State::kEmpty:
...@@ -891,13 +891,9 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> { ...@@ -891,13 +891,9 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
// Optimization opportunity: Would it makes sense to scan for trailing // Optimization opportunity: Would it makes sense to scan for trailing
// junk before allocating the result? // junk before allocating the result?
int charcount = this->length() - this->cursor(); int charcount = this->length() - this->cursor();
// For literals, we pretenure the allocated BigInt, since it's about MaybeHandle<FreshlyAllocatedBigInt> maybe =
// to be stored in the interpreter's constants array. BigInt::AllocateFor(this->isolate(), this->radix(), charcount,
AllocationType allocation = behavior_ == Behavior::kLiteral kDontThrow, allocation_type());
? AllocationType::kOld
: AllocationType::kYoung;
MaybeHandle<FreshlyAllocatedBigInt> maybe = BigInt::AllocateFor(
this->isolate(), this->radix(), charcount, kDontThrow, allocation);
if (!maybe.ToHandle(&result_)) { if (!maybe.ToHandle(&result_)) {
this->set_state(State::kError); this->set_state(State::kError);
} }
...@@ -908,6 +904,13 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> { ...@@ -908,6 +904,13 @@ class StringToBigIntHelper : public StringToIntHelper<LocalIsolate> {
static_cast<uintptr_t>(part)); 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: private:
Handle<FreshlyAllocatedBigInt> result_; Handle<FreshlyAllocatedBigInt> result_;
Behavior behavior_; Behavior behavior_;
......
...@@ -61,9 +61,12 @@ class MutableBigInt : public FreshlyAllocatedBigInt { ...@@ -61,9 +61,12 @@ class MutableBigInt : public FreshlyAllocatedBigInt {
static Handle<MutableBigInt> Copy(Isolate* isolate, static Handle<MutableBigInt> Copy(Isolate* isolate,
Handle<BigIntBase> source); Handle<BigIntBase> source);
template <typename LocalIsolate> 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. // 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) { static Handle<MutableBigInt> Cast(Handle<FreshlyAllocatedBigInt> bigint) {
...@@ -412,12 +415,13 @@ void MutableBigInt::Canonicalize(MutableBigInt result) { ...@@ -412,12 +415,13 @@ void MutableBigInt::Canonicalize(MutableBigInt result) {
} }
template <typename LocalIsolate> template <typename LocalIsolate>
Handle<BigInt> BigInt::Zero(LocalIsolate* isolate) { Handle<BigInt> BigInt::Zero(LocalIsolate* isolate, AllocationType allocation) {
return MutableBigInt::Zero(isolate); 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>( template Handle<BigInt> BigInt::Zero<OffThreadIsolate>(
OffThreadIsolate* isolate); OffThreadIsolate* isolate, AllocationType allocation);
Handle<BigInt> BigInt::UnaryMinus(Isolate* isolate, Handle<BigInt> x) { Handle<BigInt> BigInt::UnaryMinus(Isolate* isolate, Handle<BigInt> x) {
// Special case: There is no -0n. // Special case: There is no -0n.
......
...@@ -245,7 +245,8 @@ class BigInt : public BigIntBase { ...@@ -245,7 +245,8 @@ class BigInt : public BigIntBase {
// Special functions for StringToBigIntHelper: // Special functions for StringToBigIntHelper:
template <typename LocalIsolate> template <typename LocalIsolate>
static Handle<BigInt> Zero(LocalIsolate* isolate); static Handle<BigInt> Zero(LocalIsolate* isolate, AllocationType allocation =
AllocationType::kYoung);
template <typename LocalIsolate> template <typename LocalIsolate>
static MaybeHandle<FreshlyAllocatedBigInt> AllocateFor( static MaybeHandle<FreshlyAllocatedBigInt> AllocateFor(
LocalIsolate* isolate, int radix, int charcount, ShouldThrow should_throw, LocalIsolate* isolate, int radix, int charcount, ShouldThrow should_throw,
......
...@@ -301,16 +301,19 @@ class ObjectDescriptor { ...@@ -301,16 +301,19 @@ class ObjectDescriptor {
AllocationType::kOld); AllocationType::kOld);
} else { } else {
descriptor_array_template_ = DescriptorArray::Allocate( descriptor_array_template_ = DescriptorArray::Allocate(
isolate, 0, property_count_ + property_slack_); isolate, 0, property_count_ + property_slack_,
AllocationType::kOld);
} }
} }
elements_dictionary_template_ = elements_dictionary_template_ =
element_count_ || computed_count_ 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(); : factory->empty_slow_element_dictionary();
computed_properties_ = computed_count_ computed_properties_ =
? factory->NewFixedArray(computed_count_) computed_count_
? factory->NewFixedArray(computed_count_, AllocationType::kOld)
: factory->empty_fixed_array(); : factory->empty_fixed_array();
temp_handle_ = handle(Smi::zero(), isolate); temp_handle_ = handle(Smi::zero(), isolate);
...@@ -570,8 +573,8 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate( ...@@ -570,8 +573,8 @@ Handle<ClassBoilerplate> ClassBoilerplate::BuildClassBoilerplate(
static_desc.Finalize(isolate); static_desc.Finalize(isolate);
instance_desc.Finalize(isolate); instance_desc.Finalize(isolate);
Handle<ClassBoilerplate> class_boilerplate = Handle<ClassBoilerplate> class_boilerplate = Handle<ClassBoilerplate>::cast(
Handle<ClassBoilerplate>::cast(factory->NewFixedArray(kBoileplateLength)); factory->NewFixedArray(kBoileplateLength, AllocationType::kOld));
class_boilerplate->set_flags(0); class_boilerplate->set_flags(0);
class_boilerplate->set_install_class_name_accessor( 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