ZealOS/Doc/Hash.DD

77 lines
2 KiB
Text
Raw Normal View History

2020-02-15 20:01:48 +00:00
$WW,1$$SP,"",BI=1$
There is a symbol (hash) table for each task. When a sym is not found, the parent task's sym table is checked. All tasks chain back to the $FG,2$Adam$FG$ task.
TempleOS sym tables are implemented with an array of linked-lists. A num is generated from a string by $LK,"HashStr",A="MN:HashStr"$() to index into the array of linked-lists. Multiple strings can generate the same num, so linked-lists are built. Newer entries overshadow older ones.
There are various types of entries. See $LK,"Hash Entry Types",A="MN:HTT_EXPORT_SYS_SYM"$.
$FG,5$Symbol Look-up$FG$ (Used many places including the $LK,"JIT Compiler",A="FF:::/Compiler/Lex.HC,HashFind"$ and $LK,"Loader",A="FF:::/Kernel/KLoad.HC,HashFind"$.)
1) Symbol name is $LK,"hashed",A="MN:SYS_HASH_STR"$ by adding and shifting the ASCII of all chars.
2) $LK,"hash table",A="MN:CHashTable"$->body[] array is indexed.
3) Linked-lst is traversed until match of text and type of entry.
4) If not found, $LK,"hash table",A="MN:CHashTable"$->next table is searched.
Duplicate entries are allowed -- they overshadow old entries.
$FG,5$Address-to-Symbol Look-up$FG$ (Slow because not important. We could use trees.)
1) FunSeg Cache is $LK,"scanned",A="MN:FunSegCacheFind"$.
2) Hash Tables are $LK,"scanned",A="MN:FunSegFind"$.
<00>0<00>CatH_Cbsh<00>Dog<1C>_Dog<1C><00>BirdZ<00>p<00>x<00><00>o<1A><00><00><00>><00><<00>@<00>Po
)')?
)?%?
%?%'
%')'
='=?
<EFBFBD><00><00><00>
<EFBFBD><00><00><00>
Q'Q?
'?
-'-?
A'A?
'?
&<00><00>
<00><00>
<00>&<00>
&<00>&<00>
:<00>:<00>
N<00>N<00>
b<00>b<00>
v<00>v<00>
2<00>2<00>
F<00>F<00>
Z<00>Z<00>
<00><00>
<00><00>
<00><00>
<00><00>
<00><00>
?
 
 ?
??<00>&<00>3)3<00>C