Awesome
hotmem
Hot memory access for Haxe
Targets
Target | Arrays | Hot View | Bytes View | Implementation |
---|---|---|---|---|
cpp | + | + | + | hxcpp_memory / pointer |
flash | + | + | + | Memory Domain |
js | + | + | + | Parallel Typed Arrays |
nodejs | + | + | + | Parallel Typed Arrays* |
cs | + | - | - | NativeArray |
java | + | - | - | NativeArray |
Define -D hotmem_debug
enabling bounds checking, traces and additional asserts
Usage
Create your static dense fixed-length typed arrays before performance critical operations.
Use HotView
if different value-type access required
Types
hotmem.U8
: 8-bit unsigned inthotmem.U16
: 16-bit unsigned inthotmem.I32
: 32-bit signed inthotmem.F32
: 32-bit floating-point
Typed Arrays
For each types continuous memory fixed-length array is available (buffer)
hotmem.U8Array
: 8-bit unsigned int arrayhotmem.U16Array
: 16-bit unsigned int arrayhotmem.I32Array
: 32-bit signed int arrayhotmem.F32Array
: 32-bit floating-point array
Hot View
Each array could be wrapped for memory read/write operations:
var view = array.view(?atElement);
view.setU8(bytePosition, value);
view.setU16(bytePosition, value);
view.setI32(bytePosition, value);
view.setF32(bytePosition, value);
value = view.getU8(bytePosition);
value = view.getU16(bytePosition);
value = view.getI32(bytePosition);
value = view.getF32(bytePosition);
Data View
As Hot-View you able to lock
any haxe.io.BytesData
:
Modify templates and generate the code
$hotmem> haxelib run hxmake generate
TODO:
- More tests
- NodeJS implementation
- Types: I8, I16, U32, F64
- Java / CS implementation for hot/bytes view
- General fallback for other dynamic targets (
macro
as well) - More documentation on BytesView / lock / unlock flow
- Dox documentation