Commit Graph
4 Commits
Author SHA1 Message Date
Will Speak ca3cbf9a88 fix: correct GC next threshold calculation to prevent infinite collections on 32-bit builds
The previous formula `vm->bytesAllocated * (100 + heapGrowthPercent) / 100` incorrectly computed the total heap size instead of the additional allocation threshold, causing the GC to trigger endlessly when `bytesAllocated` already exceeded the calculated `nextGC` value. The fix changes the calculation to `bytesAllocated + (bytesAllocated * heapGrowthPercent / 100)`, which properly represents the next collection point as the current allocation plus a growth allowance. This resolves the infinite GC loop observed in `test/language/deeply_nested_gc.wren` on 32-bit architectures.
2016-10-09 16:59:58 +00:00
Will Speak 140fb7738e feat: replace recursive mark with iterative gray/darken GC to prevent stack overflow
The previous recursive `wrenMarkObj` approach could overflow the C stack when marking deeply nested object graphs. This commit introduces an iterative two-phase collector: objects are first "grayed" onto an explicit stack in the WrenVM struct, then `wrenDarkenObjs` iteratively processes the gray stack until all reachable objects are marked as "dark". The `marked` field is renamed to `isDark` to reflect the new semantics. A `gray` array with `grayDepth` and `maxGray` tracking is added to `WrenVM`, initialized in `initializeGC` and freed in `wrenFreeVM`. All internal mark calls (`markClass`, `markClosure`, `markFiber`, `wrenCollectGarbage`) are updated to use `wrenGrayObj` instead of `wrenMarkObj`. Two new test files (`deeply_nested_gc.wren` and `many_reallocations.wren`) verify that deeply nested object graphs and repeated GC cycles complete without stack overflow.
2015-10-19 21:45:15 +00:00
Will Speak 55c21c397d docs: add Will Speak to AUTHORS file with email contact
Append a new contributor entry for Will Speak with their email address
to the project's AUTHORS file, following the existing formatting
convention used for other contributors.
2015-10-18 09:55:34 +00:00
Will Speak 645296cbd8 feat: add \U style 8-hex-digit unicode escape support in string literals
Extend the compiler's string parser to handle `\U` escapes with 8 hex digits
for codepoints above U+FFFF, replacing the previous TODO comment. The
`readUnicodeEscape` helper now accepts a variable digit count (4 or 8) and
the `readString` function dispatches `\u` with length 4 and `\U` with length 8.
New test cases verify correct encoding of emoji and ancient scripts, plus
error handling for incomplete long escapes and values that fit in 4 digits.
2015-10-03 16:28:25 +00:00