Mercurial > hg > truffle
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java @ 2284:569d3fe7d65c
non-static VMEntries and VMExits, CompilationServer simplifications
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Thu, 07 Apr 2011 15:32:25 +0200 |
parents | e5ba25730d9b |
children |
comparison
equal
deleted
inserted
replaced
2282:0309d394eb5f | 2284:569d3fe7d65c |
---|---|
18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open | 18 * UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open |
19 * Company, Ltd. | 19 * Company, Ltd. |
20 */ | 20 */ |
21 package com.sun.hotspot.c1x; | 21 package com.sun.hotspot.c1x; |
22 | 22 |
23 import java.io.*; | |
23 import java.util.*; | 24 import java.util.*; |
24 | 25 |
25 import com.sun.cri.ri.*; | 26 import com.sun.cri.ri.*; |
26 | 27 |
27 /** | 28 /** |
35 | 36 |
36 private final FastLRUIntCache<RiMethod> methodCache = new FastLRUIntCache<RiMethod>(); | 37 private final FastLRUIntCache<RiMethod> methodCache = new FastLRUIntCache<RiMethod>(); |
37 private final FastLRUIntCache<RiField> fieldCache = new FastLRUIntCache<RiField>(); | 38 private final FastLRUIntCache<RiField> fieldCache = new FastLRUIntCache<RiField>(); |
38 private final FastLRUIntCache<RiType> typeCache = new FastLRUIntCache<RiType>(); | 39 private final FastLRUIntCache<RiType> typeCache = new FastLRUIntCache<RiType>(); |
39 | 40 |
40 public static class FastLRUIntCache<T> { | 41 public static class FastLRUIntCache<T> implements Serializable { |
41 | 42 |
42 private static final int InitialCapacity = 4; | 43 private static final int InitialCapacity = 4; |
43 private int lastKey; | 44 private int lastKey; |
44 private T lastObject; | 45 private T lastObject; |
45 | 46 |
94 objects = Arrays.copyOf(objects, objects.length * 2); | 95 objects = Arrays.copyOf(objects, objects.length * 2); |
95 } | 96 } |
96 } | 97 } |
97 } | 98 } |
98 | 99 |
99 public HotSpotConstantPool(long vmId) { | 100 public HotSpotConstantPool(Compiler compiler, long vmId) { |
101 super(compiler); | |
100 this.vmId = vmId; | 102 this.vmId = vmId; |
101 } | 103 } |
102 | 104 |
103 @Override | 105 @Override |
104 public Object lookupConstant(int cpi) { | 106 public Object lookupConstant(int cpi) { |
105 Object constant = Compiler.getVMEntries().RiConstantPool_lookupConstant(vmId, cpi); | 107 Object constant = compiler.getVMEntries().RiConstantPool_lookupConstant(vmId, cpi); |
106 return constant; | 108 return constant; |
107 } | 109 } |
108 | 110 |
109 @Override | 111 @Override |
110 public RiSignature lookupSignature(int cpi) { | 112 public RiSignature lookupSignature(int cpi) { |
111 return Compiler.getVMEntries().RiConstantPool_lookupSignature(vmId, cpi); | 113 return compiler.getVMEntries().RiConstantPool_lookupSignature(vmId, cpi); |
112 } | 114 } |
113 | 115 |
114 @Override | 116 @Override |
115 public RiMethod lookupMethod(int cpi, int byteCode) { | 117 public RiMethod lookupMethod(int cpi, int byteCode) { |
116 RiMethod result = methodCache.get(cpi); | 118 RiMethod result = methodCache.get(cpi); |
117 if (result == null) { | 119 if (result == null) { |
118 result = Compiler.getVMEntries().RiConstantPool_lookupMethod(vmId, cpi, (byte) byteCode); | 120 result = compiler.getVMEntries().RiConstantPool_lookupMethod(vmId, cpi, (byte) byteCode); |
119 methodCache.add(cpi, result); | 121 methodCache.add(cpi, result); |
120 } | 122 } |
121 return result; | 123 return result; |
122 } | 124 } |
123 | 125 |
124 @Override | 126 @Override |
125 public RiType lookupType(int cpi, int opcode) { | 127 public RiType lookupType(int cpi, int opcode) { |
126 RiType result = typeCache.get(cpi); | 128 RiType result = typeCache.get(cpi); |
127 if (result == null) { | 129 if (result == null) { |
128 result = Compiler.getVMEntries().RiConstantPool_lookupType(vmId, cpi); | 130 result = compiler.getVMEntries().RiConstantPool_lookupType(vmId, cpi); |
129 typeCache.add(cpi, result); | 131 typeCache.add(cpi, result); |
130 } | 132 } |
131 return result; | 133 return result; |
132 } | 134 } |
133 | 135 |
134 @Override | 136 @Override |
135 public RiField lookupField(int cpi, int opcode) { | 137 public RiField lookupField(int cpi, int opcode) { |
136 RiField result = fieldCache.get(cpi); | 138 RiField result = fieldCache.get(cpi); |
137 if (result == null) { | 139 if (result == null) { |
138 result = Compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi, (byte) opcode); | 140 result = compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi, (byte) opcode); |
139 fieldCache.add(cpi, result); | 141 fieldCache.add(cpi, result); |
140 } | 142 } |
141 return result; | 143 return result; |
142 } | 144 } |
143 } | 145 } |