本文整理汇总了C++中AllocateHeap函数的典型用法代码示例。如果您正苦于以下问题:C++ AllocateHeap函数的具体用法?C++ AllocateHeap怎么用?C++ AllocateHeap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AllocateHeap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
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: AgentLibrary
// 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;
}
示例3: AgentLibrary
// 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;
}
示例4: Assembler
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;
}
示例5: new
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");
}
示例6: lock
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;
}
示例7: assert
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;
}
示例8: Assembler
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();
}
示例9: Assembler
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;
}
示例10: SystemProperty
// 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;
}
示例11: new
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;
}
示例12: max
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);
}
示例13: lprintf
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);
}
示例14: AllocateHeap
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;
}
示例15: new
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");
}