Skip to content

Remove slide calculation #23875

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

Merged
merged 3 commits into from
Apr 9, 2019
Merged
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
109 changes: 52 additions & 57 deletions include/swift/Reflection/ReflectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class ReflectionContext
RangeEnd - RangeStart);

auto findMachOSectionByName = [&](std::string Name)
-> std::pair<std::pair<const char *, const char *>, uint64_t> {
-> std::pair<const char *, const char *> {
for (unsigned I = 0; I < NumSect; ++I) {
auto S = reinterpret_cast<typename T::Section *>(
SectionsBuf + (I * sizeof(typename T::Section)));
Expand All @@ -213,9 +213,9 @@ class ReflectionContext
auto LocalSectStart =
reinterpret_cast<const char *>(SectBufData + RemoteSecStart - RangeStart);
auto LocalSectEnd = reinterpret_cast<const char *>(LocalSectStart + S->size);
return {{LocalSectStart, LocalSectEnd}, 0};
return {LocalSectStart, LocalSectEnd};
}
return {{nullptr, nullptr}, 0};
return {nullptr, nullptr};
};

auto FieldMdSec = findMachOSectionByName("__swift5_fieldmd");
Expand All @@ -225,24 +225,24 @@ class ReflectionContext
auto TypeRefMdSec = findMachOSectionByName("__swift5_typeref");
auto ReflStrMdSec = findMachOSectionByName("__swift5_reflstr");

if (FieldMdSec.first.first == nullptr &&
AssocTySec.first.first == nullptr &&
BuiltinTySec.first.first == nullptr &&
CaptureSec.first.first == nullptr &&
TypeRefMdSec.first.first == nullptr &&
ReflStrMdSec.first.first == nullptr)
if (FieldMdSec.first == nullptr &&
AssocTySec.first == nullptr &&
BuiltinTySec.first == nullptr &&
CaptureSec.first == nullptr &&
TypeRefMdSec.first == nullptr &&
ReflStrMdSec.first == nullptr)
return false;

auto LocalStartAddress = reinterpret_cast<uint64_t>(SectBuf.get());
auto RemoteStartAddress = static_cast<uint64_t>(RangeStart);

ReflectionInfo info = {
{{FieldMdSec.first.first, FieldMdSec.first.second}, 0},
{{AssocTySec.first.first, AssocTySec.first.second}, 0},
{{BuiltinTySec.first.first, BuiltinTySec.first.second}, 0},
{{CaptureSec.first.first, CaptureSec.first.second}, 0},
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second}, 0},
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second}, 0},
{{FieldMdSec.first, FieldMdSec.second}, 0},
{{AssocTySec.first, AssocTySec.second}, 0},
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
{{CaptureSec.first, CaptureSec.second}, 0},
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
LocalStartAddress,
RemoteStartAddress};

Expand Down Expand Up @@ -310,7 +310,7 @@ class ReflectionContext
sizeof(llvm::object::coff_section) * COFFFileHdr->NumberOfSections);

