MCPcopy Create free account
hub / github.com/WheretIB/nullc / GenCodeCmdYield

Function GenCodeCmdYield

NULLC/CodeGen_X86.cpp:2147–2171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2145void (*yieldRestorePtr)() = yieldRestoreEIP;
2146
2147void 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
2174void yieldSaveEIP()

Callers

nothing calls this directly

Calls 7

EMIT_OP_REG_RPTRFunction · 0.85
EMIT_OP_REG_REGFunction · 0.85
EMIT_OP_LABELFunction · 0.85
EMIT_REG_READFunction · 0.85
EMIT_OP_RPTRFunction · 0.85
EMIT_LABELFunction · 0.85
EMIT_OPFunction · 0.85

Tested by

no test coverage detected