[builtins] Remove read-only CodeDataContainer optimization

Since only applies to builds without v8_enable_external_code_space and
only saves minimal snapshot size it doesn't seem worth keeping around.

Bug: v8:7464
Change-Id: I81b520235c6174abc340cb74825e6cc86b2b8958
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4136722
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85141}
This commit is contained in:
Jakob Linke 2023-01-05 10:13:09 +01:00 committed by V8 LUCI CQ
parent 7b9fa44c98
commit 82e8025d69
3 changed files with 16 additions and 45 deletions

View File

@ -412,7 +412,6 @@ Handle<Code> Builtins::GenerateOffHeapTrampolineFor(
return Factory::CodeBuilder(isolate, desc, CodeKind::BUILTIN)
.set_kind_specific_flags(kind_specific_flags)
.set_read_only_data_container(!V8_EXTERNAL_CODE_SPACE_BOOL)
.set_self_reference(generator.CodeObject())
.set_is_executable(generate_jump_to_instruction_stream)
.Build();
@ -478,7 +477,6 @@ Handle<Code> Builtins::CreateInterpreterEntryTrampolineForProfiling(
return Factory::CodeBuilder(isolate, desc, CodeKind::BUILTIN)
.set_kind_specific_flags(kind_specific_flags)
.set_read_only_data_container(false)
// Mimic the InterpreterEntryTrampoline.
.set_builtin(Builtin::kInterpreterEntryTrampoline)
.set_is_executable(true)

View File

@ -109,40 +109,26 @@ MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(
? local_isolate_->factory()->NewByteArray(code_desc_.reloc_size,
AllocationType::kOld)
: factory->NewByteArray(code_desc_.reloc_size, AllocationType::kOld);
Handle<CodeDataContainer> data_container;
// Use a canonical off-heap trampoline CodeDataContainer if possible.
const int32_t promise_rejection_flag =
Code::IsPromiseRejectionField::encode(true);
if (read_only_data_container_ &&
(kind_specific_flags_ == 0 ||
kind_specific_flags_ == promise_rejection_flag)) {
const ReadOnlyRoots roots(isolate_);
const auto canonical_code_data_container = Handle<CodeDataContainer>::cast(
kind_specific_flags_ == 0
? roots.trampoline_trivial_code_data_container_handle()
: roots.trampoline_promise_rejection_code_data_container_handle());
DCHECK_EQ(canonical_code_data_container->kind_specific_flags(kRelaxedLoad),
kind_specific_flags_);
data_container = canonical_code_data_container;
Handle<CodeDataContainer> data_container;
if (CompiledWithConcurrentBaseline()) {
data_container = local_isolate_->factory()->NewCodeDataContainer(
0, AllocationType::kOld);
} else {
if (CompiledWithConcurrentBaseline()) {
data_container = local_isolate_->factory()->NewCodeDataContainer(
0, AllocationType::kOld);
} else {
data_container = factory->NewCodeDataContainer(
0, read_only_data_container_ ? AllocationType::kReadOnly
: AllocationType::kOld);
}
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
const bool set_is_off_heap_trampoline = read_only_data_container_;
data_container->initialize_flags(kind_, builtin_, is_turbofanned_,
set_is_off_heap_trampoline);
}
data_container->set_kind_specific_flags(kind_specific_flags_,
kRelaxedStore);
AllocationType allocation_type =
V8_EXTERNAL_CODE_SPACE_BOOL || is_executable_
? AllocationType::kOld
: AllocationType::kReadOnly;
data_container = factory->NewCodeDataContainer(0, allocation_type);
}
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
static constexpr bool kIsNotOffHeapTrampoline = false;
data_container->initialize_flags(kind_, builtin_, is_turbofanned_,
kIsNotOffHeapTrampoline);
}
data_container->set_kind_specific_flags(kind_specific_flags_, kRelaxedStore);
// Basic block profiling data for builtins is stored in the JS heap rather
// than in separately-allocated C++ objects. Allocate that data now if
// appropriate.
@ -2529,9 +2515,6 @@ Handle<CodeT> Factory::NewOffHeapTrampolineFor(Handle<CodeT> code,
// stored on the Code object, refer to the off-heap metadata area.
CHECK_EQ(result->raw_metadata_size(), 0);
// The CodeDataContainer should not be modified beyond this point since it's
// now possibly canonicalized.
// The trampoline code object must inherit specific flags from the original
// builtin (e.g. the safepoint-table offset). We set them manually here.
{

View File

@ -1011,15 +1011,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
return *this;
}
// Indicates the CodeDataContainer should be allocated in read-only space.
// As an optimization, if the kind-specific flags match that of a canonical
// container, it will be used instead.
CodeBuilder& set_read_only_data_container(bool read_only) {
CHECK_IMPLIES(V8_EXTERNAL_CODE_SPACE_BOOL, !read_only);
read_only_data_container_ = read_only;
return *this;
}
CodeBuilder& set_kind_specific_flags(int32_t flags) {
kind_specific_flags_ = flags;
return *this;
@ -1061,7 +1052,6 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
Handle<HeapObject> interpreter_data_;
BasicBlockProfilerData* profiler_data_ = nullptr;
bool is_executable_ = true;
bool read_only_data_container_ = false;
bool is_turbofanned_ = false;
int stack_slots_ = 0;
};