Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedCache] Optimize parsing and applying of slide info #6321

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions view/sharedcache/core/SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,6 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
MappingInfo map;

file->Read(&map.mappingInfo, baseHeader.mappingOffset + sizeof(dyld_cache_mapping_info), sizeof(dyld_cache_mapping_info));
map.file = file;
map.slideInfoVersion = slideInfoVersion;
if (map.slideInfoVersion == 2)
file->Read(&map.slideInfoV2, slideInfoOff, sizeof(dyld_cache_slide_info_v2));
Expand All @@ -1104,7 +1103,6 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
if (mappingAndSlideInfo.slideInfoFileOffset)
{
MappingInfo map;
map.file = file;
if (mappingAndSlideInfo.size == 0)
continue;
map.slideInfoVersion = file->ReadUInt32(mappingAndSlideInfo.slideInfoFileOffset);
Expand Down Expand Up @@ -1172,7 +1170,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
{
try
{
uint16_t start = mapping.file->ReadUShort(cursor);
uint16_t start = file->ReadUShort(cursor);
cursor += sizeof(uint16_t);
if (start == DYLD_CACHE_SLIDE_PAGE_ATTR_NO_REBASE)
continue;
Expand Down Expand Up @@ -1222,7 +1220,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
uint64_t extraCursor = extrasOffset + (j * sizeof(uint16_t));
try
{
auto extra = mapping.file->ReadUShort(extraCursor);
auto extra = file->ReadUShort(extraCursor);
uint16_t aStart = extra;
uint64_t page = mapping.mappingInfo.fileOffset + (pageSize * i);
uint16_t pageStartOffset = (aStart & 0x3FFF)*4;
Expand Down Expand Up @@ -1261,7 +1259,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
{
try
{
uint16_t delta = mapping.file->ReadUShort(cursor);
uint16_t delta = file->ReadUShort(cursor);
cursor += sizeof(uint16_t);
if (delta == DYLD_CACHE_SLIDE_V3_PAGE_ATTR_NO_REBASE)
continue;
Expand All @@ -1273,8 +1271,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
loc += delta * sizeof(dyld_cache_slide_pointer3);
try
{
dyld_cache_slide_pointer3 slideInfo;
file->Read(&slideInfo, loc, sizeof(slideInfo));
dyld_cache_slide_pointer3 slideInfo = { file->ReadULong(loc) };
delta = slideInfo.plain.offsetToNextPointer;

if (slideInfo.auth.authenticated)
Expand Down Expand Up @@ -1316,7 +1313,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
{
try
{
uint16_t delta = mapping.file->ReadUShort(cursor);
uint16_t delta = file->ReadUShort(cursor);
cursor += sizeof(uint16_t);
if (delta == DYLD_CACHE_SLIDE_V5_PAGE_ATTR_NO_REBASE)
continue;
Expand All @@ -1328,8 +1325,7 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces
loc += delta * sizeof(dyld_cache_slide_pointer5);
try
{
dyld_cache_slide_pointer5 slideInfo;
file->Read(&slideInfo, loc, sizeof(slideInfo));
dyld_cache_slide_pointer5 slideInfo = { file->ReadULong(loc) };
delta = slideInfo.regular.next;
if (slideInfo.auth.auth)
{
Expand Down
1 change: 0 additions & 1 deletion view/sharedcache/core/SharedCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ namespace SharedCacheCore {

struct MappingInfo
{
std::shared_ptr<MMappedFileAccessor> file;
dyld_cache_mapping_info mappingInfo;
uint32_t slideInfoVersion;
dyld_cache_slide_info_v2 slideInfoV2;
Expand Down