[heap] Move the likeliest case of GcSafeTryFindCodeForInnerPointer up
It's much more likely to find the code object in CODE_SPACE than in LO space (or the THIRD_PARTY_HEAP). Also, remove an obsolete and misleading comment. Bug: v8:13654 Change-Id: Ia6c2a28a8eb5b0fb3f5951a9018fac0c0683a96e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4205914 Reviewed-by: Dominik Inführ <dinfuehr@chromium.org> Commit-Queue: Jakob Linke <jgruber@chromium.org> Cr-Commit-Position: refs/heads/main@{#85564}
This commit is contained in:
parent
20a592c212
commit
9901a04144
@ -6853,33 +6853,32 @@ bool Heap::GcSafeInstructionStreamContains(InstructionStream instruction_stream,
|
||||
|
||||
base::Optional<GcSafeCode> Heap::GcSafeTryFindCodeForInnerPointer(
|
||||
Address inner_pointer) {
|
||||
// Embedded builtins.
|
||||
Builtin maybe_builtin =
|
||||
OffHeapInstructionStream::TryLookupCode(isolate(), inner_pointer);
|
||||
if (Builtins::IsBuiltinId(maybe_builtin)) {
|
||||
return GcSafeCode::cast(isolate()->builtins()->code(maybe_builtin));
|
||||
}
|
||||
|
||||
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
|
||||
Address start = tp_heap_->GetObjectFromInnerPointer(inner_pointer);
|
||||
// Code space.
|
||||
if (V8_LIKELY(code_space()->Contains(inner_pointer))) {
|
||||
Address start = Page::FromAddress(inner_pointer)
|
||||
->GetCodeObjectRegistry()
|
||||
->GetCodeObjectStartFromInnerAddress(inner_pointer);
|
||||
return GcSafeGetCodeFromInstructionStream(HeapObject::FromAddress(start),
|
||||
inner_pointer);
|
||||
}
|
||||
|
||||
// Check if the inner pointer points into a large object chunk.
|
||||
// Code large object space.
|
||||
LargePage* large_page = code_lo_space()->FindPage(inner_pointer);
|
||||
if (large_page != nullptr) {
|
||||
return GcSafeGetCodeFromInstructionStream(large_page->GetObject(),
|
||||
inner_pointer);
|
||||
}
|
||||
|
||||
if (V8_LIKELY(code_space()->Contains(inner_pointer))) {
|
||||
// Iterate through the page until we reach the end or find an object
|
||||
// starting after the inner pointer.
|
||||
Page* page = Page::FromAddress(inner_pointer);
|
||||
|
||||
Address start =
|
||||
page->GetCodeObjectRegistry()->GetCodeObjectStartFromInnerAddress(
|
||||
inner_pointer);
|
||||
// Third-party heap.
|
||||
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) {
|
||||
Address start = tp_heap_->GetObjectFromInnerPointer(inner_pointer);
|
||||
return GcSafeGetCodeFromInstructionStream(HeapObject::FromAddress(start),
|
||||
inner_pointer);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user