auto findCOFFSectionByName = [&](llvm::StringRef Name)
-> std::pair<std::pair<const char *, const char *>, uint32_t> {
-> std::pair<const char *, const char *> {
for (size_t i = 0; i < COFFFileHdr->NumberOfSections; ++i) {
const llvm::object::coff_section *COFFSec =
reinterpret_cast<const llvm::object::coff_section *>(
Expand All @@ -336,45 +336,43 @@ class ReflectionContext
End -= 8;
}

return {{Begin, End}, 0};
return {Begin, End};
}
return {{nullptr, nullptr}, 0};
return {nullptr, nullptr};
};

std::pair<std::pair<const char *, const char *>, uint32_t> CaptureSec =
std::pair<const char *, const char *> CaptureSec =
findCOFFSectionByName(".sw5cptr");
std::pair<std::pair<const char *, const char *>, uint32_t> TypeRefMdSec =
std::pair<const char *, const char *> TypeRefMdSec =
findCOFFSectionByName(".sw5tyrf");
std::pair<std::pair<const char *, const char *>, uint32_t> FieldMdSec =
std::pair<const char *, const char *> FieldMdSec =
findCOFFSectionByName(".sw5flmd");
std::pair<std::pair<const char *, const char *>, uint32_t> AssocTySec =
std::pair<const char *, const char *> AssocTySec =
findCOFFSectionByName(".sw5asty");
std::pair<std::pair<const char *, const char *>, uint32_t> BuiltinTySec =
std::pair<const char *, const char *> BuiltinTySec =
findCOFFSectionByName(".sw5bltn");
std::pair<std::pair<const char *, const char *>, uint32_t> ReflStrMdSec =
std::pair<const char *, const char *> ReflStrMdSec =
findCOFFSectionByName(".sw5rfst");

if (FieldMdSec.first.first == nullptr &&
AssocTySec.first.first == nullptr &&
BuiltinTySec.first.first == nullptr &&
CaptureSec.first.first == nullptr &&
TypeRefMdSec.first.first == nullptr &&
ReflStrMdSec.first.first == nullptr)
if (FieldMdSec.first == nullptr &&
AssocTySec.first == nullptr &&
BuiltinTySec.first == nullptr &&
CaptureSec.first == nullptr &&
TypeRefMdSec.first == nullptr &&
ReflStrMdSec.first == nullptr)
return false;

auto LocalStartAddress = reinterpret_cast<uintptr_t>(DOSHdrBuf.get());
auto RemoteStartAddress =
static_cast<uintptr_t>(ImageStart.getAddressData());

ReflectionInfo Info = {
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
BuiltinTySec.second},
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
TypeRefMdSec.second},
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
ReflStrMdSec.second},
{{FieldMdSec.first, FieldMdSec.second}, 0},
{{AssocTySec.first, AssocTySec.second}, 0},
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
{{CaptureSec.first, CaptureSec.second}, 0},
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
LocalStartAddress,
RemoteStartAddress};
this->addReflectionInfo(Info);
Expand Down Expand Up @@ -450,7 +448,7 @@ class ReflectionContext
auto StrTab = reinterpret_cast<const char *>(StrTabBuf.get());

auto findELFSectionByName = [&](std::string Name)
-> std::pair<std::pair<const char *, const char *>, uint64_t> {
-> std::pair<const char *, const char *> {
// Now for all the sections, find their name.
for (const typename T::Section *Hdr : SecHdrVec) {
uint32_t Offset = Hdr->sh_name;
Expand All @@ -462,9 +460,9 @@ class ReflectionContext
auto SecSize = Hdr->sh_size;
auto SecBuf = this->getReader().readBytes(SecStart, SecSize);
auto SecContents = reinterpret_cast<const char *>(SecBuf.get());
return {{SecContents, SecContents + SecSize}, 0};
return {SecContents, SecContents + SecSize};
}
return {{nullptr, nullptr}, 0};
return {nullptr, nullptr};
};

auto FieldMdSec = findELFSectionByName("swift5_fieldmd");
Expand All @@ -476,28 +474,25 @@ class ReflectionContext

// We succeed if at least one of the sections is present in the
// ELF executable.
if (FieldMdSec.first.first == nullptr &&
AssocTySec.first.first == nullptr &&
BuiltinTySec.first.first == nullptr &&
CaptureSec.first.first == nullptr &&
TypeRefMdSec.first.first == nullptr &&
ReflStrMdSec.first.first == nullptr)
if (FieldMdSec.first == nullptr &&
AssocTySec.first == nullptr &&
BuiltinTySec.first == nullptr &&
CaptureSec.first == nullptr &&
TypeRefMdSec.first == nullptr &&
ReflStrMdSec.first == nullptr)
return false;

auto LocalStartAddress = reinterpret_cast<uint64_t>(Buf.get());
auto RemoteStartAddress =
static_cast<uint64_t>(ImageStart.getAddressData());

ReflectionInfo info = {
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
BuiltinTySec.second},
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
TypeRefMdSec.second},
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
ReflStrMdSec.second},
{{FieldMdSec.first, FieldMdSec.second}, 0},
{{AssocTySec.first, AssocTySec.second}, 0},
{{BuiltinTySec.first, BuiltinTySec.second}, 0},
{{CaptureSec.first, CaptureSec.second}, 0},
{{TypeRefMdSec.first, TypeRefMdSec.second}, 0},
{{ReflStrMdSec.first, ReflStrMdSec.second}, 0},
LocalStartAddress,
RemoteStartAddress};

Expand Down