diff options
| author | Mike Pall <mike> | 2010-10-05 01:41:51 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2010-10-05 01:41:51 +0200 |
| commit | 08ac8b0c9611ce4c10b5f8c32a704e8438bbefae (patch) | |
| tree | 5343f256107f678c836d8eafec901f35532003a5 /src | |
| parent | 8b096c5d085bea8b1ad88189592d1a0c85457047 (diff) | |
| download | luajit-08ac8b0c9611ce4c10b5f8c32a704e8438bbefae.tar.gz luajit-08ac8b0c9611ce4c10b5f8c32a704e8438bbefae.tar.bz2 luajit-08ac8b0c9611ce4c10b5f8c32a704e8438bbefae.zip | |
PPC: Add getmetatable(), setmetatable() and rawget() fast functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buildvm_ppc.dasc | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/src/buildvm_ppc.dasc b/src/buildvm_ppc.dasc index ec156e86..5dad8719 100644 --- a/src/buildvm_ppc.dasc +++ b/src/buildvm_ppc.dasc | |||
| @@ -240,6 +240,7 @@ | |||
| 240 | |.macro checkok, label; blt label; .endmacro | 240 | |.macro checkok, label; blt label; .endmacro |
| 241 | |.macro checkfail, label; bge label; .endmacro | 241 | |.macro checkfail, label; bge label; .endmacro |
| 242 | |.macro checkanyfail, label; bns label; .endmacro | 242 | |.macro checkanyfail, label; bns label; .endmacro |
| 243 | |.macro checkallok, label; bso label; .endmacro | ||
| 243 | |.endif | 244 | |.endif |
| 244 | | | 245 | | |
| 245 | |.macro branch_RD | 246 | |.macro branch_RD |
| @@ -950,13 +951,80 @@ static void build_subroutines(BuildCtx *ctx) | |||
| 950 | |//-- Base library: getters and setters --------------------------------- | 951 | |//-- Base library: getters and setters --------------------------------- |
| 951 | | | 952 | | |
| 952 | |.ffunc_1 getmetatable | 953 | |.ffunc_1 getmetatable |
| 953 | | NYI | 954 | | checktab CARG1 |
| 955 | | evmergehi TMP1, CARG1, CARG1 | ||
| 956 | | checkfail >6 | ||
| 957 | |1: // Field metatable must be at same offset for GCtab and GCudata! | ||
| 958 | | lwz TAB:RB, TAB:CARG1->metatable | ||
| 959 | |2: | ||
| 960 | | evmr CRET1, TISNIL | ||
| 961 | | cmplwi TAB:RB, 0 | ||
| 962 | | lwz STR:RC, DISPATCH_GL(gcroot[GCROOT_MMNAME+MM_metatable])(DISPATCH) | ||
| 963 | | beq ->fff_restv | ||
| 964 | | lwz TMP0, TAB:RB->hmask | ||
| 965 | | evmergelo CRET1, TISTAB, TAB:RB // Use metatable as default result. | ||
| 966 | | lwz TMP1, STR:RC->hash | ||
| 967 | | lwz NODE:TMP2, TAB:RB->node | ||
| 968 | | evmergelo STR:RC, TISSTR, STR:RC | ||
| 969 | | and TMP1, TMP1, TMP0 // idx = str->hash & tab->hmask | ||
| 970 | | slwi TMP0, TMP1, 5 | ||
| 971 | | slwi TMP1, TMP1, 3 | ||
| 972 | | sub TMP1, TMP0, TMP1 | ||
| 973 | | add NODE:TMP2, NODE:TMP2, TMP1 // node = tab->node + (idx*32-idx*8) | ||
| 974 | |3: // Rearranged logic, because we expect _not_ to find the key. | ||
| 975 | | evldd TMP0, NODE:TMP2->key | ||
| 976 | | evldd TMP1, NODE:TMP2->val | ||
| 977 | | evcmpeq TMP0, STR:RC | ||
| 978 | | lwz NODE:TMP2, NODE:TMP2->next | ||
| 979 | | checkallok >5 | ||
| 980 | | cmplwi NODE:TMP2, 0 | ||
| 981 | | beq ->fff_restv // Not found, keep default result. | ||
| 982 | | b <3 | ||
| 983 | |5: | ||
| 984 | | checknil TMP1 | ||
| 985 | | checkok ->fff_restv // Ditto for nil value. | ||
| 986 | | evmr CRET1, TMP1 // Return value of mt.__metatable. | ||
| 987 | | b ->fff_restv | ||
| 988 | | | ||
| 989 | |6: | ||
| 990 | | cmpwi TMP1, LJ_TUDATA | ||
| 991 | | not TMP1, TMP1 | ||
| 992 | | beq <1 | ||
| 993 | | checknum CARG1 | ||
| 994 | | slwi TMP1, TMP1, 2 | ||
| 995 | | li TMP2, 4*~LJ_TNUMX | ||
| 996 | | isellt TMP1, TMP2, TMP1 | ||
| 997 | | la TMP2, DISPATCH_GL(gcroot[GCROOT_BASEMT])(DISPATCH) | ||
| 998 | | lwzx TAB:RB, TMP2, TMP1 | ||
| 999 | | b <2 | ||
| 954 | | | 1000 | | |
| 955 | |.ffunc_2 setmetatable | 1001 | |.ffunc_2 setmetatable |
| 956 | | NYI | 1002 | | // Fast path: no mt for table yet and not clearing the mt. |
| 1003 | | evmergehi TMP0, TAB:CARG1, TAB:CARG2 | ||
| 1004 | | checktab TMP0 | ||
| 1005 | | checkanyfail ->fff_fallback | ||
| 1006 | | lwz TAB:TMP1, TAB:CARG1->metatable | ||
| 1007 | | cmplwi TAB:TMP1, 0 | ||
| 1008 | | lbz TMP3, TAB:CARG1->marked | ||
| 1009 | | bne ->fff_fallback | ||
| 1010 | | andi. TMP0, TMP3, LJ_GC_BLACK // isblack(table) | ||
| 1011 | | stw TAB:CARG2, TAB:CARG1->metatable | ||
| 1012 | | beq ->fff_restv | ||
| 1013 | | barrierback TAB:CARG1, TMP3, TMP0 | ||
| 1014 | | b ->fff_restv | ||
| 957 | | | 1015 | | |
| 958 | |.ffunc_2 rawget | 1016 | |.ffunc rawget |
| 959 | | NYI | 1017 | | cmplwi NARGS8:RC, 16 |
| 1018 | | evldd CARG2, 0(BASE) | ||
| 1019 | | blt ->fff_fallback | ||
| 1020 | | checktab CARG2 | ||
| 1021 | | la CARG3, 8(BASE) | ||
| 1022 | | checkfail ->fff_fallback | ||
| 1023 | | mr CARG1, L | ||
| 1024 | | bl extern lj_tab_get // (lua_State *L, GCtab *t, cTValue *key) | ||
| 1025 | | // Returns cTValue *. | ||
| 1026 | | evldd CRET1, 0(CRET1) | ||
| 1027 | | b ->fff_restv | ||
| 960 | | | 1028 | | |
| 961 | |//-- Base library: conversions ------------------------------------------ | 1029 | |//-- Base library: conversions ------------------------------------------ |
| 962 | | | 1030 | | |
