001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.mmtk.vm;
014
015 import org.vmutil.options.OptionSet;
016 import org.mmtk.utility.gcspy.Color;
017 import org.mmtk.utility.gcspy.drivers.AbstractDriver;
018 import org.mmtk.vm.gcspy.ByteStream;
019 import org.mmtk.vm.gcspy.IntStream;
020 import org.mmtk.vm.gcspy.ServerInterpreter;
021 import org.mmtk.vm.gcspy.ServerSpace;
022 import org.mmtk.vm.gcspy.ShortStream;
023 import org.mmtk.vm.gcspy.Util;
024
025 /**
026 * This class defines factory methods for VM-specific types which must
027 * be instantiated within MMTk. Since the concrete type is defined at
028 * build time, we leave it to a concrete vm-specific instance of this class
029 * to perform the object instantiation.
030 */
031 public abstract class Factory {
032
033 /**
034 * Create or retrieve the OptionSet used for MMTk options.
035 *
036 * @return A concrete VM-specific OptionSet instance
037 */
038 public abstract OptionSet getOptionSet();
039
040 /**
041 * Create a new ActivePlan instance using the appropriate VM-specific
042 * concrete ActivePlan sub-class.
043 *
044 * @see ActivePlan
045 * @return A concrete VM-specific ActivePlan instance.
046 */
047 public abstract ActivePlan newActivePlan();
048
049 /**
050 * Create a new Assert instance using the appropriate VM-specific
051 * concrete Assert sub-class.
052 *
053 * @see Assert
054 * @return A concrete VM-specific Assert instance.
055 */
056 public abstract Assert newAssert();
057
058 /**
059 * Create a new Barriers instance using the appropriate VM-specific
060 * concrete Barriers sub-class.
061 *
062 * @see Barriers
063 * @return A concrete VM-specific Barriers instance.
064 */
065 public abstract Barriers newBarriers();
066
067 /**
068 * Create a new Collection instance using the appropriate VM-specific
069 * concrete Collection sub-class.
070 *
071 * @see Collection
072 * @return A concrete VM-specific Collection instance.
073 */
074 public abstract Collection newCollection();
075
076 /**
077 * Create a new BuildTimeConfig instance using the appropriate VM-specific
078 * concrete BuildTimeConfig sub-class.
079 *
080 * @see Collection
081 * @return A concrete VM-specific Collection instance.
082 */
083 public abstract BuildTimeConfig newBuildTimeConfig();
084
085 /**
086 * Create a new Lock instance using the appropriate VM-specific
087 * concrete Lock sub-class.
088 *
089 * @see Lock
090 * @param name The string to be associated with this lock instance
091 * @return A concrete VM-specific Lock instance.
092 */
093 public abstract Lock newLock(String name);
094
095 /**
096 * Create a new Monitor instance using the appropriate VM-specific
097 * concrete Lock sub-class.
098 *
099 * @see Monitor
100 * @param name The string to be associated with this monitor instance
101 * @return A concrete VM-specific Monitor instance.
102 */
103 public abstract Monitor newMonitor(String name);
104
105 /**
106 * Create a new Memory instance using the appropriate VM-specific
107 * concrete Memory sub-class.
108 *
109 * @see Memory
110 * @return A concrete VM-specific Memory instance.
111 */
112 public abstract Memory newMemory();
113
114 /**
115 * Create a new ObjectModel instance using the appropriate VM-specific
116 * concrete ObjectModel sub-class.
117 *
118 * @see ObjectModel
119 * @return A concrete VM-specific ObjectModel instance.
120 */
121 public abstract ObjectModel newObjectModel();
122
123 /**
124 * Create a new ReferenceProcessor instance using the appropriate VM-specific
125 * concrete ReferenceProcessor sub-class.
126 *
127 * @see ReferenceProcessor
128 * @return A concrete VM-specific ReferenceProcessor instance.
129 */
130 public abstract ReferenceProcessor newReferenceProcessor(ReferenceProcessor.Semantics semantics);
131
132
133 /**
134 * Create a new FinalizbleProcessor instance using the appropriate VM-specific
135 * concrete FinalizableProcessor sub-class.
136 *
137 * @see FinalizableProcessor
138 * @return A concrete VM-specific FinalizableProcessor instance.
139 */
140 public abstract FinalizableProcessor newFinalizableProcessor();
141
142 /**
143 * Create a new Scanning instance using the appropriate VM-specific
144 * concrete Scanning sub-class.
145 *
146 * @see Scanning
147 * @return A concrete VM-specific Scanning instance.
148 */
149 public abstract Scanning newScanning();
150
151 /**
152 * Create a new Statistics instance using the appropriate VM-specific
153 * concrete Statistics sub-class.
154 *
155 * @see Statistics
156 * @return A concrete VM-specific Statistics instance.
157 */
158 public abstract Statistics newStatistics();
159
160 /**
161 * Create a new Strings instance using the appropriate VM-specific
162 * concrete Strings sub-class.
163 *
164 * @see Strings
165 * @return A concrete VM-specific Strings instance.
166 */
167 public abstract Strings newStrings();
168
169 /**
170 * Create a new SynchronizedCounter instance using the appropriate
171 * VM-specific concrete SynchronizedCounter sub-class.
172 *
173 * @see SynchronizedCounter
174 *
175 * @return A concrete VM-specific SynchronizedCounter instance.
176 */
177 public abstract SynchronizedCounter newSynchronizedCounter();
178
179 /**
180 * Create a new TraceInterface instance using the appropriate VM-specific
181 * concrete TraceInterface sub-class.
182 *
183 * @see TraceInterface
184 * @return A concrete VM-specific TraceInterface instance.
185 */
186 public abstract TraceInterface newTraceInterface();
187
188 /**
189 * Create a new MMTk_Events instance using the appropriate VM-specific
190 * concrete MMTk_Events sub-class.
191 */
192 public abstract MMTk_Events newEvents();
193
194 /**
195 * Create a new debug object
196 */
197 public abstract Debug newDebug();
198
199 /**********************************************************************
200 * GCspy methods
201 */
202
203 /**
204 * Create a new Util instance using the appropriate VM-specific
205 * concrete Util sub-class.
206 *
207 * @see Util
208 * @return A concrete VM-specific Util instance.
209 */
210 public abstract Util newGCspyUtil();
211
212 /**
213 * Create a new ServerInterpreter instance using the appropriate VM-specific
214 * concrete ServerInterpreter sub-class.
215 *
216 * @see ServerInterpreter
217 * @return A concrete VM-specific ServerInterpreter instance.
218 */
219 public abstract ServerInterpreter newGCspyServerInterpreter();
220
221 /**
222 * Create a new ServerSpace instance using the appropriate VM-specific
223 * concrete ServerSpace sub-class.
224 *
225 * @param serverInterpreter The server that owns this space
226 * @param serverName The server's name
227 * @param driverName The space driver's name
228 * @param title Title for the space
229 * @param blockInfo A label for each block
230 * @param tileNum Max number of tiles in this space
231 * @param unused A label for unused blocks
232 * @param mainSpace Whether this space is the main space
233 *
234 * @see ServerSpace
235 * @return A concrete VM-specific ServerSpace instance.
236 */
237 public abstract ServerSpace newGCspyServerSpace(
238 ServerInterpreter serverInterpreter,
239 String serverName,
240 String driverName,
241 String title,
242 String blockInfo,
243 int tileNum,
244 String unused,
245 boolean mainSpace);
246
247 /**
248 * Create a new IntStream instance using the appropriate
249 * VM-specific concrete IntStream sub-class.
250 *
251 * @param driver The driver that owns this Stream
252 * @param name The name of the stream (e.g. "Used space")
253 * @param minValue The minimum value for any item in this stream.
254 * Values less than this will be represented as "minValue-"
255 * @param maxValue The maximum value for any item in this stream.
256 * Values greater than this will be represented as "maxValue+"
257 * @param zeroValue The zero value for this stream
258 * @param defaultValue The default value for this stream
259 * @param stringPre A string to prefix values (e.g. "Used: ")
260 * @param stringPost A string to suffix values (e.g. " bytes.")
261 * @param presentation How a stream value is to be presented.
262 * @param paintStyle How the value is to be painted.
263 * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
264 * @param colour The default colour for tiles of this stream
265 * @see IntStream
266 *
267 * @return A concrete VM-specific IntStream instance.
268 */
269 public abstract IntStream newGCspyIntStream(
270 AbstractDriver driver,
271 String name,
272 int minValue,
273 int maxValue,
274 int zeroValue,
275 int defaultValue,
276 String stringPre,
277 String stringPost,
278 int presentation,
279 int paintStyle,
280 int indexMaxStream,
281 Color colour,
282 boolean summary);
283
284 /**
285 * Create a new ByteStream instance using the appropriate
286 * VM-specific concrete ByteStream sub-class.
287 *
288 * @param driver The driver that owns this Stream
289 * @param name The name of the stream (e.g. "Used space")
290 * @param minValue The minimum value for any item in this stream.
291 * Values less than this will be represented as "minValue-"
292 * @param maxValue The maximum value for any item in this stream.
293 * Values greater than this will be represented as "maxValue+"
294 * @param zeroValue The zero value for this stream
295 * @param defaultValue The default value for this stream
296 * @param stringPre A string to prefix values (e.g. "Used: ")
297 * @param stringPost A string to suffix values (e.g. " bytes.")
298 * @param presentation How a stream value is to be presented.
299 * @param paintStyle How the value is to be painted.
300 * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
301 * @param colour The default colour for tiles of this stream
302 * @see IntStream
303 *
304 * @return A concrete VM-specific ByteStream instance.
305 */
306 public abstract ByteStream newGCspyByteStream(
307 AbstractDriver driver,
308 String name,
309 byte minValue,
310 byte maxValue,
311 byte zeroValue,
312 byte defaultValue,
313 String stringPre,
314 String stringPost,
315 int presentation,
316 int paintStyle,
317 int indexMaxStream,
318 Color colour,
319 boolean summary);
320
321 /**
322 * Create a new ShortStream instance using the appropriate
323 * VM-specific concrete ShortStream sub-class.
324 *
325 * @param driver The driver that owns this Stream
326 * @param name The name of the stream (e.g. "Used space")
327 * @param minValue The minimum value for any item in this stream.
328 * Values less than this will be represented as "minValue-"
329 * @param maxValue The maximum value for any item in this stream.
330 * Values greater than this will be represented as "maxValue+"
331 * @param zeroValue The zero value for this stream
332 * @param defaultValue The default value for this stream
333 * @param stringPre A string to prefix values (e.g. "Used: ")
334 * @param stringPost A string to suffix values (e.g. " bytes.")
335 * @param presentation How a stream value is to be presented.
336 * @param paintStyle How the value is to be painted.
337 * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
338 * @param colour The default colour for tiles of this stream
339 * @see IntStream
340 *
341 * @return A concrete VM-specific ShortStream instance.
342 */
343 public abstract ShortStream newGCspyShortStream(
344 AbstractDriver driver,
345 String name,
346 short minValue,
347 short maxValue,
348 short zeroValue,
349 short defaultValue,
350 String stringPre,
351 String stringPost,
352 int presentation,
353 int paintStyle,
354 int indexMaxStream,
355 Color colour,
356 boolean summary);
357 }