diff options
author | Mike Pall <mike> | 2010-01-09 23:59:43 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-01-09 23:59:43 +0100 |
commit | 99d153bef9725db226614558d01df829afafee3c (patch) | |
tree | ec5c4778a0ac5e054fc8c3d337381e1d52f626bc /src/lj_record.c | |
parent | 2cc554db0cb37ac3600cccab97c657bb532e3c4e (diff) | |
download | luajit-99d153bef9725db226614558d01df829afafee3c.tar.gz luajit-99d153bef9725db226614558d01df829afafee3c.tar.bz2 luajit-99d153bef9725db226614558d01df829afafee3c.zip |
Improve alias analysis of upvalues using a disambiguation hash value.
All upvalue objects hold a disambiguation hash value now.
It's built from the parent prototype and the slot number.
Different hash values imply the upvalues cannot alias.
Same hash values don't imply anything (collision or different closures).
Upvalue disambiguation makes use of a reduced hash due to IR contraints.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r-- | src/lj_record.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lj_record.c b/src/lj_record.c index 0dfd1f73..b998c020 100644 --- a/src/lj_record.c +++ b/src/lj_record.c | |||
@@ -781,6 +781,15 @@ static TRef rec_idx(jit_State *J, RecordIndex *ix) | |||
781 | 781 | ||
782 | /* -- Upvalue access ------------------------------------------------------ */ | 782 | /* -- Upvalue access ------------------------------------------------------ */ |
783 | 783 | ||
784 | /* Shrink disambiguation hash into an 8 bit value. */ | ||
785 | static uint32_t shrink_dhash(uint32_t lo, uint32_t hi) | ||
786 | { | ||
787 | lo ^= hi; hi = lj_rol(hi, 14); | ||
788 | lo -= hi; hi = lj_rol(hi, 5); | ||
789 | hi ^= lo; hi -= lj_rol(lo, 27); | ||
790 | return (hi & 0xff); | ||
791 | } | ||
792 | |||
784 | /* Record upvalue load/store. */ | 793 | /* Record upvalue load/store. */ |
785 | static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) | 794 | static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) |
786 | { | 795 | { |
@@ -788,6 +797,8 @@ static TRef rec_upvalue(jit_State *J, uint32_t uv, TRef val) | |||
788 | TRef fn = getcurrf(J); | 797 | TRef fn = getcurrf(J); |
789 | IRRef uref; | 798 | IRRef uref; |
790 | int needbarrier = 0; | 799 | int needbarrier = 0; |
800 | /* Note: this effectively limits LJ_MAX_UPVAL to 127. */ | ||
801 | uv = (uv << 8) | shrink_dhash(uvp->dhash, uvp->dhash-0x04c11db7); | ||
791 | if (!uvp->closed) { | 802 | if (!uvp->closed) { |
792 | /* In current stack? */ | 803 | /* In current stack? */ |
793 | if (uvval(uvp) >= J->L->stack && uvval(uvp) < J->L->maxstack) { | 804 | if (uvval(uvp) >= J->L->stack && uvval(uvp) < J->L->maxstack) { |