1. 22 May, 2020 5 commits
    • Eric Myhre's avatar
      Maps now correctly stay in representation mode when read. · 3d4cd439
      Eric Myhre authored
      Correct representational creation mode still coming up, as you can
      see in the fixme comment.
      
      Tests will come in the next commit along with the creation mode.
      3d4cd439
    • Eric Myhre's avatar
      Test for lists-of-lists and that representation-mode recursion works for both... · 6c65fd6a
      Eric Myhre authored
      Test for lists-of-lists and that representation-mode recursion works for both assembly and traversal.
      
      It does.
      6c65fd6a
    • Eric Myhre's avatar
      Make this error less fragile. · d87c67e1
      Eric Myhre authored
      Having a nil pointer dereference cause a panic *during* error stringing
      is really unpleasant.
      
      We shouldn't "ever" have this problem, when the library is done.
      But right no we certainly do.
      d87c67e1
    • Eric Myhre's avatar
      Fix missing zeroing of wip pointer during nullable children in recursives. · 160062b4
      Eric Myhre authored
      Would cause the same memory to get reused inappropriately; need the nil
      value there to kick the child assembler to do the new allocation on the
      next round.
      160062b4
    • Eric Myhre's avatar
      Finish list repr list gen. · 9cae922e
      Eric Myhre authored
      A lot of the coments in earlier commit messages about choosing a path
      and cutting through it roughly and leaving DRY for latter still
      applies (see f1eeeafb).
      
      The hardest part of writing this was giving up on having shared code
      in the output.  It just can't be done along the current edges without
      giving up some performance at runtime, and that's generally not a trade
      we want to make.  Maybe there's different cuts for function boundaries
      that would do better -- but we'll leave that for later fun work.
      
      I did at least get a bunch of templates to be textually shared.
      
      Comments abound in the diff for future possibilities, as well as what's
      not possible to go further on without making undesired trades.
      9cae922e
  2. 08 May, 2020 4 commits
  3. 28 Apr, 2020 1 commit
    • Eric Myhre's avatar
      Comments contemplating options to DRY list repr. · f1eeeafb
      Eric Myhre authored
      This is a really tricky thing, because we're balancing three concerns:
      
      - minimizing our gen&template code size (and maximizing legibility)
        (okay, *four* concerns!)
      - minimizing our generated output lines of code ("gsloc")
      - minimizing our binary output size
      - maximizing our optimizations and fine runtime speed
        (okay, *five* concerns!)
      
      So, in addition to being the darned Spanish Inquisition about counting
      the concerns here...
      
      They're wildly divergent concerns.  And minimizing one tends to push
      up the numbers for the others.  Or simply make it harder to see and
      iterate on ways to manage the others.
      
      It's likely that at some point I'm going to give up and write something
      that works and seems simple as a first draft, and just roll with it.
      It's important to get something more widely usable to simply be
      finished enough that we can start gathering experiences on it;
      the rest of this is optimization problems we can iterate and improve on
      over time.
      
      We may also need to invest in some tooling to measure things like
      gsloc and binary output size, and possibly testing what's inlinable
      (though simply measuring performance with regular benchmarks may remain
      a decent substitute for that, even though it's limited to working on
      finished systems and thus not very helpful to use in design planning).
      Right now I'm running off vague intuitions from prior experiences, and
      occasionally going on splunks through the disassembler, but this is a
      high cost action to perform manually so I'm not doing it often and it's
      not producing feedback frequently enough.  Tooling could both make it
      easier to gather this feedback, and make it more maintainable over time
      and available to other maintainers, which would be... capital-G Good.
      f1eeeafb
  4. 26 Apr, 2020 11 commits
    • Eric Myhre's avatar
      All the other scalars. · 2f7df511
      Eric Myhre authored
      It's possible these could be dedup'd... a lot, honestly.  I'm wondering
      if they actually need a discrete type per kind at all, anymore; it's
      seeming much more tractable to try to turn that into a "no" after all
      the other successful work this morning abstracting things.
      
      But I have some other things I want to ship and do demos and prototypes
      of that's a lot more interesting than shaving more lines off today.
      So just gonna roll with the existing convention and stamp these out.
      Might deserve a revisit in the future.  Might not.  Time will tell.
      2f7df511
    • Eric Myhre's avatar
      More extraction and DRY'ing. · 7754ce08
      Eric Myhre authored
      Int is now basically all common stuff.  Now I'm really gonna quit.
      
      Interestingly, the total line count isn't going down very fast.
      108 insertions, 165 deletions, according to the git diff stat.
      Evidentally the overhead of things opting into this is darn near
      the amount of lines saved in many cases.
      7754ce08
    • Eric Myhre's avatar
      Basically everything for scalar assemblers DRY. · 7cdaa71e
      Eric Myhre authored
      This'll probably be the end of my cleanup quest for the day, but it's
      a pretty pleasing result.  More cleaned up more easily than I expected.
      7cdaa71e
    • Eric Myhre's avatar
      AssignNull method now also DRY across reprs :D · 3c03a6d3
      Eric Myhre authored
      Decided a basic bool property for this is probably fine after all.
      (For quite a while I'd been wondering if we'd end up with an enum
      of variants that are more or less semantic siblings of Repr, but it
      still hasn't happened, and thus it's now seeming quite unlikely.)
      3c03a6d3
    • Eric Myhre's avatar
      Extract and DRY AssignNull method for most types. · ef17e649
      Eric Myhre authored
      This one turns out to be different betweens scalars and recursives,
      if in a small (and fortunately consistent) way.
      ef17e649
    • Eric Myhre's avatar
      Comment typo fix. · 9737070b
      Eric Myhre authored
      9737070b
    • Eric Myhre's avatar
      The string of kinds should really be lowercase. · 680f1386
      Eric Myhre authored
      Yes, even though in practice in most of codegen we'll just turn around
      and title-case it again for symbol export reasons.
      
      The keywords everywhere throughout the schema language are lower-case,
      and kinds are such a keyword.  They should therefore be consistently
      handled and shown as lowercase.
      
      This has bugged me for a while but it's time to fix it before any more
      code starts passing by the area (and it's about to).
      680f1386
    • Eric Myhre's avatar
      More DRY'ing efforts in codegen. · f6cbe842
      Eric Myhre authored
      Some are easier than others.
      
      I'm starting to evolve a (still ad-hoc) naming convention for the
      extracted functions in order to provide some cues for how common you can
      expect the thing to be.  Scalars have a lot more commonizable stuff
      than non-scalars, for example.
      f6cbe842
    • Eric Myhre's avatar
      Typo fix in error messages in generated ints. · 8d848edd
      Eric Myhre authored
      8d848edd
    • Eric Myhre's avatar
      DRY EmitTypedNodeMethodRepresentation. · 83bf3c07
      Eric Myhre authored
      83bf3c07
    • Eric Myhre's avatar
      Considering extracting some common parts. · ca7481a6
      Eric Myhre authored
      ca7481a6
  5. 24 Apr, 2020 8 commits
    • Eric Myhre's avatar
      Update int gen to use the Style.FromInt pattern. · 75595eda
      Eric Myhre authored
      This brings it back in line with how strings now act.
      75595eda
    • Eric Myhre's avatar
      The type(/style) access table is now genned. · 33c611f0
      Eric Myhre authored
      33c611f0
    • Eric Myhre's avatar
      Fix stutters in some generated messages. · ac7732ca
      Eric Myhre authored
      ac7732ca
    • Eric Myhre's avatar
      List gen support, and tests. · 0827921d
      Eric Myhre authored
      These are getting increasingly straightforward as most of the hard
      problems have been ironed out already when getting the other recursives
      (maps and structs) sorted.
      
      Now, we just need to stamp out the rest of the scalars, and I think
      this codegen stuff is at least early-alpha level usable!
      
      Also in this commit: added some new error types and fixed up the
      basicnode.List implementation to use it, removing some todos there.
      0827921d
    • Eric Myhre's avatar
      Remove todo comment fixed in 2c41e282. · 7975725a
      Eric Myhre authored
      7975725a
    • Eric Myhre's avatar
      Update struct stringjoin repr assembler. · 5e8f180c
      Eric Myhre authored
      It's oddly hard to get a test in to poke these bits -- lots of uses
      funnel into shortcut codepaths that avoid a lot of the assembler.
      
      Tests for errors on misuse (double assigment, etc) should probe this,
      but we don't have any of those anywhere yet, and they're not
      well-typed yet, and that's more/different than what I want to tear off
      today.
      
      Tests where the stringjoin repr'd struct is reached as a child of
      other things should be another way to poke the right spot, but...
      I got nervous heading that way because... well, this reason might be
      wobbly, but I'm worried about keeping some order of concentrically
      growing growing circles of feature sets.  I'm becoming afraid if I
      ever need to do large scale updates to anything, *all* the tests will
      break at once, thus giving little in the way of incrementally helpful
      nudges in the direction of fixes.  If struct tests use maps, and map
      tests use structs, who's depending on who, and which test failures
      indicate what and where?
      
      I think I see the outline of some heuristics that could help here;
      I'll start adding more tests accordingly in subsequent commits.
      5e8f180c
    • Eric Myhre's avatar
      Test for nested structs with stringjoin repr. · 05519035
      Eric Myhre authored
      Works.
      05519035
    • Eric Myhre's avatar
      Add test for maps with complex keys. · 2c41e282
      Eric Myhre authored
      Required a few fixes to the stringjoin struct representation
      (namely, AssembleKey initialization hadn't been exercised yet).
      2c41e282
  6. 19 Apr, 2020 11 commits
    • Eric Myhre's avatar
      MapNStrMap3StrInt benchmarks on codegen. · 3b33e05c
      Eric Myhre authored
      Marshal is on par with basicnode.  Both basicnode and then gen stuff
      does a solid job of alloc amortization on reads, so the dominant cost
      remaining for both is in getting iterators.  Thus, they come out
      pretty comparable overall.
      
      Unmarshal is winning *nicely* over basicnode.  Roughly a third fewer
      allocations, and gen is about 125% faster on the clock.
      
      I haven't looked to see if unmarshal can be further improved with any
      low-hanging-fruit sorts of fixes.  Wouldn't be surprised if it can.
      
      We're gonna need more standard benchmarks... and in particular,
      need them working without the marshal/unmarshal indirections.
      Those are handy, but add a *lot* of noise from directions we're not
      necessarily interested in when looking at different node impls.
      3b33e05c
    • Eric Myhre's avatar
      Terribly important character. Avoids alloc. · 66047ce9
      Eric Myhre authored
      With use of pointer here: overall benchmarks if marshalling or suchlike
      are perfectly reasonable and on par with the basicnode implementations
      (the biggest cost is getting iterators, which is similar in each).
      
      With the typo causing a copy and another heap escape: that extra alloc
      causes a zonking 10% slowdown on selected marshalling benchmark.
      
      (I'm using benchmarks on the 'realgen' package.  MapNStrMap3StrInt can
      be exercised now -- isn't that neat?  Suppose I'll commit that next.)
      66047ce9
    • Eric Myhre's avatar
      Recursive maps: works, and tested. · d52e2c27
      Eric Myhre authored
      Reset methods on assemblers were needed for this.  So far, we'd gotten
      along without these, because structs happen to not reuse assemblers
      between fields.  But we definitely do need them in general.
      
      It would've been possible to avoid having the reset methods on scalars,
      but it doesn't seem work the effort; it would save a line of GSLOC,
      but make absolutely no other practical difference, and also make the
      templates a fair sight more complicated.  So meh to that.
      d52e2c27
    • Eric Myhre's avatar
      Several functional tests for generated maps. · bb7c9122
      Eric Myhre authored
      bb7c9122
    • Eric Myhre's avatar
      Dry up emitNativeMaybe, and apply it everywhere. · 51460752
      Eric Myhre authored
      Also, hej: now recursive maps can be compiled!  (Previously they were
      stymied simply because the maybe emission hadn't been pasted in.)
      51460752
    • Eric Myhre's avatar
      Test structs with nested structs. · 9c925d14
      Eric Myhre authored
      Largely works, although a fix was needed on representations -- they
      should *keep* returning representation nodes.
      
      (Ironically this simplified some things, because using a method to
      get the representation node means the compiler does more of the
      "is this or is this not being called on a ptr" dance for us.)
      9c925d14
    • Eric Myhre's avatar
      Fix typo in interface assertions. · 51d3e053
      Eric Myhre authored
      These interface assertions have become pretty low-value.  Hmm.
      51d3e053
    • Eric Myhre's avatar
      Map gen now works. · fa8b487a
      Eric Myhre authored
      Through compilation, at least.  No functional tests yet written.
      
      Bunch of small fixes for maybe pointers.  (Somehow I had gotten their
      embedding in the entry struct wrong, and that kinda splashed all over.)
      
      The refactor of method names 'construct'->'fromString' also made a
      bunch of the generated map code line up, since it was already written
      to target that convention.
      
      Then it's just the matter of adding the tests that compile.
      
      And so far so good: combos of nullable values, not nullable,
      and maybe with or without use of pointers all appear to compile!
      fa8b487a
    • Eric Myhre's avatar
      Refactor 'construct'->'fromString'. · 7fe8c836
      Eric Myhre authored
      Using a function name that has kind info in it feels better in many
      small ways (it's a nice sanity check; if we add coercion helper
      methods for more kinds, it'll sure matter; etc).
      
      And, that method on String types belongs on the type, not just on the
      representation side.
      
      And, drop the 'NewT' method for String types; instead, have them
      generate use 'pkg.Style.T.FromString' pattern.
      7fe8c836
    • Eric Myhre's avatar
      Third checkpoint in progress towards map gen. · 81bdd932
      Eric Myhre authored
      This seems to be getting pretty close: the only compile errors left
      are about not finding "fromString" methods for key reification...
      which is of course sensible, because that's not what those methods
      have been called yet in the cases where they've shown up;
      and they also haven't been placed on type-level styles yet.
      
      So the next commit will be a little detour to touch over those methods
      formerly known as "construct" and update them a bit to this pattern.
      81bdd932
    • Eric Myhre's avatar
      Next checkpoint in progress towards map gen. · 2a347854
      Eric Myhre authored
      Fixes many issues with maybes.  Some minor typo-scale stuff; some
      pretty consequential.  What to do about speciated lookup methods
      still has big honking questions on it: returning a maybe there if
      you didn't already have data in that format can be *not cheap*.
      Figuring out the best DX there is gonna be interesting.
      
      Making progress on how to handle keys, but slow.  Complex keys are...
      well, really complex.  So far I've learned several things that *won't*
      work, which is fun.  It's looking unlikely that having a KeyAssembler
      type at all is actually going to be a good idea.
      2a347854