[PATCH] D59269: ELF: Use bump pointer allocator for uncompressed section buffers. NFCI.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 13:31:33 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD355966: ELF: Use bump pointer allocator for uncompressed section buffers. NFCI. (authored by pcc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59269?vs=190300&id=190320#toc
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59269/new/
https://reviews.llvm.org/D59269
Files:
ELF/InputSection.cpp
ELF/InputSection.h
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -144,13 +144,18 @@
void InputSectionBase::uncompress() const {
size_t Size = UncompressedSize;
- UncompressedBuf.reset(new char[Size]);
+ char *UncompressedBuf;
+ {
+ static std::mutex Mu;
+ std::lock_guard<std::mutex> Lock(Mu);
+ UncompressedBuf = BAlloc.Allocate<char>(Size);
+ }
- if (Error E =
- zlib::uncompress(toStringRef(RawData), UncompressedBuf.get(), Size))
+ if (Error E = zlib::uncompress(toStringRef(RawData), UncompressedBuf, Size))
fatal(toString(this) +
": uncompress failed: " + llvm::toString(std::move(E)));
- RawData = makeArrayRef((uint8_t *)UncompressedBuf.get(), Size);
+ RawData = makeArrayRef((uint8_t *)UncompressedBuf, Size);
+ UncompressedSize = -1;
}
uint64_t InputSectionBase::getOffsetInFile() const {
@@ -1062,7 +1067,7 @@
// If this is a compressed section, uncompress section contents directly
// to the buffer.
- if (UncompressedSize >= 0 && !UncompressedBuf) {
+ if (UncompressedSize >= 0) {
size_t Size = UncompressedSize;
if (Error E = zlib::uncompress(toStringRef(RawData),
(char *)(Buf + OutSecOff), Size))
Index: ELF/InputSection.h
===================================================================
--- ELF/InputSection.h
+++ ELF/InputSection.h
@@ -133,7 +133,7 @@
}
ArrayRef<uint8_t> data() const {
- if (UncompressedSize >= 0 && !UncompressedBuf)
+ if (UncompressedSize >= 0)
uncompress();
return RawData;
}
@@ -210,10 +210,11 @@
mutable ArrayRef<uint8_t> RawData;
- // A pointer that owns uncompressed data if a section is compressed by zlib.
- // Since the feature is not used often, this is usually a nullptr.
- mutable std::unique_ptr<char[]> UncompressedBuf;
- int64_t UncompressedSize = -1;
+ // This field stores the uncompressed size of the compressed data in RawData,
+ // or -1 if RawData is not compressed (either because the section wasn't
+ // compressed in the first place, or because we ended up uncompressing it).
+ // Since the feature is not used often, this is usually -1.
+ mutable int64_t UncompressedSize = -1;
};
// SectionPiece represents a piece of splittable section contents.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59269.190320.patch
Type: text/x-patch
Size: 2357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190312/c31324b8/attachment.bin>
More information about the llvm-commits
mailing list