FCIMPL1(void, ArrayNative::Initialize, ArrayBase* array) { FCALL_CONTRACT; if (array == NULL) { FCThrowVoid(kNullReferenceException); } MethodTable* pArrayMT = array->GetMethodTable(); TypeHandle thElem = pArrayMT->GetApproxArrayElementTypeHandle(); if (thElem.IsTypeDesc()) return; MethodTable * pElemMT = thElem.AsMethodTable(); if (!pElemMT->HasDefaultConstructor() || !pElemMT->IsValueType()) return; ARRAYBASEREF arrayRef (array); HELPER_METHOD_FRAME_BEGIN_1(arrayRef); ArrayInitializeWorker(&arrayRef, pArrayMT, pElemMT); HELPER_METHOD_FRAME_END(); }
FCIMPLEND #endif // !FEATURE_CORECLR FCIMPL4(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fForIntrospection, CLR_BOOL fRaiseResolveEvent) { FCALL_CONTRACT; ASSEMBLYNAMEREF pThis = (ASSEMBLYNAMEREF) (OBJECTREF) refThisUNSAFE; HRESULT hr = S_OK; HELPER_METHOD_FRAME_BEGIN_1(pThis); *pAssemblyRef = NULL; if (pThis == NULL) COMPlusThrow(kNullReferenceException, W("NullReference_This")); Thread * pThread = GetThread(); CheckPointHolder cph(pThread->m_MarshalAlloc.GetCheckpoint()); //hold checkpoint for autorelease AssemblySpec spec; hr = spec.InitializeSpec(&(pThread->m_MarshalAlloc), (ASSEMBLYNAMEREF *) &pThis, TRUE, FALSE); if (SUCCEEDED(hr)) { spec.AssemblyNameInit(&pThis,NULL); } else if ((hr == FUSION_E_INVALID_NAME) && fRaiseResolveEvent) { Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec, fForIntrospection, FALSE); if (pAssembly == NULL) { EEFileLoadException::Throw(&spec, hr); } else { *((OBJECTREF *) (&(*pAssemblyRef))) = pAssembly->GetExposedObject(); } } else { ThrowHR(hr); } HELPER_METHOD_FRAME_END(); }
// Block waiting for data to become available on the console stream indicated by the safe file handle passed. // Ensure that the thread remains abortable in the process. FCIMPL2(void, ConsoleStreamHelper::WaitForAvailableConsoleInput, SafeHandle* refThisUNSAFE, CLR_BOOL bIsPipe) { FCALL_CONTRACT; SAFEHANDLEREF refConsoleHandle(refThisUNSAFE); HELPER_METHOD_FRAME_BEGIN_1(refConsoleHandle); // Prevent the console handle being closed under our feet. SafeHandleHolder shh(&refConsoleHandle); // Don't pass the address of the native handle within the safe handle to DoAppropriateWait since the safe // handle is on the GC heap and could be moved. Instead copy the native handle out into a stack location // (this is safe because we've ref-counted the safe handle to prevent it being disposed on us). HANDLE hNativeConsoleHandle = refConsoleHandle->GetHandle(); bool skipWait = false; // If we are reading from a pipe and the other end of the pipe was closed, then do not block. No one can write to it. // Also we can skip blocking if we do have data available. We should block if nothing is available, with the assumption // that Windows is smart enough to handle pipes where the other end is closed. if (bIsPipe) { DWORD cBytesRead, cTotalBytesAvailable, cBytesLeftThisMessage; int r = PeekNamedPipe(hNativeConsoleHandle, NULL, 0, &cBytesRead, &cTotalBytesAvailable, &cBytesLeftThisMessage); if (r != 0) { skipWait = cTotalBytesAvailable > 0; } else { // Windows returns ERROR_BROKEN_PIPE if the other side of a pipe is closed. However, we've seen // pipes return ERROR_NO_DATA and ERROR_PIPE_NOT_CONNECTED. Check for those too. int errorCode = GetLastError(); skipWait = errorCode == ERROR_BROKEN_PIPE || errorCode == ERROR_NO_DATA || errorCode == ERROR_PIPE_NOT_CONNECTED; } } // Perform the wait (DoAppropriateWait automatically handles thread aborts). if (!skipWait) { GetThread()->DoAppropriateWait(1, &hNativeConsoleHandle, TRUE, INFINITE, WaitMode_Alertable); } HELPER_METHOD_FRAME_END(); }