示例#1
0
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
      address caller_pc){
#ifdef ASSERT
    void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC));
    if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
    return p;
#else
    return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC));
#endif
  }
示例#2
0
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
  const std::nothrow_t&  nothrow_constant, address caller_pc) {
#ifdef ASSERT
  void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC),
      AllocFailStrategy::RETURN_NULL);
    if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
    return p;
#else
  return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC),
      AllocFailStrategy::RETURN_NULL);
#endif
}
 // Constructor
 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
   _name = AllocateHeap(strlen(name)+1);
   strcpy(_name, name);
   if (options == NULL) {
     _options = NULL;
   } else {
     _options = AllocateHeap(strlen(options)+1);
     strcpy(_options, options);
   }
   _is_absolute_path = is_absolute_path;
   _os_lib = os_lib;
   _next = NULL;
 }
示例#4
0
 // Constructor
 AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
   _name = AllocateHeap(strlen(name)+1, mtInternal);
   strcpy(_name, name);
   if (options == NULL) {
     _options = NULL;
   } else {
     _options = AllocateHeap(strlen(options)+1, mtInternal);
     strcpy(_options, options);
   }
   _is_absolute_path = is_absolute_path;
   _os_lib = os_lib;
   _next = NULL;
   _state = agent_invalid;
   _is_static_lib = false;
 }
示例#5
0
  void CountCodePattern::initComparing() {
    // general count stub;
    //  0: lea   count_addr, %eax
    //  6: movl  (%eax), %edx
    //  8: leal  1(%edx), %edx
    // 11: movl  %edx, (%eax)
    // 13: cmpl  %edx, limit
    // ??: jne jump_addr
    //     call recompile_addr
 
    
    Assembler* oldAssembler = theAssembler;
    Assembler* a = theAssembler = new Assembler(100, 100, false, true);

    a->leal(no_reg, initial_count_addr, VMAddressOperand, edx);
    countAddr_offset = a->offset() - sizeof(int32);
    a->movl(edx, 0, NumberOperand,  eax);
    a->incl(eax);
    a->movl(eax,  edx, 0, NumberOperand);
    a->cmpl(0xabcdef01, NumberOperand,   eax); 
    limit_offset = a->offset() - sizeof(int32);
    a->jne(0x87654321, CodeAddressOperand);
    nmAddr_offset = a->offset() - sizeof(int32);
    a->call((int32)Recompile_stub, VMAddressOperand);
    recompileStub_offset = a->offset() - sizeof(int32);

    instsSize = a->offset();
    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_bytes(a->instsStart, pattern, instsSize);
    *(int32*)&pattern[recompileStub_offset] -= pattern - a->instsStart; // fixup the call
    a->finalize();
    theAssembler = oldAssembler;    
  }
