Commit graph

288 commits

Author SHA1 Message Date
poprocks627
b526f3dba6
Merge 6b53caeef3 into c27d303e54 2025-12-09 07:19:33 -08:00
poprocks627
6b53caeef3
Create devcontainer.json
Signed-off-by: poprocks627 <Amaranthandamber@gmail.com>
2025-12-09 07:17:53 -08:00
Ronald Caesar
c27d303e54
Updaye Readme 2025-12-07 17:40:32 -04:00
Ronald Caesar
b138abb540
jit/interpreter: Implement translator and hardened entrypoint
Introduces the translation stage fod the ARM32 interpreter and
significantly hardens the application's core logic to meet my high
integrity standards.

- translator.c converts raw ARM32 guest code into an array of
  interpreter op-codes
- main.c was completly rewritten to be as safe as possible.
- pmath.h provides safe, checked arithmetic functions to prevent integer
  overflow.
- adds binary files in src/ for testing the interpreter.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-06 19:48:58 -04:00
Ronald Caesar
b1d9a64866
common/logging: Remove timestamp from logs
Timestamp clutters the terminal and doesnt provide any tangible
benefits.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-06 18:28:30 -04:00
Ronald Caesar
0d957968df
jit/interpreter: Organize ifdefs
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-06 01:55:55 -04:00
Ronald Caesar
b9b62574bf
jit: Implement build-time generation of jit infrastructure
generate_jit_assets.py expands the automatated code generation to
include:

- Opcode enumerations in arm32_opcodes.h.
- Decoder lookup tables in arm32_table.c
- Computed-goto jump tables foe the interpreter in handler_table.inc.

Relocates arm32.inc to src/jit/common/a32_instructions.inc.

