{"id":30770655,"url":"https://github.com/cpscript/simple-jit-compiler","last_synced_at":"2025-11-06T19:05:10.859Z","repository":{"id":302948959,"uuid":"1013578973","full_name":"CPScript/Simple-JIT-Compiler","owner":"CPScript","description":"A Simple JIT Compiler: For arithmetic expressions, emitting native x86-64 code.","archived":false,"fork":false,"pushed_at":"2025-07-04T06:14:23.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-30T05:57:44.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CPScript.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T06:12:09.000Z","updated_at":"2025-07-17T18:20:15.000Z","dependencies_parsed_at":"2025-07-04T23:35:36.978Z","dependency_job_id":"e5c9a257-a163-42e2-b280-d95780b11b50","html_url":"https://github.com/CPScript/Simple-JIT-Compiler","commit_stats":null,"previous_names":["cpscript/simple-jit-compiler"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CPScript/Simple-JIT-Compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CPScript%2FSimple-JIT-Compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CPScript%2FSimple-JIT-Compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CPScript%2FSimple-JIT-Compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CPScript%2FSimple-JIT-Compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CPScript","download_url":"https://codeload.github.com/CPScript/Simple-JIT-Compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CPScript%2FSimple-JIT-Compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273685604,"owners_count":25149722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-04T23:11:57.744Z","updated_at":"2025-11-06T19:05:05.823Z","avatar_url":"https://github.com/CPScript.png","language":"C","readme":"### This JIT compiler implements a complete pipeline from arithmetic expression parsing to native x86-64 code execution.\n\u003eBleh :P\n---\n\n**Architecture:** The compiler uses a recursive descent parser to build an AST from infix expressions, then traverses the AST to emit x86-64 machine code directly into executable memory allocated via mmap with PROT_EXEC.\n\n**Parser Implementation:** Tokenizes input into numbers and operators, builds AST using standard precedence rules (multiplication/division before addition/subtraction), handles parentheses for grouping.\n\n**Code Generation:** Emits raw x86-64 opcodes using RAX as primary accumulator and RBX for binary operations. Uses stack for intermediate values during expression evaluation. Key instruction sequences: MOV RAX immediate for loading constants, PUSH/POP for stack management, ADD/SUB/IMUL for arithmetic, XOR RDX + IDIV for division.\n\n**Memory Management:** Uses mmap to allocate executable pages, automatically handles machine code layout, returns function pointer for direct execution.\n\n**Execution Model:** Generated code follows x86-64 calling convention, returns result in RAX register, can be called directly as C function pointer.\n\nCompile with: `gcc -o jit jit.c`\nUsage: `./jit \"2 + 3 * 4\"`\n\nSupports nested expressions, proper operator precedence, and generates efficient native code without intermediate interpretation layers.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpscript%2Fsimple-jit-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcpscript%2Fsimple-jit-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpscript%2Fsimple-jit-compiler/lists"}