示例#6
0
void Particles::createGeometry()
{
	gb = AllocateThis(GeometryBuffer);
	gb->setBufferAccess(BufferAccess::Write);
	gb->setBufferUsage(BufferUsage::Dynamic);
	
	material = MaterialCreate(AllocatorGetHeap(), "ParticlesMaterial");

	Material* pMaterial = material.Resolve();
	pMaterial->setDepthWrite(false);
	pMaterial->setBlending(BlendSource::SourceAlpha, BlendDestination::One);
	pMaterial->setShader("Tex");

	RenderBatchPtr renderable = AllocateHeap(RenderBatch);
	renderable->setPrimitiveType(PrimitiveType::Points);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(material);
	renderable->setRenderLayer(RenderLayer::Transparency);

	renderable->onPreRender.Bind( this, &Particles::onPreRender );
	renderable->onPostRender.Bind( this, &Particles::onPostRender );
	
	addRenderable(renderable);

	particles.resize(MAX_PARTICLES);
}
void* operator new(size_t size){
  static bool warned = false;
  if (!warned && warn_new_operator) 
    warning("should not call global (default) operator new");
  warned = true;
  return (void *) AllocateHeap(size, "global operator new");
}
示例#8
0
bool CFYSPrintDoc::GetConfigurationElement(CString& strFYSInfo)
{
	COleDateTime Date(COleDateTime::GetCurrentTime());
	CString strTime = Date.Format("%Y-%m-%dT%H:%M:%S");

	CString strTemp;
	strTemp.Format("	<Configuration>\r\n"
					"		<ProcessingInformation>\r\n"
					"			%s\r\n"
					"		</ProcessingInformation>\r\n"
					"		<SenderInformation FYS_ClientID='31'/>\r\n"
					"		<ThisFileInformation CreationDateTime='%s' CLT_CorrelationID='15'/>\r\n"
					"		<GlobalDocumentConfiguration UnitOfMeasure='Inches'/>\r\n"
					"	</Configuration>\r\n",
					strFYSInfo,
					strTime);

	bool bVal = AllocateHeap((DWORD)&m_pConfig, strTemp);
	if (!m_pConfig)
	{
		SetError("Failed to allocate memory for Configuration element.");
		return false;
	}
	return true;
}
示例#9
0
RenderBatchPtr Model::createDebugRenderable() const
{
	MaterialHandle handleMaterial = MaterialCreate(AllocatorGetHeap(), "SkeletonDebug");

	Material* material = handleMaterial.Resolve();
	material->setDepthTest(false);

	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);
	
	RenderBatch* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Lines);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(handleMaterial);

	return renderable;
}
示例#10
0
D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapAllocator::AllocateHeapSlot(SIZE_T & outIndex)
{
	std::unique_lock<std::mutex> lock(m_AllocMutex);
	if (m_FreeHeaps.empty()) 
	{
		AllocateHeap();
	}
	SIZE_T head = m_FreeHeaps.front();
	outIndex = head;
	Entry &heapEntry = m_Heaps[outIndex];
	assert(!heapEntry.m_FreeList.empty());
	Node range = heapEntry.m_FreeList.front();
	D3D12_CPU_DESCRIPTOR_HANDLE ret = { range.Start };
	range.Start += m_DescriptorSize;
	if (range.Start == range.End)
	{
		Node freeNode = heapEntry.m_FreeList.front();
		heapEntry.m_FreeList.remove(freeNode);
		if (heapEntry.m_FreeList.empty()) 
		{
			m_FreeHeaps.remove(head);
		}
	}
	return ret;
}
示例#11
0
E* ArrayAllocator<E, F>::allocate(size_t length) {
  assert(_addr == NULL, "Already in use");

  _size = sizeof(E) * length;
  _use_malloc = _size < ArrayAllocatorMallocLimit;

  if (_use_malloc) {
    _addr = AllocateHeap(_size, F);
    if (_addr == NULL && _size >=  (size_t)os::vm_allocation_granularity()) {
      // malloc failed let's try with mmap instead
      _use_malloc = false;
    } else {
      return (E*)_addr;
    }
  }

  int alignment = os::vm_allocation_granularity();
  _size = align_size_up(_size, alignment);

  _addr = os::reserve_memory(_size, NULL, alignment, F);
  if (_addr == NULL) {
    vm_exit_out_of_memory(_size, OOM_MMAP_ERROR, "Allocator (reserve)");
  }

  os::commit_memory_or_exit(_addr, _size, !ExecMem, "Allocator (commit)");

  return (E*)_addr;
}
示例#12
0
SelectionOperation* CreateSelectionOperation(const String& desc)
{
	SelectionOperation* selection = AllocateHeap(SelectionOperation);
	selection->description = desc;

	return selection;
}
示例#13
0
void CountCodePattern::initCounting() {
    // general count stub; 7 instrs = 12 cycles on SS-2.  Could be reduced to
    // 6 insts / 10 cy if one additional register were available (e.g. could
    // use %o5 for sends with < 5 args).
    // 0: sethi count_addr, Temp1
    // 1: ld    [Temp1+lo(count_addr)], Temp2
    // 2: inc   Temp2
    // 3: st    Temp2, [Temp1+lo(count_addr)]
    // 4: sethi jump_addr, Temp1
    // 5: jmpl   Temp1 + low(jump_addr), g0
    // 6: nop
    instsSize = 7 * 4;
    countAddr_offset = 0;
    ld_offset = 1;
    st_offset = 3;
    nm_sethi_offset = 4;
    nm_jmp_offset = 5;
    limit_sethi_offset = countAddr_offset2 = recompile_offset = BadOffset;

    Assembler* a = new Assembler(instsSize, instsSize, false, true);
    a->SetHiA(0, Temp1);
    a->LoadI(Temp1, 0, Temp2);
    a->AddI(Temp2, 1, Temp2);
    a->StoreI(Temp1, 0, Temp2);
    a->SetHiX(0, CodeAddressOperand, Temp1);
    a->JmpLC(Temp1, 0, G0);
    a->Nop();

    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4);
    a->finalize();
}
示例#14
0
  void CountCodePattern::initCounting() {
    // general count stub; 8 instructions.
    // 0: lis     Temp1, high(count_addr)
    // 1: lwz     Temp2, [low(count_addr) + Temp1]
    // 2: addi    Temp2, Temp2, 1
    // 3: stw     Temp2, [low(count_addr) + Temp1]
    // 4: lis     Temp1, high(jump_addr)
    // 5: ori     Temp1, Temp1, low(jump_addr)
    // 6: mtctr   Temp1
    // 7: balwctr

    instsSize         = 8 * 4;
     countAddr_offset = 0;
           lwz_offset = 1;
           stw_offset = 3;
        nm_lis_offset = 4;
        nm_ori_offset = 5;
         limit_offset = recompile_lis_offset = recompile_ori_offset = BadOffset;

    Assembler* oldAssembler = theAssembler;
    Assembler* a = theAssembler = new Assembler(instsSize, instsSize, false, true);
    a->load_from_address(Temp2, 0, VMAddressOperand, Temp1);      // 2 instructions
    a->addi(Temp2, Temp2, 1, NumberOperand);
    a->stw(Temp2, 0, VMAddressOperand, Temp1);
    a->long_branch_to((pc_t)0, CodeAddressOperand, Temp1, false); // 4 instructions

    pattern = (pc_t)AllocateHeap(instsSize, "countStub pattern");
    copy_words((int32*)a->instsStart, (int32*)pattern, instsSize / 4);
    a->finalize();
    theAssembler = oldAssembler;
  }
