Next: Simple Advice, Previous: Byte-Code Objects, Up: Byte Compilation [Contents][Index]
¿Í´Ö¤Ï¥Ð¥¤¥È¥³¡¼¥É¤ò½ñ¤¤Þ¤»¤ó¡£ ¤½¤ì¤Ï¥Ð¥¤¥È¥³¥ó¥Ñ¥¤¥é¤Î»Å»ö¤Ç¤¹¡£ ¤·¤«¤·¡¢¹¥´ñ¿´¤òËþ¤¿¤¹¤¿¤á¤ËµÕ¥¢¥»¥ó¥Ö¥é¤òÍѰդ·¤Æ¤¢¤ê¤Þ¤¹¡£ µÕ¥¢¥»¥ó¥Ö¥é¤Ï¥Ð¥¤¥È¥³¥ó¥Ñ¥¤¥ë¤·¤¿¥³¡¼¥É¤ò¿Í¤¬ÆÉ¤á¤ë·Á¼°¤ËÊÑ´¹¤·¤Þ¤¹¡£
¥Ð¥¤¥È¥³¡¼¥É¥¤¥ó¥¿¡¼¥×¥ê¥¿¤Ï¡¢Ã±½ã¤Ê¥¹¥¿¥Ã¥¯¥Þ¥·¥ó¤È¤·¤Æ¼ÂÁõ¤·¤Æ¤¢¤ê¤Þ¤¹¡£ Ãͤò¼«Á°¤Î¥¹¥¿¥Ã¥¯¤ËÀѤߡ¢·×»»¤Ë»È¤¦¤¿¤á¤Ë¥¹¥¿¥Ã¥¯¤«¤é¼è¤ê½Ð¤·¡¢ ·×»»·ë²Ì¤½¤Î¤â¤Î¤Ï¥¹¥¿¥Ã¥¯¤Ë¤Þ¤¿ÀѤߤޤ¹¡£ ¥Ð¥¤¥È¥³¡¼¥É´Ø¿ô¤«¤éÌá¤ë¤È¤¤Ë¤Ï¡¢¥¹¥¿¥Ã¥¯¤«¤éÃͤò¼è¤ê½Ð¤·¤Æ ´Ø¿ôÃͤȤ·¤Æ¤½¤ÎÃͤòÊÖ¤·¤Þ¤¹¡£
¥¹¥¿¥Ã¥¯¤Ë²Ã¤¨¤Æ¡¢ÊÑ¿ô¤È¥¹¥¿¥Ã¥¯¤Î¤¢¤¤¤À¤ÇÃͤòžÁ÷¤¹¤ë¤³¤È¤Ç¡¢ ¥Ð¥¤¥È¥³¡¼¥É´Ø¿ô¤Ï¡¢ÉáÄ̤ÎLispÊÑ¿ô¤ò»È¤Ã¤¿¤ê¡¢ «Çû¤·¤¿¤ê¡¢ÃͤòÀßÄê¤Ç¤¤Þ¤¹¡£
¤³¤Î´Ø¿ô¤Ïobject¤ÎµÕ¥¢¥»¥ó¥Ö¥ë¤·¤¿¥³¡¼¥É¤ò½ÐÎϤ¹¤ë¡£
stream¤ò»ØÄꤹ¤ë¤È¡¢¤½¤³¤Ø½ÐÎϤ¹¤ë¡£
¤µ¤â¤Ê¤±¤ì¤Ð¡¢µÕ¥¢¥»¥ó¥Ö¥ë¤·¤¿¥³¡¼¥É¤Ï¥¹¥È¥ê¡¼¥àstandard-output
¤Ø
½ÐÎϤ¹¤ë¡£
°ú¿ôobject¤Ï´Ø¿ô̾¤«¥é¥à¥À¼°¤Ç¤¢¤ë¡£
ÆÃÊ̤ÊÎã³°¤È¤·¤Æ¡¢¤³¤Î´Ø¿ô¤òÂÐÏÃŪ¤Ë»È¤¦¤È¡¢ ‘*Disassemble*’¤È¤¤¤¦Ì¾Á°¤Î¥Ð¥Ã¥Õ¥¡¤Ø½ÐÎϤ¹¤ë¡£
disassemble
´Ø¿ô¤Î»ÈÍÑÎã¤ò2¤Ä¼¨¤·¤Þ¤¹¡£
¥Ð¥¤¥È¥³¡¼¥É¤ÈLisp¥½¡¼¥¹¤È¤ÎÂбþ¤ò¼è¤ì¤ë¤è¤¦¤Ë
ÆÃÊ̤ʥ³¥á¥ó¥È¤òÄɲ䷤Ƥ¢¤ê¤Þ¤¹¤¬¡¢
¤³¤ì¤é¤Ïdisassemble
¤Î½ÐÎϤˤϸ½¤ì¤Þ¤»¤ó¡£
¤³¤ì¤é¤ÎÎã¤Ï¡¢ºÇŬ²½¤·¤Æ¤Ê¤¤¥Ð¥¤¥È¥³¡¼¥É¤Ç¤¹¡£
¸½ºß¡¢¥Ð¥¤¥È¥³¡¼¥É¤Ï¡¢ÉáÄÌ¡¢ºÇŬ²½¤·¤Þ¤¹¤¬¡¢
ÌÜŪ¤Ï²Ì¤¿¤»¤ë¤Î¤Ç¡¢Îã¤ò½ñ¤´¹¤¨¤Æ¤¢¤ê¤Þ¤»¤ó¡£
(defun factorial (integer) "Compute factorial of an integer." (if (= 1 integer) 1 (* integer (factorial (1- integer))))) ⇒ factorial
(factorial 4) ⇒ 24
(disassemble 'factorial) -| byte-code for factorial: doc: Compute factorial of an integer. args: (integer)
0 constant 1 ; ¥¹¥¿¥Ã¥¯¤Ë1¤òÀѤà
1 varref integer ; ´Ä¶¤«¤éinteger
¤ÎÃͤò¼èÆÀ¤·¡¢
; ¥¹¥¿¥Ã¥¯¤ËÀѤà
2 eqlsign ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤é2¤Ä¤ÎÃͤò ; ¼è¤ê¤µ¤Ã¤ÆÈæ³Ó¤·¡¢ ; ·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
3 goto-if-nil 10 ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤éÃͤò¼è¤ê¤µ¤ê
; ¸¡ºº¤¹¤ë¡£nil
¤Ê¤é¤Ð10¤ØÈô¤Ó¡¢
; ¤µ¤â¤Ê¤±¤ì¤Ð¤Ä¤®¤Ø¿Ê¤à
6 constant 1 ; ¥¹¥¿¥Ã¥¯¤Ë1¤òÀѤà 7 goto 17 ; 17¤ØÈô¤Ö¡Ê¤³¤Î¾ì¹ç¡¢´Ø¿ô¤Ï1¤òÊÖ¤¹¡Ë
10 constant * ; ¥¹¥¿¥Ã¥¯¤Ë¥·¥ó¥Ü¥ë*
¤òÀѤà 11 varref integer ; ¥¹¥¿¥Ã¥¯¤Ëinteger
¤ÎÃͤòÀѤà
12 constant factorial ; ¥¹¥¿¥Ã¥¯¤Ëfactorial
¤òÀѤà 13 varref integer ; ¥¹¥¿¥Ã¥¯¤Ëinteger
¤ÎÃͤòÀѤà 14 sub1 ; ¥¹¥¿¥Ã¥¯¤«¤éinteger
¤ò¼è¤ê¤µ¤ê¡¢ ; ¸º¤·¤¿¿·¤¿¤ÊÃͤò¥¹¥¿¥Ã¥¯¤ËÀѤà
; ¥¹¥¿¥Ã¥¯¤Î¸½ºß¤ÎÆâÍÆ¤Ï¤Ä¤®¤Î¤È¤ª¤ê ; -integer
¤ò¸º¤é¤·¤¿ÃÍ ; -factorial
; -integer
¤ÎÃÍ ; -*
15 call 1 ; ¥¹¥¿¥Ã¥¯¤ÎºÇ½é¡ÊÀèÆ¬¡ËÍ×ÁǤò»È¤Ã¤Æ
; ´Ø¿ôfactorial
¤ò¸Æ¤Ó½Ð¤¹
; Ìá¤êÃͤò¥¹¥¿¥Ã¥¯¤ËÀѤà
; ¥¹¥¿¥Ã¥¯¤Î¸½ºß¤ÎÆâÍÆ¤Ï¤Ä¤®¤Î¤È¤ª¤ê ; -factorial
¤Î ; ºÆµ¢¸Æ¤Ó½Ð¤·¤Î·ë²Ì ; -integer
¤ÎÃÍ ; -*
16 call 2 ; ¥¹¥¿¥Ã¥¯¤ÎºÇ½é¤ÎÍ×ÁǤÎ2¤Ä
; ¡ÊÀèÆ¬¤Î2¤Ä¡Ë¤ò°ú¿ô¤È¤·¤Æ
; ´Ø¿ô*
¤ò¸Æ¤Ó½Ð¤·
; ·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
17 return ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬Í×ÁǤòÊÖ¤¹
⇒ nil
´Ø¿ôsilly-loop
¤Ï¡¢¾¯¡¹Ê£»¨¤Ç¤¹¡£
(defun silly-loop (n) "Return time before and after N iterations of a loop." (let ((t1 (current-time-string))) (while (> (setq n (1- n)) 0)) (list t1 (current-time-string)))) ⇒ silly-loop
(disassemble 'silly-loop)
-| byte-code for silly-loop:
doc: Return time before and after N iterations of a loop.
args: (n)
0 constant current-time-string ; current-time-string
¤ò
; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ËÀѤà
1 call 0 ; °ú¿ô¤Ê¤·¤Çcurrent-time-string
¤ò
; ¸Æ¤Ó½Ð¤·¡¢·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
2 varbind t1 ; ¥¹¥¿¥Ã¥¯¤«¤éÃͤò¼è¤ê¤µ¤ê¡¢
; t1
¤Ë«Çû¤¹¤ë
3 varref n ; ´Ä¶¤«¤én
¤ÎÃͤò¼èÆÀ¤·¡¢
; Ãͤò¥¹¥¿¥Ã¥¯¤ËÀѤà
4 sub1 ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤é1¤ò°ú¤¯
5 dup ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ÎÃͤòÊ£À½¤¹¤ë ; ¤Ä¤Þ¤ê¡¢¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ÎÃͤò ; ¥³¥Ô¡¼¤·¤Æ¡¢¤½¤ì¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
6 varset n ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤éÃͤò¼è¤ê¤µ¤ê¡¢ ; Ãͤòn
¤Ë«Çû¤¹¤ë ; ¤Ä¤Þ¤ê¡¢dup varset
¤Ï ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ÎÃͤò¼è¤ê¤µ¤é¤º¤Ë ;n
¤Ë¥³¥Ô¡¼¤¹¤ë
7 constant 0 ; ¥¹¥¿¥Ã¥¯¤Ë0¤òÀѤà
8 gtr ; ¥¹¥¿¥Ã¥¯¤«¤é2¤Ä¤ÎÃͤò¼è¤ê¤µ¤ê¡¢ ; n¤¬0¤è¤êÂ礤¤¤«Ä´¤Ù¡¢ ; ·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
9 goto-if-nil-else-pop 17 ; n
<= 0¤Ê¤é¤Ð17¤ØÈô¤Ö
; ¡Êwhile¥ë¡¼¥×¤«¤éÈ´¤±¤ë¡Ë
; ¤µ¤â¤Ê¤±¤ì¤Ð¡¢¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤é
; Ãͤò¼è¤ê¤µ¤ê¡¢¤Ä¤®¤Ø¿Ê¤à
12 constant nil ; ¥¹¥¿¥Ã¥¯¤Ënil
¤òÀѤà
; ¡Ê¤³¤ì¤Ï¥ë¡¼¥×¤ÎËÜÂΡË
13 discard ; ¥ë¡¼¥×¤ÎËÜÂΤηë²Ì¤ò¼Î¤Æ¤ë ; ¡Êwhile¥ë¡¼¥×¤ÏÉûºîÍѤΤ¿¤á¤Ë ; ¤Ä¤Í¤Ëɾ²Á¤µ¤ì¤ë¡Ë
14 goto 3 ; while¥ë¡¼¥×¤ÎÀèÆ¬¤ØÈô¤Ö
17 discard ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ÎÃͤò¼è¤ê¤µ¤Ã¤Æ¡¢
; while¥ë¡¼¥×¤Î·ë²Ì¤ò¼Î¤Æ¤ë¡£
; ¤³¤ì¤Ï¡¢9¤Ç¤ÎÈô¤Ó±Û¤·¤Î¤¿¤á¤Ë
; ¼è¤ê¤µ¤Ã¤Æ¤¤¤Ê¤¤ÃÍnil
18 varref t1 ; t1
¤ÎÃͤò¥¹¥¿¥Ã¥¯¤ËÀѤà
19 constant current-time-string ; current-time-string
¤ò
; ¥¹¥¿¥Ã¥¯¤ËÀѤà
20 call 0 ; ¤Õ¤¿¤¿¤Ócurrent-time-string
¤ò
; ¸Æ¤Ó½Ð¤¹
21 list2 ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤«¤é2¤Ä¤ÎÃͤò¼è¤ê¤µ¤ê ; ¤½¤ì¤é¤Î¥ê¥¹¥È¤òºî¤ê¡¢ ; ¥ê¥¹¥È¤ò¥¹¥¿¥Ã¥¯¤ËÀѤà
22 unbind 1 ; ¥í¡¼¥«¥ë¤Î´Ä¶¤Ît1
¤Î«Çû¤ò²ò¤¯
23 return ; ¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤ÎÃͤòÊÖ¤¹
⇒ nil
Next: Simple Advice, Previous: Byte-Code Objects, Up: Byte Compilation [Contents][Index]