void CMemAccessRefTest::Compile(Jitter::CJitter& jitter) { Framework::CMemStream codeStream; jitter.SetStream(&codeStream); jitter.Begin(); { //Read ref test { jitter.PushRelRef(offsetof(CONTEXT, memory)); jitter.PushCst(LOAD_IDX * sizeof(void*)); jitter.AddRef(); jitter.LoadRefFromRef(); jitter.LoadFromRef(); jitter.PullRel(offsetof(CONTEXT, readValueResult)); } EmitNullTest(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck0)); EmitNullTest(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck1)); EmitNullComparison(jitter, NULLCHECK_IDX, offsetof(CONTEXT, nullCheck2)); EmitNullComparison(jitter, LOAD_IDX, offsetof(CONTEXT, nullCheck3)); } jitter.End(); m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize()); }
void CMemAccessTest::Compile(Jitter::CJitter& jitter) { Framework::CMemStream codeStream; jitter.SetStream(&codeStream); jitter.Begin(); { //Store test jitter.PushRelRef(offsetof(CONTEXT, memory)); jitter.PushRel(offsetof(CONTEXT, offset)); jitter.AddRef(); jitter.PushCst(CONSTANT_1); jitter.StoreAtRef(); //Read test jitter.PushRelRef(offsetof(CONTEXT, memory)); jitter.PushCst(0x08); jitter.AddRef(); jitter.LoadFromRef(); jitter.PullRel(offsetof(CONTEXT, result0)); //Write array test jitter.PushRelAddrRef(offsetof(CONTEXT, array0)); jitter.PushCst(ARRAY_IDX_0 * 4); jitter.AddRef(); jitter.PushCst(CONSTANT_2); jitter.StoreAtRef(); //Read array test jitter.PushRelAddrRef(offsetof(CONTEXT, array0)); jitter.PushCst(ARRAY_IDX_1 * 4); jitter.AddRef(); jitter.LoadFromRef(); jitter.PullRel(offsetof(CONTEXT, result1)); } jitter.End(); m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize()); }
void CMemAccessRefTest::EmitNullTest(Jitter::CJitter& jitter, uint32 index, size_t resultOffset) { jitter.PushRelRef(offsetof(CONTEXT, memory)); jitter.PushCst(index * sizeof(void*)); jitter.AddRef(); jitter.LoadRefFromRef(); jitter.IsRefNull(); jitter.PullRel(resultOffset); }
void CMemAccessRefTest::EmitNullComparison(Jitter::CJitter& jitter, uint32 index, size_t resultOffset) { jitter.PushRelRef(offsetof(CONTEXT, memory)); jitter.PushCst(index * sizeof(void*)); jitter.AddRef(); jitter.LoadRefFromRef(); jitter.PushCst(0); jitter.BeginIf(Jitter::CONDITION_EQ); { jitter.PushCst(1); jitter.PullRel(resultOffset); } jitter.EndIf(); }
void CMdMemAccessTest::Compile(Jitter::CJitter& jitter) { Framework::CMemStream codeStream; jitter.SetStream(&codeStream); jitter.Begin(); { jitter.PushRelRef(offsetof(CONTEXT, array)); jitter.MD_LoadFromRef(); jitter.MD_PullRel(offsetof(CONTEXT, result)); jitter.PushRelRef(offsetof(CONTEXT, array)); jitter.PushCst(0x10); jitter.AddRef(); jitter.MD_PushRel(offsetof(CONTEXT, op)); jitter.MD_StoreAtRef(); } jitter.End(); m_function = CMemoryFunction(codeStream.GetBuffer(), codeStream.GetSize()); }