diff lib/ExecutionEngine/SectionMemoryManager.cpp @ 147:c2174574ed3a

LLVM 10
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 16:55:33 +0900
parents 3a76565eade5
children
line wrap: on
line diff
--- a/lib/ExecutionEngine/SectionMemoryManager.cpp	Sat Feb 17 09:57:20 2018 +0900
+++ b/lib/ExecutionEngine/SectionMemoryManager.cpp	Wed Aug 14 16:55:33 2019 +0900
@@ -1,9 +1,8 @@
 //===- SectionMemoryManager.cpp - Memory manager for MCJIT/RtDyld *- C++ -*-==//
 //
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
 //
@@ -65,9 +64,9 @@
   // Look in the list of free memory regions and use a block there if one
   // is available.
   for (FreeMemBlock &FreeMB : MemGroup.FreeMem) {
-    if (FreeMB.Free.size() >= RequiredSize) {
+    if (FreeMB.Free.allocatedSize() >= RequiredSize) {
       Addr = (uintptr_t)FreeMB.Free.base();
-      uintptr_t EndOfBlock = Addr + FreeMB.Free.size();
+      uintptr_t EndOfBlock = Addr + FreeMB.Free.allocatedSize();
       // Align the address.
       Addr = (Addr + Alignment - 1) & ~(uintptr_t)(Alignment - 1);
 
@@ -116,7 +115,7 @@
   // Remember that we allocated this memory
   MemGroup.AllocatedMem.push_back(MB);
   Addr = (uintptr_t)MB.base();
-  uintptr_t EndOfBlock = Addr + MB.size();
+  uintptr_t EndOfBlock = Addr + MB.allocatedSize();
 
   // Align the address.
   Addr = (Addr + Alignment - 1) & ~(uintptr_t)(Alignment - 1);
@@ -173,12 +172,12 @@
 }
 
 static sys::MemoryBlock trimBlockToPageSize(sys::MemoryBlock M) {
-  static const size_t PageSize = sys::Process::getPageSize();
+  static const size_t PageSize = sys::Process::getPageSizeEstimate();
 
   size_t StartOverlap =
       (PageSize - ((uintptr_t)M.base() % PageSize)) % PageSize;
 
-  size_t TrimmedSize = M.size();
+  size_t TrimmedSize = M.allocatedSize();
   TrimmedSize -= StartOverlap;
   TrimmedSize -= TrimmedSize % PageSize;
 
@@ -186,8 +185,9 @@
                            TrimmedSize);
 
   assert(((uintptr_t)Trimmed.base() % PageSize) == 0);
-  assert((Trimmed.size() % PageSize) == 0);
-  assert(M.base() <= Trimmed.base() && Trimmed.size() <= M.size());
+  assert((Trimmed.allocatedSize() % PageSize) == 0);
+  assert(M.base() <= Trimmed.base() &&
+         Trimmed.allocatedSize() <= M.allocatedSize());
 
   return Trimmed;
 }
@@ -210,17 +210,19 @@
   }
 
   // Remove all blocks which are now empty
-  MemGroup.FreeMem.erase(
-      remove_if(MemGroup.FreeMem,
-                [](FreeMemBlock &FreeMB) { return FreeMB.Free.size() == 0; }),
-      MemGroup.FreeMem.end());
+  MemGroup.FreeMem.erase(remove_if(MemGroup.FreeMem,
+                                   [](FreeMemBlock &FreeMB) {
+                                     return FreeMB.Free.allocatedSize() == 0;
+                                   }),
+                         MemGroup.FreeMem.end());
 
   return std::error_code();
 }
 
 void SectionMemoryManager::invalidateInstructionCache() {
   for (sys::MemoryBlock &Block : CodeMem.PendingMem)
-    sys::Memory::InvalidateInstructionCache(Block.base(), Block.size());
+    sys::Memory::InvalidateInstructionCache(Block.base(),
+                                            Block.allocatedSize());
 }
 
 SectionMemoryManager::~SectionMemoryManager() {
@@ -232,6 +234,8 @@
 
 SectionMemoryManager::MemoryMapper::~MemoryMapper() {}
 
+void SectionMemoryManager::anchor() {}
+
 namespace {
 // Trivial implementation of SectionMemoryManager::MemoryMapper that just calls
 // into sys::Memory.