Source code: Allocator/DefaultCodeAllocator.java
1 // DefaultCodeAllocator.java, created Mon Apr 9 1:01:21 2001 by joewhaley
2 // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3 // Licensed under the terms of the GNU LGPL; see COPYING for details.
4 package Allocator;
5
6 import Allocator.CodeAllocator.x86CodeBuffer;
7 import Bootstrap.PrimordialClassLoader;
8 import Clazz.jq_Class;
9 import Clazz.jq_StaticField;
10 import Memory.Address;
11 import Memory.CodeAddress;
12 import Run_Time.Unsafe;
13
14 /**
15 * DefaultCodeAllocator
16 *
17 * @author John Whaley <jwhaley@alum.mit.edu>
18 * @version $Id: DefaultCodeAllocator.java,v 1.8 2003/05/12 10:04:52 joewhaley Exp $
19 */
20 public abstract class DefaultCodeAllocator {
21
22 public static CodeAllocator default_allocator;
23
24 public static final CodeAllocator def() {
25 if (default_allocator != null) return default_allocator;
26 return Unsafe.getThreadBlock().getNativeThread().getCodeAllocator();
27 }
28
29 public static final void init() {
30 def().init();
31 }
32 public static final x86CodeBuffer getCodeBuffer(int estimatedSize, int offset, int alignment) {
33 x86CodeBuffer o = def().getCodeBuffer(estimatedSize, offset, alignment);
34 return o;
35 }
36 public static final void patchAbsolute(Address code, Address heap) {
37 def().patchAbsolute(code, heap);
38 }
39 public static final void patchRelativeOffset(CodeAddress code, CodeAddress target) {
40 def().patchRelativeOffset(code, target);
41 }
42
43 public static final jq_StaticField _default_allocator;
44 static {
45 jq_Class k = (jq_Class)PrimordialClassLoader.loader.getOrCreateBSType("LAllocator/DefaultCodeAllocator;");
46 _default_allocator = k.getOrCreateStaticField("default_allocator", "LAllocator/CodeAllocator;");
47 }
48 }