CodeGenNumberAllocator.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "Backend.h"
  6. CodeGenNumberThreadAllocator::CodeGenNumberThreadAllocator(Recycler * recycler)
  7. : recycler(recycler), currentNumberSegment(nullptr), currentChunkSegment(nullptr),
  8. numberSegmentEnd(nullptr), currentNumberBlockEnd(nullptr), nextNumber(nullptr), chunkSegmentEnd(nullptr),
  9. currentChunkBlockEnd(nullptr), nextChunk(nullptr), hasNewNumberBlock(nullptr), hasNewChunkBlock(nullptr),
  10. pendingIntegrationNumberSegmentCount(0), pendingIntegrationChunkSegmentCount(0),
  11. pendingIntegrationNumberSegmentPageCount(0), pendingIntegrationChunkSegmentPageCount(0)
  12. {
  13. }
  14. CodeGenNumberThreadAllocator::~CodeGenNumberThreadAllocator()
  15. {
  16. pendingIntegrationNumberSegment.Clear(&NoThrowNoMemProtectHeapAllocator::Instance);
  17. pendingIntegrationChunkSegment.Clear(&NoThrowNoMemProtectHeapAllocator::Instance);
  18. pendingIntegrationNumberBlock.Clear(&NoThrowHeapAllocator::Instance);
  19. pendingIntegrationChunkBlock.Clear(&NoThrowHeapAllocator::Instance);
  20. pendingFlushNumberBlock.Clear(&NoThrowHeapAllocator::Instance);
  21. pendingFlushChunkBlock.Clear(&NoThrowHeapAllocator::Instance);
  22. pendingReferenceNumberBlock.Clear(&NoThrowHeapAllocator::Instance);
  23. }
  24. size_t
  25. CodeGenNumberThreadAllocator::GetNumberAllocSize()
  26. {
  27. #ifdef RECYCLER_MEMORY_VERIFY
  28. if (recycler->VerifyEnabled())
  29. {
  30. return HeapInfo::GetAlignedSize(AllocSizeMath::Add(sizeof(Js::JavascriptNumber) + sizeof(size_t), recycler->verifyPad));
  31. }
  32. #endif
  33. return HeapInfo::GetAlignedSizeNoCheck(sizeof(Js::JavascriptNumber));
  34. }
  35. size_t
  36. CodeGenNumberThreadAllocator::GetChunkAllocSize()
  37. {
  38. #ifdef RECYCLER_MEMORY_VERIFY
  39. if (recycler->VerifyEnabled())
  40. {
  41. return HeapInfo::GetAlignedSize(AllocSizeMath::Add(sizeof(CodeGenNumberChunk) + sizeof(size_t), recycler->verifyPad));
  42. }
  43. #endif
  44. return HeapInfo::GetAlignedSizeNoCheck(sizeof(CodeGenNumberChunk));
  45. }
  46. Js::JavascriptNumber *
  47. CodeGenNumberThreadAllocator::AllocNumber()
  48. {
  49. AutoCriticalSection autocs(&cs);
  50. size_t sizeCat = GetNumberAllocSize();
  51. if (nextNumber + sizeCat > currentNumberBlockEnd)
  52. {
  53. AllocNewNumberBlock();
  54. }
  55. Js::JavascriptNumber * newNumber = (Js::JavascriptNumber *)nextNumber;
  56. #ifdef RECYCLER_MEMORY_VERIFY
  57. recycler->FillCheckPad(newNumber, sizeof(Js::JavascriptNumber), sizeCat);
  58. #endif
  59. nextNumber += sizeCat;
  60. return newNumber;
  61. }
  62. CodeGenNumberChunk *
  63. CodeGenNumberThreadAllocator::AllocChunk()
  64. {
  65. AutoCriticalSection autocs(&cs);
  66. size_t sizeCat = GetChunkAllocSize();
  67. if (nextChunk + sizeCat > currentChunkBlockEnd)
  68. {
  69. AllocNewChunkBlock();
  70. }
  71. CodeGenNumberChunk * newChunk = (CodeGenNumberChunk *)nextChunk;
  72. #ifdef RECYCLER_MEMORY_VERIFY
  73. recycler->FillCheckPad(nextChunk, sizeof(CodeGenNumberChunk), sizeCat);
  74. #endif
  75. memset(newChunk, 0, sizeof(CodeGenNumberChunk));
  76. nextChunk += sizeCat;
  77. return newChunk;
  78. }
  79. void
  80. CodeGenNumberThreadAllocator::AllocNewNumberBlock()
  81. {
  82. Assert(cs.IsLocked());
  83. Assert(nextNumber + GetNumberAllocSize() > currentNumberBlockEnd);
  84. if (hasNewNumberBlock)
  85. {
  86. if (!pendingReferenceNumberBlock.PrependNode(&NoThrowHeapAllocator::Instance,
  87. currentNumberBlockEnd - BlockSize, currentNumberSegment))
  88. {
  89. Js::Throw::OutOfMemory();
  90. }
  91. hasNewNumberBlock = false;
  92. }
  93. if (currentNumberBlockEnd == numberSegmentEnd)
  94. {
  95. Assert(cs.IsLocked());
  96. // Reserve the segment, but not committing it
  97. currentNumberSegment = PageAllocator::AllocPageSegment(pendingIntegrationNumberSegment, this->recycler->GetRecyclerLeafPageAllocator(), false, true);
  98. if (currentNumberSegment == nullptr)
  99. {
  100. currentNumberBlockEnd = nullptr;
  101. numberSegmentEnd = nullptr;
  102. nextNumber = nullptr;
  103. Js::Throw::OutOfMemory();
  104. }
  105. pendingIntegrationNumberSegmentCount++;
  106. pendingIntegrationNumberSegmentPageCount += currentNumberSegment->GetPageCount();
  107. currentNumberBlockEnd = currentNumberSegment->GetAddress();
  108. numberSegmentEnd = currentNumberSegment->GetEndAddress();
  109. }
  110. // Commit the page.
  111. if (!::VirtualAlloc(currentNumberBlockEnd, BlockSize, MEM_COMMIT, PAGE_READWRITE))
  112. {
  113. Js::Throw::OutOfMemory();
  114. }
  115. nextNumber = currentNumberBlockEnd;
  116. currentNumberBlockEnd += BlockSize;
  117. hasNewNumberBlock = true;
  118. this->recycler->GetRecyclerLeafPageAllocator()->FillAllocPages(nextNumber, 1);
  119. }
  120. void
  121. CodeGenNumberThreadAllocator::AllocNewChunkBlock()
  122. {
  123. Assert(cs.IsLocked());
  124. Assert(nextChunk + GetChunkAllocSize() > currentChunkBlockEnd);
  125. if (hasNewChunkBlock)
  126. {
  127. if (!pendingFlushChunkBlock.PrependNode(&NoThrowHeapAllocator::Instance,
  128. currentChunkBlockEnd - BlockSize, currentChunkSegment))
  129. {
  130. Js::Throw::OutOfMemory();
  131. }
  132. // All integrated pages' object are all live initially, so don't need to rescan them
  133. ::ResetWriteWatch(currentChunkBlockEnd - BlockSize, BlockSize);
  134. pendingReferenceNumberBlock.MoveTo(&pendingFlushNumberBlock);
  135. hasNewChunkBlock = false;
  136. }
  137. if (currentChunkBlockEnd == chunkSegmentEnd)
  138. {
  139. Assert(cs.IsLocked());
  140. // Reserve the segment, but not committing it
  141. currentChunkSegment = PageAllocator::AllocPageSegment(pendingIntegrationChunkSegment, this->recycler->GetRecyclerPageAllocator(), false, true);
  142. if (currentChunkSegment == nullptr)
  143. {
  144. currentChunkBlockEnd = nullptr;
  145. chunkSegmentEnd = nullptr;
  146. nextChunk = nullptr;
  147. Js::Throw::OutOfMemory();
  148. }
  149. pendingIntegrationChunkSegmentCount++;
  150. pendingIntegrationChunkSegmentPageCount += currentChunkSegment->GetPageCount();
  151. currentChunkBlockEnd = currentChunkSegment->GetAddress();
  152. chunkSegmentEnd = currentChunkSegment->GetEndAddress();
  153. }
  154. // Commit the page.
  155. if (!::VirtualAlloc(currentChunkBlockEnd, BlockSize, MEM_COMMIT, PAGE_READWRITE))
  156. {
  157. Js::Throw::OutOfMemory();
  158. }
  159. nextChunk = currentChunkBlockEnd;
  160. currentChunkBlockEnd += BlockSize;
  161. hasNewChunkBlock = true;
  162. this->recycler->GetRecyclerLeafPageAllocator()->FillAllocPages(nextChunk, 1);
  163. }
  164. void
  165. CodeGenNumberThreadAllocator::Integrate()
  166. {
  167. AutoCriticalSection autocs(&cs);
  168. PageAllocator * leafPageAllocator = this->recycler->GetRecyclerLeafPageAllocator();
  169. leafPageAllocator->IntegrateSegments(pendingIntegrationNumberSegment, pendingIntegrationNumberSegmentCount, pendingIntegrationNumberSegmentPageCount);
  170. PageAllocator * recyclerPageAllocator = this->recycler->GetRecyclerPageAllocator();
  171. recyclerPageAllocator->IntegrateSegments(pendingIntegrationChunkSegment, pendingIntegrationChunkSegmentCount, pendingIntegrationChunkSegmentPageCount);
  172. pendingIntegrationNumberSegmentCount = 0;
  173. pendingIntegrationChunkSegmentCount = 0;
  174. pendingIntegrationNumberSegmentPageCount = 0;
  175. pendingIntegrationChunkSegmentPageCount = 0;
  176. #ifdef TRACK_ALLOC
  177. TrackAllocData oldAllocData = recycler->nextAllocData;
  178. recycler->nextAllocData.Clear();
  179. #endif
  180. while (!pendingIntegrationNumberBlock.Empty())
  181. {
  182. TRACK_ALLOC_INFO(recycler, Js::JavascriptNumber, Recycler, 0, (size_t)-1);
  183. BlockRecord& record = pendingIntegrationNumberBlock.Head();
  184. if (!recycler->IntegrateBlock<LeafBit>(record.blockAddress, record.segment, GetNumberAllocSize(), sizeof(Js::JavascriptNumber)))
  185. {
  186. Js::Throw::OutOfMemory();
  187. }
  188. pendingIntegrationNumberBlock.RemoveHead(&NoThrowHeapAllocator::Instance);
  189. }
  190. while (!pendingIntegrationChunkBlock.Empty())
  191. {
  192. // REVIEW: the above number block integration can be moved into this loop
  193. TRACK_ALLOC_INFO(recycler, CodeGenNumberChunk, Recycler, 0, (size_t)-1);
  194. BlockRecord& record = pendingIntegrationChunkBlock.Head();
  195. if (!recycler->IntegrateBlock<NoBit>(record.blockAddress, record.segment, GetChunkAllocSize(), sizeof(CodeGenNumberChunk)))
  196. {
  197. Js::Throw::OutOfMemory();
  198. }
  199. pendingIntegrationChunkBlock.RemoveHead(&NoThrowHeapAllocator::Instance);
  200. }
  201. #ifdef TRACK_ALLOC
  202. Assert(recycler->nextAllocData.IsEmpty());
  203. recycler->nextAllocData = oldAllocData;
  204. #endif
  205. }
  206. void
  207. CodeGenNumberThreadAllocator::FlushAllocations()
  208. {
  209. AutoCriticalSection autocs(&cs);
  210. pendingFlushNumberBlock.MoveTo(&pendingIntegrationNumberBlock);
  211. pendingFlushChunkBlock.MoveTo(&pendingIntegrationChunkBlock);
  212. }
  213. CodeGenNumberAllocator::CodeGenNumberAllocator(CodeGenNumberThreadAllocator * threadAlloc, Recycler * recycler) :
  214. threadAlloc(threadAlloc), recycler(recycler), chunk(nullptr), chunkTail(nullptr), currentChunkNumberCount(CodeGenNumberChunk::MaxNumberCount)
  215. {
  216. #if DBG
  217. finalized = false;
  218. #endif
  219. }
  220. // We should never call this function if we are using tagged float
  221. #if !FLOATVAR
  222. Js::JavascriptNumber *
  223. CodeGenNumberAllocator::Alloc()
  224. {
  225. Assert(!finalized);
  226. if (currentChunkNumberCount == CodeGenNumberChunk::MaxNumberCount)
  227. {
  228. CodeGenNumberChunk * newChunk = threadAlloc? threadAlloc->AllocChunk()
  229. : RecyclerNewStructZ(recycler, CodeGenNumberChunk);
  230. // Need to always put the new chunk last, as when we flush
  231. // pages, new chunk's page might not be full yet, and won't
  232. // be flushed, and we will have a broken link in the link list.
  233. newChunk->next = nullptr;
  234. if (this->chunkTail != nullptr)
  235. {
  236. this->chunkTail->next = newChunk;
  237. }
  238. else
  239. {
  240. this->chunk = newChunk;
  241. }
  242. this->chunkTail = newChunk;
  243. this->currentChunkNumberCount = 0;
  244. }
  245. Js::JavascriptNumber * newNumber = threadAlloc? threadAlloc->AllocNumber()
  246. : Js::JavascriptNumber::NewUninitialized(recycler);
  247. this->chunkTail->numbers[this->currentChunkNumberCount++] = newNumber;
  248. return newNumber;
  249. }
  250. #endif
  251. CodeGenNumberChunk *
  252. CodeGenNumberAllocator::Finalize()
  253. {
  254. Assert(!finalized);
  255. #if DBG
  256. finalized = true;
  257. #endif
  258. CodeGenNumberChunk * finalizedChunk = this->chunk;
  259. this->chunk = nullptr;
  260. this->chunkTail = nullptr;
  261. this->currentChunkNumberCount = 0;
  262. return finalizedChunk;
  263. }
  264. /* static */
  265. uint
  266. XProcNumberPageSegmentImpl::GetSizeCat()
  267. {
  268. return (uint)HeapInfo::GetAlignedSizeNoCheck(sizeof(Js::JavascriptNumber));
  269. }
  270. Js::JavascriptNumber* XProcNumberPageSegmentImpl::AllocateNumber(HANDLE hProcess, double value, Js::StaticType* numberTypeStatic, void* javascriptNumberVtbl)
  271. {
  272. XProcNumberPageSegmentImpl* tail = this;
  273. if (this->pageAddress != 0)
  274. {
  275. while (tail->nextSegment)
  276. {
  277. tail = (XProcNumberPageSegmentImpl*)tail->nextSegment;
  278. }
  279. if (tail->pageAddress + tail->committedEnd - tail->allocEndAddress >= GetSizeCat())
  280. {
  281. auto number = tail->allocEndAddress;
  282. tail->allocEndAddress += GetSizeCat();
  283. Js::JavascriptNumber localNumber(value, numberTypeStatic
  284. #if DBG
  285. , true
  286. #endif
  287. );
  288. // change vtable to the remote one
  289. *(void**)&localNumber = javascriptNumberVtbl;
  290. // initialize number by WriteProcessMemory
  291. SIZE_T bytesWritten;
  292. WriteProcessMemory(hProcess, (void*)number, &localNumber, sizeof(localNumber), &bytesWritten);
  293. return (Js::JavascriptNumber*) number;
  294. }
  295. // alloc blocks
  296. if ((void*)tail->committedEnd < tail->GetEndAddress())
  297. {
  298. Assert((unsigned int)((char*)tail->GetEndAddress() - (char*)tail->committedEnd) >= BlockSize);
  299. // TODO: implement guard pages (still necessary for OOP JIT?)
  300. auto ret = ::VirtualAllocEx(hProcess, tail->GetCommitEndAddress(), BlockSize, MEM_COMMIT, PAGE_READWRITE);
  301. if (!ret)
  302. {
  303. Js::Throw::OutOfMemory();
  304. }
  305. tail->committedEnd += BlockSize;
  306. return AllocateNumber(hProcess, value, numberTypeStatic, javascriptNumberVtbl);
  307. }
  308. }
  309. // alloc new segment
  310. void* pages = ::VirtualAllocEx(hProcess, nullptr, PageCount * AutoSystemInfo::PageSize, MEM_RESERVE, PAGE_READWRITE);
  311. if (pages == nullptr)
  312. {
  313. Js::Throw::OutOfMemory();
  314. }
  315. if (tail->pageAddress == 0)
  316. {
  317. tail = new (tail) XProcNumberPageSegmentImpl();
  318. tail->pageAddress = (intptr_t)pages;
  319. tail->allocStartAddress = this->pageAddress;
  320. tail->allocEndAddress = this->pageAddress;
  321. tail->nextSegment = nullptr;
  322. return AllocateNumber(hProcess, value, numberTypeStatic, javascriptNumberVtbl);
  323. }
  324. else
  325. {
  326. XProcNumberPageSegmentImpl* seg = (XProcNumberPageSegmentImpl*)midl_user_allocate(sizeof(XProcNumberPageSegment));
  327. if (seg == nullptr)
  328. {
  329. Js::Throw::OutOfMemory();
  330. }
  331. seg = new (seg) XProcNumberPageSegmentImpl();
  332. tail->nextSegment = seg;
  333. return seg->AllocateNumber(hProcess, value, numberTypeStatic, javascriptNumberVtbl);
  334. }
  335. }
  336. XProcNumberPageSegmentImpl::XProcNumberPageSegmentImpl()
  337. {
  338. this->blockIntegratedSize = 0;
  339. this->pageSegment = 0;
  340. }
  341. CodeGenNumberChunk* ::XProcNumberPageSegmentManager::RegisterSegments(XProcNumberPageSegment* segments)
  342. {
  343. Assert(segments->pageAddress && segments->allocStartAddress && segments->allocEndAddress);
  344. XProcNumberPageSegmentImpl* segmentImpl = (XProcNumberPageSegmentImpl*)segments;
  345. auto temp = segmentImpl;
  346. CodeGenNumberChunk* chunk = nullptr;
  347. int numberCount = CodeGenNumberChunk::MaxNumberCount;
  348. while (temp)
  349. {
  350. auto start = temp->allocStartAddress;
  351. if (temp->GetChunkAllocator() == nullptr)
  352. {
  353. temp->chunkAllocator = (intptr_t)HeapNew(CodeGenNumberThreadAllocator, this->recycler);
  354. chunkAllocators.Add(temp->GetChunkAllocator());
  355. }
  356. while (start < temp->allocEndAddress)
  357. {
  358. if (numberCount == CodeGenNumberChunk::MaxNumberCount)
  359. {
  360. auto newChunk = temp->GetChunkAllocator()->AllocChunk();
  361. newChunk->next = chunk;
  362. chunk = newChunk;
  363. numberCount = 0;
  364. }
  365. chunk->numbers[numberCount++] = (Js::JavascriptNumber*)start;
  366. start += XProcNumberPageSegmentImpl::GetSizeCat();
  367. }
  368. temp->GetChunkAllocator()->FlushAllocations();
  369. temp = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  370. }
  371. AutoCriticalSection autoCS(&cs);
  372. if (this->segmentsList == nullptr)
  373. {
  374. this->segmentsList = segmentImpl;
  375. }
  376. else
  377. {
  378. temp = segmentsList;
  379. while (temp->nextSegment)
  380. {
  381. temp = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  382. }
  383. temp->nextSegment = segmentImpl;
  384. }
  385. return chunk;
  386. }
  387. void XProcNumberPageSegmentManager::GetFreeSegment(XProcNumberPageSegment * seg)
  388. {
  389. AutoCriticalSection autoCS(&cs);
  390. if (segmentsList == nullptr)
  391. {
  392. new (seg) XProcNumberPageSegmentImpl();
  393. return;
  394. }
  395. auto temp = segmentsList;
  396. auto prev = &segmentsList;
  397. while (temp)
  398. {
  399. if (temp->allocEndAddress != temp->pageAddress + (int)(XProcNumberPageSegmentImpl::PageCount*AutoSystemInfo::PageSize)) // not full
  400. {
  401. *prev = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  402. // remove from the list
  403. memcpy(seg, temp, sizeof(XProcNumberPageSegment));
  404. midl_user_free(temp);
  405. return;
  406. }
  407. prev = (XProcNumberPageSegmentImpl**)&temp->nextSegment;
  408. temp = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  409. }
  410. }
  411. void XProcNumberPageSegmentManager::Integrate()
  412. {
  413. AutoCriticalSection autoCS(&cs);
  414. auto temp = this->segmentsList;
  415. auto prev = &this->segmentsList;
  416. while (temp)
  417. {
  418. if (temp->pageSegment == 0)
  419. {
  420. auto leafPageAllocator = recycler->GetRecyclerLeafPageAllocator();
  421. DListBase<PageSegment> segmentList;
  422. temp->pageSegment = (intptr_t)leafPageAllocator->AllocPageSegment(segmentList, leafPageAllocator,
  423. (void*)temp->pageAddress, XProcNumberPageSegmentImpl::PageCount, temp->committedEnd / AutoSystemInfo::PageSize);
  424. leafPageAllocator->IntegrateSegments(segmentList, 1, XProcNumberPageSegmentImpl::PageCount);
  425. this->integratedSegmentCount++;
  426. }
  427. if (!temp->GetChunkAllocator()->pendingIntegrationChunkBlock.Empty())
  428. {
  429. Assert(sizeof(CodeGenNumberChunk) == sizeof(Js::JavascriptNumber));
  430. unsigned int minIntegrateSize = XProcNumberPageSegmentImpl::BlockSize *CodeGenNumberChunk::MaxNumberCount;
  431. for (; temp->pageAddress + temp->blockIntegratedSize + minIntegrateSize < (unsigned int)temp->allocEndAddress;
  432. temp->blockIntegratedSize += minIntegrateSize)
  433. {
  434. TRACK_ALLOC_INFO(recycler, Js::JavascriptNumber, Recycler, 0, (size_t)-1);
  435. if (!recycler->IntegrateBlock<LeafBit>((char*)temp->pageAddress + temp->blockIntegratedSize, (PageSegment*)temp->pageSegment, XProcNumberPageSegmentImpl::GetSizeCat(), sizeof(Js::JavascriptNumber)))
  436. {
  437. Js::Throw::OutOfMemory();
  438. }
  439. }
  440. }
  441. temp->GetChunkAllocator()->Integrate();
  442. if (temp->blockIntegratedSize >= XProcNumberPageSegmentImpl::PageCount*AutoSystemInfo::PageSize)
  443. {
  444. // all pages are integrated, don't need this segment any more
  445. *prev = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  446. if (chunkAllocators.Contains(temp->GetChunkAllocator()))
  447. {
  448. chunkAllocators.Remove(temp->GetChunkAllocator());
  449. HeapDelete(temp->GetChunkAllocator());
  450. }
  451. midl_user_free(temp);
  452. temp = *prev;
  453. }
  454. else
  455. {
  456. prev = (XProcNumberPageSegmentImpl**)&temp->nextSegment;
  457. temp = (XProcNumberPageSegmentImpl*)temp->nextSegment;
  458. }
  459. }
  460. }
  461. XProcNumberPageSegmentManager::~XProcNumberPageSegmentManager()
  462. {
  463. auto temp = segmentsList;
  464. while (temp)
  465. {
  466. auto next = temp->nextSegment;
  467. if (temp->GetChunkAllocator())
  468. {
  469. if (chunkAllocators.Contains(temp->GetChunkAllocator()))
  470. {
  471. chunkAllocators.Remove(temp->GetChunkAllocator());
  472. HeapDelete(temp->GetChunkAllocator());
  473. }
  474. }
  475. midl_user_free(temp);
  476. temp = (XProcNumberPageSegmentImpl*)next;
  477. }
  478. }