Redesign and harden string interning.

Up to 40% faster on hash-intensive benchmarks.
With some ideas from Sokolov Yura.
This commit is contained in:
Mike Pall
2020-06-23 03:06:45 +02:00
parent a44f53acf5
commit ff34b48ddd
22 changed files with 394 additions and 202 deletions

View File

@@ -1230,7 +1230,7 @@ static void build_subroutines(BuildCtx *ctx)
| mov [BASE-16], TAB:RC // Store metatable as default result.
| mov STR:RC, [DISPATCH+DISPATCH_GL(gcroot)+8*(GCROOT_MMNAME+MM_metatable)]
| mov RAd, TAB:RB->hmask
| and RAd, STR:RC->hash
| and RAd, STR:RC->sid
| settp STR:RC, LJ_TSTR
| imul RAd, #NODE
| add NODE:RA, TAB:RB->node
@@ -3674,7 +3674,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| checktab TAB:RB, ->vmeta_tgets
|->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *
| mov TMPRd, TAB:RB->hmask
| and TMPRd, STR:RC->hash
| and TMPRd, STR:RC->sid
| imul TMPRd, #NODE
| add NODE:TMPR, TAB:RB->node
| settp ITYPE, STR:RC, LJ_TSTR
@@ -3806,7 +3806,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| checktab TAB:RB, ->vmeta_tsets
|->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *
| mov TMPRd, TAB:RB->hmask
| and TMPRd, STR:RC->hash
| and TMPRd, STR:RC->sid
| imul TMPRd, #NODE
| mov byte TAB:RB->nomm, 0 // Clear metamethod cache.
| add NODE:TMPR, TAB:RB->node