[LLVMdev] Status of YAML IO?

Sean Silva silvas at purdue.edu
Thu Oct 25 09:59:06 PDT 2012


> To better understand how a client would use YAML I/O.  I've completely rewritten the ReaderYAML and WriterYAML in lld to use YAML I/O.  The source code is now about half the size.  But more importantly,  the error checking is much, much better and any time an attribute (e.g. of an Atom) is changed or added, there is just one place to update the yaml code instead of two places (the reader and writer).

Fantastic!

> The StringRef ownership works, but is a little clunky.  Because one yaml stream can contain many documents, the ownership of the input file MemoryBuffer cannot be handed off to the newly created lld::File object (which would have allowed any StringRefs provided by the parse to be used as is).  Instead whenever a trait needs to keep a StringRef it must make a copy of the underlying string, and the copies are owned by  the generated lld::File object.

Copying seems like a performance problem waiting to happen. Maybe this
could be addressed through reference counting? What are "typical"
sizes of strings that would be copied?

-- Sean Silva

On Wed, Oct 24, 2012 at 9:34 PM, Nick Kledzik <kledzik at apple.com> wrote:
>
> On Oct 22, 2012, at 5:07 PM, Nick Kledzik wrote:
>> On Oct 22, 2012, at 4:40 PM, Sean Silva wrote:
>>> Hey Nick, what's the status on YAML IO? The other thread seems to have died.
>>
>> I'm waiting on Michael Spencer's feedback.
>
> To better understand how a client would use YAML I/O.  I've completely rewritten the ReaderYAML and WriterYAML in lld to use YAML I/O.  The source code is now about half the size.  But more importantly,  the error checking is much, much better and any time an attribute (e.g. of an Atom) is changed or added, there is just one place to update the yaml code instead of two places (the reader and writer).
>
> This code requires no changes to the rest of lld.  The traits based approach was thus non-invasive.  It is able to produce yaml from existing data structures and when reading yaml recreate the existing data structures.
>
> The example also shows how context sensitive yaml conversion is done, using io.getContext() to make conversion decisions.
>
> The StringRef ownership works, but is a little clunky.  Because one yaml stream can contain many documents, the ownership of the input file MemoryBuffer cannot be handed off to the newly created lld::File object (which would have allowed any StringRefs provided by the parse to be used as is).  Instead whenever a trait needs to keep a StringRef it must make a copy of the underlying string, and the copies are owned by  the generated lld::File object.
>
>
>
>
>
> -Nick
>
>




More information about the llvm-dev mailing list