mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-01 09:41:39 +00:00
The motivation for this is that allocating and clearing symbol tables is a common operation, especially with C99+, where a construct like "if (...) { ... }" involves three levels of scope with their own symbol tables. In some tests, it could take an appreciable fraction of total execution time (sometimes ~10%). This patch allows symbol tables that have already been allocated and cleared to be reused for a subsequent scope, as long as they are still empty. It does this by maintaining a pool of empty symbol tables and taking one from there rather than allocating a new one when possible. We impose a somewhat arbitrary limit of MaxBlock/150000 on the number of symbol tables we keep, to avoid filling up memory with them. It would probably be better to use purgeable handles here, but that would be a little more work, and this should be good enough for now.
42 lines
1.0 KiB
NASM
42 lines
1.0 KiB
NASM
mcopy symbol.macros
|
|
****************************************************************
|
|
*
|
|
* ClearTable - set the symbol table to zeros
|
|
*
|
|
* Inputs:
|
|
* table - symbol table address
|
|
*
|
|
****************************************************************
|
|
*
|
|
ClearTable private cc
|
|
hashSize2 equ 1753 # hash buckets * 2 - 1
|
|
sizeofBuckets equ 4*(hashSize2+1) sizeof(symbolTable.buckets)
|
|
|
|
subroutine (4:table),0
|
|
|
|
ldy #sizeofBuckets-2
|
|
lda #0
|
|
lb1 sta [table],Y
|
|
dey
|
|
dey
|
|
bpl lb1
|
|
|
|
return
|
|
end
|
|
|
|
****************************************************************
|
|
*
|
|
* SaveBF - save a value to a bit-field
|
|
*
|
|
* Inputs:
|
|
* addr - address to copy to
|
|
* bitdisp - displacement past the address
|
|
* bitsize - number of bits
|
|
* val - value to copy
|
|
*
|
|
****************************************************************
|
|
*
|
|
SaveBF private cc
|
|
jml ~SaveBF call ~SaveBF in ORCALib
|
|
end
|