bool ThunkBuilder::buildIL() { TR::IlType *pWord = typeDictionary()->PointerTo(Word); uint32_t numArgs = _numCalleeParams+1; TR::IlValue **args = (TR::IlValue **) comp()->trMemory()->allocateHeapMemory(numArgs * sizeof(TR::IlValue *)); // first argument is the target address args[0] = Load("target"); // followed by the actual arguments for (uint32_t p=0; p < _numCalleeParams; p++) { uint32_t a=p+1; args[a] = ConvertTo(_calleeParamTypes[p], LoadAt(pWord, IndexAt(pWord, Load("args"), ConstInt32(p)))); } TR::IlValue *retValue = ComputedCall("thunkCallee", numArgs, args); if (getReturnType() != NoType) Return(retValue); Return(); return true; }
inline void Add(int32 value) { if (value >= 0) { // keep the list sorted int32 count = CountItems(); int32 index = 0; for (; index < count; index++) { if (IndexAt(index) > value) { break; } } BList::AddItem((void*)value, index); } }
void MemAllocator::Free(PVOID ptr) { if (CountFree < CountTotal) { ULONG nDiff = ((ULONG) ptr) - ((ULONG) Cache); ULONG nIndex = nDiff / (AllocationSize + sizeof(ULONG)); if (nIndex < CountTotal) { IndexAt((FirstFree + CountFree) % CountTotal) = nIndex; CountFree++; return; } } free(ptr); }
PVOID MemAllocator::Alloc() { //_aligned_malloc( AllocationSize, 32 ); assert(CountFree); if (!CountFree) { return malloc(AllocationSize); //new BYTE[AllocationSize]; } ULONG nFreeIndex = IndexAt(FirstFree); ++FirstFree %= CountTotal; CountFree--; return NodeAt(nFreeIndex); }
T& FlatQueue<T>::operator[]( int idx ) { return IndexAt( idx ); }
T const & FlatQueue<T>::operator[]( int idx ) const { return IndexAt( idx ); }
void MemAllocator::Drop() { for (CountFree = 0; CountFree < CountTotal; ++CountFree) IndexAt(CountFree) = CountFree; }