本文整理汇总了C++中Stub::IncRef方法的典型用法代码示例。如果您正苦于以下问题:C++ Stub::IncRef方法的具体用法?C++ Stub::IncRef怎么用?C++ Stub::IncRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stub
的用法示例。
在下文中一共展示了Stub::IncRef方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompileMLStub
//---------------------------------------------------------
// Returns the equivalent hashed Stub, creating a new hash
// entry if necessary. If the latter, will call out to CompileMLStub.
//
// Refcounting:
// The caller is responsible for DecRef'ing the returned stub in
// order to avoid leaks.
//
//
// On successful exit, *pMode is set to describe
// the compiled nature of the MLStub.
//
// callerContext can be used by the caller to push some context through
// to the compilation routine.
//
// Returns NULL for out of memory or other fatal error.
//---------------------------------------------------------
Stub *MLStubCache::Canonicalize(const BYTE * pRawMLStub, MLStubCompilationMode *pMode,
void *callerContext)
{
m_crst.Enter();
MLCHASHENTRY *phe = (MLCHASHENTRY*)Find((LPVOID)pRawMLStub);
if (phe) {
Stub *pstub = phe->m_pMLStub;
pstub->IncRef();
*pMode = (MLStubCompilationMode) (phe->m_compilationMode);
m_crst.Leave();
return pstub;
}
m_crst.Leave();
{
CPUSTUBLINKER sl;
CPUSTUBLINKER slempty;
CPUSTUBLINKER *psl = &sl;
MLStubCompilationMode mode;
mode = CompileMLStub(pRawMLStub, psl, callerContext);
if (mode == INTERPRETED) {
// CompileMLStub returns INTERPRETED for error cases:
// in this case, redirect to the empty stublinker so
// we don't accidentally pick up any crud that
// CompileMLStub threw into the stublinker before
// it ran into the error condition.
psl = &slempty;
}
*pMode = mode;
UINT32 offset;
Stub *pstub;
if (NULL == (pstub = FinishLinking(psl, pRawMLStub, &offset))) {
return NULL;
}
if (offset > 0xffff) {
return NULL;
}
m_crst.Enter();
bool bNew;
phe = (MLCHASHENTRY*)FindOrAdd((LPVOID)pRawMLStub, /*modifies*/bNew);
if (phe) {
if (bNew) {
// Note: FinishLinking already does the IncRef.
phe->m_pMLStub = pstub;
phe->m_offsetOfRawMLStub = (UINT16)offset;
phe->m_compilationMode = mode;
} else {
// If we got here, some other thread got in
// and enregistered an identical stub during
// the window in which we were out of the m_crst.
//Under DEBUG, two identical ML streams can actually compile
// to different compiled stubs due to the checked build's
// toggling between inlined TLSGetValue and api TLSGetValue.
//_ASSERTE(phe->m_offsetOfRawMLStub == (UINT16)offset);
_ASSERTE(phe->m_compilationMode == mode);
pstub->DecRef(); // Destroy the stub we just created
pstub = phe->m_pMLStub; //Use the previously created stub
}
// IncRef so that caller has firm ownership of stub.
pstub->IncRef();
}
m_crst.Leave();
if (phe) {
return pstub;
} else {
// Couldn't grow hash table due to lack of memory.
// Destroy the stub and return NULL.
pstub->DecRef();
}
//.........这里部分代码省略.........