555 Commits

Author SHA1 Message Date
Ronald Caesar 35b73efa1b assembler: add ownership rules to bal_assembler_t documentation
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 03:30:43 -04:00
Ronald Caesar bd363ae18f actions: update ubuntu package index before install
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 03:24:42 -04:00
Ronald Caesar 35ef021fc9 engine: add magic numbers to verify struct integrity
The main focus of this commit is 'bal_safety.h'. This header file
adds magic numbers to prevent Undefined Behavior. Right now this
has only been added to 'bal_assembler_t'.

This introduces 3 magic numbers:

#define BAL_MAGIC_UNINITIALIZED 0x00000000U
#define BAL_ASSEMBLER_MAGIC_ALIVE 0xBA11A550U
#define BAL_ASSEMBLER_MAGIC_DEAD  0xDEADBA11U

'ALIVE' magic numbers will be set only if the struct has been
initialized properly. Every function should check a struct's magic
number to make sure it's not operating on a memory corrupted struct.

'DEAD' magic numbers should be set on a struct's 'destory()' function.
This is done to prevent Double Free and Use-After-Free scenarios.

Convenience macro 'BAL_CHECK_MAGIC' and 'BAL_CHECK_MAGIC_VOID' have
been added to easily validate struct integrity.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 03:20:17 -04:00
Ronald Caesar 2e7240e9d4 engine: make capacity error more specific
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 03:00:39 -04:00
Ronald Caesar a69df0101a engine: add missing documentation to error enum values
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 01:58:53 -04:00
Ronald Caesar 87923661a0 engine: reorganize error enum values
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 01:47:03 -04:00
Ronald Caesar 5b931324c6 engine: add new error for very large buffer capacities
This introduces BAL_ERROR_INVALID_CAPACITY which happens when a
buffer capacity exceeds SIZE_MAX or whatever the type's max value is.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 01:40:55 -04:00
Ronald Caesar 8b7b152492 docs: add rules for ai generated code.
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-16 03:28:16 -04:00
Ronald Caesar c45acbf6ad cpu: add explicit padding to bal_cpu_t
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 03:34:17 -04:00
Ronald Caesar 247005edd5 tests/x86/assembler: check for buffer overflows
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 03:18:55 -04:00
Ronald Caesar cb7314dbcc tests/x86/assembler: check for null buffer in emit() functions
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 03:17:39 -04:00
Ronald Caesar 13b0e53597 tests/x86/assembler: fix incorrect function argument
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 03:06:49 -04:00
Ronald Caesar 548b3791e2 test/x86/assembler: add missing function to Public_InvalidRegister_NoEmit
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 03:05:52 -04:00
Ronald Caesar 81f238f646 tests/x86/assembler: add more functions to Public_BadStatus_NoEmit test
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 02:49:44 -04:00
Ronald Caesar d598391055 x86/assembler: remove duplicate if statement
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 02:48:30 -04:00
Ronald Caesar 645fa7d3e5 tests/x86/assembler: add 100% branch coverage to bal_x86_assembler_reset()
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-15 02:32:01 -04:00
Ronald Caesar 28129be379 dashboard: generate lua ffi bindings for file dialog
I've added `tools/generate_ffi.lua` which generates lua ffi bindings
to C for all structs in a header file and functions in that have the
`BAL_EXPORT` keyword.

Right now only `tools/dashboard/dashboard_file_dialog.h` have ffi
bindings generated for it and saved to
`tools/dashboard/scripts/generated/dashboard_file_dialog_ffi.lua`.

The script only handles one header file at a time. Later on I will need
to add support for recursively scanning all header files in a folder
with options to exclude certain folders.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-14 03:57:39 -04:00
Ronald Caesar 80706ef77b engine: remove outdated docs
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-14 02:45:50 -04:00
mcrib884 50876e7968 tests: add encode and safety tests for bal_x86_emit_sub_r64_r64
Adds Encode_SubRegToReg_LowLow and Encode_SubRegToReg_HighHigh
byte-exact encode tests asserting every emitted byte, plus
NullContext, BadStatus, and InvalidRegister safety tests.

Signed-off-by: mcrib884 <farukkaya229@outlook.com>
2026-06-14 05:56:23 +00:00
mcrib884 40246aa4f0 assembler: add bal_x86_emit_sub_r64_r64
Emits the x86 sub r64, r64 instruction (opcode 0x2B, REX.W + ModRM,
3 bytes). Follows the 5-check guard pattern matching add_r64_r64.

Signed-off-by: mcrib884 <farukkaya229@outlook.com>
2026-06-14 05:56:23 +00:00
Ronald Caesar dd442e8a82 docs: add more immediate goals
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-12 04:57:24 -04:00
Ronald Caesar ac231fc159 dashboard/filedialog: move imgui rendering logic to lua
I want hot-reloading on the file dialog, so a moved
'dashboard_file_dialog_draw()' to Lua and named it
'dashboard_render_file_dialog()'. This requires adding the following
helper functions:

* dashboard_file_dialog_refresh()
* dashboard_file_dialog_append_path()
* dashboard_file_dialog_navigate_home()

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-12 04:57:24 -04:00
Ronald Caesar 8247ec9fe5 dashboard/filedialog: fix padding violation
Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-12 04:57:24 -04:00
mcrib884 94cca0e48f assembler: fix branch encoding and add reset function
The B (unconditional branch) instruction encoding used integer
division (/) instead of bitwise OR (|) to combine the opcode with
the branch offset. This produced incorrect machine code for every
branch target other than zero.

Also add bal_assembler_reset() to match the reset API provided by
every other module in Ballistic (bal_x86_assembler, sliding window,
tier1 compiler). The function zeroes the instruction buffer and
resets offset and status.

Wrap the hot function in BAL_UNLIKELY.

Signed-off-by: mcrib884 <farukkaya229@outlook.com>
2026-06-12 04:25:47 +00:00
Ronald Caesar bf360f9bc8 tests/decoder: skip empty buckets
If a hash bucket is empty, the test still loops 2,097,152 times which
is crazy. An empty bucket means `bal_decode_arm64()` will always
return NULL, so I've added a `continue` statement to skip the massive
loop.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-11 22:44:22 -04:00