{"id":13398775,"url":"https://github.com/anse1/firmforth","last_synced_at":"2025-12-24T23:17:17.737Z","repository":{"id":72943452,"uuid":"50492926","full_name":"anse1/firmforth","owner":"anse1","description":"A just-in-time-compiling forth system using libfirm.","archived":false,"fork":false,"pushed_at":"2017-04-01T09:38:38.000Z","size":103,"stargazers_count":56,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-02-17T15:35:07.615Z","etag":null,"topics":["forth","jit-compiler","libfirm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anse1.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2016-01-27T08:25:30.000Z","updated_at":"2024-07-30T21:37:31.778Z","dependencies_parsed_at":"2023-05-26T04:00:49.277Z","dependency_job_id":null,"html_url":"https://github.com/anse1/firmforth","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/anse1%2Ffirmforth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anse1%2Ffirmforth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anse1%2Ffirmforth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anse1%2Ffirmforth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anse1","download_url":"https://codeload.github.com/anse1/firmforth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243511660,"owners_count":20302595,"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":["forth","jit-compiler","libfirm"],"created_at":"2024-07-30T19:00:31.576Z","updated_at":"2025-12-24T23:17:12.704Z","avatar_url":"https://github.com/anse1.png","language":"C","readme":"* firmforth\n\nfirmforth is a just-in-time-compiling forth-like system using [[http://libfirm.org][libfirm]].\nIt is small and comprehensible and was written to evaluate\nJIT-compilation using libfirm.\n\n** Design\n\nFirmforth is built around a dictionary of functions that can be\ninvoked for an effect on a stack of values or a side effect.  It also\nsports a typical forth outer interpreter.  In interpreter mode, it\nexecutes the words that are input.  In compilation mode, its action\ndepends on whether an entered word is flagged immediate.  Immediate\nwords - e.g. \"if\" - are still executed right-away and implement the\ncompiler itself.  Normal words end up as Call nodes in the\nintermediate language.\n\nWhen the definition of a new word is complete, libfirm-provided\noptimizations are invoked, possibly inlining Calls of functions for\nwhich the intermediate representation is available.  An assembly file\nis then generated by libfirm and assembled into a shared object.  This\nis in turn loaded into the program using dlopen() and the word is\nadded to the dictionary.  The IR is also kept around for future\ninlining of the word.\n\n[[file:firmforth.png]]\n\n** Usage\n\nA couple of standard forth words are written in forth itself in the\nfile =core.fifo=.  To get an interactive session with these words\ndefined, you could invoke firmforth like this:\n\n: make \u0026\u0026 cat core.fifo - | ./firmforth\n\nSome of the forth words are currently implemented in C.  In order to\nbe able to inline them into new words for a major speedup, the\nintermediate representation for them can be made available by invoking\n[[https://github.com/MatzeB/cparser][cparser]] like this:\n\n: cparser --export-ir firmforth.c\n\n** Goals\n- [X] Interactively compile forth words using graphs of Call nodes\n- [X] Add control flow primitives\n- [X] Keep IR of newly defined words around and inline them\n- [X] Keep IR of statically defined words around and inline them\n- [ ] Use libfirm's binary emitter instead of dlopen()\n\n** Benchmark\nThe table below lists times[s] required for compiling and executing\nthe word =fibonacci= and =queens= in =examples.fifo= on my machine for\nvarious forth systems.\n\n| benchmark    | firmforth 95ab9b7        | gforth-fast 0.7.2 |\n|--------------+--------------------------+-------------------|\n| 40 fibonacci | 0.82 (+0.05 compilation) |               3.2 |\n| 16 queens    | 25.1 (+0.28 compilation) |              43.9 |\n\n** References\n- https://korte.credativ.com/~ase/firm-postgres-jit-forth.pdf\n** Authors\n\nAndreas Seltenreich \u003cseltenreich@gmx.de\u003e\n","funding_links":[],"categories":["Uncategorized","C"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanse1%2Ffirmforth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanse1%2Ffirmforth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanse1%2Ffirmforth/lists"}