{"id":16170197,"url":"https://github.com/porglezomp/scheme-jit","last_synced_at":"2025-06-17T15:42:27.899Z","repository":{"id":106859412,"uuid":"154361756","full_name":"porglezomp/scheme-jit","owner":"porglezomp","description":"A JIT compiler for a small scheme dialect, as a project for Advanced Compilers.","archived":false,"fork":false,"pushed_at":"2018-12-19T21:47:31.000Z","size":239,"stargazers_count":10,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-17T01:02:58.979Z","etag":null,"topics":["bounds-checking","compiler","interpreter","jit-optimization","scheme"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/porglezomp.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-10-23T16:31:13.000Z","updated_at":"2023-09-28T01:58:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"d5236b11-5c9a-4391-a21b-a72bb5566827","html_url":"https://github.com/porglezomp/scheme-jit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fscheme-jit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fscheme-jit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fscheme-jit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fscheme-jit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porglezomp","download_url":"https://codeload.github.com/porglezomp/scheme-jit/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244325292,"owners_count":20435080,"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","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":["bounds-checking","compiler","interpreter","jit-optimization","scheme"],"created_at":"2024-10-10T03:17:49.419Z","updated_at":"2025-03-18T23:31:08.117Z","avatar_url":"https://github.com/porglezomp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scheme JIT\n\nOur goal is to demonstrate measurable benefits from some JIT optimizations.\nWe want tail call optimization so that we’ve got places to do loop optimization, so we'll have more visible improvements.\nWe want some monomorphization or something to get into an interesting JIT optimization.\n\n## Values\n- Numbers\n- Symbols\n- N-tuples (is `nil = []`?)\n  Lists are nested pairs, so `'(1 2 3)` is `[1 [2 [3 []]]]`\n  Immutable data\n- Closures\n\n## Monomorphization opportunities\n- Specializing higher-order functions for a given function\n- Removing bounds checks on tuple indexing\n- Removing arity checks when calling functions\n- Removing type checks before arithmetic / polymorphic comparison / etc.\n\n## Special Forms\n\n- `(define (f x ...) body ...)`\n- `(if p t f)`\n- `(quote x)`\n\n## Builtin functions\n\n- `(typeof x)`\n- `(vector-make n x)`\n- `(vector-index v n)`\n- `(vector-set! v n x)`\n- `(vector-length v)`\n- `(pointer= a b)`\n- `(number= a b)`\n- `(symbol= a b)`\n- `(number\u003c a b)`\n- `(trap)`\n\nAnd arithmetic operators\n\n## Prelude\n\n- `=`, `!=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`\n- `not`\n- `number?`, `symbol?`, `vector?`, `function?`, `bool?`, `pair?`, `nil?`\n- `cons`, `car`, `cdr`\n\n## Bytecode design\n\nSplit operations into many instructions.\nFor example, an `add_num` instruction wouldn't check the types of its arguments, typechecking would be separate.\nBad for efficiency, good for evaluating the effectiveness of JIT optimizations at removing bounds checks / type checks / etc.\n\nWe pick a register machine, in the hopes that it'll be easier to translate for optimizations.\n\n## Sample code\n\n```scheme\n(define (nil? xs) (= xs []))\n(define (car xs) (nth xs 0))\n(define (cdr xs) (nth xs 1))\n(define (cons x xs) [x xs])\n(define (pair? x) (= (vlen x) 2))\n\n(define (list? xs)\n  (if (nil? xs)\n    true\n    (if (pair? xs)\n      (list? (cdr xs))\n      false)))\n\n(define (map0 f xs)\n  (if (nil? xs)\n    []\n    (cons\n      (f (car xs))\n      (map0 f (cdr xs)))))\n\n(define (reverse-onto xs acc)\n  (if (nil? xs)\n    acc\n    (reverse-onto\n      (cdr xs)\n      (cons (car xs) acc))))\n      \n(define (map-onto f xs acc)\n  (if (nil? xs)\n    acc\n    (map-onto\n      f (cdr xs)\n      (cons (f (car xs) acc)))))\n      \n(define (map f xs)\n  (reverse-onto\n    (map-onto f xs [])\n    []))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fscheme-jit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporglezomp%2Fscheme-jit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fscheme-jit/lists"}