Skip to content

Commit c32449a

Browse files
committed
Implement initblk in the interpreter
1 parent d38a4d1 commit c32449a

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/coreclr/interpreter/compiler.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,6 +5623,21 @@ void InterpCompiler::GenerateCode(CORINFO_METHOD_INFO* methodInfo)
56235623
m_ip += 5;
56245624
break;
56255625
}
5626+
case CEE_INITBLK:
5627+
{
5628+
if (volatile_)
5629+
{
5630+
AddIns(INTOP_MEMBAR);
5631+
volatile_ = false;
5632+
}
5633+
5634+
CHECK_STACK(3);
5635+
AddIns(INTOP_INITBLK);
5636+
m_pStackPointer -= 3;
5637+
m_pLastNewIns->SetSVars3(m_pStackPointer[0].var, m_pStackPointer[1].var, m_pStackPointer[2].var);
5638+
m_ip++;
5639+
break;
5640+
}
56265641
case CEE_CPBLK:
56275642
CHECK_STACK(3);
56285643
if (volatile_)

src/coreclr/interpreter/intops.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ OPDEF(INTOP_GENERICLOOKUP, "generic", 4, 1, 1, InterpOpGenericLookup)
397397
OPDEF(INTOP_CALL_FINALLY, "call.finally", 2, 0, 0, InterpOpBranch)
398398

399399
OPDEF(INTOP_ZEROBLK_IMM, "zeroblk.imm", 3, 0, 1, InterpOpInt)
400+
OPDEF(INTOP_INITBLK, "initblk", 4, 0, 3, InterpOpNoArgs)
400401
OPDEF(INTOP_CPBLK, "cpblk", 4, 0, 3, InterpOpNoArgs)
401402
OPDEF(INTOP_LOCALLOC, "localloc", 3, 1, 1, InterpOpNoArgs)
402403
OPDEF(INTOP_BREAKPOINT, "breakpoint", 1, 0, 0, InterpOpNoArgs)

src/coreclr/vm/interpexec.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,18 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
21722172
ip += 4;
21732173
break;
21742174
}
2175+
case INTOP_INITBLK:
2176+
{
2177+
void* dst = LOCAL_VAR(ip[1], void*);
2178+
uint8_t value = LOCAL_VAR(ip[2], uint8_t);
2179+
uint32_t size = LOCAL_VAR(ip[3], uint32_t);
2180+
if (size && !dst)
2181+
COMPlusThrow(kNullReferenceException);
2182+
else
2183+
memset(dst, value, size);
2184+
ip += 4;
2185+
break;
2186+
}
21752187
case INTOP_LOCALLOC:
21762188
{
21772189
size_t len = LOCAL_VAR(ip[2], size_t);

0 commit comments

Comments
 (0)