Ignore:
Timestamp:
Sep 14, 2020, 7:34:28 PM (5 years ago)
Author:
bird
Message:

kash: New parser allocator for non-forked-mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shinstance.h

    r3451 r3457  
    8484        char space[MINSIZE];
    8585};
     86
     87#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     88/** Parser stack allocator block.
     89 * These are reference counted so they can be shared between the parent and
     90 * child shells.  They are also using as an alternative to copying function
     91 * definitions, here the final goal is to automatically emit separate
     92 * pstack_blocks for function while parsing to make it more flexible. */
     93typedef struct pstack_block {
     94    /** Pointer to the next unallocated byte (= stacknxt). */
     95    char               *nextbyte;
     96    /** Number of bytes available in the current stack block (= stacknleft). */
     97    size_t              avail;
     98    /* Number of chars left for string data (PSTPUTC, PSTUPUTC, et al) (= sstrnleft). */
     99    size_t              strleft;
     100    /** Top of the allocation stack (nextbyte points within this). */
     101    struct stack_block *top;
     102    /** Size of the top stack element (user space only). */
     103    size_t              topsize;
     104    /** @name statistics
     105     * @{ */
     106    size_t              allocations;
     107    size_t              bytesalloced;
     108    size_t              nodesalloced;
     109    size_t              entriesalloced;
     110    size_t              strbytesalloced;
     111    size_t              blocks;
     112    size_t              fragmentation;
     113    /** @} */
     114    /** Reference counter. */
     115    unsigned volatile   refs;
     116    unsigned            padding;
     117    /** The first stack block. */
     118    struct stack_block  first;
     119} pstack_block;
     120#endif
    86121
    87122/* input.c */
     
    275310    struct stack_block *stackp/* = &stackbase*/;
    276311    struct stackmark   *markp;
     312
     313#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     314    pstack_block       *curpstack;      /**< The pstack entry we're currently allocating from (NULL when not in parse.c). */
     315    pstack_block      **pstack;         /**< Stack of parsed stuff. */
     316    unsigned            pstacksize;     /**< Number of entries in pstack. */
     317    unsigned            pstackalloced;  /**< The allocated size of pstack. */
     318#endif
    277319
    278320    /* myhistedit.h */
Note: See TracChangeset for help on using the changeset viewer.