{"id":20400374,"url":"https://github.com/fschutt/gsr-jit","last_synced_at":"2026-05-26T23:11:06.651Z","repository":{"id":90270338,"uuid":"121560623","full_name":"fschutt/gsr-jit","owner":"fschutt","description":"Test JIT compiler","archived":false,"fork":false,"pushed_at":"2018-06-24T20:23:34.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T07:18:21.032Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/fschutt.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}},"created_at":"2018-02-14T20:58:22.000Z","updated_at":"2025-02-17T03:14:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"363db247-5485-4cb3-bbb6-ba5b38364488","html_url":"https://github.com/fschutt/gsr-jit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fschutt/gsr-jit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fgsr-jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fgsr-jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fgsr-jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fgsr-jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fschutt","download_url":"https://codeload.github.com/fschutt/gsr-jit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fschutt%2Fgsr-jit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33542603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2024-11-15T04:39:55.703Z","updated_at":"2026-05-26T23:11:06.635Z","avatar_url":"https://github.com/fschutt.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gsr-jit\n\n## Notice\n\nFor now, this was only a test, this repository isn't further maintained.\n\n## What is GSR?\n\nThis repository was supposed to be a \"game-specific Rust compiler\", i.e. a \nJIT compiler that would simply parse a Rust module and translate it to assembly,\nthen execute it (when a game level is loaded). This is important because:\n\n- In larger game engines you don't want to re-compile the whole engine just for every minimal change (faster iteration)\n- You want certain mathematical operation / vector operations to use specific assembly instructions, but you only know\n  what CPU features you can use at runtime, so either you write duplicated code or you use JIT on the target system.\n- Interpreters such as Lua can incur significant overhead when calling across FFI boundaries (function lookup)\n\nGSR can compile a file in less then a millisecond, which is important if you want fast iteration.\nI tried using the official Rust compiler for this and using LLVM, but it doesn't work, this can not output the\nasm directly, only compile to an ELF binary or similar. \n\n## Syntax\n\nGSR uses the `syn` parser, adhering to the regular Rust syntax. Currently it can only compile \nfunctions that return integers, just as a test. GSR loads the file, then looks for the `#[start]` attribute, \nwhich is the program entry point. It assembles the dependent files into assembly **without any optimization**.\nThen it allocates memory pages for executable memory and jumps to the begin of the page and executes.\n\nExample:\n\n```rust\n// in to_be_ji_compiled.rs\n#[start]\nfn my_main_function() -\u003e u32 {\n    500\n}\n```\n```rust \n// in main.rs\n// this can be done in a loop, at runtime, for hot-reloading code\nlet ast = syn::parse_file(include_str!(\"to_be_ji_compiled.rs\")).unwrap();\n// assemble the AST into asm opcodes\nlet assembly_instructions = compiler::compile(ast); \n// load the executable memory and load the assembly into it\nlet jit = JitMemory::from_assembly_buf(\u0026assembly_instructions).unwrap();\n// tell the CPU to jump to the entry function and start executing\nlet result = (jit.run())();\nprintln!(\"the returned number is: {}\", result); // prints \"500\"\n```\n\nWhat GSR currently checks for:\n\n- It checks that a function isn't declared twice in the current scope\n- There must be at least one function with a `#[start]` attribute, otherwise, there'd be no main entry function.\n- It checks that the return type of the function is the same return type of the last expression\n- It uses the `movabs` instructions only if a 64-bit integer is necessary.\n\n## Goals and non-goals\n\nGSR does not aim to be a general-purpose JIT compiler, rather it aims to use the regular Rust syntax \nfor \"gameplay scripting\". There should be no generics support or large optimizatiosn, for example:\nit's purely for simple gameplay scripting, not large libraries. There is also no dependency management and\n`extern crate` is forbidden: The goal is to make levels playable, where the AOT-compiled game engine\nprovides an API which the JIT-compiled code can then call into. modules are allowed, in order to split \nfunctionality across files, but extern libraries are forbidden, because each \"level\" is just one start module \nwith an entry function and from there on the functions are executed accordingly. \n\nGSR should know about special mathematical optimizations, specifically SIMD and vector instructions.\nThese should be JIT-compiled on the target users CPU, according to the features that the CPU supports.\nA secondary goal is to integrate the JIT with an Entity-Component-System such as SPECS. This would make it ideal for\ndefining the data models ahead of time, but tweaking the behaviour at runtime. A third goal is to make\nGSR available for modding, but check that the code is not doing anything malicious (no reading or writing files,\nthose have to be called from the game engine).\n\n## Roadmap\n\nFor now, the next step would be calling sub-functions, if, else and loops, register allocation mechanisms \nas well as dynamic allocation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffschutt%2Fgsr-jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffschutt%2Fgsr-jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffschutt%2Fgsr-jit/lists"}