summaryrefslogtreecommitdiffhomepage
path: root/vm.c
AgeCommit message (Collapse)Author
2021-04-26types: support creating ressource values without associated typeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-25treewide: rework internal data type systemJo-Philipp Wich
Instead of relying on json_object values internally, use custom types to represent the different ucode value types which brings a number of advantages compared to the previous approach: - Due to the use of tagged pointers, small integer, string and bool values can be stored directly in the pointer addresses, vastly reducing required heap memory - Ability to create circular data structures such as `let o; o = { test: o };` - Ability to register custom `tostring()` function through prototypes - Initial mark/sweep GC implementation to tear down circular object graphs on VM deinit The change also paves the way for possible future extensions such as constant variables and meta methods for custom ressource types. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-29vm: add trace mode instruction dump output fixesJo-Philipp Wich
- Fix an off-by-one when printing push/pop stack indexes - Properly print negative hexadecimal values Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-26vm: fix another for-loop memory leakJo-Philipp Wich
Fixes: 20a3763 ("vm: fix loop variable memory leak in NEXTK/NEXTKV instruction") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-25vm: fix further memory leaks in trace modeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-25vm: fix loop variable memory leak in NEXTK/NEXTKV instructionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-23vm: fix leaking source context strings in trace modeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-11vm: gracefully handle property setting on non-array, non-object valuesJo-Philipp Wich
Before this fix, the VM aborted due to an assert in libjson-c when an attempt was made to set a property on a non-object value. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08vm: use uc_prototype_lookup() to obtain require function pointerJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08vm: fix global scope refcount imbalanceJo-Philipp Wich
The uc_vm_execute() API function decreases the refcount of the globals object when finishing but does not increase it initially which leads to a double free at main.c:155 Fix the issue by both increasing and decreasing the refcount. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-25vm: use portable printf format for pointer differencesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-02-17treewide: rewrite ucode interpreterJo-Philipp Wich
Replace the former AST walking interpreter implementation with a single pass bytecode compiler and a corresponding virtual machine. The rewrite lays the groundwork for a couple of improvements with will be subsequently implemented: - Ability to precompile ucode sources into binary byte code - Strippable debug information - Reduced runtime memory usage Signed-off-by: Jo-Philipp Wich <jo@mein.io>