{"id":16987306,"url":"https://github.com/weliveindetail/statefuljit","last_synced_at":"2026-04-16T22:30:58.952Z","repository":{"id":70995677,"uuid":"48204864","full_name":"weliveindetail/StatefulJit","owner":"weliveindetail","description":"A minimal experimental JIT compiler that maintains variable state during recompilation","archived":false,"fork":false,"pushed_at":"2016-03-07T18:38:48.000Z","size":2022,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-14T10:34:25.430Z","etag":null,"topics":["experimental","language","llvm","stateful"],"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/weliveindetail.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2015-12-18T00:06:09.000Z","updated_at":"2017-10-25T21:51:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"033625b2-b4df-49f1-90de-eed988313b43","html_url":"https://github.com/weliveindetail/StatefulJit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/weliveindetail/StatefulJit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weliveindetail%2FStatefulJit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weliveindetail%2FStatefulJit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weliveindetail%2FStatefulJit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weliveindetail%2FStatefulJit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weliveindetail","download_url":"https://codeload.github.com/weliveindetail/StatefulJit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weliveindetail%2FStatefulJit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31907424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["experimental","language","llvm","stateful"],"created_at":"2024-10-14T02:48:59.359Z","updated_at":"2026-04-16T22:30:58.923Z","avatar_url":"https://github.com/weliveindetail.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StatefulJit\n\nA minimal experimental Just-in-Time compiler that maintains variable state during recompilation.\nThis may become interesting especially for \n[live coding systems](https://en.wikipedia.org/wiki/Live_coding).\n\n## Table of Contents  \n* [Project Structure](#project-structure)\n* [Language Definition](#language-definition)\n* [Basic Example](#basic-example)\n* [Compound Types and References](#compounds-and-refs)\n* [Next Steps](#next-steps)\n* [Build with CMake](#build-with-cmake)\n\n\u003ca name=\"project-structure\"/\u003e\n## Project Structure\n\nStatefulJit is a static library that contains the compiler and the execution engine. It defines \na very basic API via the StatefulJitApi.h used by the two \"client\" projects InteractiveClient and \nTestClient. The former is useful for playing around and debugging while the latter aims to \nbecome a comprehensive test suite.\n\n\u003ca name=\"language-definition\"/\u003e\n## Language Definition\n\nThe language used for this project is a subset of the original \n[kaleidoscope language](http://llvm.org/docs/tutorial/index.html). \nTo keep focus and show the basic techniques, control flow and function definition constructs \nhave been removed. Example programs are one-liners compiled into a single implicitly defined \ntop-level function. The generated code is executed immediately after the compilation finished.\n\n\u003ca name=\"basic-example\"/\u003e\n## Basic Example\n\nThe following code is part of the TestClient gtest project. It shows how variable states survive \nrecompilation. It compiles and executes three programs in sequence on the same JIT and validates \nthe return values. The current implemention successfully passes the test case.\n\n```\n  auto jit = SetupStatefulJit();\n  EXPECT_EQ(1.0, Eval(*jit, \"def int a=1           in a;\"));\n  EXPECT_EQ(1.0, Eval(*jit, \"def int a, double b   in a + b;\"));\n  EXPECT_EQ(3.0, Eval(*jit, \"def int a, double c=2 in a + c;\"));\n```\n\n`a` is the interesting variable here. All tests declare this variable with the same type. \nHowever, only the first one initializes it. In the second and the third program the compiler \nfinds it uninitialized. This is the time to start searching for previous revisions of the \nvariable's state. If it's successful (as here in the case of `a`) it maps the new variable \nto the existing location in memory. Otherwise it emits code to allocate new memory on the heap and execute \nthe default initialization. For more examples have a look at [the gtest](https://github.com/weliveindetail/StatefulJit/blob/master/Clients/TestClient/test.cpp).\n\n\u003ca name=\"compounds-and-refs\"/\u003e\n## Compound Types and References\n\nApart from using only the primitive types `double` and `int` one can now also define custom \ncompound types in a new `types` section using the `struct` keyword. Compound types can have \nprimitive members as well as compound members. It's now also possible to define references\nwith the `\u0026` postfix on a type specifier.\n\n```\n  auto jit = SetupStatefulJit();\n  EXPECT_EQ(1.0, Eval(*jit, R\"(\n    types t1: struct { int a, double b },\n          t2: struct { t1 a, int b },\n          t3: struct { t1\u0026 a, t2 b }\n    def t1 x1 = (1, 2), t2 x2 = (x1, 3), t3 x3 = (x1, x2), t3\u0026 y3 = x3\n    run x2.a.a - x1.a + x3.b.a.b - x2.a.b + y3.a.b - x3.a.b + 1;\n  )\"));\n```\n\nCovering the basic constructs for type definitions available in typical general-purpose \nlanguages serves as a basis for further research on runtime state transfer.\n\n\u003ca name=\"next-steps\"/\u003e\n## Next Steps\n\nIn the next step I will first do some architectural refactoring on the `StatefulJit` compiler\nlayer and its interface. This is necessary to sharpen my understanding on how it can be \nimplemented as a reusable library independent from a specific language or compiler.\n\nHaving this done, I'm finally prepared to implement logical mappings for variables with\ntypes that evolve from one runtime revision to the next. This includes scenarios like:\n* adding members to compound types\n* removing members from compound types\n* rearranging members in compound types\n\nThis is certainly the next big step for the project and I'm looking forward to get it done \nwithin the next few weeks.\n\n\u003ca name=\"build-with-cmake\"/\u003e\n## Build with CMake\n\nGet CMake ready:\n* install the latest CMake for your operating system, you can [find it here](https://cmake.org/)\n\nGet LLVM ready:\n* checkout the latest version of LLVM from [SVN trunk](http://llvm.org/svn/llvm-project/llvm/trunk) or the master branch of the [git mirror](https://github.com/llvm-mirror/llvm)\n* **on Windows**, find the downloaded sources and **patch the top-level CMakeLists.txt** as [shown here](https://rawgit.com/weliveindetail/StatefulJit/master/docs/patch-llvm-cmakelists.html)\n* build and install LLVM with CMake as [described here](http://llvm.org/docs/CMake.html)\n\nGet the sources:\n* select a folder of your choice in the command line\n* run `git clone https://github.com/weliveindetail/StatefulJit.git`\n* create and switch to a build directory using `mkdir StatefulJit/build` and `cd StatefulJit/build`\n* generate project files for your preferred development environment with cmake, e.g. `cmake -G \"Xcode\" ..`\n\nFor Windows users:\n* get the free non-commercial version of Visual Studio 2015 [from here](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx) (it's a complete IDE and it will not expire!)\n* there is a prepared `configure-msvc.bat` that generates you both, a 32-bit and a 64-bit VS project\n\nFor other OS' users:\n* you know how it works..\n* you'll need a C++14 compatible compiler to build this project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweliveindetail%2Fstatefuljit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweliveindetail%2Fstatefuljit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweliveindetail%2Fstatefuljit/lists"}