void AsmJsEncoder::EncoderReloc::New( EncoderRelocLabel* label, BYTE* _patchAddr, BYTE* _pc, ArenaAllocator* allocator ) { AsmJsEncoder::EncoderReloc* reloc = AnewStruct( allocator, AsmJsEncoder::EncoderReloc ); reloc->next = label->relocList; label->relocList = reloc; reloc->patchAddr = _patchAddr; reloc->pc = _pc; }
EmitBufferAllocation * EmitBufferManager<SyncObject>::NewAllocation(size_t bytes, ushort pdataCount, ushort xdataSize, bool canAllocInPreReservedHeapPageSegment, bool isAnyJittedCode) { FAULTINJECT_MEMORY_THROW(L"JIT", bytes); Assert(this->criticalSection.IsLocked()); bool isAllJITCodeInPreReservedRegion = true; CustomHeap::Allocation* heapAllocation = this->allocationHeap.Alloc(bytes, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, isAnyJittedCode, &isAllJITCodeInPreReservedRegion); if (!isAllJITCodeInPreReservedRegion) { this->scriptContext->GetThreadContext()->ResetIsAllJITCodeInPreReservedRegion(); } if (heapAllocation == nullptr) { // This is used in interpreter scenario, thus we need to try to recover memory, if possible. // Can't simply throw as in JIT scenario, for which throw is what we want in order to give more mem to interpreter. JsUtil::ExternalApi::RecoverUnusedMemory(); heapAllocation = this->allocationHeap.Alloc(bytes, pdataCount, xdataSize, canAllocInPreReservedHeapPageSegment, isAnyJittedCode, &isAllJITCodeInPreReservedRegion); } if (heapAllocation == nullptr) { Js::Throw::OutOfMemory(); } AutoCustomHeapPointer allocatedMemory(&this->allocationHeap, heapAllocation); VerboseHeapTrace(L"New allocation: 0x%p, size: %p\n", heapAllocation->address, heapAllocation->size); EmitBufferAllocation * allocation = AnewStruct(this->allocator, EmitBufferAllocation); allocation->bytesCommitted = heapAllocation->size; allocation->allocation = allocatedMemory.Detach(); allocation->bytesUsed = 0; allocation->nextAllocation = this->allocations; allocation->recorded = false; this->allocations = allocation; #if DBG heapAllocation->isAllocationUsed = true; #endif #if DBG_DUMP this->totalBytesCommitted += heapAllocation->size; #endif return allocation; }