示例#15
0
 // Constructor
 SystemProperty(const char* key, const char* value, bool writeable) {
   if (key == NULL) {
     _key = NULL;
   } else {
     _key = AllocateHeap(strlen(key)+1, mtInternal);
     strcpy(_key, key);
   }
   if (value == NULL) {
     _value = NULL;
   } else {
     _value = AllocateHeap(strlen(value)+1, mtInternal);
     strcpy(_value, value);
   }
   _next = NULL;
   _writeable = writeable;
 }
示例#16
0
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
      const NativeCallStack& stack) throw() {
  void* p = (void*)AllocateHeap(size, F, stack);
#ifdef ASSERT
  if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
#endif
  return p;
}
示例#17
0
RenderablePtr DebugBuildFrustum( const Frustum& box )
{
	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);

	MaterialHandle materialHandle = MaterialCreate(AllocatorGetHeap(), "FrustumDebug");
	Material* material = materialHandle.Resolve();
	material->setBackfaceCulling( false );

	Renderable* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Quads);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(materialHandle);
	renderable->setPrimitiveRasterMode( PrimitiveRasterMode::Wireframe );

	DebugUpdateFrustum(renderable, box);
	return renderable;
}
示例#18
0
void* ResourceObj::operator new(size_t size, allocation_type type) {
  switch (type) {
   case C_HEAP:        return (char*)AllocateHeap(size, "C_Heap: ResourceOBJ");
   case RESOURCE_AREA: return operator new(size);
  }
  ShouldNotReachHere();
  return NULL;
}
示例#19
0
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
  const std::nothrow_t&  nothrow_constant, const NativeCallStack& stack) throw() {
  void* p = (void*)AllocateHeap(size, F, stack,
      AllocFailStrategy::RETURN_NULL);
#ifdef ASSERT
    if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
#endif
    return p;
  }