Implements the primary execution loop in
src/jit/interpreter/arm32/instruction.c. The code is messy and will be
rewritten in the future.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-06 00:31:46 -04:00
Ronald Caesar
e714dc47d0
jit/decoder: rename decoder script
Renames generate_decoder_tests.py to generate_jit_decoder_tests.py.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-06 00:16:18 -04:00
GloriousTacoo
c508a927ea
docs: Adjust one typo (#87)
## Description
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.

Just a simple typo in this one README file to adjust. 

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [X] Documentation update
- [ ] Refactoring (no functional change, code cleanup)
- [ ] Performance improvement

## Code Review Process
**IMPORTANT**: This project maintains an extremely high standard for
code quality and correctness. By submitting this pull request, you
acknowledge and agree to the following:

1. **You must be able to defend every single line of code you have added
or modified**
2. **You must be prepared to explain the reasoning behind every design
decision**
3. **You must be able to discuss and justify your approach to solving
the problem**
4. **You must be ready to address all feedback and make requested
changes**
5. **You must have thoroughly tested your changes and be confident in
their correctness**

The code review process for this project is intentionally tedious and
thorough. Do not submit a pull request unless you are prepared to defend
your PR changes.

## Breaking Changes
If this change introduces any breaking changes, please describe them
here.

## Checklist
- [X] My code follows the project's coding style guidelines
- [X] I have commented my code, particularly in hard-to-understand areas
- [X] I have made corresponding changes to the documentation
- [X] My changes generate no new warnings
- [X] I have read the project's CONTRIBUTING guidelines
- [X] I understand and agree to the rigorous code review process
described above
2025-12-05 18:19:21 -04:00
kokomo123
3c269833a1
Adjust one typo
Signed-off-by: kokomo123 <70863536+kokomo123@users.noreply.github.com>
2025-12-05 10:37:57 -05:00
Ronald Caesar
cc8cc63478
host/memory: Fix typo
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-04 19:52:37 -04:00
Ronald Caesar
54166a54ea
jit/interpreter: Add stub files for arm32 decoding
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-04 19:43:40 -04:00
Ronald Caesar
195893389d
Add future goals for Pound
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-04 19:43:34 -04:00
Ronald Caesar
d454bea4cc
Convert codebase to C
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-12-04 07:26:16 -04:00
Ronald Caesar
d1e3919a8c
jit/decoder: Add generated arm32 tests
Introduces the first unit tests for the ARM32 JIT decoder. A new script
automatically generates a test case for every instruction in arm32.inc,
providing 100% of the isa.

This also includes a critical rework of the decoder's lookup table
generation logic. The previous hashing method was flawed, causing
build-time overflows and incorrect instruction matching (shadowing) for
patterns with wildcards. The new algorithm correctly populates the
lookup table.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-30 06:14:03 -04:00
Ronald Caesar
c235e57071
jit/decoder: move decoder to frontend/decoder
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-29 15:49:57 -04:00
Ronald Caesar
fb7a2a6b32
jit/decoder: Remove log statement from decoder hit path
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-29 15:43:11 -04:00
Ronald Caesar
2b5131e56c
refactor: Humongous Commit
Major architectural refactorbto focus exclusively on JIT development.

JIT & Decoder Architecture
-    Implemented scripts/generate_jit_decoder_a32_table.py to parse
     instruction definitions at build-time rather than runtime.
-    Moves decoder lookup tables from RAM to ROM.

Scope Reduction:
-    Removed frontend, GUI, and rendering dependencies.
-    delete src/frontend, src/target, and associated design docs.

Most importantly, this commit starts the transition of this codebase
from C++ to C. I cant stand creating C++ code, and since no one else
is contributing to this project this change shouldnt matter.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-29 14:53:02 -04:00
Ronald Caesar
2ea7647dc2
jit/decoder: Fix decoder hash logic
Fixes `relevant_mask` calculation in arm32_init() to use bitwise AND
instead of OR. The previous logic incorrectly validated bits outside the
hash region, preventing valid instructions like 'BX` from being added to
the lookup table.

Increased LOOKUP_TABLE_MAX_BUCKET_SIZE from 8 to 16. Instructions with
wildcard bits in the hash region (eg, AND, EOR) must map to multiple
buckets to ensure O(1) lookup.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-29 07:47:49 -04:00
Ronald Caesar
27710ca8c9
jit/decoder: Overhaul arm32 decoder
Rewrites the Arm32 instruction decoder to align with high integrity
software standards such as MISRA C and BARR-C.

Key Architectural  Changes:

- Added compile time validation.
- Removed dependency on memory allocator. The decoder now uses
   statically allocated global storage.
- Implement a hash-based lookup table to reduce decoding complexity to
   O(1).
- Removed decoder_t in favour of a singleton pattern.
- Add documentation stating thread safety, preconditions, and
   postconditions for all public functions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-28 23:50:27 -04:00
Ronald Caesar
04b5af2517 build: Disable most 3rd party dependencies
SDL3, ImGUI, and OpenGL are unused dependencies. They will be enabled
once a GUI becomes necessary

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-28 04:04:15 -04:00
Ronald Caesar
0011bb7825
jit/ir: remove the prefix p_ from pointers
Although this is mandated in the Barr C style guide, I find this
specific rule uneccesarry and tedious.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-27 16:03:01 -04:00
Ronald Caesar
d61fbe3514
jit/ir: Remove instruction linked list
The linked list was implemented to store instructions in a basic block.
Instructions will now be stored in arrays to keep logic simple and
straight-foward.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-27 15:59:16 -04:00
Ronald Caesar
21c0f0bdef
Remove PVM folder
The folder will be rewritten once the JIT compiler is completed.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-25 22:58:50 -04:00
Ronald Caesar
d6c29e412a
Fix formatting compiler warnings
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-23 04:54:41 -04:00
Ronald Caesar
e47570693f
Rewrote Contributing guidelines
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-22 22:37:51 -04:00
Ronald Caesar
bd0bf1deba
jit/ir: Implement IR instruction management
Introduces IR instruction management, including instruction_t and
instruction_list_t definitions and their implementations. It also added
const-correctness to the value_t API.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-22 22:12:22 -04:00
Ronald Caesar
ffea35bc8f
Merge branch 'Xphalnos-memory' into arm64
Xphalnos says:
==============
The memory arena is created but not destroyed at the end of execution.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-21 16:33:17 -04:00
Xphalnos
7d6a721e36 Memory deallocation at the end of execution 2025-11-16 13:51:07 +01:00
Ronald Caesar
523d1e6656
jit/ir: Add opcode interface
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-09 13:01:23 -04:00
Ronald Caesar
fa1f91dc94
jit/ir: Include A32 opcodes
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-09 09:11:02 -04:00
Ronald Caesar
304aeed9f6
tests/jit: Add IR tests
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-08 16:37:41 -04:00
Ronald Caesar
a57ce183a1
extern/googletest: Add testing library
Need a testing framework to test the IR layer. GoogleTest is a popular
choice so it was chosen.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-08 15:41:04 -04:00
Ronald Caesar
d832bb1151
jit/ir: Define value_t interface
Introduces jit/ir/value.h, which defines the value_t structure which is
a polymorphic container designed to hold various kinds of data that IR
instructions operate on or produce.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-08 14:45:13 -04:00
Ronald Caesar
dfd91ced48
jit/ir: add value_t getter functions
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-02 14:08:58 -04:00
Ronald Caesar
14ef99faf9
jit/ir: Introduce A32 register type definitions
A new header, jit/a32_types.h, defines a32_register_t, an enum for Arm32
general purpose register's R0-R15, including standard aliases for SP,
LR, and PC.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-02 13:22:23 -04:00
Ronald Caesar
621665c659
jit/ir: Add value_t struct
This type is designed to hold various kinds of data that IR instructions
operate on, starting with immediate integer constants.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-11-01 16:09:22 -04:00
Ronald Caesar
cf504e107e
jit/ir: Add type.h
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-31 17:04:38 -04:00
Ronald Caesar
49dbc25818
jit/ir: Change namespace from decoder to IR
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-30 00:21:09 -04:00
Ronald Caesar
a25e4ccbe0
jit/ir: Add IR types
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-27 12:45:04 -04:00
Ronald Caesar
ac950250a8
jit: Remove global decoder variable
The decoder is created in main.cpp so having a global decoder is
useless.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-26 14:01:59 -04:00
Ronald Caesar
1c3b730899
jit: Add Barr C code standard
Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-26 13:59:48 -04:00
Ronald Caesar
a543f78b77
jit: made private functions static
This comforms to Rule 6.2 of Barr C code standard.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-26 06:07:29 -04:00
Ronald Caesar
a0ed4382a5
jit: Implement arm32 instruction decoding logic
Introduces the core Arm32 decoder, including the instruction parsing
mechanism and an initial set of defined instructions.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-26 02:19:35 -04:00
Ronald Caesar
2e2b5df20c
Merge branch 'ramenrrami-arm64' into arm64 2025-10-17 21:32:33 -04:00
ramenrrami
aff8491a19
jit: inline ARM32 instruction logging and remove redundant traces 2025-10-17 21:28:07 -04:00
ramenrrami
15938b667b
jit: add detailed logging for ARM32 instruction registration 2025-10-17 21:23:34 -04:00
Ronald Caesar
9341e8d4ee
Merge remote-tracking branch 'Xphalnos/arm64' into arm64
Made freeing memory from our arena allocator safer. Replaced free() with munmap().
2025-10-17 17:13:47 -04:00
Ronald Caesar
194b15b556
host: add assertions
Munmap can fail if the length argument is 0, and the address being freed
is not a multiple of the host's page size.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2025-10-17 16:28:02 -04:00
Xphalnos
51e7adcbee Replace free() by munmap()
Signed-off-by: Xphalnos <yiga.steam@gmail.com>
2025-10-16 08:16:32 +02:00