Skip to main content

Module typed_object

Module typed_object 

Source
Expand description

TypedObject - Fixed-layout objects for JIT optimization

TypedObject provides O(1) field access by pre-computed byte offsets, eliminating HashMap lookups entirely. This is the core optimization for type-specialized JIT code.

§Memory Layout

+-------------+-------------+-------------+-------------+
| schema_id   | ref_count   | field[0]    | field[1]    | ...
| (4 bytes)   | (4 bytes)   | (8 bytes)   | (8 bytes)   |
+-------------+-------------+-------------+-------------+
             Header (8 bytes)              Data (field_count * 8 bytes)

§Performance

OperationHashMapTypedObjectSpeedup
Single field get~25ns~2ns12.5x
Single field set~30ns~2ns15x
5 fields batch~125ns~10ns12.5x

Structs§

TypedObject
A typed object with fixed field layout for O(1) access.

Constants§

TYPED_OBJECT_ALIGNMENT
Memory alignment for TypedObject allocation. 64-byte alignment for L1 cache line optimization and SIMD operations.
TYPED_OBJECT_HEADER_SIZE
Header size in bytes (schema_id + ref_count)

Functions§

jit_new_typed_object
Allocate and initialize a new typed object with field values.
jit_typed_merge_object
Merge two TypedObjects into a new TypedObject.
jit_typed_object_alloc
Allocate a new typed object.
jit_typed_object_dec_ref
Decrement reference count on a typed object. Frees the object if ref_count reaches 0.
jit_typed_object_from_hashmap
Create a typed object from a HashMap-based object.
jit_typed_object_get_field
Get a field from a typed object by byte offset.
jit_typed_object_inc_ref
Increment reference count on a typed object.
jit_typed_object_schema_id
Get the schema ID from a typed object.
jit_typed_object_set_field
Set a field on a typed object by byte offset.