summaryrefslogtreecommitdiff
path: root/src/chunklets
Commit message (Collapse)AuthorAgeFilesLines
* Make x86 library a little bit smaller againGravatar Michael Smith 2026-02-162-37/+127
|
* Switch cmeta from chibicc to a new homegrown lexerGravatar Michael Smith 2026-02-162-0/+2395
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lexer is being written as a chunklet, not quite quite complete yet as it lacks some functionality to make it generally useful for things, but good enough for the gluegen use case now. So it's in the repo now and we can go ahead and use it for this instead of having this hacked-to-pieces third party thing that's nowhere near as efficient. In the future the goal is to have a decently usable library for any sort of C metaprogramming needs, not just within this project. This design does the data-oriented thing of storing as little about each token as possible (just 5 bytes), and re-lexing specific pieces only when necessary. In some cases, full validation of correct syntax is only possible through this secondary step. Since the use case is metaprogramming and code-generation rather than the reimplementation of Clang, this slight sloppiness in validation doesn't seem too bad. It's been a while since I did a proper performance measurement of this code but in some crude tests I did in the past the primary tokenisation step was running at well over 500MB/s, which is fast enough for me. It's possible that this version is a tiny bit slower due to the added complexity of making UCNs work. UCNs, incidentally, are one of the dumbest features of C by far. However, unlike trigraphs - which this lexer does not handle - UCNs are still in the language, so it's kind of sort of necessary to support them. It's probably still possible to come up with a faster design with some SIMD trickery, but the main loop is currently branchless and the lookup tables are too big for the SIMD lookup things, so that seems kind of hard. A separate SIMD path for whitespace or comment runs seems dubious as it would introduce branch mispredictions everywhere. I also made previous attempts to unroll the main loop and every attempt just made it slower, so I guess code size is a significant factor. Optimising the secondary tokenisation of identifiers (and later numerals and string/character literals once those are handled) is still on the cards, but since that happens less often, I don't know how much difference it'll make. At any rate, in a multithreaded context this thing would already come pretty close to SSD speeds, if open-read-close syscall overhead doesn't get in the way first. I imagine it's fast enough for anyone who hasn't *already* written something faster.
* Size-optimise a few thingsGravatar Michael Smith 2026-02-161-0/+7
| | | | | Saves multiple kilobytes, somehow. Unlikely to make much of a performance difference since it's mostly init/shutdown stuff.
* Turn x86 stuff into a chunklet to help out SPTGravatar Michael Smith 2025-11-243-0/+729
| | | | Quick unused header cleanup pass while we're at it.
* Use shorter spellings of __asm and __attributeGravatar Michael Smith 2025-08-031-3/+3
| | | | | | | Turns out, there's no need for the trailing underscores. Plus, glibc does some stupid stuff with __attribute__ for non-GCC compilers. Not that that matters here, but it seems like a good practice just to use the forms that never have such problems. And it's shorter too.
* Fix minor idiocy in msg.cGravatar Michael Smith 2025-04-161-2/+2
| | | | | | | | | | I had at one point tried to macrofy the repetitive functions. After being talked down from that madness, I LSP-expanded all the macros out and went through rewriting the crazy expressions into constants. Except those two for some reason, because I'm blind I guess. Thanks bill for pointing this out.
* Remove years from copyright headersGravatar Michael Smith 2025-04-074-4/+4
| | | | | | | | They're legally unnecessary as far as I know, and kind of annoying to maintain on a long-term basis. This was done with the consent of all 3 other contributors, in case anyone was wondering.
* Fix a couple of dumb typos in the fastspin libraryGravatar Michael Smith 2025-04-061-5/+3
|
* Develop the msg chunklet furtherGravatar Michael Smith 2025-04-062-166/+638
| | | | | | | | - Add reverse-put functions for stack-based and/or left-pad-inspired use cases. - Fix an incorrect return value. - Clean up the doc comments, fixing a few errors and omissions. - Make some trivial functions static inline.
* Revise syntax macros and add a ton of branch hintsGravatar Michael Smith 2024-08-231-4/+2
| | | | | | | | | My new programming style is branch hints. All non-confusing branches must be hinted when I can be bothered. It's faster, sometimes, maybe. Also, start trying to use more signed sizes in at least some of the places where it makes sense. Unsigned sizes are surprisingly error-prone!
* Fix msgpack sizing blundersGravatar Michael Smith 2023-08-272-4/+4
| | | | | Reminder not to actually use any of the code I write until it's at least been included in a few releases of something. :^)
* Get things at least compiling under LinuxGravatar Michael Smith 2023-08-271-0/+1
| | | | | | | | | | | Nothing really works yet, but at least test.h and fastspin are fixed and some of the issues with RTTI and libdl and stuff are maybe kind of sorted, subject to more testing later. The main issue now seems to be the cvar interface not quite lining up and crashing pretty much immediately. That'll probably take a lot more debugging to figure out, which likely still won't be a priority for quite a while.
* Make various preparations for upcoming featuresGravatar Michael Smith 2023-08-028-0/+1225
A lot of this is random WIP from a while back, at least a month ago, and is being committed now to get it out of the way so that other patches can be brought in and integrated against it without causing headaches. Also rolled into this commit is a way to distinguish plugin_unload from exiting the game. This is required for another soon-to-be-integrated feature to avoid crashing on exit, and could in theory also be used to speed up unloading on exit in future. While we're at it, this also avoids the need to linearly scan through the plugin list to do the old branch unloading fix, because we can. Rough summary of the other smaller stuff I can remember doing: - Rework bitbuf a bit - Add some cryptographic nonsense in ac.c (not final at all) - Introduce the first couple of "chunklets" libraries as a sort-of subproject of this one - Tidy up random small bits and bobs - Add source for a small keypair generation tool - Rework democustom to be very marginally more useful