Optimize boolean fields in JSFunctionDef, JSParseState and JSToken#1232
Optimize boolean fields in JSFunctionDef, JSParseState and JSToken#1232bnoordhuis merged 5 commits intoquickjs-ng:masterfrom
Conversation
Changed multiple boolean fields in JSFunctionDef and JSParseState structures from 'bool' to '_Bool flag : 1' to optimize memory usage while maintaining readability.
…l flag` to fit with my prior PR: JSRuntime, JSMapRecord, JSMapState, JSForInIterator, JSTypedArray, JSAsyncFunctionState, JSAsyncFunctionData, JSModuleDef, JSCallSiteData, JSParsePos, ClassFieldsDef, BCWriterState, ClassFieldsDef, BCReaderState, JSIteratorConcatData, JSRegExpStringIteratorData, JSPromiseData, JSPromiseFunctionDataResolved, JSAtomicsWaiter,
|
|
…the bit-field space optimization
|
Sorry, I didn't realize; I’ve updated the fields to use bool flag : 1 instead. The intent was mainly to reduce the memory footprint of these structs, since they contain many flags, and bit-field width still provides a measurable space optimization even when keeping bool. |
|
Changing a field to a Phrased another way, something like
That's why I mentioned reordering fields in the linked issue. There are probably also plenty of opportunities to reduce the bit size of adjacent fields; in lots of places we store things like lengths that fit in 31 bits as uint32s. Such changes need to be carefully considered and reviewed though. I suggest updating this PR to only cover the lowest-hanging fruit like JSFunctionDef, and then follow up with a series of pull requests where you pick off the more complicated ones one by one. |
…s. Reverted previous `bool : 1` changes in other structs; only JSFunctionDef is optimized in this PR. This reduces the memory footprint for JSFunctionDef.
|
In this commit, all previous |
Changed multiple boolean fields in JSFunctionDef and JSParseState structures from 'bool' to '_Bool flag : 1' to optimize memory usage while maintaining readability. This is realted to issue #1125.