Main features:
- DOM, fully parsed/validated ahead of time
- All DOM elements arena-allocated and owned by the document
- tagged-pointer representation of Values, integers/nulls/booleans inline
- expressive syntax for JSON literals with Twine-like semantics
Paths
| Differential D39180
JSON library (just a prototype at this point). AbandonedPublic Authored by sammccall on Oct 23 2017, 6:36 AM.
Details
Summary Main features:
Diff Detail
Event TimelineComment Actions I've simply skimmed through the code, but overall design looks great. It's a bit of a pity that Arrays may allocate outside the arena. What are the reasons we prefer SmallVector to std::vector if we're allocating in the arena anyway?
Comment Actions
Yeah :-( It's not trivial to retrofit SmallVector (we'd need to add realloc to Allocator, and SmallVector's complex inheritance hierarchy, templates, and empty base optimization might need some untangling). BTW, If it wasn't for Array's heap allocations, I think we might be able to make Value's destructor empty and just abandon the objects, which would speed up/simplify a bit. The arenas just have PODs, vectors, and StringMaps...
Huh, you're right: a sized std::vector initialized on an arena has the same layout as a perfectly-sized SmallVector. With our current broken arena-allocation, SmallVector's SSO means we end up on the arena some of the time. (And avoiding the small allocations is the important part, because there won't be many big ones). But if we can adapt BumpPtrAllocator& to be an STL allocator, then std::vector would be the way to go. Time to see if someone already did that...
Comment Actions Switch to std::vector, with BumpPtrAllocator adapted to the STL allocator.
Revision Contents
Diff 120565 include/llvm/Support/JSON.h
include/llvm/Support/JSONDetail.h
lib/Support/CMakeLists.txt
lib/Support/JSON.cpp
unittests/Support/CMakeLists.txt
unittests/Support/JSONTest.cpp
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
s/ValeWrapper/ValueWrapper