wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Rework pointer-patching on 64-bit. #29

Open wc-duck opened 9 years ago

wc-duck commented 9 years ago

Currently pointers are stored in packed data as the offset from instance. This could be reworked to make patching a lot faster and simpler. Currently patching is done by traversing the struct with stored type-info.

If the storeage instead was stored as x bits offset and y bits offset-to-next-pointer a simple loop as this could be used to patch pointers:

uint64 iter = instance->first_ptr; while( iter & NEXT_MASK ) { patch_pointer( iter, iter & OFFSET_MASK ); iter = iter + ( iter & NEXT_MASK ); }

this will however force instances to be less than 4GB on 64bit and less than 65kb on 32bit.

To begin with I'll save the old parse-code, set a flag in instance how the pointers is patched, and dispatch depending on that flag.

wc-duck commented 5 years ago

I guess that we could support a bit larger instances by shifting offset by 2 or 3 bits depending on ptr-size as offsets will always point to aligned data. Still the instance-size on 32bit feel a bit small :/

Tisten commented 2 years ago

https://github.com/wc-duck/datalibrary/pull/158