示例#20
0
ResourceAreaChunk::ResourceAreaChunk(int min_capacity,
    ResourceAreaChunk* previous) {
  // lprintf("Resources cap=%d used=%d\n", resources.capacity(), resources.used());

  int size =
      max(min_capacity + min_resource_free_size, min_resource_chunk_size);
  bottom = (char*) AllocateHeap(size, "resourceAreaChunk");
  top = bottom + size;
  initialize(previous);
}
示例#21
0
ResourceAreaChunk::ResourceAreaChunk(fint min_capacity,
                                     ResourceAreaChunk* previous) {
  if (PrintResourceChunkAllocation)
    lprintf("allocating new resource chunk %#lx\n", this);
  fint size = max(min_capacity + min_resource_free_size,
                  min_resource_chunk_size);
  bottom = (char*) AllocateHeap(size,"resourceAreaChunk");
  top    = bottom + size;
  initialize(previous);
}
示例#22
0
void SelectionPlugin::onDocumentSelect( Document& document )
{
	DocumentContextMap& documentContext = document.documentContext;

	if( documentContext.find(this) == documentContext.end() )
	{
		documentContext[this] = AllocateHeap(SelectionManager);
	}

	selections = (SelectionManager*) documentContext[this].get();
}
示例#23
0
ThreadProfiler::ThreadProfiler() {
  // Space for the ProfilerNodes
  const int area_size = 1 * ProfilerNodeSize * 1024;
  area_bottom = AllocateHeap(area_size, mtInternal);
  area_top    = area_bottom;
  area_limit  = area_bottom + area_size;

  // ProfilerNode pointer table
  table = NEW_C_HEAP_ARRAY(ProfilerNode*, table_size, mtInternal);
  initialize();
  engaged = false;
}
示例#24
0
RenderablePtr DebugBuildBoundingBox( const BoundingBox& box )
{
	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);

	MaterialHandle materialHandle = MaterialCreate(AllocatorGetHeap(), "BoundingBoxDebug");
	
	Material* mat = materialHandle.Resolve();
	mat->setDepthCompare( DepthCompare::LessOrEqual );
	mat->setBackfaceCulling( false );
	//mat->setDepthRange( Vector2(0.1f, 0.9f) );

	Renderable* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Quads);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(materialHandle);
	renderable->setPrimitiveRasterMode( PrimitiveRasterMode::Wireframe );

	DebugUpdateBoudingBox(gb, box, Color::White);

	return renderable;
}
示例#25
0
RenderablePtr DebugBuildRay( const Ray& pickRay, float length )
{
	std::vector<Vector3> vertex;
	vertex.push_back( pickRay.origin );
	vertex.push_back( pickRay.getPoint(length) );

	std::vector<Vector3> colors( 2, Color::Red );

	GeometryBuffer* gb = AllocateHeap(GeometryBuffer);
	gb->set( VertexAttribute::Position, vertex );
	gb->set( VertexAttribute::Color, colors );

	MaterialHandle material = MaterialCreate(AllocatorGetHeap(), "RayDebug");

	Renderable* renderable = AllocateHeap(Renderable);
	renderable->setPrimitiveType(PrimitiveType::Lines);
	renderable->setGeometryBuffer(gb);
	renderable->setMaterial(material);
	
	return renderable;
}
示例#26
0
GeometryBufferPtr GizmoRotate::generateCircles()
{
	// Vertex data
	std::vector< Vector3 > pos;
	std::vector< Vector3 > colors;

	Matrix4x3 transform;

	// X axis
	std::vector< Vector3 > posX;
	generateCircle(posX, SLICES);
	generateColors(colors, X);

	transform = Matrix4x3::createScale( Vector3(0.4f) );
	TransformVertices(pos, posX, transform);

	// Y axis
	std::vector< Vector3 > posY;
	generateCircle(posY, SLICES);
	generateColors(colors, Y);
	
	transform = Matrix4x3::createScale( Vector3(0.4f) );
	transform = transform*Matrix4x3::createRotation( EulerAngles(0, 90, 0) );
	TransformVertices(pos, posY, transform);
	
	// Z axis
	std::vector< Vector3 > posZ;
	generateCircle(posZ, SLICES);
	generateColors(colors, Z);

	transform = Matrix4x3::createScale( Vector3(0.4f) );
	transform = transform*Matrix4x3::createRotation( EulerAngles(90, 0, 0) );
	TransformVertices(pos, posZ, transform);

	// Translate it a bit.
	transform = Matrix4x3::createTranslation( Vector3::UnitY * 0.5f );
	for( uint i = 0; i < pos.size(); i++ )
	{
		Vector3& v = pos[i];
		v = transform*v;
	}

	// Vertex buffer setup
	GeometryBufferPtr gb = AllocateHeap(GeometryBuffer);

	assert( pos.size() == colors.size() );

	gb->set( VertexAttribute::Position, pos );
	gb->set( VertexAttribute::Color, colors );
	
	return gb;
}
示例#27
0
void* rSet::operator new(size_t size) {
  assert((int(Universe::new_gen.low_boundary) & (card_size - 1)) == 0,
	 "new must start at card boundary");
  assert((int(Universe::old_gen.low_boundary) & (card_size - 1)) == 0,
	 "old must start at card boundary");
  assert((int(Universe::old_gen.high_boundary) & (card_size - 1)) == 0,
	 "old must end at card boundary");
  assert(card_size >= 512, "card_size must be at least 512");
  int bmsize =
    (Universe::old_gen.high_boundary - Universe::new_gen.low_boundary)
      / card_size;
  return AllocateHeap(size + bmsize, "rSet");
}
示例#28
0
 bool set_value(char *value) {
   if (writeable()) {
     if (_value != NULL) {
       FreeHeap(_value);
     }
     _value = AllocateHeap(strlen(value)+1, mtInternal);
     if (_value != NULL) {
       strcpy(_value, value);
     }
     return true;
   }
   return false;
 }
示例#29
0
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
  address res;
  switch (type) {
   case C_HEAP:
    res = (address)AllocateHeap(size, flags, CALLER_PC);
    DEBUG_ONLY(set_allocation_type(res, C_HEAP);)
    break;
   case RESOURCE_AREA:
    // new(size) sets allocation type RESOURCE_AREA.
    res = (address)operator new(size);
    break;
   default:
    ShouldNotReachHere();
  }
示例#30
0
AudioDevice* AudioCreateDevice(const String& name)
{
	// Select the "preferred device".
	ALCdevice* device = alcOpenDevice("");

	if( !device )
	{
		LogWarn("Could not create OpenAL device");
		return nullptr;
	}

	AudioDevice* audioDevice = AllocateHeap(AudioDevice, device);
	
	return audioDevice;
}