diff options
Diffstat (limited to '')
-rw-r--r-- | src/buildvm_mips.dasc | 127 |
1 files changed, 118 insertions, 9 deletions
diff --git a/src/buildvm_mips.dasc b/src/buildvm_mips.dasc index 6b3103dd..9e984189 100644 --- a/src/buildvm_mips.dasc +++ b/src/buildvm_mips.dasc | |||
@@ -270,7 +270,13 @@ | |||
270 | |.macro jmp_extern; jr CFUNCADDR; .endmacro | 270 | |.macro jmp_extern; jr CFUNCADDR; .endmacro |
271 | | | 271 | | |
272 | |.macro hotcheck, delta, target | 272 | |.macro hotcheck, delta, target |
273 | |NYI | 273 | | srl TMP1, PC, 1 |
274 | | andi TMP1, TMP1, 126 | ||
275 | | addu TMP1, TMP1, DISPATCH | ||
276 | | lhu TMP2, GG_DISP2HOT(TMP1) | ||
277 | | addiu TMP2, TMP2, -delta | ||
278 | | bltz TMP2, target | ||
279 | |. sh TMP2, GG_DISP2HOT(TMP1) | ||
274 | |.endmacro | 280 | |.endmacro |
275 | | | 281 | | |
276 | |.macro hotloop | 282 | |.macro hotloop |
@@ -1995,7 +2001,21 @@ static void build_subroutines(BuildCtx *ctx) | |||
1995 | | | 2001 | | |
1996 | |->vm_hotloop: // Hot loop counter underflow. | 2002 | |->vm_hotloop: // Hot loop counter underflow. |
1997 | #if LJ_HASJIT | 2003 | #if LJ_HASJIT |
1998 | |NYI | 2004 | | lw LFUNC:TMP1, FRAME_FUNC(BASE) |
2005 | | addiu CARG1, DISPATCH, GG_DISP2J | ||
2006 | | sw PC, SAVE_PC | ||
2007 | | lw TMP1, LFUNC:TMP1->pc | ||
2008 | | move CARG2, PC | ||
2009 | | sw L, DISPATCH_J(L)(DISPATCH) | ||
2010 | | lbu TMP1, PC2PROTO(framesize)(TMP1) | ||
2011 | | load_got lj_trace_hot | ||
2012 | | sw BASE, L->base | ||
2013 | | sll TMP1, TMP1, 3 | ||
2014 | | addu TMP1, BASE, TMP1 | ||
2015 | | call_intern lj_trace_hot // (jit_State *J, const BCIns *pc) | ||
2016 | |. sw TMP1, L->top | ||
2017 | | b <3 | ||
2018 | |. nop | ||
1999 | #endif | 2019 | #endif |
2000 | | | 2020 | | |
2001 | |->vm_callhook: // Dispatch target for call hooks. | 2021 | |->vm_callhook: // Dispatch target for call hooks. |
@@ -2031,13 +2051,102 @@ static void build_subroutines(BuildCtx *ctx) | |||
2031 | |//-- Trace exit handler ------------------------------------------------- | 2051 | |//-- Trace exit handler ------------------------------------------------- |
2032 | |//----------------------------------------------------------------------- | 2052 | |//----------------------------------------------------------------------- |
2033 | | | 2053 | | |
2054 | |.macro savex_, a, b | ||
2055 | | sdc1 f..a, 16+a*8(sp) | ||
2056 | | sw r..a, 16+32*8+a*4(sp) | ||
2057 | | sw r..b, 16+32*8+b*4(sp) | ||
2058 | |.endmacro | ||
2059 | | | ||
2034 | |->vm_exit_handler: | 2060 | |->vm_exit_handler: |
2035 | #if LJ_HASJIT | 2061 | #if LJ_HASJIT |
2036 | |NYI | 2062 | | addiu sp, sp, -(16+32*8+32*4) |
2063 | | savex_ 0, 1 | ||
2064 | | savex_ 2, 3 | ||
2065 | | savex_ 4, 5 | ||
2066 | | savex_ 6, 7 | ||
2067 | | savex_ 8, 9 | ||
2068 | | savex_ 10, 11 | ||
2069 | | savex_ 12, 13 | ||
2070 | | savex_ 14, 15 | ||
2071 | | savex_ 16, 17 | ||
2072 | | savex_ 18, 19 | ||
2073 | | savex_ 20, 21 | ||
2074 | | savex_ 22, 23 | ||
2075 | | savex_ 24, 25 | ||
2076 | | savex_ 26, 27 | ||
2077 | | sdc1 f28, 16+28*8(sp) | ||
2078 | | sw r28, 16+32*8+28*4(sp) | ||
2079 | | sdc1 f30, 16+30*8(sp) | ||
2080 | | sw r30, 16+32*8+30*4(sp) | ||
2081 | | sw r0, 16+32*8+31*4(sp) // Clear RID_TMP. | ||
2082 | | li_vmstate EXIT | ||
2083 | | addiu TMP2, sp, 16+32*8+32*4 // Recompute original value of sp. | ||
2084 | | addiu DISPATCH, JGL, -GG_DISP2G-32768 | ||
2085 | | lw TMP1, 0(TMP2) // Load exit number. | ||
2086 | | st_vmstate | ||
2087 | | sw TMP2, 16+32*8+29*4(sp) // Store sp in RID_SP. | ||
2088 | | lw L, DISPATCH_GL(jit_L)(DISPATCH) | ||
2089 | | lw BASE, DISPATCH_GL(jit_base)(DISPATCH) | ||
2090 | | load_got lj_trace_exit | ||
2091 | | sw L, DISPATCH_J(L)(DISPATCH) | ||
2092 | | sw ra, DISPATCH_J(parent)(DISPATCH) // Store trace number. | ||
2093 | | sw TMP1, DISPATCH_J(exitno)(DISPATCH) // Store exit number. | ||
2094 | | addiu CARG1, DISPATCH, GG_DISP2J | ||
2095 | | sw BASE, L->base | ||
2096 | | call_intern lj_trace_exit // (jit_State *J, ExitState *ex) | ||
2097 | |. addiu CARG2, sp, 16 | ||
2098 | | // Returns MULTRES (unscaled) or negated error code. | ||
2099 | | lw TMP1, L->cframe | ||
2100 | | li AT, -4 | ||
2101 | | lw BASE, L->base | ||
2102 | | and sp, TMP1, AT | ||
2103 | | lw PC, SAVE_PC // Get SAVE_PC. | ||
2104 | | b >1 | ||
2105 | |. sw L, SAVE_L // Set SAVE_L (on-trace resume/yield). | ||
2037 | #endif | 2106 | #endif |
2038 | |->vm_exit_interp: | 2107 | |->vm_exit_interp: |
2039 | #if LJ_HASJIT | 2108 | #if LJ_HASJIT |
2040 | |NYI | 2109 | | // CRET1 = MULTRES or negated error code, BASE, PC and JGL set. |
2110 | | lw L, SAVE_L | ||
2111 | | addiu DISPATCH, JGL, -GG_DISP2G-32768 | ||
2112 | |1: | ||
2113 | | bltz CRET1, >3 // Check for error from exit. | ||
2114 | |. lw LFUNC:TMP1, FRAME_FUNC(BASE) | ||
2115 | | lui TMP3, 0x59c0 // TOBIT = 2^52 + 2^51 (float). | ||
2116 | | sll MULTRES, CRET1, 3 | ||
2117 | | li TISNIL, LJ_TNIL | ||
2118 | | sw MULTRES, SAVE_MULTRES | ||
2119 | | mtc1 TMP3, TOBIT | ||
2120 | | lw TMP1, LFUNC:TMP1->pc | ||
2121 | | sw r0, DISPATCH_GL(jit_L)(DISPATCH) | ||
2122 | | lw KBASE, PC2PROTO(k)(TMP1) | ||
2123 | | cvt.d.s TOBIT, TOBIT | ||
2124 | | // Modified copy of ins_next which handles function header dispatch, too. | ||
2125 | | lw INS, 0(PC) | ||
2126 | | addiu PC, PC, 4 | ||
2127 | | // Assumes TISNIL == ~LJ_VMST_INTERP == -1 | ||
2128 | | sw TISNIL, DISPATCH_GL(vmstate)(DISPATCH) | ||
2129 | | decode_OP4a TMP1, INS | ||
2130 | | decode_OP4b TMP1 | ||
2131 | | sltiu TMP2, TMP1, BC_FUNCF*4 // Function header? | ||
2132 | | addu TMP0, DISPATCH, TMP1 | ||
2133 | | decode_RD8a RD, INS | ||
2134 | | lw AT, 0(TMP0) | ||
2135 | | decode_RA8a RA, INS | ||
2136 | | beqz TMP2, >2 | ||
2137 | |. decode_RA8b RA | ||
2138 | | jr AT | ||
2139 | |. decode_RD8b RD | ||
2140 | |2: | ||
2141 | | addiu RC, MULTRES, -8 | ||
2142 | | jr AT | ||
2143 | |. add RA, RA, BASE | ||
2144 | | | ||
2145 | |3: // Rethrow error from the right C frame. | ||
2146 | | load_got lj_err_throw | ||
2147 | | negu CARG2, CRET1 | ||
2148 | | call_intern lj_err_throw // (lua_State *L, int errcode) | ||
2149 | |. move CARG1, L | ||
2041 | #endif | 2150 | #endif |
2042 | | | 2151 | | |
2043 | |//----------------------------------------------------------------------- | 2152 | |//----------------------------------------------------------------------- |
@@ -3739,13 +3848,13 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop) | |||
3739 | if (op == BC_JFORI) { | 3848 | if (op == BC_JFORI) { |
3740 | | li TMP1, 1 | 3849 | | li TMP1, 1 |
3741 | | li TMP2, 1 | 3850 | | li TMP2, 1 |
3742 | | lw INS, -4(PC) | 3851 | | addu TMP0, RD, TMP0 |
3743 | | slt TMP3, TMP3, r0 | 3852 | | slt TMP3, TMP3, r0 |
3744 | | movt TMP1, r0, 0 | 3853 | | movf TMP1, r0, 0 |
3745 | | movt TMP2, r0, 1 | 3854 | | addu PC, PC, TMP0 |
3746 | | addu PC, RD, TMP0 | 3855 | | movf TMP2, r0, 1 |
3856 | | lhu RD, -4+OFS_RD(PC) | ||
3747 | | movn TMP1, TMP2, TMP3 | 3857 | | movn TMP1, TMP2, TMP3 |
3748 | | decode_RD8a RD, INS | ||
3749 | | bnez TMP1, =>BC_JLOOP | 3858 | | bnez TMP1, =>BC_JLOOP |
3750 | |. decode_RD8b RD | 3859 | |. decode_RD8b RD |
3751 | } else if (op == BC_JFORL) { | 3860 | } else if (op == BC_JFORL) { |