1 //===- RecordingMemoryManager.cpp - Recording memory manager --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This memory manager allocates local storage and keeps a record of each
11 // allocation. Iterators are provided for all data and code allocations.
13 //===----------------------------------------------------------------------===//
15 #include "RecordingMemoryManager.h"
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;
30 uint8_t *RecordingMemoryManager::
31 allocateDataSection(uintptr_t Size, unsigned Alignment,
32 unsigned SectionID, bool IsReadOnly) {
33 // The recording memory manager is just a local copy of the remote target.
34 // The alignment requirement is just stored here for later use. Regular
35 // heap storage is sufficient here.
36 void *Addr = malloc(Size);
37 assert(Addr && "malloc() failure!");
38 sys::MemoryBlock Block(Addr, Size);
39 AllocatedDataMem.push_back(Allocation(Block, Alignment));
40 return (uint8_t*)Addr;
42 void RecordingMemoryManager::setMemoryWritable() { llvm_unreachable("Unexpected!"); }
43 void RecordingMemoryManager::setMemoryExecutable() { llvm_unreachable("Unexpected!"); }
44 void RecordingMemoryManager::setPoisonMemory(bool poison) { llvm_unreachable("Unexpected!"); }
45 void RecordingMemoryManager::AllocateGOT() { llvm_unreachable("Unexpected!"); }
46 uint8_t *RecordingMemoryManager::getGOTBase() const {
47 llvm_unreachable("Unexpected!");
50 uint8_t *RecordingMemoryManager::startFunctionBody(const Function *F, uintptr_t &ActualSize){
51 llvm_unreachable("Unexpected!");
54 uint8_t *RecordingMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize,
56 llvm_unreachable("Unexpected!");
59 void RecordingMemoryManager::endFunctionBody(const Function *F, uint8_t *FunctionStart,
60 uint8_t *FunctionEnd) {
61 llvm_unreachable("Unexpected!");
63 uint8_t *RecordingMemoryManager::allocateSpace(intptr_t Size, unsigned Alignment) {
64 llvm_unreachable("Unexpected!");
67 uint8_t *RecordingMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment) {
68 llvm_unreachable("Unexpected!");
71 void RecordingMemoryManager::deallocateFunctionBody(void *Body) {
72 llvm_unreachable("Unexpected!");
74 uint8_t* RecordingMemoryManager::startExceptionTable(const Function* F, uintptr_t &ActualSize) {
75 llvm_unreachable("Unexpected!");
78 void RecordingMemoryManager::endExceptionTable(const Function *F, uint8_t *TableStart,
79 uint8_t *TableEnd, uint8_t* FrameRegister) {
80 llvm_unreachable("Unexpected!");
82 void RecordingMemoryManager::deallocateExceptionTable(void *ET) {
83 llvm_unreachable("Unexpected!");
86 static int jit_noop() {
90 void *RecordingMemoryManager::getPointerToNamedFunction(const std::string &Name,
91 bool AbortOnFailure) {
92 // We should not invoke parent's ctors/dtors from generated main()!
93 // On Mingw and Cygwin, the symbol __main is resolved to
94 // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors
95 // (and register wrong callee's dtors with atexit(3)).
96 // We expect ExecutionEngine::runStaticConstructorsDestructors()
97 // is called before ExecutionEngine::runFunctionAsMain() is called.
98 if (Name == "__main") return (void*)(intptr_t)&jit_noop;