-
English: README.en.md
-
Working log (English): LOG.md
-
λΉλ λ° μ€ν μμ: Youtube
-
2015 νκ΅ νμ΄μ½: PyPy/RPythonμΌλ‘ 20λ°° λΉ¨λΌμ§λ JIT μν¬ μΈν°ν리ν°
μνν¬μ¬(RPython)μ PyPyλ₯Ό κ°λ°νκΈ° μν΄ κ°λ°/μ¬μ©λ pythonμ λ°©μΈμΌλ‘μ μ μ μΈμ΄λ‘ μ»΄νμΌλκ³ tracing-JITλ₯Ό μ§μνκΈ° μν λΌμ΄λΈλ¬λ¦¬λ₯Ό λ΄μ₯νκ³ μμ΅λλ€. μνν¬μ¬μΌλ‘ κ°λ°ν μΈμ΄λ μμ½κ² νμ΄μ¬μΌλ‘ μ€ννκ±°λ λ°μ΄λλ¦¬λ‘ λΉλν μ μκ³ , JITλ₯Ό μ μ©νκΈ°λ μ½μ΅λλ€.
μ΄ νλ‘μ νΈλ RPythonμΌλ‘ JIT μΈν°ν리ν°λ₯Ό κ°λ°νλ μμ λ‘ νμ©ν μ μμ΅λλ€. μμ λ§ν¬μμ LOG.mdλ₯Ό νμΈν΄ λ μμ보μΈμ.
- νμ΄μ¬μ΄λ?
μμ§ νμ΄μ¬μ λͺ¨λ₯΄μΈμ? μνν¬ κ°λ°μκ° λ²μν μ± μΌλ‘ νμ΄μ¬μ 곡λΆν΄ λ΄ μλ€.
- μνν¬μ¬μ΄λ?: http://rpython.readthedocs.org
git clone https://github.com/aheui/rpaheui
make # RPYTHON νκ²½λ³μ μ€μ νμ. rpythonμ pypy μμ€μ½λλ₯Ό λ΄λ €λ°μΌλ©΄ ν¬ν¨λμ΄ μμ΅λλ€. λ²μ μ github actions μ€μ μ μ°Έκ³ ν΄ μ£ΌμΈμ.
./bin/aheui-c <μν¬ μ½λ νμΌ>
./bin/aheui-bigint-c <ν° μ μκ° νμν μν¬ μ½λ νμΌ>
PyPy κΈ°μ μ PyPyλ₯Ό CPythonλ³΄λ€ λΉ λ₯΄κ² λμνκ² λ§λλλ€. (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
-
- μλ¦Ό:
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>