QuickJS Mist Memory Format Refactoring
Current Status
The codebase is partially refactored but doesn't compile due to missing KeyId type definitions.

Incremental Refactoring Tasks
Phase 0: Fix Compilation (Prerequisite)
 Define missing KeyId type as transitional typedef (will be replaced by JSValue later)
 Define K_EMPTY, K_TOMB, 
key_text()
, 
key_is_text()
, 
key_payload()
 macros/functions
 Verify build compiles and tests pass
Phase 1: New JSValue Encoding in quickjs.h
 Add new LSB-based tag constants alongside existing tags
 Add JS_TAG_SHORT_FLOAT for 61-bit truncated double
 Add JS_TAG_STRING_ASCII for immediate 7-byte ASCII strings
 Add new value extraction/creation macros
 Add type check inline functions
 Keep existing NaN-boxing code active (compile-time switch)
Phase 2: Short Float Implementation
 Implement JS_NewFloat64_ShortFloat() with range checking
 Implement JS_VALUE_GET_FLOAT64_ShortFloat() for decoding
 Out-of-range values return JS_NULL
 Prefer integer encoding when exact
Phase 3: Immediate ASCII String
Phase 3: Immediate ASCII String
 Implement JS_TryNewImmediateASCII() for strings up to 7 chars
 Implement JS_IsImmediateASCII() type check
 Implement JS_GetImmediateASCIILen() and JS_GetImmediateASCIIChar()
Integrate with 
JS_NewStringLen()
 to try immediate first
Phase 4: Remove JSStringRope
 Delete JSStringRope structure
 Remove JS_TAG_STRING_ROPE handling
 Update string concatenation to create immediate mist_text objects
 Remove rope-related iterator functions
Phase 5: Refactor JSString to UTF-32 (mist_text)
 Modify struct JSString to store UTF-32 characters only
 Remove is_wide_char flag and 8.16 unions
 Update 
js_alloc_string
 to allocate UTF-32 buffer
 Update string creation functions (
js_new_string8
, etc.)
 Update all string accessors to use UTF-32
 Implement immediate-to-UTF32 conversion helper
 Update string operations (
concat
, 
compare
) to work on UTF-32
Phase 6: Replace KeyId with JSValue in Records
 Change JSRecordEntry.key from KeyId to JSValue
 Update 
rec_hash_key()
 to hash JSValue keys directly
 Update 
rec_find_slot()
 for JSValue key comparison
 Update 
rec_get_own()
, 
rec_get()
, 
rec_set_own()
 for JSValue keys
 Remove KeyId typedef and related functions
Phase 7: Consolidate JSObject → JSRecord
 Remove JSShape and JSShapeProperty structures
 Remove shape hash table from JSRuntime
 Update all property access to use JSRecord
 Migrate JSObject users to JSRecord
 Remove JSObject structure
Phase 8: Update GC for New Format
 Update mark_children for JSRecord with JSValue keys
 Update free_record for JSValue keys
 Handle immediate values correctly (no marking needed)
 Test for cycles and correct collection
Phase 9: C Class Storage in Slot 0
 Implement slot 0 reservation for class_id and opaque pointer
 Update JS_SetOpaque() / JS_GetOpaque()
 Migrate existing class storage
Verification Checklist
 Build compiles without errors
 Existing tests pass
 Property access works correctly
 GC correctly handles cycles
 Short float encoding/decoding verified
 Immediate ASCII strings work