알파희 - 알파희썬(rpython)으로 만든 엔터프라이즈급 고성능 아희
====
[![Build Status](https://travis-ci.org/aheui/rpaheui.svg?branch=master)](https://travis-ci.org/aheui/rpaheui)
* English: [README.en.md](https://github.com/aheui/rpaheui/blob/master/README.en.md)
* Working log (English): [LOG.md](https://github.com/aheui/rpaheui/blob/master/LOG.md)
* 빌드 및 실행 영상: [Youtube](https://www.youtube.com/watch?v=mjoj69i_f8s)
* 2015 한국 파이콘: [PyPy/RPython으로 20배 빨라지는 JIT 아희 인터프리터](http://www.slideshare.net/YunWonJeong/pypyrpython-20-jit)
알파희썬(RPython)은 PyPy를 개발하기 위해 개발/사용된 python의 방언으로서 정적 언어로 컴파일되고 tracing-JIT를 지원하기 위한 라이브러리를 내장하고 있습니다.
알파희썬으로 개발한 언어는 손쉽게 파이썬으로 실행하거나 바이너리로 빌드할 수 있고, JIT를 적용하기도 쉽습니다.
이 프로젝트는 RPython으로 JIT 인터프리터를 개발하는 예제로 활용할 수 있습니다. 위의 링크에서 LOG.md를 확인해 더 알아보세요.
* 파이썬이란?
아직 파이썬을 모르세요? [알파희 개발자가 번역한 책](http://www.yes24.com/24/Goods/15240210?Acode=101)으로 파이썬을 공부해 봅시다.
* 알파희썬이란?: [http://rpython.readthedocs.org][rpython]
```
git clone https://github.com/aheui/rpaheui
make # set RPYTHON in Makefile. You can get pypy by: hg clone http://bitbucket.org/pypy/pypy
./aheui-c <your-aheui-code>
```
JIT로 속도 올리기
----
PyPy 기술은 PyPy를 CPython보다 빠르게 동작하게 만듭니다. ([http://speed.pypy.org/](http://speed.pypy.org/) 참고)
알파희도 이 기술을 이용해 JIT로 빨라지고 있습니다. 벤치마크에 널리 쓰이는 로고 실행이 caheui보다 30배 이상 더 빠릅니다!
```
$ time ./rpaheui-c snippets/logo/logo.aheui > /dev/null
real 0m0.915s
user 0m0.640s
sys 0m0.269s
```
```
$ time ../caheui/aheui snippets/logo/logo.aheui > /dev/null
real 0m26.026s
user 0m25.970s
sys 0m0.035s
```
실행 옵션
----
- 옵션을 제외한 첫 인자는 파일 이름입니다. 파일이름이 `-`면 표준 입력입니다.
- --help,-h: 도움말
- --version,-v: 버전
- --opt,-O: 최적화 수준. 기본값은 `1`입니다. `0`과 `2` 사이의 정수를 쓸 수 있습니다.
- 0: 최적화 없음.
- 1: 간단한 스택크기 추정으로 빠르게 쓰이지 않는 코드를 제거하고 상수 연산을 병합합니다.
- 2: 스택크기 추정으로 완벽하게 쓰이지 않는 코드를 제거하고, 코드 조각을 직렬화해 재배치하고, 상수 연산을 병합합니다.
- usage: `--opt=0`, `-O1` or `-O 2`
- --source,-S: 소스 유형. 기본 값은 `auto`입니다. `auto`, `bytecode`, `asm`, `text` 가운데 하나를 쓸 수 있습니다.
- `auto`: 소스 유형을 추측합니다. 파일이름이 `.aheuic`이거나 바이트코드 종료 패턴이 담겨 있으면 `bytecode`로 추측합니다. 파일이름이 `.aheuis`이면 `asm`으로 추측합니다. 파일이름이 `.aheui`이면 `text`로 추정합니다. 추정할 수 없으면 `text`로 추정합니다.
- `bytecode`: 아희 바이트코드. (`앟셈블리`의 바이트코드 표현형)
- `asm`: `앟셈블리` 참고
- usage: `--source=asm`, `-Sbytecode` or `-S text`
- --target,-T: 결과물 유형. 기본값은 `run`입니다. `run`, `bytecode`, `asm` 가운데 하나를 쓸 수 있습니다.
- `run`: 주어진 코드를 실행합니다.
- `bytecode`: 아희 바이트코드. (`앟셈블리`의 바이트코드 표현형)
- `asm`: `앟셈블리` 참고
- usage: `--target=asm`, `-Tbytecode` or `-T run`
- --output,-o: 결과물 파일. 기본값은 아래와 같습니다. 각 결과물 유형에 따라 자세한 내용을 확인하세요. `-`이면 표준 출력입니다.
- --target=run: 이 옵션은 무시됩니다.
- --target=bytecode: 기본 값은 `.aheuic` 파일입니다.
- --target=asm: 기본 값은 `.aheuis` 파일입니다.
- --target=asm+comment: `asm`에 주석이 추가됩니다.
- --cmd,-c: 코드를 파일 대신 문자열로 받아 넘겨줍니다.
- --no-c: `.aheuic` 파일을 자동으로 생성하지 않습니다.
- `.aheuic` 파일은 왜 생성되나요?: [https://github.com/aheui/snippets/commit/cbb5a12e7cd2db771538ab28dfbc9ad1ada86f35](https://github.com/aheui/snippets/commit/cbb5a12e7cd2db771538ab28dfbc9ad1ada86f35)
앟셈블리와 ahsembler
----
* 알림: `ahsembler`는 `./aheui-c --source=asm --output=-`와 같은 명령입니다.
앟셈블러로 아희 코드를 컴파일해 직렬화 된 앟셈블리로 만드세요!
아희 코드를 선형으로 디버그할 수 있습니다!
원시 명령
- halt: ㅎ
- add: ㄷ
- mul: ㄸ
- sub: ㅌ
- div: ㄴ
- mod: ㄹ
- pop: ㅁ without ㅇ/ㅎ
- popnum: ㅁ with ㅇ
- popchar: ㅁ with ㅎ
- push $v: ㅂ without ㅇ/ㅎ. Push THE VALUE $v. $v is not an index of consonants.
- pushnum: ㅂ with ㅇ
- pushchar: ㅂ with ㅎ
- dup: ㅃ
- swap: ㅍ
- sel $v: ㅅ. $v is always an integer order of final consonants.
- mov $v: ㅆ. $v is always an integer order of final consonants.
- cmp: ㅈ
- brz $v: ㅊ. If a popped value is zero, program counter is set to $v; otherwise +1.
확장 명령 (선형 코드는 위치 정보를 잃고 일부 명령이 스택 크기 점검을 하지 않으므로 추가 명령이 필요합니다)
- brpop2 $v: If current stack doesn't have 2 values to pop, program counter is set to $v; otherwise +1.
- brpop1 $v: If current stack doesn't have 1 values to pop, program counter is set to $v; otherwise +1.
- jmp $v: Program counter is set to $v.
사용법
```
git clone https://github.com/aheui/rpaheui
python ahsembler.py <your-aheui-code>
```
[rpython]: http://rpython.readthedocs.org
Raw data
{
"_id": null,
"home_page": "https://github.com/aheui/rpaheui",
"name": "aheui",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Jeong YunWon",
"author_email": "aheui@youknowone.org",
"download_url": "https://files.pythonhosted.org/packages/57/4a/41ff12dbe025905f534ab2c0e0cc6efbc502ed4d733ec8994832c7f0b622/aheui-1.2.4.tar.gz",
"platform": null,
"description": "\uc54c\ud30c\ud76c - \uc54c\ud30c\ud76c\uc36c(rpython)\uc73c\ub85c \ub9cc\ub4e0 \uc5d4\ud130\ud504\ub77c\uc774\uc988\uae09 \uace0\uc131\ub2a5 \uc544\ud76c\n====\n\n[![Build Status](https://travis-ci.org/aheui/rpaheui.svg?branch=master)](https://travis-ci.org/aheui/rpaheui)\n\n* English: [README.en.md](https://github.com/aheui/rpaheui/blob/master/README.en.md)\n* Working log (English): [LOG.md](https://github.com/aheui/rpaheui/blob/master/LOG.md)\n\n* \ube4c\ub4dc \ubc0f \uc2e4\ud589 \uc601\uc0c1: [Youtube](https://www.youtube.com/watch?v=mjoj69i_f8s)\n* 2015 \ud55c\uad6d \ud30c\uc774\ucf58: [PyPy/RPython\uc73c\ub85c 20\ubc30 \ube68\ub77c\uc9c0\ub294 JIT \uc544\ud76c \uc778\ud130\ud504\ub9ac\ud130](http://www.slideshare.net/YunWonJeong/pypyrpython-20-jit)\n\n\uc54c\ud30c\ud76c\uc36c(RPython)\uc740 PyPy\ub97c \uac1c\ubc1c\ud558\uae30 \uc704\ud574 \uac1c\ubc1c/\uc0ac\uc6a9\ub41c python\uc758 \ubc29\uc5b8\uc73c\ub85c\uc11c \uc815\uc801 \uc5b8\uc5b4\ub85c \ucef4\ud30c\uc77c\ub418\uace0 tracing-JIT\ub97c \uc9c0\uc6d0\ud558\uae30 \uc704\ud55c \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ub0b4\uc7a5\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4.\n\uc54c\ud30c\ud76c\uc36c\uc73c\ub85c \uac1c\ubc1c\ud55c \uc5b8\uc5b4\ub294 \uc190\uc27d\uac8c \ud30c\uc774\uc36c\uc73c\ub85c \uc2e4\ud589\ud558\uac70\ub098 \ubc14\uc774\ub108\ub9ac\ub85c \ube4c\ub4dc\ud560 \uc218 \uc788\uace0, JIT\ub97c \uc801\uc6a9\ud558\uae30\ub3c4 \uc27d\uc2b5\ub2c8\ub2e4.\n\n\uc774 \ud504\ub85c\uc81d\ud2b8\ub294 RPython\uc73c\ub85c JIT \uc778\ud130\ud504\ub9ac\ud130\ub97c \uac1c\ubc1c\ud558\ub294 \uc608\uc81c\ub85c \ud65c\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc704\uc758 \ub9c1\ud06c\uc5d0\uc11c LOG.md\ub97c \ud655\uc778\ud574 \ub354 \uc54c\uc544\ubcf4\uc138\uc694.\n\n* \ud30c\uc774\uc36c\uc774\ub780?\n\n\uc544\uc9c1 \ud30c\uc774\uc36c\uc744 \ubaa8\ub974\uc138\uc694? [\uc54c\ud30c\ud76c \uac1c\ubc1c\uc790\uac00 \ubc88\uc5ed\ud55c \ucc45](http://www.yes24.com/24/Goods/15240210?Acode=101)\uc73c\ub85c \ud30c\uc774\uc36c\uc744 \uacf5\ubd80\ud574 \ubd05\uc2dc\ub2e4.\n\n* \uc54c\ud30c\ud76c\uc36c\uc774\ub780?: [http://rpython.readthedocs.org][rpython]\n\n\n```\ngit clone https://github.com/aheui/rpaheui\nmake # set RPYTHON in Makefile. You can get pypy by: hg clone http://bitbucket.org/pypy/pypy\n./aheui-c <your-aheui-code>\n```\n\nJIT\ub85c \uc18d\ub3c4 \uc62c\ub9ac\uae30\n----\n\nPyPy \uae30\uc220\uc740 PyPy\ub97c CPython\ubcf4\ub2e4 \ube60\ub974\uac8c \ub3d9\uc791\ud558\uac8c \ub9cc\ub4ed\ub2c8\ub2e4. ([http://speed.pypy.org/](http://speed.pypy.org/) \ucc38\uace0)\n\n\uc54c\ud30c\ud76c\ub3c4 \uc774 \uae30\uc220\uc744 \uc774\uc6a9\ud574 JIT\ub85c \ube68\ub77c\uc9c0\uace0 \uc788\uc2b5\ub2c8\ub2e4. \ubca4\uce58\ub9c8\ud06c\uc5d0 \ub110\ub9ac \uc4f0\uc774\ub294 \ub85c\uace0 \uc2e4\ud589\uc774 caheui\ubcf4\ub2e4 30\ubc30 \uc774\uc0c1 \ub354 \ube60\ub985\ub2c8\ub2e4!\n\n```\n$ time ./rpaheui-c snippets/logo/logo.aheui > /dev/null\n\nreal 0m0.915s\nuser 0m0.640s\nsys 0m0.269s\n```\n\n```\n$ time ../caheui/aheui snippets/logo/logo.aheui > /dev/null\n\nreal 0m26.026s\nuser 0m25.970s\nsys 0m0.035s\n```\n\n\uc2e4\ud589 \uc635\uc158\n----\n- \uc635\uc158\uc744 \uc81c\uc678\ud55c \uccab \uc778\uc790\ub294 \ud30c\uc77c \uc774\ub984\uc785\ub2c8\ub2e4. \ud30c\uc77c\uc774\ub984\uc774 `-`\uba74 \ud45c\uc900 \uc785\ub825\uc785\ub2c8\ub2e4.\n- --help,-h: \ub3c4\uc6c0\ub9d0\n- --version,-v: \ubc84\uc804\n- --opt,-O: \ucd5c\uc801\ud654 \uc218\uc900. \uae30\ubcf8\uac12\uc740 `1`\uc785\ub2c8\ub2e4. `0`\uacfc `2` \uc0ac\uc774\uc758 \uc815\uc218\ub97c \uc4f8 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n - 0: \ucd5c\uc801\ud654 \uc5c6\uc74c.\n - 1: \uac04\ub2e8\ud55c \uc2a4\ud0dd\ud06c\uae30 \ucd94\uc815\uc73c\ub85c \ube60\ub974\uac8c \uc4f0\uc774\uc9c0 \uc54a\ub294 \ucf54\ub4dc\ub97c \uc81c\uac70\ud558\uace0 \uc0c1\uc218 \uc5f0\uc0b0\uc744 \ubcd1\ud569\ud569\ub2c8\ub2e4.\n - 2: \uc2a4\ud0dd\ud06c\uae30 \ucd94\uc815\uc73c\ub85c \uc644\ubcbd\ud558\uac8c \uc4f0\uc774\uc9c0 \uc54a\ub294 \ucf54\ub4dc\ub97c \uc81c\uac70\ud558\uace0, \ucf54\ub4dc \uc870\uac01\uc744 \uc9c1\ub82c\ud654\ud574 \uc7ac\ubc30\uce58\ud558\uace0, \uc0c1\uc218 \uc5f0\uc0b0\uc744 \ubcd1\ud569\ud569\ub2c8\ub2e4.\n - usage: `--opt=0`, `-O1` or `-O 2`\n- --source,-S: \uc18c\uc2a4 \uc720\ud615. \uae30\ubcf8 \uac12\uc740 `auto`\uc785\ub2c8\ub2e4. `auto`, `bytecode`, `asm`, `text` \uac00\uc6b4\ub370 \ud558\ub098\ub97c \uc4f8 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n - `auto`: \uc18c\uc2a4 \uc720\ud615\uc744 \ucd94\uce21\ud569\ub2c8\ub2e4. \ud30c\uc77c\uc774\ub984\uc774 `.aheuic`\uc774\uac70\ub098 \ubc14\uc774\ud2b8\ucf54\ub4dc \uc885\ub8cc \ud328\ud134\uc774 \ub2f4\uaca8 \uc788\uc73c\uba74 `bytecode`\ub85c \ucd94\uce21\ud569\ub2c8\ub2e4. \ud30c\uc77c\uc774\ub984\uc774 `.aheuis`\uc774\uba74 `asm`\uc73c\ub85c \ucd94\uce21\ud569\ub2c8\ub2e4. \ud30c\uc77c\uc774\ub984\uc774 `.aheui`\uc774\uba74 `text`\ub85c \ucd94\uc815\ud569\ub2c8\ub2e4. \ucd94\uc815\ud560 \uc218 \uc5c6\uc73c\uba74 `text`\ub85c \ucd94\uc815\ud569\ub2c8\ub2e4.\n - `bytecode`: \uc544\ud76c \ubc14\uc774\ud2b8\ucf54\ub4dc. (`\uc55f\uc148\ube14\ub9ac`\uc758 \ubc14\uc774\ud2b8\ucf54\ub4dc \ud45c\ud604\ud615)\n - `asm`: `\uc55f\uc148\ube14\ub9ac` \ucc38\uace0\n - usage: `--source=asm`, `-Sbytecode` or `-S text`\n- --target,-T: \uacb0\uacfc\ubb3c \uc720\ud615. \uae30\ubcf8\uac12\uc740 `run`\uc785\ub2c8\ub2e4. `run`, `bytecode`, `asm` \uac00\uc6b4\ub370 \ud558\ub098\ub97c \uc4f8 \uc218 \uc788\uc2b5\ub2c8\ub2e4.\n - `run`: \uc8fc\uc5b4\uc9c4 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.\n - `bytecode`: \uc544\ud76c \ubc14\uc774\ud2b8\ucf54\ub4dc. (`\uc55f\uc148\ube14\ub9ac`\uc758 \ubc14\uc774\ud2b8\ucf54\ub4dc \ud45c\ud604\ud615)\n - `asm`: `\uc55f\uc148\ube14\ub9ac` \ucc38\uace0\n - usage: `--target=asm`, `-Tbytecode` or `-T run`\n- --output,-o: \uacb0\uacfc\ubb3c \ud30c\uc77c. \uae30\ubcf8\uac12\uc740 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4. \uac01 \uacb0\uacfc\ubb3c \uc720\ud615\uc5d0 \ub530\ub77c \uc790\uc138\ud55c \ub0b4\uc6a9\uc744 \ud655\uc778\ud558\uc138\uc694. `-`\uc774\uba74 \ud45c\uc900 \ucd9c\ub825\uc785\ub2c8\ub2e4.\n - --target=run: \uc774 \uc635\uc158\uc740 \ubb34\uc2dc\ub429\ub2c8\ub2e4.\n - --target=bytecode: \uae30\ubcf8 \uac12\uc740 `.aheuic` \ud30c\uc77c\uc785\ub2c8\ub2e4.\n - --target=asm: \uae30\ubcf8 \uac12\uc740 `.aheuis` \ud30c\uc77c\uc785\ub2c8\ub2e4.\n - --target=asm+comment: `asm`\uc5d0 \uc8fc\uc11d\uc774 \ucd94\uac00\ub429\ub2c8\ub2e4.\n- --cmd,-c: \ucf54\ub4dc\ub97c \ud30c\uc77c \ub300\uc2e0 \ubb38\uc790\uc5f4\ub85c \ubc1b\uc544 \ub118\uaca8\uc90d\ub2c8\ub2e4.\n- --no-c: `.aheuic` \ud30c\uc77c\uc744 \uc790\ub3d9\uc73c\ub85c \uc0dd\uc131\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.\n - `.aheuic` \ud30c\uc77c\uc740 \uc65c \uc0dd\uc131\ub418\ub098\uc694?: [https://github.com/aheui/snippets/commit/cbb5a12e7cd2db771538ab28dfbc9ad1ada86f35](https://github.com/aheui/snippets/commit/cbb5a12e7cd2db771538ab28dfbc9ad1ada86f35)\n\n\uc55f\uc148\ube14\ub9ac\uc640 ahsembler\n----\n\n* \uc54c\ub9bc: `ahsembler`\ub294 `./aheui-c --source=asm --output=-`\uc640 \uac19\uc740 \uba85\ub839\uc785\ub2c8\ub2e4.\n\n\uc55f\uc148\ube14\ub7ec\ub85c \uc544\ud76c \ucf54\ub4dc\ub97c \ucef4\ud30c\uc77c\ud574 \uc9c1\ub82c\ud654 \ub41c \uc55f\uc148\ube14\ub9ac\ub85c \ub9cc\ub4dc\uc138\uc694!\n\uc544\ud76c \ucf54\ub4dc\ub97c \uc120\ud615\uc73c\ub85c \ub514\ubc84\uadf8\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4!\n\n\uc6d0\uc2dc \uba85\ub839\n\n- halt: \u314e\n- add: \u3137\n- mul: \u3138\n- sub: \u314c\n- div: \u3134\n- mod: \u3139\n- pop: \u3141 without \u3147/\u314e\n- popnum: \u3141 with \u3147\n- popchar: \u3141 with \u314e\n- push $v: \u3142 without \u3147/\u314e. Push THE VALUE $v. $v is not an index of consonants.\n- pushnum: \u3142 with \u3147\n- pushchar: \u3142 with \u314e\n- dup: \u3143\n- swap: \u314d\n- sel $v: \u3145. $v is always an integer order of final consonants.\n- mov $v: \u3146. $v is always an integer order of final consonants.\n- cmp: \u3148\n- brz $v: \u314a. If a popped value is zero, program counter is set to $v; otherwise +1.\n\n\ud655\uc7a5 \uba85\ub839 (\uc120\ud615 \ucf54\ub4dc\ub294 \uc704\uce58 \uc815\ubcf4\ub97c \uc783\uace0 \uc77c\ubd80 \uba85\ub839\uc774 \uc2a4\ud0dd \ud06c\uae30 \uc810\uac80\uc744 \ud558\uc9c0 \uc54a\uc73c\ubbc0\ub85c \ucd94\uac00 \uba85\ub839\uc774 \ud544\uc694\ud569\ub2c8\ub2e4)\n\n- brpop2 $v: If current stack doesn't have 2 values to pop, program counter is set to $v; otherwise +1.\n- brpop1 $v: If current stack doesn't have 1 values to pop, program counter is set to $v; otherwise +1.\n- jmp $v: Program counter is set to $v.\n\n\uc0ac\uc6a9\ubc95\n\n```\ngit clone https://github.com/aheui/rpaheui\npython ahsembler.py <your-aheui-code>\n```\n\n [rpython]: http://rpython.readthedocs.org",
"bugtrack_url": null,
"license": null,
"summary": "Aheui compiler & assembler toolkit.",
"version": "1.2.4",
"project_urls": {
"Homepage": "https://github.com/aheui/rpaheui"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "574a41ff12dbe025905f534ab2c0e0cc6efbc502ed4d733ec8994832c7f0b622",
"md5": "7a11641aed5939327cc05b7166649775",
"sha256": "02ac39e7ac8db216b2f6f003c65f50c471bf9c50ce65f145b7d800eb69ff4607"
},
"downloads": -1,
"filename": "aheui-1.2.4.tar.gz",
"has_sig": false,
"md5_digest": "7a11641aed5939327cc05b7166649775",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21085,
"upload_time": "2024-03-31T18:50:30",
"upload_time_iso_8601": "2024-03-31T18:50:30.286400Z",
"url": "https://files.pythonhosted.org/packages/57/4a/41ff12dbe025905f534ab2c0e0cc6efbc502ed4d733ec8994832c7f0b622/aheui-1.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-31 18:50:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aheui",
"github_project": "rpaheui",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pytest",
"specs": []
}
],
"tox": true,
"lcname": "aheui"
}