{"id":13500984,"url":"https://github.com/Nymphium/opeth","last_synced_at":"2025-03-29T07:32:14.261Z","repository":{"id":77510423,"uuid":"78761939","full_name":"Nymphium/opeth","owner":"Nymphium","description":"Opeth is the optimizer and debug tools for Lua 5.3 VM bytecode, or Metal band","archived":true,"fork":false,"pushed_at":"2017-11-02T11:29:44.000Z","size":78,"stargazers_count":70,"open_issues_count":5,"forks_count":1,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-31T19:37:43.410Z","etag":null,"topics":["debugger","lua","moonscript","optimizer","visualiser","vm-bytecode"],"latest_commit_sha":null,"homepage":"http://www.coins.tsukuba.ac.jp/syllabus/GB13312_GB13322.html","language":"MoonScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nymphium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-12T16:00:25.000Z","updated_at":"2024-10-29T04:00:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e24984a-bf87-4527-8f36-bbc84493a07e","html_url":"https://github.com/Nymphium/opeth","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/Nymphium%2Fopeth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nymphium%2Fopeth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nymphium%2Fopeth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nymphium%2Fopeth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nymphium","download_url":"https://codeload.github.com/Nymphium/opeth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246155998,"owners_count":20732355,"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":["debugger","lua","moonscript","optimizer","visualiser","vm-bytecode"],"created_at":"2024-07-31T22:01:21.446Z","updated_at":"2025-03-29T07:32:13.989Z","avatar_url":"https://github.com/Nymphium.png","language":"MoonScript","readme":"Opeth\n===\n\nOpeth is the optimizer and debug tools for [Lua](https://lua.org) VM bytecode, or [Metal band](http://www.opeth.com/).\n\n# tools\n## opeth\nLua VM Bytecode optimizer\n\n### install\n```\nluarocks --local install opeth-opeth\n```\n### usage\n\n```\nUsage: opeth [-o \u003coutput\u003e] [-V] [-T] [-v] [--show-optimizations] [-h]\n       \u003cinput\u003e [-x index [index] ...]\n\nLua VM Bytecode Optimizer\n\nArguments:\n   input                 luac file\n\nOptions:\n   -o \u003coutput\u003e, --output \u003coutput\u003e\n                         output file (default: optimized.out)\n   -x index [index] ..., --disable-optimize index [index] ...\n                         disable a part of optimizer\n   -V, --verbose         verbose optimization process\n   -T, --time            measure the time\n   -v, --version         version information\n   --show-optimizations  show a sort of otimization\n   -h, --help            Show this help message and exit.\n```\n\n#### example\n```\n$ # Show the optimization techniques. The order corrensponds to the index which needs to `--disable-optimize` option.\n$ opeth --show-optimizations\nunreachable blocks removal : remove all the blocks which are unreachable for the top\nconstant fold              : evaluate some operations beforehand\nconstant propagation       : replace `MOVE` instruction with the another\ndead-code elimination      : eliminate the instructions which aren't needed\nfunction inlining          : expand a funcion call with the function's instructions\n$\n$ opeth luac.out -o optimized.out\n$\n$ opeth luac.out -o optimized.out --verbose --time\nread from luac.out (size: 226 byte, time: 0.79703330993652 msec)\nunreachable blocks removal#main: 0 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 2 modified\nunreachable blocks removal#main: 3 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 1 modified\nunreachable blocks removal#main: 0 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 1 modified\ndead-code elimination#main: 0 modified\nunreachable blocks removal#main: 0 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 0 modified\nunused resources removal#main: 3 modified\n(optimize time: 3.058910369873 msec)\nchange of the number of instructions: 11 -\u003e 5\n\nwrite to optimized.out (size: 110 byte, time: 0.25796890258789 msec)\n$\n$ # optimize without the op-technique which the index points to.\n$ opeth luac.out -o optimized.out --verbose --time --disable-optimize 1\nread from luac.out (size: 226 byte, time: 0.7932186126709 msec)\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 2 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 1 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 1 modified\ndead-code elimination#main: 0 modified\nconstant fold#main: 0 modified\nconstant propagation#main: 0 modified\ndead-code elimination#main: 0 modified\nunused resources removal#main: 2 modified\n(optimize time: 3.7388801574707 msec)\nchange of the number of instructions: 11 -\u003e 8\n\nwrite to optimized.out (size: 129 byte, time: 0.32711029052734 msec)\n```\n\n### optimize functions inscripts\nyou can use the optimizer in your scripts.\n```moon\noptimizer = require'opeth.opeth'\n\nf = -\u003e ......\nf_ = optimizer f\nf_!\n```\n\n## lvis\nLua VM Bytecode Control Flow Graph Visualizer\n### install\n```\nluarocks --local install opeth-lvis\n```\n\n### usage\n#### example\nSupporse think about the lua code and following bytecode.\n```lua\nlocal x = 3\n\nif x \u003c 5 then\n\tprint(\"hello\")\nelse\n\tprint(\"world\")\nend\n```\n\n```\n        1       [1]     LOADK           0 -1    ; 3\n        2       [3]     LT              0 0 -2  ; - 5\n        3       [3]     JMP             0 4     ; to 8\n        4       [4]     GETTABUP        1 0 -3  ; _ENV \"print\"\n        5       [4]     LOADK           2 -4    ; \"hello\"\n        6       [4]     CALL            1 2 1\n        7       [4]     JMP             0 3     ; to 11\n        8       [6]     GETTABUP        1 0 -3  ; _ENV \"print\"\n        9       [6]     LOADK           2 -5    ; \"world\"\n        10      [6]     CALL            1 2 1\n        11      [7]     RETURN          0 1\n```\n\nGiven a bytecode,\n```\n$ lvis luac.out\n```\nlvis outputs the pdf\n\n![lvis-output](img/lvis-output.png)\n\n## moonstep\nLua VM Bytecode step-by-step execution machine\n### install\n```\nluarocks --local install opeth-moonstep\n```\n\n### usage\n#### commands in dialogue\n```\ncommand:\n        bp \u003cpc\u003e: set a breakpoint to \u003cpc\u003e\n        r: run the code. if the breakpoint is set, stop at \u003cpc\u003e\n        n: execute the next instruction\n        d: dump the current register and PC\n        dp: dump the bytecode structure\n        q: quit\n```\n\n## lasmc\n**L**ua VM Bytecode **As**se**m**bly-like Language **C**ompiler\n### install\n```\nluarocks --local install opeth-lasm\n```\n\n### syntax\n......\n\n# dependencies\n- [MoonScript](https://moonscript.org)\n- [luasocket](http://w3.impa.br/~diego/software/luasocket/)\n- [argparse](http://mpeterv.github.io/argparse/)\n- [lua-graphviz](https://github.com/Nymphium/lua-graphviz)\n- [inspect.lua](https://github.com/kikito/inspect.lua)\n\n# reference\nhttps://nymphium.github.io/pdf/opeth_report.pdf\n\n# LICENSE\n[MIT](https://opensource.org/licenses/MIT)\n\n","funding_links":[],"categories":["MoonScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNymphium%2Fopeth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNymphium%2Fopeth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNymphium%2Fopeth/lists"}