llvm.org GIT mirror llvm / bae049c
Revert 72650 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72783 91177308-0d34-0410-b5e6-96231b3b80d8 Bruno Cardoso Lopes 11 years ago
5 changed file(s) with 117 addition(s) and 113 deletion(s). Raw diff Collapse all Expand all
8888 /// emitByte - This callback is invoked when a byte needs to be written to the
8989 /// output stream.
9090 ///
91 void emitByte(uint8_t B) {
91 void emitByte(unsigned char B) {
9292 if (CurBufferPtr != BufferEnd)
9393 *CurBufferPtr++ = B;
9494 }
9898 ///
9999 void emitWordLE(unsigned W) {
100100 if (4 <= BufferEnd-CurBufferPtr) {
101 *CurBufferPtr++ = (uint8_t)(W >> 0);
102 *CurBufferPtr++ = (uint8_t)(W >> 8);
103 *CurBufferPtr++ = (uint8_t)(W >> 16);
104 *CurBufferPtr++ = (uint8_t)(W >> 24);
101 *CurBufferPtr++ = (unsigned char)(W >> 0);
102 *CurBufferPtr++ = (unsigned char)(W >> 8);
103 *CurBufferPtr++ = (unsigned char)(W >> 16);
104 *CurBufferPtr++ = (unsigned char)(W >> 24);
105105 } else {
106106 CurBufferPtr = BufferEnd;
107107 }
112112 ///
113113 void emitWordBE(unsigned W) {
114114 if (4 <= BufferEnd-CurBufferPtr) {
115 *CurBufferPtr++ = (uint8_t)(W >> 24);
116 *CurBufferPtr++ = (uint8_t)(W >> 16);
117 *CurBufferPtr++ = (uint8_t)(W >> 8);
118 *CurBufferPtr++ = (uint8_t)(W >> 0);
115 *CurBufferPtr++ = (unsigned char)(W >> 24);
116 *CurBufferPtr++ = (unsigned char)(W >> 16);
117 *CurBufferPtr++ = (unsigned char)(W >> 8);
118 *CurBufferPtr++ = (unsigned char)(W >> 0);
119119 } else {
120120 CurBufferPtr = BufferEnd;
121121 }
126126 ///
127127 void emitDWordLE(uint64_t W) {
128128 if (8 <= BufferEnd-CurBufferPtr) {
129 *CurBufferPtr++ = (uint8_t)(W >> 0);
130 *CurBufferPtr++ = (uint8_t)(W >> 8);
131 *CurBufferPtr++ = (uint8_t)(W >> 16);
132 *CurBufferPtr++ = (uint8_t)(W >> 24);
133 *CurBufferPtr++ = (uint8_t)(W >> 32);
134 *CurBufferPtr++ = (uint8_t)(W >> 40);
135 *CurBufferPtr++ = (uint8_t)(W >> 48);
136 *CurBufferPtr++ = (uint8_t)(W >> 56);
129 *CurBufferPtr++ = (unsigned char)(W >> 0);
130 *CurBufferPtr++ = (unsigned char)(W >> 8);
131 *CurBufferPtr++ = (unsigned char)(W >> 16);
132 *CurBufferPtr++ = (unsigned char)(W >> 24);
133 *CurBufferPtr++ = (unsigned char)(W >> 32);
134 *CurBufferPtr++ = (unsigned char)(W >> 40);
135 *CurBufferPtr++ = (unsigned char)(W >> 48);
136 *CurBufferPtr++ = (unsigned char)(W >> 56);
137137 } else {
138138 CurBufferPtr = BufferEnd;
139139 }
144144 ///
145145 void emitDWordBE(uint64_t W) {
146146 if (8 <= BufferEnd-CurBufferPtr) {
147 *CurBufferPtr++ = (uint8_t)(W >> 56);
148 *CurBufferPtr++ = (uint8_t)(W >> 48);
149 *CurBufferPtr++ = (uint8_t)(W >> 40);
150 *CurBufferPtr++ = (uint8_t)(W >> 32);
151 *CurBufferPtr++ = (uint8_t)(W >> 24);
152 *CurBufferPtr++ = (uint8_t)(W >> 16);
153 *CurBufferPtr++ = (uint8_t)(W >> 8);
154 *CurBufferPtr++ = (uint8_t)(W >> 0);
147 *CurBufferPtr++ = (unsigned char)(W >> 56);
148 *CurBufferPtr++ = (unsigned char)(W >> 48);
149 *CurBufferPtr++ = (unsigned char)(W >> 40);
150 *CurBufferPtr++ = (unsigned char)(W >> 32);
151 *CurBufferPtr++ = (unsigned char)(W >> 24);
152 *CurBufferPtr++ = (unsigned char)(W >> 16);
153 *CurBufferPtr++ = (unsigned char)(W >> 8);
154 *CurBufferPtr++ = (unsigned char)(W >> 0);
155155 } else {
156156 CurBufferPtr = BufferEnd;
157157 }
165165 if(Alignment <= (uintptr_t)(BufferEnd-CurBufferPtr)) {
166166 // Move the current buffer ptr up to the specified alignment.
167167 CurBufferPtr =
168 (uint8_t*)(((uintptr_t)CurBufferPtr+Alignment-1) &
169 ~(uintptr_t)(Alignment-1));
168 (unsigned char*)(((uintptr_t)CurBufferPtr+Alignment-1) &
169 ~(uintptr_t)(Alignment-1));
170170 } else {
171171 CurBufferPtr = BufferEnd;
172172 }
177177 /// written to the output stream.
178178 void emitULEB128Bytes(unsigned Value) {
179179 do {
180 uint8_t Byte = Value & 0x7f;
180 unsigned char Byte = Value & 0x7f;
181181 Value >>= 7;
182182 if (Value) Byte |= 0x80;
183183 emitByte(Byte);
186186
187187 /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
188188 /// written to the output stream.
189 void emitSLEB128Bytes(int32_t Value) {
190 int32_t Sign = Value >> (8 * sizeof(Value) - 1);
189 void emitSLEB128Bytes(int Value) {
190 int Sign = Value >> (8 * sizeof(Value) - 1);
191191 bool IsMore;
192192
193193 do {
194 uint8_t Byte = Value & 0x7f;
194 unsigned char Byte = Value & 0x7f;
195195 Value >>= 7;
196196 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
197197 if (IsMore) Byte |= 0x80;
204204 void emitString(const std::string &String) {
205205 for (unsigned i = 0, N = static_cast(String.size());
206206 i < N; ++i) {
207 uint8_t C = String[i];
207 unsigned char C = String[i];
208208 emitByte(C);
209209 }
210210 emitByte(0);
211211 }
212212
213213 /// emitInt32 - Emit a int32 directive.
214 void emitInt32(int32_t Value) {
214 void emitInt32(int Value) {
215215 if (4 <= BufferEnd-CurBufferPtr) {
216216 *((uint32_t*)CurBufferPtr) = Value;
217217 CurBufferPtr += 4;
4949 protected:
5050 /// BufferBegin/BufferEnd - Pointers to the start and end of the memory
5151 /// allocated for this code buffer.
52 uint8_t *BufferBegin, *BufferEnd;
52 unsigned char *BufferBegin, *BufferEnd;
5353
5454 /// CurBufferPtr - Pointer to the next byte of memory to fill when emitting
5555 /// code. This is guranteed to be in the range [BufferBegin,BufferEnd]. If
5656 /// this pointer is at BufferEnd, it will never move due to code emission, and
5757 /// all code emission requests will be ignored (this is the buffer overflow
5858 /// condition).
59 uint8_t *CurBufferPtr;
59 unsigned char *CurBufferPtr;
6060
6161 public:
6262 virtual ~MachineCodeEmitter() {}
9595 /// emitByte - This callback is invoked when a byte needs to be written to the
9696 /// output stream.
9797 ///
98 void emitByte(uint8_t B) {
98 void emitByte(unsigned char B) {
9999 if (CurBufferPtr != BufferEnd)
100100 *CurBufferPtr++ = B;
101101 }
105105 ///
106106 void emitWordLE(unsigned W) {
107107 if (4 <= BufferEnd-CurBufferPtr) {
108 *CurBufferPtr++ = (uint8_t)(W >> 0);
109 *CurBufferPtr++ = (uint8_t)(W >> 8);
110 *CurBufferPtr++ = (uint8_t)(W >> 16);
111 *CurBufferPtr++ = (uint8_t)(W >> 24);
108 *CurBufferPtr++ = (unsigned char)(W >> 0);
109 *CurBufferPtr++ = (unsigned char)(W >> 8);
110 *CurBufferPtr++ = (unsigned char)(W >> 16);
111 *CurBufferPtr++ = (unsigned char)(W >> 24);
112112 } else {
113113 CurBufferPtr = BufferEnd;
114114 }
119119 ///
120120 void emitWordBE(unsigned W) {
121121 if (4 <= BufferEnd-CurBufferPtr) {
122 *CurBufferPtr++ = (uint8_t)(W >> 24);
123 *CurBufferPtr++ = (uint8_t)(W >> 16);
124 *CurBufferPtr++ = (uint8_t)(W >> 8);
125 *CurBufferPtr++ = (uint8_t)(W >> 0);
122 *CurBufferPtr++ = (unsigned char)(W >> 24);
123 *CurBufferPtr++ = (unsigned char)(W >> 16);
124 *CurBufferPtr++ = (unsigned char)(W >> 8);
125 *CurBufferPtr++ = (unsigned char)(W >> 0);
126126 } else {
127127 CurBufferPtr = BufferEnd;
128128 }
133133 ///
134134 void emitDWordLE(uint64_t W) {
135135 if (8 <= BufferEnd-CurBufferPtr) {
136 *CurBufferPtr++ = (uint8_t)(W >> 0);
137 *CurBufferPtr++ = (uint8_t)(W >> 8);
138 *CurBufferPtr++ = (uint8_t)(W >> 16);
139 *CurBufferPtr++ = (uint8_t)(W >> 24);
140 *CurBufferPtr++ = (uint8_t)(W >> 32);
141 *CurBufferPtr++ = (uint8_t)(W >> 40);
142 *CurBufferPtr++ = (uint8_t)(W >> 48);
143 *CurBufferPtr++ = (uint8_t)(W >> 56);
136 *CurBufferPtr++ = (unsigned char)(W >> 0);
137 *CurBufferPtr++ = (unsigned char)(W >> 8);
138 *CurBufferPtr++ = (unsigned char)(W >> 16);
139 *CurBufferPtr++ = (unsigned char)(W >> 24);
140 *CurBufferPtr++ = (unsigned char)(W >> 32);
141 *CurBufferPtr++ = (unsigned char)(W >> 40);
142 *CurBufferPtr++ = (unsigned char)(W >> 48);
143 *CurBufferPtr++ = (unsigned char)(W >> 56);
144144 } else {
145145 CurBufferPtr = BufferEnd;
146146 }
151151 ///
152152 void emitDWordBE(uint64_t W) {
153153 if (8 <= BufferEnd-CurBufferPtr) {
154 *CurBufferPtr++ = (uint8_t)(W >> 56);
155 *CurBufferPtr++ = (uint8_t)(W >> 48);
156 *CurBufferPtr++ = (uint8_t)(W >> 40);
157 *CurBufferPtr++ = (uint8_t)(W >> 32);
158 *CurBufferPtr++ = (uint8_t)(W >> 24);
159 *CurBufferPtr++ = (uint8_t)(W >> 16);
160 *CurBufferPtr++ = (uint8_t)(W >> 8);
161 *CurBufferPtr++ = (uint8_t)(W >> 0);
154 *CurBufferPtr++ = (unsigned char)(W >> 56);
155 *CurBufferPtr++ = (unsigned char)(W >> 48);
156 *CurBufferPtr++ = (unsigned char)(W >> 40);
157 *CurBufferPtr++ = (unsigned char)(W >> 32);
158 *CurBufferPtr++ = (unsigned char)(W >> 24);
159 *CurBufferPtr++ = (unsigned char)(W >> 16);
160 *CurBufferPtr++ = (unsigned char)(W >> 8);
161 *CurBufferPtr++ = (unsigned char)(W >> 0);
162162 } else {
163163 CurBufferPtr = BufferEnd;
164164 }
172172 if(Alignment <= (uintptr_t)(BufferEnd-CurBufferPtr)) {
173173 // Move the current buffer ptr up to the specified alignment.
174174 CurBufferPtr =
175 (uint8_t*)(((uintptr_t)CurBufferPtr+Alignment-1) &
176 ~(uintptr_t)(Alignment-1));
175 (unsigned char*)(((uintptr_t)CurBufferPtr+Alignment-1) &
176 ~(uintptr_t)(Alignment-1));
177177 } else {
178178 CurBufferPtr = BufferEnd;
179179 }
184184 /// written to the output stream.
185185 void emitULEB128Bytes(unsigned Value) {
186186 do {
187 uint8_t Byte = Value & 0x7f;
187 unsigned char Byte = Value & 0x7f;
188188 Value >>= 7;
189189 if (Value) Byte |= 0x80;
190190 emitByte(Byte);
193193
194194 /// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
195195 /// written to the output stream.
196 void emitSLEB128Bytes(int32_t Value) {
197 int32_t Sign = Value >> (8 * sizeof(Value) - 1);
196 void emitSLEB128Bytes(int Value) {
197 int Sign = Value >> (8 * sizeof(Value) - 1);
198198 bool IsMore;
199199
200200 do {
201 uint8_t Byte = Value & 0x7f;
201 unsigned char Byte = Value & 0x7f;
202202 Value >>= 7;
203203 IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
204204 if (IsMore) Byte |= 0x80;
211211 void emitString(const std::string &String) {
212212 for (unsigned i = 0, N = static_cast(String.size());
213213 i < N; ++i) {
214 uint8_t C = String[i];
214 unsigned char C = String[i];
215215 emitByte(C);
216216 }
217217 emitByte(0);
218218 }
219219
220220 /// emitInt32 - Emit a int32 directive.
221 void emitInt32(int32_t Value) {
221 void emitInt32(int Value) {
222222 if (4 <= BufferEnd-CurBufferPtr) {
223223 *((uint32_t*)CurBufferPtr) = Value;
224224 CurBufferPtr += 4;
5959
6060 /// getGOTBase - If this is managing a Global Offset Table, this method should
6161 /// return a pointer to its base.
62 virtual uint8_t *getGOTBase() const = 0;
62 virtual unsigned char *getGOTBase() const = 0;
6363
6464 /// SetDlsymTable - If the JIT must be able to relocate stubs after they have
6565 /// been emitted, potentially because they are being copied to a process
8888 /// emit the function, so it doesn't pass in the size. Instead, this method
8989 /// is required to pass back a "valid size". The JIT will be careful to not
9090 /// write more than the returned ActualSize bytes of memory.
91 virtual uint8_t *startFunctionBody(const Function *F,
92 uintptr_t &ActualSize) = 0;
91 virtual unsigned char *startFunctionBody(const Function *F,
92 uintptr_t &ActualSize) = 0;
9393
9494 /// allocateStub - This method is called by the JIT to allocate space for a
9595 /// function stub (used to handle limited branch displacements) while it is
9999 /// thunk for it. The stub should be "close" to the current function body,
100100 /// but should not be included in the 'actualsize' returned by
101101 /// startFunctionBody.
102 virtual uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize,
103 unsigned Alignment) = 0;
102 virtual unsigned char *allocateStub(const GlobalValue* F, unsigned StubSize,
103 unsigned Alignment) =0;
104
104105
105106 /// endFunctionBody - This method is called when the JIT is done codegen'ing
106107 /// the specified function. At this point we know the size of the JIT
108109 /// the startFunctionBody method) and FunctionEnd which is a pointer to the
109110 /// actual end of the function. This method should mark the space allocated
110111 /// and remember where it is in case the client wants to deallocate it.
111 virtual void endFunctionBody(const Function *F, uint8_t *FunctionStart,
112 uint8_t *FunctionEnd) = 0;
112 virtual void endFunctionBody(const Function *F, unsigned char *FunctionStart,
113 unsigned char *FunctionEnd) = 0;
113114
114115 /// allocateSpace - Allocate a memory block of the given size.
115 virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) = 0;
116 virtual unsigned char *allocateSpace(intptr_t Size, unsigned Alignment) = 0;
116117
117118 /// deallocateMemForFunction - Free JIT memory for the specified function.
118119 /// This is never called when the JIT is currently emitting a function.
120121
121122 /// startExceptionTable - When we finished JITing the function, if exception
122123 /// handling is set, we emit the exception table.
123 virtual uint8_t* startExceptionTable(const Function* F,
124 uintptr_t &ActualSize) = 0;
124 virtual unsigned char* startExceptionTable(const Function* F,
125 uintptr_t &ActualSize) = 0;
125126
126127 /// endExceptionTable - This method is called when the JIT is done emitting
127128 /// the exception table.
128 virtual void endExceptionTable(const Function *F, uint8_t *TableStart,
129 uint8_t *TableEnd, uint8_t* FrameRegister) = 0;
129 virtual void endExceptionTable(const Function *F, unsigned char *TableStart,
130 unsigned char *TableEnd,
131 unsigned char* FrameRegister) = 0;
130132 };
131133
132134 } // end namespace llvm.
550550
551551 // When outputting a function stub in the context of some other function, we
552552 // save BufferBegin/BufferEnd/CurBufferPtr here.
553 uint8_t *SavedBufferBegin, *SavedBufferEnd, *SavedCurBufferPtr;
553 unsigned char *SavedBufferBegin, *SavedBufferEnd, *SavedCurBufferPtr;
554554
555555 /// Relocations - These are the relocations that the function needs, as
556556 /// emitted.
10551055
10561056 // FnStart is the start of the text, not the start of the constant pool and
10571057 // other per-function data.
1058 uint8_t *FnStart =
1059 (uint8_t *)TheJIT->getPointerToGlobalIfAvailable(F.getFunction());
1058 unsigned char *FnStart =
1059 (unsigned char *)TheJIT->getPointerToGlobalIfAvailable(F.getFunction());
10601060
10611061 // FnEnd is the end of the function's machine code.
1062 uint8_t *FnEnd = CurBufferPtr;
1062 unsigned char *FnEnd = CurBufferPtr;
10631063
10641064 if (!Relocations.empty()) {
10651065 CurFn = F.getFunction();
11821182 } else {
11831183 DOUT << "JIT: Binary code:\n";
11841184 DOUT << std::hex;
1185 uint8_t* q = FnStart;
1185 unsigned char* q = FnStart;
11861186 for (int i = 0; q < FnEnd; q += 4, ++i) {
11871187 if (i == 4)
11881188 i = 0;
12201220 BufferBegin = CurBufferPtr = MemMgr->startExceptionTable(F.getFunction(),
12211221 ActualSize);
12221222 BufferEnd = BufferBegin+ActualSize;
1223 uint8_t* FrameRegister = DE->EmitDwarfTable(F, *this, FnStart, FnEnd);
1223 unsigned char* FrameRegister = DE->EmitDwarfTable(F, *this, FnStart, FnEnd);
12241224 MemMgr->endExceptionTable(F.getFunction(), BufferBegin, CurBufferPtr,
12251225 FrameRegister);
12261226 BufferBegin = SavedBufferBegin;
14151415 SavedBufferEnd = BufferEnd;
14161416 SavedCurBufferPtr = CurBufferPtr;
14171417
1418 BufferBegin = CurBufferPtr = (uint8_t *)Buffer;
1418 BufferBegin = CurBufferPtr = (unsigned char *)Buffer;
14191419 BufferEnd = BufferBegin+StubSize+1;
14201420 }
14211421
256256 // When emitting code into a memory block, this is the block.
257257 MemoryRangeHeader *CurBlock;
258258
259 uint8_t *CurStubPtr, *StubBase;
260 uint8_t *GOTBase; // Target Specific reserved memory
261 void *DlsymTable; // Stub external symbol information
259 unsigned char *CurStubPtr, *StubBase;
260 unsigned char *GOTBase; // Target Specific reserved memory
261 void *DlsymTable; // Stub external symbol information
262262
263263 // Centralize memory block allocation.
264264 sys::MemoryBlock getNewMemoryBlock(unsigned size);
272272 void AllocateGOT();
273273 void SetDlsymTable(void *);
274274
275 uint8_t *allocateStub(const GlobalValue* F, unsigned StubSize,
276 unsigned Alignment);
275 unsigned char *allocateStub(const GlobalValue* F, unsigned StubSize,
276 unsigned Alignment);
277277
278278 /// startFunctionBody - When a function starts, allocate a block of free
279279 /// executable memory, returning a pointer to it and its actual size.
280 uint8_t *startFunctionBody(const Function *F, uintptr_t &ActualSize) {
280 unsigned char *startFunctionBody(const Function *F, uintptr_t &ActualSize) {
281281
282282 FreeRangeHeader* candidateBlock = FreeMemoryList;
283283 FreeRangeHeader* head = FreeMemoryList;
300300 // Allocate the entire memory block.
301301 FreeMemoryList = candidateBlock->AllocateBlock();
302302 ActualSize = CurBlock->BlockSize-sizeof(MemoryRangeHeader);
303 return (uint8_t *)(CurBlock+1);
303 return (unsigned char *)(CurBlock+1);
304304 }
305305
306306 /// endFunctionBody - The function F is now allocated, and takes the memory
307307 /// in the range [FunctionStart,FunctionEnd).
308 void endFunctionBody(const Function *F, uint8_t *FunctionStart,
309 uint8_t *FunctionEnd) {
308 void endFunctionBody(const Function *F, unsigned char *FunctionStart,
309 unsigned char *FunctionEnd) {
310310 assert(FunctionEnd > FunctionStart);
311 assert(FunctionStart == (uint8_t *)(CurBlock+1) &&
311 assert(FunctionStart == (unsigned char *)(CurBlock+1) &&
312312 "Mismatched function start/end!");
313313
314 uintptr_t BlockSize = FunctionEnd - (uint8_t *)CurBlock;
314 uintptr_t BlockSize = FunctionEnd - (unsigned char *)CurBlock;
315315 FunctionBlocks[F] = CurBlock;
316316
317317 // Release the memory at the end of this block that isn't needed.
319319 }
320320
321321 /// allocateSpace - Allocate a memory block of the given size.
322 uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) {
322 unsigned char *allocateSpace(intptr_t Size, unsigned Alignment) {
323323 CurBlock = FreeMemoryList;
324324 FreeMemoryList = FreeMemoryList->AllocateBlock();
325325
326 uint8_t *result = (uint8_t *)CurBlock+1;
326 unsigned char *result = (unsigned char *)CurBlock+1;
327327
328328 if (Alignment == 0) Alignment = 1;
329 result = (uint8_t*)(((intptr_t)result+Alignment-1) &
329 result = (unsigned char*)(((intptr_t)result+Alignment-1) &
330330 ~(intptr_t)(Alignment-1));
331331
332 uintptr_t BlockSize = result + Size - (uint8_t *)CurBlock;
332 uintptr_t BlockSize = result + Size - (unsigned char *)CurBlock;
333333 FreeMemoryList =CurBlock->TrimAllocationToSize(FreeMemoryList, BlockSize);
334334
335335 return result;
337337
338338 /// startExceptionTable - Use startFunctionBody to allocate memory for the
339339 /// function's exception table.
340 uint8_t* startExceptionTable(const Function* F, uintptr_t &ActualSize) {
340 unsigned char* startExceptionTable(const Function* F,
341 uintptr_t &ActualSize) {
341342 return startFunctionBody(F, ActualSize);
342343 }
343344
344345 /// endExceptionTable - The exception table of F is now allocated,
345346 /// and takes the memory in the range [TableStart,TableEnd).
346 void endExceptionTable(const Function *F, uint8_t *TableStart,
347 uint8_t *TableEnd, uint8_t* FrameRegister) {
347 void endExceptionTable(const Function *F, unsigned char *TableStart,
348 unsigned char *TableEnd,
349 unsigned char* FrameRegister) {
348350 assert(TableEnd > TableStart);
349 assert(TableStart == (uint8_t *)(CurBlock+1) &&
351 assert(TableStart == (unsigned char *)(CurBlock+1) &&
350352 "Mismatched table start/end!");
351353
352 uintptr_t BlockSize = TableEnd - (uint8_t *)CurBlock;
354 uintptr_t BlockSize = TableEnd - (unsigned char *)CurBlock;
353355 TableBlocks[F] = CurBlock;
354356
355357 // Release the memory at the end of this block that isn't needed.
356358 FreeMemoryList =CurBlock->TrimAllocationToSize(FreeMemoryList, BlockSize);
357359 }
358360
359 uint8_t *getGOTBase() const {
361 unsigned char *getGOTBase() const {
360362 return GOTBase;
361363 }
362364
430432 sys::MemoryBlock MemBlock = getNewMemoryBlock(16 << 20);
431433 #endif
432434
433 uint8_t *MemBase = static_cast*>(MemBlock.base());
435 unsigned char *MemBase = static_cast*>(MemBlock.base());
434436
435437 // Allocate stubs backwards from the base, allocate functions forward
436438 // from the base.
489491
490492 void DefaultJITMemoryManager::AllocateGOT() {
491493 assert(GOTBase == 0 && "Cannot allocate the got multiple times");
492 GOTBase = new uint8_t[sizeof(void*) * 8192];
494 GOTBase = new unsigned char[sizeof(void*) * 8192];
493495 HasGOT = true;
494496 }
495497
505507 Blocks.clear();
506508 }
507509
508 uint8_t *DefaultJITMemoryManager::allocateStub(const GlobalValue* F,
510 unsigned char *DefaultJITMemoryManager::allocateStub(const GlobalValue* F,
509511 unsigned StubSize,
510512 unsigned Alignment) {
511513 CurStubPtr -= StubSize;
512 CurStubPtr = (uint8_t*)(((intptr_t)CurStubPtr) &
513 ~(intptr_t)(Alignment-1));
514 CurStubPtr = (unsigned char*)(((intptr_t)CurStubPtr) &
515 ~(intptr_t)(Alignment-1));
514516 if (CurStubPtr < StubBase) {
515517 // FIXME: allocate a new block
516518 fprintf(stderr, "JIT ran out of memory for function stubs!\n");