[BACK]Return to gc.texi CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc / int-parts

Annotation of OpenXM/src/asir-doc/int-parts/gc.texi, Revision 1.2

1.2     ! noro        1: @comment $OpenXM: OpenXM/src/asir-doc/int-parts/gc.texi,v 1.1 2001/04/23 05:45:35 noro Exp $
        !             2: \JP @chapter $B%a%b%j4IM}(B
        !             3: \EG @chapter Memory management
1.1       noro        4:
1.2     ! noro        5: \JP @section $B%a%b%j4IM}5!9=(B
        !             6: \EG @section Machinery for memory management
1.1       noro        7:
1.2     ! noro        8: \BJP
1.1       noro        9: @code{risa} $B$K$*$1$k%a%b%j4IM}$O(B, [Boehm,Weiser] $B$K$h$k$b$N$rMQ$$$F$$$k(B.
                     10: $B$3$N%a%b%j4IM}5!9=$NFCD'$O(B, $B%?%0IU$1$rI,MW$H$;$:(B, $B<+F0E*$K%,!<%Y%C%8%3%l(B
                     11: $B%/%7%g%s(B(GC) $B$r9T$J$&$3$H$G$"$k(B. $B=>$C$F%f!<%6$OI,MW$JNN0h$r<h$j$C$Q$J$7(B
                     12: $B$K$7$F$h$$(B. $B7gE@$H$7$F$O(B, $B0l2s$N(B GC $B$G$9$Y$F$N%,!<%Y%C%8$r2s<}$G$-$k$H$O(B
                     13: $B$+$.$i$J$$$3$H$H(B, $B%3%s%Q%/%7%g%s$r9T$J$o$J$$$3$H$G$"$k$,(B, $B<BMQ>e==J,$J5!(B
                     14: $BG=$r;}$D(B. $B%a%b%j3d$jEv$F4o$K8=$l$k%^%/%m$O$9$Y$F$3$N%a%b%j4IM}$N$b$H$G%a(B
                     15: $B%b%j$N3d$jEv$F$r9T$J$C$F$$$k(B. GC $B$O(B, $B$=$N;~E@$K$*$1$k(B, $B%9%?%C%/(B, $B%l%8%9(B
                     16: $B%?(B, $B@EE*NN0h$+$i%^!<%-%s%0$r;O$a(B, $B$3$l$K$h$jE~C#$G$-$J$$NN0h$r$9$Y$F2s<}(B
                     17: $B$9$k(B. $B%3%s%Q%$%i$N:GE,2=$K$h$j(B, $B:G=iNN0h$N@hF,$r;X$7$F$$$?%]%$%s%?$,(B, $BNN(B
                     18: $B0h$NFbIt$r;X$7$F$$$k>l9g$K$b(B, GC $B@5$7$/$=$NNN0h$,;HMQCf$HH=CG$9$k(B.
                     19:
                     20: $BCm0U$9$Y$-$3$H$O(B, $BDL>o$N(B @code{malloc()} $B$K$h$j3d$jEv$F$i$l$?NN0hFb$O%9(B
                     21: $B%-%c%s$5$l$J$$$3$H$G$"$k(B. $B$h$C$F(B, @code{malloc()} $B$O(B, $B$=$NB>$N(B C $B$N%i%$(B
                     22: $B%V%i%j$NCf$+$i8F$P$l$k>l9g$r=|$$$F;HMQ$OHr$1$J$1$l$P$J$i$J$$(B. $B$^$?(B, $B0l$D(B
                     23: $B$NNN0h$O(B, $BJ#?t$NNN0h$+$i;2>H$5$l$F$$$k2DG=@-$,$"$k$?$a(B, $B%f!<%6$,3+J|$9$k(B
                     24: $B$3$H$O4m81$G$"$k(B. $B$?$@$7(B, $B:n6HMQ$N%P%C%U%!$J$I(B, $BL@$i$+$KB>$+$i$N;2>H$,$J(B
                     25: $B$$$b$N$K4X$7$F$O3+J|$7$F9=$o$J$$(B. $B%a%b%j4IM}4X78$N<g$JH!?t$O<!$NDL$j(B.
1.2     ! noro       26: \E
        !            27: \BEG
        !            28: \E
1.1       noro       29:
1.2     ! noro       30: \BJP
1.1       noro       31: @example
                     32: void GC_init()
                     33: $B=i4|2=%k!<%A%s(B. $B5/F0;~$K<B9T$9$k(B.
                     34:
                     35: void *GC_malloc(int n)
                     36: n bytes $B$NNN0h$r3d$jEv$F$k(B. $BNN0h$O(B 0 $B$G=i4|2=$5$l$k(B.
                     37:
                     38: void *GC_malloc_atomic(int n)
                     39: $B%]%$%s%?$r4^$`$3$H$,$J$$$HJ]>Z$5$l$k(B n bytes $B$NNN0h$r3d$jEv$F$k(B.
                     40:
                     41: GC_free(void *p)
                     42: p $B$N;X$9NN0h$r3+J|$9$k(B. Risa $B$G$O(B, $B$"$kNN0h$,$I$3$+$i$I$N0L;X$5$l$F$$$k(B
                     43: $B$+0lHL$K$OH=CG$G$-$J$$$N$G(B, $BDL>o$O$3$N4X?t$,;HMQ$5$l$k$3$H$O$J$$(B.
                     44: $B4X?tFb$G3d$jEv$F$?%P%C%U%!$N3+J|$J$I$KMQ$$$k$3$H$O$G$-$k(B.
                     45: @end example
                     46: @noindent
                     47: $BDL>o$O(B @code{GC_malloc()} $B$r;HMQ$9$k$,(B, $BB?G\D9?tMQ$NNN0h$J$I(B, $BFbIt$K%]%$(B
                     48: $B%s%?$r4^$^$J$$$3$H$,J,$+$C$F$$$kNN0hMQ$K(B @code{GC_malloc_atomic()} $B$,MQ(B
                     49: $B0U$5$l$F$$$k(B. GC $B%k!<%A%s$O(B, @code{GC_malloc_atomic()} $B$K$h$j3d$jEv$F$i(B
                     50: $B$l$?NN0h$NFbIt$O%9%-%c%s$7$J$$$N$G(B, GC $B$N8zN($,NI$/$J$k(B.
1.2     ! noro       51: \E
        !            52: \BEG
        !            53: @example
        !            54: void GC_init()
1.1       noro       55:
1.2     ! noro       56: void *GC_malloc(int n)
        !            57:
        !            58: void *GC_malloc_atomic(int n)
        !            59:
        !            60: GC_free(void *p)
        !            61: @end example
        !            62: @noindent
        !            63: \E
1.1       noro       64:
1.2     ! noro       65: \JP @section Risa $B$K$*$1$k%a%b%j$N;HMQ(B
        !            66: \EG @section Usage of memory in Risa
1.1       noro       67:
1.2     ! noro       68: \BJP
1.1       noro       69: Risa $B$K$*$1$k3F1i;;4X?t$K$D$$$F6&DL$N?6Iq$$$H$7$F(B, $B7k2L$H$7$F@8@.$5$l$k(B
                     70: object $B$NFbIt$G(B, $BF~NO$G$"$k(B object $B$N3FIt$X$N;2>H$,9T$o$l$F$$$k2DG=@-(B
                     71: $B$,$"$k(B, $B$H$$$&$3$H$,$"$k(B.
                     72:
                     73: $B<!$NNc$O(B, $BB?9`<0$N2C;;4X?t$G$"$k(B. $B$3$NCf$G(B, $BNc$($P@hF,$N9`$N<!?t$,0[$J$k(B
                     74: $B>l9g$K$O(B, $B78?t(B($B$X$N%]%$%s%?(B)$B$,$=$N$^$^7k2L$K%3%T!<$5$l$F$$$k(B. $B$^$?(B,
                     75: $B0z?t$N0lJ}$N<!?t78?t%j%9%H$NKvHx$^$G$?$I$C$?;~$K(B, $B0lJ}$N<!?t78?t%j%9%H$,(B
                     76: $B;D$C$F$$$k>l9g$K$O(B, $B$=$N;D$j$,$=$N$^$^7k2L$N<!?t78?t%j%9%H$K$D$J$,$l$k(B.
1.2     ! noro       77: \E
        !            78: \BEG
        !            79: \E
1.1       noro       80:
                     81: @example
                     82: #include "ca.h"
                     83:
                     84: void addp(vl,p1,p2,pr)
                     85: VL vl;
                     86: P p1,p2,*pr;
                     87: @{
                     88:   DCP dc1,dc2,dcr0,dcr;
                     89:   V v1,v2;
                     90:   P t;
                     91:
                     92:   if ( !p1 )
                     93:     *pr = p2;
                     94:   else if ( !p2 )
                     95:     *pr = p1;
                     96:   else if ( NUM(p1) )
                     97:     if ( NUM(p2) )
                     98:       addnum(vl,p1,p2,pr);
                     99:     else
                    100:       addpq(p2,p1,pr);
                    101:   else if ( NUM(p2) )
                    102:     addpq(p1,p2,pr);
                    103:   else if ( ( v1 = VR(p1) ) ==  ( v2 = VR(p2) ) ) @{
                    104:     for ( dc1 = DC(p1), dc2 = DC(p2), dcr0 = 0; dc1 && dc2; )
                    105:       switch ( cmpq(DEG(dc1),DEG(dc2)) ) @{
                    106:         case 0:
                    107:           addp(vl,COEF(dc1),COEF(dc2),&t);
                    108:           if ( t )  @{
                    109:             NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc1); COEF(dcr) = t;
                    110:           @}
                    111:           dc1 = NEXT(dc1); dc2 = NEXT(dc2); break;
                    112:         case 1:
                    113:           NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc1); COEF(dcr) = COEF(dc1);
                    114:           dc1 = NEXT(dc1); break;
                    115:         case -1:
                    116:           NEXTDC(dcr0,dcr); DEG(dcr) = DEG(dc2); COEF(dcr) = COEF(dc2);
                    117:           dc2 = NEXT(dc2); break;
                    118:       @}
                    119:     if ( !dcr0 )
                    120:       if ( dc1 )
                    121:         dcr0 = dc1;
                    122:       else if ( dc2 )
                    123:         dcr0 = dc2;
                    124:       else @{
                    125:         *pr = 0;
                    126:         return;
                    127:       @}
                    128:     else
                    129:       if ( dc1 )
                    130:         NEXT(dcr) = dc1;
                    131:       else if ( dc2 )
                    132:         NEXT(dcr) = dc2;
                    133:       else
                    134:         NEXT(dcr) = 0;
                    135:     MKP(v1,dcr0,*pr);
                    136:   @} else @{
                    137:     while ( v1 != VR(vl) && v2 != VR(vl) )
                    138:       vl = NEXT(vl);
                    139:     if ( v1 == VR(vl) )
                    140:       addptoc(vl,p1,p2,pr);
                    141:     else
                    142:       addptoc(vl,p2,p1,pr);
                    143:   @}
                    144: @}
                    145: @end example
                    146:
1.2     ! noro      147: \BJP
1.1       noro      148: $B$3$N$h$&$K(B, Risa $B$N1i;;4X?t$G$O(B, $B0l8+ITMW$K$J$C$?Cf4VE*$J7k2L$G$b(B, $B$=$N(B
                    149: $BItJ,<0$,:G=*7k2L$KMQ$$$i$l$F$$$k$3$H$,$"$k$?$a(B, $BCm0U$,I,MW$G$"$k(B. $BFC$K(B,
                    150: $BG[Ns$r=q$-49$($kI,MW$,$"$k>l9g$J$I$K$O(B, $BG[Ns$=$N$b$N$r?7$7$/@8@.$7$F(B, $B@.(B
                    151: $BJ,$r%3%T!<$7$F$+$iMQ$$$kI,MW$,$"$k(B.
1.2     ! noro      152: \E
        !           153: \BEG
        !           154: \E

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>