Commit 2e83e749 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Heap] Don't try and find SFIs FunctionLiteralId when flushing it's bytecode.

For compiled SFIs, finding the FunctionLiteralId is a slow operation that requires
doing a binary search in the script's SFI table. Given the SFI has been flushed,
it is unlikely we will need the FunctionLiteralId again, so just mark the
UncompiledData has having an invalid FunctionLiteralID such that we only do
the search if it is required from the UncompiledData.

This addresses a significant regression on gc_latency when bytecode flushing was
enabled.

BUG=chromium:927038,v8:8395

Change-Id: I7123c3fe05034ff96e84f9d1d36d5f312a2a56e0
Reviewed-on: https://chromium-review.googlesource.com/c/1450118Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59319}
parent 83908b86
......@@ -1999,7 +1999,6 @@ void MarkCompactCollector::FlushBytecodeFromSFI(
String inferred_name = shared_info->inferred_name();
int start_position = shared_info->StartPosition();
int end_position = shared_info->EndPosition();
int function_literal_id = shared_info->FunctionLiteralId(isolate());
shared_info->DiscardCompiledMetadata(
isolate(), [](HeapObject object, ObjectSlot slot, HeapObject target) {
......@@ -2043,7 +2042,7 @@ void MarkCompactCollector::FlushBytecodeFromSFI(
UncompiledData uncompiled_data = UncompiledData::cast(compiled_data);
UncompiledData::Initialize(
uncompiled_data, inferred_name, start_position, end_position,
function_literal_id,
FunctionLiteral::kIdTypeInvalid,
[](HeapObject object, ObjectSlot slot, HeapObject target) {
RecordSlot(object, slot, target);
});
......
......@@ -5348,7 +5348,7 @@ int SharedFunctionInfo::EndPosition() const {
int SharedFunctionInfo::FunctionLiteralId(Isolate* isolate) const {
// Fast path for the common case when the SFI is uncompiled and so the
// function literal id is already in the uncompiled data.
if (HasUncompiledData()) {
if (HasUncompiledData() && uncompiled_data()->has_function_literal_id()) {
int id = uncompiled_data()->function_literal_id();
// Make sure the id is what we should have found with the slow path.
DCHECK_EQ(id, FindIndexInScript(isolate));
......@@ -5356,7 +5356,7 @@ int SharedFunctionInfo::FunctionLiteralId(Isolate* isolate) const {
}
// Otherwise, search for the function in the SFI's script's function list,
// and return its index in that list.e
// and return its index in that list.
return FindIndexInScript(isolate);
}
......
......@@ -7,6 +7,7 @@
#include "src/objects/shared-function-info.h"
#include "src/ast/ast.h"
#include "src/feedback-vector-inl.h"
#include "src/handles-inl.h"
#include "src/heap/heap-inl.h"
......@@ -661,6 +662,10 @@ void UncompiledDataWithPreparseData::Initialize(
scope_data);
}
bool UncompiledData::has_function_literal_id() {
return function_literal_id() != FunctionLiteral::kIdTypeInvalid;
}
bool SharedFunctionInfo::HasWasmExportedFunctionData() const {
return function_data()->IsWasmExportedFunctionData();
}
......
......@@ -103,6 +103,9 @@ class UncompiledData : public HeapObject {
DECL_INT32_ACCESSORS(end_position)
DECL_INT32_ACCESSORS(function_literal_id)
// Returns true if the UncompiledData contains a valid function_literal_id.
inline bool has_function_literal_id();
DECL_CAST(UncompiledData)
inline static void Initialize(
......
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