9e1cff55277d3130f34e09251d83467528609dcd
[oota-llvm.git] / tools / lli / RecordingMemoryManager.cpp
1 //===- RecordingMemoryManager.cpp - Recording memory manager --------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This memory manager allocates local storage and keeps a record of each
11 // allocation. Iterators are provided for all data and code allocations.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "RecordingMemoryManager.h"
16 using namespace llvm;
17
18 uint8_t *RecordingMemoryManager::
19 allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
20   // The recording memory manager is just a local copy of the remote target.
21   // The alignment requirement is just stored here for later use. Regular
22   // heap storage is sufficient here.
23   void *Addr = malloc(Size);
24   assert(Addr && "malloc() failure!");
25   sys::MemoryBlock Block(Addr, Size);
26   AllocatedCodeMem.push_back(Allocation(Block, Alignment));
27   return (uint8_t*)Addr;
28 }
29
30 uint8_t *RecordingMemoryManager::
31 allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
32   // The recording memory manager is just a local copy of the remote target.
33   // The alignment requirement is just stored here for later use. Regular
34   // heap storage is sufficient here.
35   void *Addr = malloc(Size);
36   assert(Addr && "malloc() failure!");
37   sys::MemoryBlock Block(Addr, Size);
38   AllocatedDataMem.push_back(Allocation(Block, Alignment));
39   return (uint8_t*)Addr;
40 }
41 void RecordingMemoryManager::setMemoryWritable() { llvm_unreachable("Unexpected!"); }
42 void RecordingMemoryManager::setMemoryExecutable() { llvm_unreachable("Unexpected!"); }
43 void RecordingMemoryManager::setPoisonMemory(bool poison) { llvm_unreachable("Unexpected!"); }
44 void RecordingMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); }
45 uint8_t *RecordingMemoryManager::getGOTBase() const {
46   llvm_unreachable("Unexpected!");
47   return 0;
48 }
49 uint8_t *RecordingMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){
50   llvm_unreachable("Unexpected!");
51   return 0;
52 }
53 uint8_t *RecordingMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize,
54                                               unsigned Alignment) {
55   llvm_unreachable("Unexpected!");
56   return 0;
57 }
58 void RecordingMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart,
59                                              uint8_t *FunctionEnd) {
60   llvm_unreachable("Unexpected!");
61 }
62 uint8_t *RecordingMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) {
63   llvm_unreachable("Unexpected!");
64   return 0;
65 }
66 uint8_t *RecordingMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) {
67   llvm_unreachable("Unexpected!");
68   return 0;
69 }
70 void RecordingMemoryManager::deallocateFunctionBody(void *Body) {
71   llvm_unreachable("Unexpected!");
72 }
73 uint8_t* RecordingMemoryManager::startExceptionTable(const Function* F, uintptr_t &ActualSize) {
74   llvm_unreachable("Unexpected!");
75   return 0;
76 }
77 void RecordingMemoryManager::endExceptionTable(const Function *F, uint8_t *TableStart,
78                                                uint8_t *TableEnd, uint8_t* FrameRegister) {
79   llvm_unreachable("Unexpected!");
80 }
81 void RecordingMemoryManager::deallocateExceptionTable(void *ET) {
82   llvm_unreachable("Unexpected!");
83 }
84 void *RecordingMemoryManager::getPointerToNamedFunction(const std::string &Name,
85                                                         bool AbortOnFailure) {
86   return NULL;
87 }