-
Code's Tags
-
Your Codes
-
Reffers
-
Linked Codes
|
Code:
Short link for Twitter:
HTML:
HTML view:
Copy Source | Copy HTML- /****************************************************************************/
- /* assigns 'val to 'array[idx], after doing all the proper checks */
-
- HCIMPL3(void, JIT_Stelem_Ref_Portable, PtrArray* array, unsigned idx, Object *val)
- {
- if (!array)
- {
- FCThrowVoid(kNullReferenceException);
- }
- if (idx >= array->GetNumComponents())
- {
- FCThrowVoid(kIndexOutOfRangeException);
- }
-
- if (val)
- {
- MethodTable *valMT = val->GetMethodTable();
- TypeHandle arrayElemTH = array->GetArrayElementTypeHandle();
-
- if (arrayElemTH != TypeHandle(valMT) && arrayElemTH != TypeHandle(g_pObjectClass))
- {
- TypeHandle::CastResult result = ObjIsInstanceOfNoGC(val, arrayElemTH);
- if (result != TypeHandle::CanCast)
- {
- HELPER_METHOD_FRAME_BEGIN_2(val, array);
-
- // This is equivalent to ArrayStoreCheck(&val, &array);
- #ifdef STRESS_HEAP
- // Force a GC on every jit if the stress level is high enough
- if (g_pConfig->GetGCStressLevel() != 0
- #ifdef _DEBUG
- && !g_pConfig->FastGCStressLevel()
- #endif
- )
- GCHeap::GetGCHeap()->StressHeap();
- #endif
-
- #if CHECK_APP_DOMAIN_LEAKS
- // If the instance is agile or check agile
- if (!arrayElemTH.IsAppDomainAgile() && !arrayElemTH.IsCheckAppDomainAgile() && g_pConfig->AppDomainLeaks())
- {
- val->AssignAppDomain(array->GetAppDomain());
- }
- #endif
- if (!ObjIsInstanceOf(val, arrayElemTH))
- {
- COMPlusThrow(kArrayTypeMismatchException);
- }
-
- HELPER_METHOD_FRAME_END();
- }
- }
-
- // The performance gain of the optimized JIT_Stelem_Ref in
- // jitinterfacex86.cpp is mainly due to calling JIT_WriteBarrierReg_Buf.
- // By calling write barrier directly here,
- // we can avoid translating in-line assembly from MSVC to gcc
- // while keeping most of the performance gain.
- HCCALL2(JIT_WriteBarrier, (Object **)&array->m_Array[idx], val);
-
- }
- else
- {
- // no need to go through write-barrier for NULL
- ClearObjectReference(&array->m_Array[idx]);
- }
- }
- HCIMPLEND
|