| 2145 | void (*yieldRestorePtr)() = yieldRestoreEIP; |
| 2146 | |
| 2147 | void GenCodeCmdYield(VMCmd cmd) |
| 2148 | { |
| 2149 | // If flag is set, jump to saved offset |
| 2150 | if(cmd.flag) |
| 2151 | { |
| 2152 | // Take pointer to closure in hidden argument |
| 2153 | EMIT_OP_REG_RPTR(o_mov, rEAX, sDWORD, rEBP, cmd.argument + paramBase); |
| 2154 | // Read jump offset at 4 byte shift (ExternFuncInfo::Upvalue::next) |
| 2155 | EMIT_OP_REG_RPTR(o_mov, rEBX, sDWORD, rEAX, 4); |
| 2156 | // Test for 0 |
| 2157 | EMIT_OP_REG_REG(o_test, rEBX, rEBX); |
| 2158 | // If zero, don't change anything |
| 2159 | EMIT_OP_LABEL(o_jz, aluLabels); |
| 2160 | |
| 2161 | // Jump to saved position |
| 2162 | EMIT_REG_READ(rEBX); |
| 2163 | EMIT_OP_RPTR(o_call, sDWORD, rNONE, 1, rNONE, (unsigned)(intptr_t)&yieldRestorePtr); |
| 2164 | |
| 2165 | EMIT_LABEL(aluLabels); |
| 2166 | aluLabels++; |
| 2167 | }else{ |
| 2168 | EMIT_OP(o_nop); // some instruction must be generated so that it is possible to jump to it |
| 2169 | yieldCmd = cmd; |
| 2170 | } |
| 2171 | } |
| 2172 | |
| 2173 | #ifdef __linux |
| 2174 | void yieldSaveEIP() |
nothing calls this directly
no test coverage detected