home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / XLSP21TC.ZIP / XLSPEED.DIF / text0000.txt < prev    next >
Encoding:
Text File  |  1991-04-14  |  23.8 KB  |  913 lines

  1. The following are changes I have made to xlisp 2.0 source. Most of these
  2. changes produce considerable speed ups. This distribution is very
  3. rough but maybe someone can wade through it and come of with a cleaned
  4. up version of the speed ups. Note this is a striaght context diff so
  5. more than just the speed ups are included, BEWARE! If you are able to
  6. clean up or enhance these speed ups in any way I would apreciate the
  7. feedback.
  8.  
  9.                 JonnyG.
  10.  
  11. diff -c ../xlisp.org/xlbfun.c ../xlisp/xlbfun.c
  12. *** ../xlisp.org/xlbfun.c    Sun May  7 22:25:38 1989
  13. --- ../xlisp/xlbfun.c    Wed Apr  5 16:18:23 1989
  14. ***************
  15. *** 558,563 ****
  16. --- 558,578 ----
  17.       return (val);
  18.   }
  19.   
  20. + LVAL xcopyarray()
  21. + {
  22. +     LVAL src, dest;
  23. +     int num;
  24. +     register int i;
  25. +     src = xlgavector();
  26. +     dest = xlgavector();
  27. +     xllastarg();
  28. +     num = (getsize(src) < getsize(dest)) ? getsize(src) : getsize(dest);
  29. +     for (i = 0; i < num; i++)
  30. +         setelement(dest,i,getelement(src,i));
  31. +     return(dest);
  32. + }
  33.   /* xerror - special form 'error' */
  34.   LVAL xerror()
  35.   {
  36. diff -c ../xlisp.org/xldbug.c ../xlisp/xldbug.c
  37. *** ../xlisp.org/xldbug.c    Sun May  7 22:25:43 1989
  38. --- ../xlisp/xldbug.c    Wed Apr  5 16:18:24 1989
  39. ***************
  40. *** 14,20 ****
  41.   extern char buf[];
  42.   
  43.   /* external routines */
  44. ! extern char *malloc();
  45.   
  46.   /* forward declarations */
  47.   FORWARD LVAL stacktop();
  48. --- 14,20 ----
  49.   extern char buf[];
  50.   
  51.   /* external routines */
  52. ! extern char *xlmalloc();
  53.   
  54.   /* forward declarations */
  55.   FORWARD LVAL stacktop();
  56. diff -c ../xlisp.org/xldmem.c ../xlisp/xldmem.c
  57. *** ../xlisp.org/xldmem.c    Sun May  7 22:25:46 1989
  58. --- ../xlisp/xldmem.c    Wed Apr  5 16:18:25 1989
  59. ***************
  60. *** 6,13 ****
  61.   #include "xlisp.h"
  62.   
  63.   /* node flags */
  64. ! #define MARK    1
  65. ! #define LEFT    2
  66.   
  67.   /* macro to compute the size of a segment */
  68.   #define segsize(n) (sizeof(SEGMENT)+((n)-1)*sizeof(struct node))
  69. --- 6,13 ----
  70.   #include "xlisp.h"
  71.   
  72.   /* node flags */
  73. ! #define MARK    0x20
  74. ! #define LEFT    0x40
  75.   
  76.   /* macro to compute the size of a segment */
  77.   #define segsize(n) (sizeof(SEGMENT)+((n)-1)*sizeof(struct node))
  78. ***************
  79. *** 21,37 ****
  80.   SEGMENT *segs,*lastseg,*fixseg,*charseg;
  81.   int anodes,nsegs,gccalls;
  82.   long nnodes,nfree,total;
  83. ! LVAL fnodes;
  84.   
  85.   /* external procedures */
  86. ! extern char *malloc();
  87. ! extern char *calloc();
  88.   
  89.   /* forward declarations */
  90. ! FORWARD LVAL newnode();
  91.   FORWARD unsigned char *stralloc();
  92.   FORWARD SEGMENT *newsegment();
  93.   
  94.   /* cons - construct a new cons node */
  95.   LVAL cons(x,y)
  96.     LVAL x,y;
  97. --- 21,50 ----
  98.   SEGMENT *segs,*lastseg,*fixseg,*charseg;
  99.   int anodes,nsegs,gccalls;
  100.   long nnodes,nfree,total;
  101. ! LVAL fnodes = NIL;
  102.   
  103.   /* external procedures */
  104. ! extern char *xlmalloc();
  105. ! extern char *xlcalloc();
  106.   
  107.   /* forward declarations */
  108. ! FORWARD LVAL Newnode();
  109.   FORWARD unsigned char *stralloc();
  110.   FORWARD SEGMENT *newsegment();
  111.   
  112. + LVAL _nnode;
  113. + FIXTYPE _tfixed;
  114. + int _tint;
  115. + #define    newnode(type) (((_nnode = fnodes) != NIL) ? \
  116. +             ((fnodes = cdr(_nnode)), \
  117. +              nfree--, \
  118. +              (_nnode->n_type = type), \
  119. +              rplacd(_nnode,NIL), \
  120. +              _nnode) \
  121. +             : (_nnode = Newnode(type)))
  122.   /* cons - construct a new cons node */
  123.   LVAL cons(x,y)
  124.     LVAL x,y;
  125. ***************
  126. *** 129,140 ****
  127.   }
  128.   
  129.   /* cvfixnum - convert an integer to a fixnum node */
  130. ! LVAL cvfixnum(n)
  131.     FIXTYPE n;
  132.   {
  133.       LVAL val;
  134. -     if (n >= SFIXMIN && n <= SFIXMAX)
  135. -     return (&fixseg->sg_nodes[(int)n-SFIXMIN]);
  136.       val = newnode(FIXNUM);
  137.       val->n_fixnum = n;
  138.       return (val);
  139. --- 142,151 ----
  140.   }
  141.   
  142.   /* cvfixnum - convert an integer to a fixnum node */
  143. ! LVAL Cvfixnum(n)
  144.     FIXTYPE n;
  145.   {
  146.       LVAL val;
  147.       val = newnode(FIXNUM);
  148.       val->n_fixnum = n;
  149.       return (val);
  150. ***************
  151. *** 151,157 ****
  152.   }
  153.   
  154.   /* cvchar - convert an integer to a character node */
  155. ! LVAL cvchar(n)
  156.     int n;
  157.   {
  158.       if (n >= CHARMIN && n <= CHARMAX)
  159. --- 162,168 ----
  160.   }
  161.   
  162.   /* cvchar - convert an integer to a character node */
  163. ! LVAL Cvchar(n)
  164.     int n;
  165.   {
  166.       if (n >= CHARMIN && n <= CHARMAX)
  167. ***************
  168. *** 180,185 ****
  169. --- 191,225 ----
  170.       return (val);
  171.   }
  172.   
  173. + #ifdef    WINDOWS
  174. + LVAL newwinobj(size)
  175. + int size;
  176. + {
  177. +     LVAL val;
  178. +     val = newnode(WINOBJ);
  179. +     if (size > 0) {
  180. +         xlprot1(val);
  181. +         if ((val->n_winobj = xldcalloc(1,size)) == NULL) {
  182. +             findmem();
  183. +             if ((val->n_winobj = xldcalloc(1,size)) == NULL)
  184. +                 xlfail("insufficient memory");
  185. +             }
  186. +         xlpop();
  187. +         }
  188. +     else val->n_winobj = NULL;
  189. +     return(val);
  190. + }
  191. + LVAL cvwinobj(p)
  192. + char *p;
  193. +     {
  194. +     LVAL val;
  195. +     val = newnode(WINOBJ);
  196. +     val->n_winobj = p;
  197. +     return(val);
  198. +     }
  199. + #endif
  200.   /* newclosure - allocate and initialize a new closure */
  201.   LVAL newclosure(name,type,env,fenv)
  202.     LVAL name,type,env,fenv;
  203. ***************
  204. *** 204,212 ****
  205.       vect = newnode(VECTOR);
  206.       vect->n_vsize = 0;
  207.       if (bsize = size * sizeof(LVAL)) {
  208. !     if ((vect->n_vdata = (LVAL *)calloc(1,bsize)) == NULL) {
  209.           findmem();
  210. !         if ((vect->n_vdata = (LVAL *)calloc(1,bsize)) == NULL)
  211.           xlfail("insufficient vector space");
  212.       }
  213.       vect->n_vsize = size;
  214. --- 244,252 ----
  215.       vect = newnode(VECTOR);
  216.       vect->n_vsize = 0;
  217.       if (bsize = size * sizeof(LVAL)) {
  218. !     if ((vect->n_vdata = (LVAL *)xldcalloc(1,bsize)) == NULL) {
  219.           findmem();
  220. !         if ((vect->n_vdata = (LVAL *)xldcalloc(1,bsize)) == NULL)
  221.           xlfail("insufficient vector space");
  222.       }
  223.       vect->n_vsize = size;
  224. ***************
  225. *** 217,223 ****
  226.   }
  227.   
  228.   /* newnode - allocate a new node */
  229. ! LOCAL LVAL newnode(type)
  230.     int type;
  231.   {
  232.       LVAL nnode;
  233. --- 257,263 ----
  234.   }
  235.   
  236.   /* newnode - allocate a new node */
  237. ! LVAL Newnode(type)
  238.     int type;
  239.   {
  240.       LVAL nnode;
  241. ***************
  242. *** 248,256 ****
  243.       unsigned char *sptr;
  244.   
  245.       /* allocate memory for the string copy */
  246. !     if ((sptr = (unsigned char *)malloc(size)) == NULL) {
  247.       gc();  
  248. !     if ((sptr = (unsigned char *)malloc(size)) == NULL)
  249.           xlfail("insufficient string space");
  250.       }
  251.       total += (long)size;
  252. --- 288,296 ----
  253.       unsigned char *sptr;
  254.   
  255.       /* allocate memory for the string copy */
  256. !     if ((sptr = (unsigned char *)xldmalloc(size)) == NULL) {
  257.       gc();  
  258. !     if ((sptr = (unsigned char *)xldmalloc(size)) == NULL)
  259.           xlfail("insufficient string space");
  260.       }
  261.       total += (long)size;
  262. ***************
  263. *** 330,336 ****
  264.     LVAL ptr;
  265.   {
  266.       register LVAL this,prev,tmp;
  267. !     int type,i,n;
  268.   
  269.       /* initialize */
  270.       prev = NIL;
  271. --- 370,376 ----
  272.     LVAL ptr;
  273.   {
  274.       register LVAL this,prev,tmp;
  275. !     register int i,n;
  276.   
  277.       /* initialize */
  278.       prev = NIL;
  279. ***************
  280. *** 340,380 ****
  281.       for (;;) {
  282.   
  283.       /* descend as far as we can */
  284. !     while (!(this->n_flags & MARK))
  285.   
  286.           /* check cons and symbol nodes */
  287. !         if ((type = ntype(this)) == CONS) {
  288. !         if (tmp = car(this)) {
  289. !             this->n_flags |= MARK|LEFT;
  290. !             rplaca(this,prev);
  291. !         }
  292. !         else if (tmp = cdr(this)) {
  293. !             this->n_flags |= MARK;
  294.               rplacd(this,prev);
  295. !         }
  296. !         else {                /* both sides nil */
  297. !             this->n_flags |= MARK;
  298.               break;
  299. !         }
  300. !         prev = this;            /* step down the branch */
  301. !         this = tmp;
  302. !         }
  303. !         /* mark other node types */
  304.           else {
  305. !         this->n_flags |= MARK;
  306. !         switch (type) {
  307. !         case SYMBOL:
  308. !         case OBJECT:
  309. !         case VECTOR:
  310. !         case CLOSURE:
  311. !             for (i = 0, n = getsize(this); --n >= 0; ++i)
  312. !             if (tmp = getelement(this,i))
  313. !                 mark(tmp);
  314. !             break;
  315. !         }
  316. !         break;
  317. !         }
  318.   
  319.       /* backup to a point where we can continue descending */
  320.       for (;;)
  321. --- 380,409 ----
  322.       for (;;) {
  323.   
  324.       /* descend as far as we can */
  325. !     while (!(this->n_type & MARK))
  326.   
  327.           /* check cons and symbol nodes */
  328. !         if ((i = (this->n_type |= MARK) & TYPEFIELD) == CONS) {
  329. !           if (tmp = car(this)) {
  330. !             this->n_type |= LEFT;
  331. !             rplaca(this,prev);}
  332. !           else if (tmp = cdr(this))
  333.               rplacd(this,prev);
  334. !           else                /* both sides nil */
  335.               break;
  336. !           prev = this;            /* step down the branch */
  337. !           this = tmp;
  338. !           }
  339.           else {
  340. !           if ((i & ARRAY) != 0)
  341. !         for (i = 0, n = getsize(this); i < n;)
  342. !           if (tmp = getelement(this,i++))
  343. !             if ((tmp->n_type & (ARRAY|MARK)) == ARRAY ||
  344. !              tmp->n_type == CONS)
  345. !                 mark(tmp);
  346. !             else tmp->n_type |= MARK;
  347. !           break;
  348. !           }
  349.   
  350.       /* backup to a point where we can continue descending */
  351.       for (;;)
  352. ***************
  353. *** 381,388 ****
  354.   
  355.           /* make sure there is a previous node */
  356.           if (prev) {
  357. !         if (prev->n_flags & LEFT) {    /* came from left side */
  358. !             prev->n_flags &= ~LEFT;
  359.               tmp = car(prev);
  360.               rplaca(prev,this);
  361.               if (this = cdr(prev)) {
  362. --- 410,417 ----
  363.   
  364.           /* make sure there is a previous node */
  365.           if (prev) {
  366. !         if (prev->n_type & LEFT) {    /* came from left side */
  367. !             prev->n_type &= ~LEFT;
  368.               tmp = car(prev);
  369.               rplaca(prev,this);
  370.               if (this = cdr(prev)) {
  371. ***************
  372. *** 399,406 ****
  373.           }
  374.   
  375.           /* no previous node, must be done */
  376. !         else
  377. !         return;
  378.       }
  379.   }
  380.   
  381. --- 428,434 ----
  382.           }
  383.   
  384.           /* no previous node, must be done */
  385. !         else return;
  386.       }
  387.   }
  388.   
  389. ***************
  390. *** 407,434 ****
  391.   /* sweep - sweep all unmarked nodes and add them to the free list */
  392.   LOCAL sweep()
  393.   {
  394. !     SEGMENT *seg;
  395. !     LVAL p;
  396. !     int n;
  397.   
  398. -     /* empty the free list */
  399.       fnodes = NIL;
  400. !     nfree = 0L;
  401.   
  402.       /* add all unmarked nodes */
  403.       for (seg = segs; seg; seg = seg->sg_next) {
  404. !     if (seg == fixseg)     /* don't sweep the fixnum segment */
  405.           continue;
  406. -     else if (seg == charseg) /* don't sweep the character segment */
  407. -         continue;
  408.       p = &seg->sg_nodes[0];
  409. !     for (n = seg->sg_size; --n >= 0; ++p)
  410. !         if (!(p->n_flags & MARK)) {
  411.           switch (ntype(p)) {
  412.           case STRING:
  413.               if (getstring(p) != NULL) {
  414.                   total -= (long)getslength(p);
  415. !                 free(getstring(p));
  416.               }
  417.               break;
  418.           case STREAM:
  419. --- 435,463 ----
  420.   /* sweep - sweep all unmarked nodes and add them to the free list */
  421.   LOCAL sweep()
  422.   {
  423. !     register SEGMENT *seg;
  424. !     register LVAL p;
  425. !     register int n;
  426.   
  427.       fnodes = NIL;
  428. !     nfree = 0l;
  429.   
  430.       /* add all unmarked nodes */
  431.       for (seg = segs; seg; seg = seg->sg_next) {
  432. !     if (seg == fixseg || seg == charseg)
  433. !          /* don't sweep the fixed segments */
  434.           continue;
  435.       p = &seg->sg_nodes[0];
  436. !     for (n = seg->sg_size; --n >= 0;)
  437. !         if (p->n_type & MARK)
  438. !         (p++)->n_type &= ~MARK;
  439. !         else {
  440.           switch (ntype(p)) {
  441.           case STRING:
  442.               if (getstring(p) != NULL) {
  443.                   total -= (long)getslength(p);
  444. !            /* Using getstring here breaks VMEM (JonnyG) */
  445. !                 xldfree(p->n_string);
  446.               }
  447.               break;
  448.           case STREAM:
  449. ***************
  450. *** 435,440 ****
  451. --- 464,474 ----
  452.               if (getfile(p))
  453.                   osclose(getfile(p));
  454.               break;
  455. + #ifdef    WINDOWS
  456. +         case WINOBJ:
  457. +             free_winobj(p);
  458. +             break;
  459. + #endif
  460.           case SYMBOL:
  461.           case OBJECT:
  462.           case VECTOR:
  463. ***************
  464. *** 441,447 ****
  465.           case CLOSURE:
  466.               if (p->n_vsize) {
  467.                   total -= (long) (p->n_vsize * sizeof(LVAL));
  468. !                 free(p->n_vdata);
  469.               }
  470.               break;
  471.           }
  472. --- 475,481 ----
  473.           case CLOSURE:
  474.               if (p->n_vsize) {
  475.                   total -= (long) (p->n_vsize * sizeof(LVAL));
  476. !                 xldfree(p->n_vdata);
  477.               }
  478.               break;
  479.           }
  480. ***************
  481. *** 448,458 ****
  482.           p->n_type = FREE;
  483.           rplaca(p,NIL);
  484.           rplacd(p,fnodes);
  485. !         fnodes = p;
  486. !         nfree += 1L;
  487.           }
  488. -         else
  489. -         p->n_flags &= ~MARK;
  490.       }
  491.   }
  492.   
  493. --- 482,490 ----
  494.           p->n_type = FREE;
  495.           rplaca(p,NIL);
  496.           rplacd(p,fnodes);
  497. !         fnodes = p++;
  498. !         nfree++;
  499.           }
  500.       }
  501.   }
  502.   
  503. ***************
  504. *** 485,491 ****
  505.       SEGMENT *newseg;
  506.   
  507.       /* allocate the new segment */
  508. !     if ((newseg = (SEGMENT *)calloc(1,segsize(n))) == NULL)
  509.       return (NULL);
  510.   
  511.       /* initialize the new segment */
  512. --- 517,524 ----
  513.       SEGMENT *newseg;
  514.   
  515.       /* allocate the new segment */
  516. !     if ((newseg = (SEGMENT *)xlcalloc(1,segsize(n))) == NULL)
  517.       return (NULL);
  518.   
  519.       /* initialize the new segment */
  520. ***************
  521. *** 666,677 ****
  522.       s_gcflag = s_gchook = NIL;
  523.   
  524.       /* allocate the evaluation stack */
  525. !     if ((xlstkbase = (LVAL **)malloc(EDEPTH * sizeof(LVAL *))) == NULL)
  526.       xlfatal("insufficient memory");
  527.       xlstack = xlstktop = xlstkbase + EDEPTH;
  528.   
  529.       /* allocate the argument stack */
  530. !     if ((xlargstkbase = (LVAL *)malloc(ADEPTH * sizeof(LVAL))) == NULL)
  531.       xlfatal("insufficient memory");
  532.       xlargstktop = xlargstkbase + ADEPTH;
  533.       xlfp = xlsp = xlargstkbase;
  534. --- 699,710 ----
  535.       s_gcflag = s_gchook = NIL;
  536.   
  537.       /* allocate the evaluation stack */
  538. !     if ((xlstkbase = (LVAL **)xlmalloc(EDEPTH * sizeof(LVAL *))) == NULL)
  539.       xlfatal("insufficient memory");
  540.       xlstack = xlstktop = xlstkbase + EDEPTH;
  541.   
  542.       /* allocate the argument stack */
  543. !     if ((xlargstkbase = (LVAL *)xlmalloc(ADEPTH * sizeof(LVAL))) == NULL)
  544.       xlfatal("insufficient memory");
  545.       xlargstktop = xlargstkbase + ADEPTH;
  546.       xlfp = xlsp = xlargstkbase;
  547. diff -c ../xlisp.org/xldmem.h ../xlisp/xldmem.h
  548. *** ../xlisp.org/xldmem.h    Sun May  7 22:25:47 1989
  549. --- ../xlisp/xldmem.h    Wed Apr  5 16:45:38 1989
  550. ***************
  551. *** 13,21 ****
  552.   #define CHARMAX        255
  553.   #define CHARSIZE    256
  554.   
  555. - /* new node access macros */
  556. - #define ntype(x)    ((x)->n_type)
  557.   /* cons access macros */
  558.   #define car(x)        ((x)->n_car)
  559.   #define cdr(x)        ((x)->n_cdr)
  560. --- 13,18 ----
  561. ***************
  562. *** 23,72 ****
  563.   #define rplacd(x,y)    ((x)->n_cdr = (y))
  564.   
  565.   /* symbol access macros */
  566. ! #define getvalue(x)     ((x)->n_vdata[0])
  567. ! #define setvalue(x,v)     ((x)->n_vdata[0] = (v))
  568. ! #define getfunction(x)     ((x)->n_vdata[1])
  569. ! #define setfunction(x,v) ((x)->n_vdata[1] = (v))
  570. ! #define getplist(x)     ((x)->n_vdata[2])
  571. ! #define setplist(x,v)     ((x)->n_vdata[2] = (v))
  572. ! #define getpname(x)     ((x)->n_vdata[3])
  573. ! #define setpname(x,v)     ((x)->n_vdata[3] = (v))
  574.   #define SYMSIZE        4
  575.   
  576.   /* closure access macros */
  577. ! #define getname(x)         ((x)->n_vdata[0])
  578. ! #define setname(x,v)       ((x)->n_vdata[0] = (v))
  579. ! #define gettype(x)        ((x)->n_vdata[1])
  580. ! #define settype(x,v)      ((x)->n_vdata[1] = (v))
  581. ! #define getargs(x)         ((x)->n_vdata[2])
  582. ! #define setargs(x,v)       ((x)->n_vdata[2] = (v))
  583. ! #define getoargs(x)        ((x)->n_vdata[3])
  584. ! #define setoargs(x,v)      ((x)->n_vdata[3] = (v))
  585. ! #define getrest(x)         ((x)->n_vdata[4])
  586. ! #define setrest(x,v)       ((x)->n_vdata[4] = (v))
  587. ! #define getkargs(x)        ((x)->n_vdata[5])
  588. ! #define setkargs(x,v)      ((x)->n_vdata[5] = (v))
  589. ! #define getaargs(x)        ((x)->n_vdata[6])
  590. ! #define setaargs(x,v)      ((x)->n_vdata[6] = (v))
  591. ! #define getbody(x)         ((x)->n_vdata[7])
  592. ! #define setbody(x,v)       ((x)->n_vdata[7] = (v))
  593. ! #define getenv(x)    ((x)->n_vdata[8])
  594. ! #define setenv(x,v)    ((x)->n_vdata[8] = (v))
  595. ! #define getfenv(x)    ((x)->n_vdata[9])
  596. ! #define setfenv(x,v)    ((x)->n_vdata[9] = (v))
  597. ! #define getlambda(x)    ((x)->n_vdata[10])
  598. ! #define setlambda(x,v)    ((x)->n_vdata[10] = (v))
  599.   #define CLOSIZE        11
  600.   
  601.   /* vector access macros */
  602.   #define getsize(x)    ((x)->n_vsize)
  603. ! #define getelement(x,i)    ((x)->n_vdata[i])
  604. ! #define setelement(x,i,v) ((x)->n_vdata[i] = (v))
  605.   
  606.   /* object access macros */
  607. ! #define getclass(x)    ((x)->n_vdata[0])
  608. ! #define getivar(x,i)    ((x)->n_vdata[i+1])
  609. ! #define setivar(x,i,v)    ((x)->n_vdata[i+1] = (v))
  610.   
  611.   /* subr/fsubr access macros */
  612.   #define getsubr(x)    ((x)->n_subr)
  613. --- 20,69 ----
  614.   #define rplacd(x,y)    ((x)->n_cdr = (y))
  615.   
  616.   /* symbol access macros */
  617. ! #define getvalue(x)     (ACESSV(x,0))
  618. ! #define setvalue(x,v)     (ACESSV(x,0) = (v))
  619. ! #define getfunction(x)     (ACESSV(x,1))
  620. ! #define setfunction(x,v) (ACESSV(x,1) = (v))
  621. ! #define getplist(x)     (ACESSV(x,2))
  622. ! #define setplist(x,v)     (ACESSV(x,2) = (v))
  623. ! #define getpname(x)     (ACESSV(x,3))
  624. ! #define setpname(x,v)     (ACESSV(x,3) = (v))
  625.   #define SYMSIZE        4
  626.   
  627.   /* closure access macros */
  628. ! #define getname(x)         (ACESSV(x,0))
  629. ! #define setname(x,v)       (ACESSV(x,0) = (v))
  630. ! #define gettype(x)        (ACESSV(x,1))
  631. ! #define settype(x,v)      (ACESSV(x,1) = (v))
  632. ! #define getargs(x)         (ACESSV(x,2))
  633. ! #define setargs(x,v)       (ACESSV(x,2) = (v))
  634. ! #define getoargs(x)        (ACESSV(x,3))
  635. ! #define setoargs(x,v)      (ACESSV(x,3) = (v))
  636. ! #define getrest(x)         (ACESSV(x,4))
  637. ! #define setrest(x,v)       (ACESSV(x,4) = (v))
  638. ! #define getkargs(x)        (ACESSV(x,5))
  639. ! #define setkargs(x,v)      (ACESSV(x,5) = (v))
  640. ! #define getaargs(x)        (ACESSV(x,6))
  641. ! #define setaargs(x,v)      (ACESSV(x,6) = (v))
  642. ! #define getbody(x)         (ACESSV(x,7))
  643. ! #define setbody(x,v)       (ACESSV(x,7) = (v))
  644. ! #define getenv(x)    (ACESSV(x,8))
  645. ! #define setenv(x,v)    (ACESSV(x,8) = (v))
  646. ! #define getfenv(x)    (ACESSV(x,9))
  647. ! #define setfenv(x,v)    (ACESSV(x,9) = (v))
  648. ! #define getlambda(x)    (ACESSV(x,10))
  649. ! #define setlambda(x,v)    (ACESSV(x,10) = (v))
  650.   #define CLOSIZE        11
  651.   
  652.   /* vector access macros */
  653.   #define getsize(x)    ((x)->n_vsize)
  654. ! #define getelement(x,i)    (ACESSV(x,i))
  655. ! #define setelement(x,i,v) (ACESSV(x,i) = (v))
  656.   
  657.   /* object access macros */
  658. ! #define getclass(x)    (ACESSV(x,0))
  659. ! #define getivar(x,i)    (ACESSV(x,i+1))
  660. ! #define setivar(x,i,v)    (ACESSV(x,i+1) = (v))
  661.   
  662.   /* subr/fsubr access macros */
  663.   #define getsubr(x)    ((x)->n_subr)
  664. ***************
  665. *** 78,84 ****
  666.   #define getchcode(x)    ((x)->n_chcode)
  667.   
  668.   /* string access macros */
  669. ! #define getstring(x)    ((x)->n_string)
  670.   #define getslength(x)    ((x)->n_strlen)
  671.   
  672.   /* file stream access macros */
  673. --- 75,81 ----
  674.   #define getchcode(x)    ((x)->n_chcode)
  675.   
  676.   /* string access macros */
  677. ! #define getstring(x)    (ACESSS((x)->n_string))
  678.   #define getslength(x)    ((x)->n_strlen)
  679.   
  680.   /* file stream access macros */
  681. ***************
  682. *** 93,114 ****
  683.   #define gettail(x)    ((x)->n_cdr)
  684.   #define settail(x,v)    ((x)->n_cdr = (v))
  685.   
  686.   /* node types */
  687.   #define FREE    0
  688.   #define SUBR    1
  689.   #define FSUBR    2
  690.   #define CONS    3
  691. ! #define SYMBOL    4
  692. ! #define FIXNUM    5
  693. ! #define FLONUM    6
  694. ! #define STRING    7
  695. ! #define OBJECT    8
  696. ! #define STREAM    9
  697. ! #define VECTOR    10
  698. ! #define CLOSURE    11
  699. ! #define CHAR    12
  700. ! #define USTREAM    13
  701.   
  702.   /* subr/fsubr node */
  703.   #define n_subr        n_info.n_xsubr.xs_subr
  704.   #define n_offset    n_info.n_xsubr.xs_offset
  705. --- 90,121 ----
  706.   #define gettail(x)    ((x)->n_cdr)
  707.   #define settail(x,v)    ((x)->n_cdr = (v))
  708.   
  709. + #define    getwinobj(x)    (ACESSS((x)->n_winobj))
  710. + #define    setwinobj(x,v)    ((x)->n_winobj = (v))
  711.   /* node types */
  712.   #define FREE    0
  713. + #define SYMBOL    17
  714. + #define OBJECT    18
  715. + #define VECTOR    19
  716. + #define CLOSURE    20
  717.   #define SUBR    1
  718.   #define FSUBR    2
  719.   #define CONS    3
  720. ! #define FIXNUM    4
  721. ! #define FLONUM    5
  722. ! #define STRING    6
  723. ! #define STREAM    7
  724. ! #define CHAR    8
  725. ! #define USTREAM    9
  726. ! #define    WINOBJ    10
  727.   
  728. + #define    ARRAY    16
  729. + #define TYPEFIELD 0x1f
  730. + /* new node access macros */
  731. + #define ntype(x)    ((x)->n_type & TYPEFIELD)
  732.   /* subr/fsubr node */
  733.   #define n_subr        n_info.n_xsubr.xs_subr
  734.   #define n_offset    n_info.n_xsubr.xs_offset
  735. ***************
  736. *** 137,146 ****
  737.   #define n_vsize        n_info.n_xvector.xv_size
  738.   #define n_vdata        n_info.n_xvector.xv_data
  739.   
  740.   /* node structure */
  741.   typedef struct node {
  742.       char n_type;        /* type of node */
  743. -     char n_flags;        /* flag bits */
  744.       union ninfo {         /* value */
  745.       struct xsubr {        /* subr/fsubr node */
  746.           struct node *(*xs_subr)();    /* function pointer */
  747. --- 144,155 ----
  748.   #define n_vsize        n_info.n_xvector.xv_size
  749.   #define n_vdata        n_info.n_xvector.xv_data
  750.   
  751. + /* window/font node */
  752. + #define    n_winobj    n_info.n_xwinobj.xw_ptr
  753.   /* node structure */
  754.   typedef struct node {
  755.       char n_type;        /* type of node */
  756.       union ninfo {         /* value */
  757.       struct xsubr {        /* subr/fsubr node */
  758.           struct node *(*xs_subr)();    /* function pointer */
  759. ***************
  760. *** 171,176 ****
  761. --- 180,188 ----
  762.           int xv_size;        /* vector size */
  763.           struct node **xv_data;    /* vector data */
  764.       } n_xvector;
  765. +     struct xwinobj {    /* window/font object */
  766. +         char *xw_ptr;        /* Generic structure pointer */
  767. +     } n_xwinobj;
  768.       } n_info;
  769.   } *LVAL;
  770.   
  771. ***************
  772. *** 187,195 ****
  773.   extern LVAL cvstring();           /* convert a string */
  774.   extern LVAL cvfile();        /* convert a FILE * to a file */
  775.   extern LVAL cvsubr();        /* convert a function to a subr/fsubr */
  776. ! extern LVAL cvfixnum();           /* convert a fixnum */
  777.   extern LVAL cvflonum();           /* convert a flonum */
  778. ! extern LVAL cvchar();        /* convert a character */
  779.   
  780.   extern LVAL newstring();    /* create a new string */
  781.   extern LVAL newvector();    /* create a new vector */
  782. --- 199,207 ----
  783.   extern LVAL cvstring();           /* convert a string */
  784.   extern LVAL cvfile();        /* convert a FILE * to a file */
  785.   extern LVAL cvsubr();        /* convert a function to a subr/fsubr */
  786. ! extern LVAL Cvfixnum();           /* convert a fixnum */
  787.   extern LVAL cvflonum();           /* convert a flonum */
  788. ! extern LVAL Cvchar();        /* convert a character */
  789.   
  790.   extern LVAL newstring();    /* create a new string */
  791.   extern LVAL newvector();    /* create a new vector */
  792. ***************
  793. *** 196,198 ****
  794. --- 208,249 ----
  795.   extern LVAL newobject();    /* create a new object */
  796.   extern LVAL newclosure();    /* create a new closure */
  797.   extern LVAL newustream();    /* create a new unnamed stream */
  798. + /* Speed ups, reduce function calls for fixed characters and numbers       */
  799. + /* Speed is exeptionaly noticed on machines with large a instruction cache */
  800. + /* No size effects here (JonnyG) */
  801. + extern SEGMENT *fixseg,*charseg;
  802. + extern FIXTYPE _tfixed;
  803. + extern int _tint;
  804. + #define cvfixnum(n) ((_tfixed = n), \
  805. +         ((_tfixed > SFIXMIN && _tfixed < SFIXMAX) ? \
  806. +         &fixseg->sg_nodes[(int)_tfixed-SFIXMIN] : \
  807. +         Cvfixnum(_tfixed)))
  808. + #define cvchar(c) ((_tint = c), \
  809. +         ((_tint >= CHARMIN && _tint <= CHARMIN) ? \
  810. +             &charseg->sg_nodes[_tint-CHARMIN] : \
  811. +         Cvchar(_tint)))
  812. + extern    char *xldmalloc();
  813. + extern    char *xldcalloc();
  814. + #ifdef    VMEM
  815. + extern char *vload();
  816. + extern    unsigned char *vaccess();
  817. + #define    ACESSV(x,i)    (((LVAL *)vaccess((x)->n_vdata))[i])
  818. + #define    ACESSS(x)    (vaccess(x))
  819. + #else
  820. + #define    xlfcalloc    xlcalloc
  821. + #define ACESSV(x,i)    (x)->n_vdata[i]
  822. + #define    ACESSS(x)    x
  823. + #endif
  824. diff -c ../xlisp.org/xlfio.c ../xlisp/xlfio.c
  825. *** ../xlisp.org/xlfio.c    Sun May  7 22:25:52 1989
  826. --- ../xlisp/xlfio.c    Wed Apr  5 16:18:27 1989
  827. ***************
  828. *** 349,355 ****
  829.   
  830.       /* copy the substring into the stream */
  831.       for (i = start; i < end; ++i)
  832. !     xlputc(val,str[i]);
  833.   
  834.       /* restore the stack */
  835.       xlpop();
  836. --- 349,355 ----
  837.   
  838.       /* copy the substring into the stream */
  839.       for (i = start; i < end; ++i)
  840. !     xlputc(val,getstring(string) + i);
  841.   
  842.       /* restore the stack */
  843.       xlpop();
  844. ***************
  845. *** 450,456 ****
  846.   LOCAL LVAL getstroutput(stream)
  847.     LVAL stream;
  848.   {
  849. !     unsigned char *str;
  850.       LVAL next,val;
  851.       int len,ch;
  852.   
  853. --- 450,456 ----
  854.   LOCAL LVAL getstroutput(stream)
  855.     LVAL stream;
  856.   {
  857. !     int i;
  858.       LVAL next,val;
  859.       int len,ch;
  860.   
  861. ***************
  862. *** 462,471 ****
  863.       val = newstring(len + 1);
  864.       
  865.       /* copy the characters into the new string */
  866. !     str = getstring(val);
  867.       while ((ch = xlgetc(stream)) != EOF)
  868. !     *str++ = ch;
  869. !     *str = '\0';
  870.   
  871.       /* return the string */
  872.       return (val);
  873. --- 462,471 ----
  874.       val = newstring(len + 1);
  875.       
  876.       /* copy the characters into the new string */
  877. !     i = 0;
  878.       while ((ch = xlgetc(stream)) != EOF)
  879. !     getstring(val)[i++] = ch;
  880. !     getstring(val)[i] = '\0';
  881.   
  882.       /* return the string */
  883.       return (val);
  884.  
  885.  
  886.