示例#1
0
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;
   }
示例#2
0
	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);
			}
		}
示例#3
0
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);
}
示例#4
0
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);
}
示例#5
0
 T& FlatQueue<T>::operator[]( int idx )
 {
     return IndexAt( idx );
 }
示例#6
0
 T const & FlatQueue<T>::operator[]( int idx ) const
 {
     return IndexAt( idx );
 }
示例#7
0
void MemAllocator::Drop()
{
	for (CountFree = 0; CountFree < CountTotal; ++CountFree)
		IndexAt(CountFree) = CountFree;
}