Commit Graph

6 Commits

Author SHA1 Message Date
Bob Nystrom
ca400d725e chore: disable DEBUG_GC_STRESS and refactor initCompiler with addConstant helper 2013-11-20 04:54:47 +00:00
Bob Nystrom
9c663aa13c feat: implement NaN tagging for Value union and hoist bytecode/IP into locals in interpret loop
Switch Value from a struct with type/num/obj fields to a NaN-tagged uint64_t/double union, enabling faster type checks and unboxed numbers. Refactor all macros and accessors (IS_OBJ, AS_OBJ, AS_NUM, etc.) to work with the new representation. Hoist CallFrame pointer, instruction pointer, and bytecode array into local variables inside the interpret loop, updating them on frame push/pop. Enable NAN_TAGGING define and DEBUG_GC_STRESS in common.h. Update Xcode project to use c99 standard, pedantic warnings, and treat warnings as errors. Add benchmark/fib.txt with timing comparisons showing fib benchmark within 25% of Lua.
2013-11-17 22:20:15 +00:00
Bob Nystrom
7c54588c0d chore: replace AS_STRING macro with AS_CSTRING and AS_STRING, refactor GC marking into type-specific functions 2013-11-17 01:41:09 +00:00
Bob Nystrom
21d600ebe5 fix: increase default GC heap threshold from 1MB to 10MB in newVM
The default garbage collection trigger threshold in newVM() is raised from 1024*1024 (1MB) to 1024*1024*10 (10MB) to reduce GC frequency for larger workloads. Additionally, the DEBUG_GC_STRESS macro in common.h is commented out to disable stress-test GC collections on every allocation by default.
2013-11-16 19:43:40 +00:00
Bob Nystrom
5930aacb24 feat: replace boxed Obj bool/null with direct VAL_TRUE/FALSE_VAL/NULL_VAL macros 2013-11-16 19:35:59 +00:00
Bob Nystrom
944591339f feat: implement mark-sweep garbage collector with object linked list and pinned roots
Replace manual malloc/free for Obj allocations with GC-managed heap. Add Obj->next linked list, markObj traversal for all object types, and sweep phase in VM. Introduce MAX_PINNED stack for temporary GC roots during compilation. Refactor all object constructors (newBool, newFunction, newClass, newNum, newString) to accept VM pointer and register allocations. Move function constant registration earlier in compiler to ensure GC reachability. Add DEBUG_GC_STRESS and TRACE_MEMORY macros in new common.h header.
2013-11-12 16:32:35 +00:00