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 */
013package org.mmtk.vm;
014
015import org.vmutil.options.OptionSet;
016import org.mmtk.utility.gcspy.Color;
017import org.mmtk.utility.gcspy.drivers.AbstractDriver;
018import org.mmtk.vm.gcspy.ByteStream;
019import org.mmtk.vm.gcspy.IntStream;
020import org.mmtk.vm.gcspy.ServerInterpreter;
021import org.mmtk.vm.gcspy.ServerSpace;
022import org.mmtk.vm.gcspy.ShortStream;
023import 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 */
031public 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   * Creates a new ReferenceProcessor instance using the appropriate VM-specific
125   * concrete ReferenceProcessor sub-class.
126   *
127   * @param semantics the semantics that the reference processor will use
128   * @return A concrete VM-specific ReferenceProcessor instance.
129   * @see ReferenceProcessor
130   */
131  public abstract ReferenceProcessor newReferenceProcessor(ReferenceProcessor.Semantics semantics);
132
133
134  /**
135   * Create a new FinalizbleProcessor instance using the appropriate VM-specific
136   * concrete FinalizableProcessor sub-class.
137   *
138   * @see FinalizableProcessor
139   * @return A concrete VM-specific FinalizableProcessor instance.
140   */
141  public abstract FinalizableProcessor newFinalizableProcessor();
142
143  /**
144   * Create a new Scanning instance using the appropriate VM-specific
145   * concrete Scanning sub-class.
146   *
147   * @see Scanning
148   * @return A concrete VM-specific Scanning instance.
149   */
150  public abstract Scanning newScanning();
151
152  /**
153   * Create a new Statistics instance using the appropriate VM-specific
154   * concrete Statistics sub-class.
155   *
156   * @see Statistics
157   * @return A concrete VM-specific Statistics instance.
158   */
159  public abstract Statistics newStatistics();
160
161  /**
162   * Create a new Strings instance using the appropriate VM-specific
163   * concrete Strings sub-class.
164   *
165   * @see Strings
166   * @return A concrete VM-specific Strings instance.
167   */
168  public abstract Strings newStrings();
169
170  /**
171   * Create a new SynchronizedCounter instance using the appropriate
172   * VM-specific concrete SynchronizedCounter sub-class.
173   *
174   * @see SynchronizedCounter
175   *
176   * @return A concrete VM-specific SynchronizedCounter instance.
177   */
178  public abstract SynchronizedCounter newSynchronizedCounter();
179
180  /**
181   * Create a new TraceInterface instance using the appropriate VM-specific
182   * concrete TraceInterface sub-class.
183   *
184   * @see TraceInterface
185   * @return A concrete VM-specific TraceInterface instance.
186   */
187  public abstract TraceInterface newTraceInterface();
188
189  /**
190   * Create a new MMTk_Events instance using the appropriate VM-specific
191   * concrete MMTk_Events sub-class.
192   *
193   * @return a new MMTK_Events instance
194   */
195  public abstract MMTk_Events newEvents();
196
197  /**
198   * @return a newly created debug object
199   */
200  public abstract Debug newDebug();
201
202  /**********************************************************************
203   * GCspy methods
204   */
205
206  /**
207   * Create a new Util instance using the appropriate VM-specific
208   * concrete Util sub-class.
209   *
210   * @see Util
211   * @return A concrete VM-specific Util instance.
212   */
213  public abstract Util newGCspyUtil();
214
215  /**
216   * Create a new ServerInterpreter instance using the appropriate VM-specific
217   * concrete ServerInterpreter sub-class.
218   *
219   * @see ServerInterpreter
220   * @return A concrete VM-specific ServerInterpreter instance.
221   */
222  public abstract ServerInterpreter newGCspyServerInterpreter();
223
224  /**
225   * Create a new ServerSpace instance using the appropriate VM-specific
226   * concrete ServerSpace sub-class.
227   *
228   * @param serverInterpreter The server that owns this space
229   * @param serverName The server's name
230   * @param driverName The space driver's name
231   * @param title Title for the space
232   * @param blockInfo A label for each block
233   * @param tileNum Max number of tiles in this space
234   * @param unused A label for unused blocks
235   * @param mainSpace Whether this space is the main space
236   *
237   * @see ServerSpace
238   * @return A concrete VM-specific ServerSpace instance.
239   */
240  public abstract ServerSpace newGCspyServerSpace(
241      ServerInterpreter serverInterpreter,
242      String serverName,
243      String driverName,
244      String title,
245      String blockInfo,
246      int tileNum,
247      String unused,
248      boolean mainSpace);
249
250  /**
251   * Create a new IntStream instance using the appropriate
252   * VM-specific concrete IntStream sub-class.
253   *
254   * @param driver        The driver that owns this Stream
255   * @param name           The name of the stream (e.g. "Used space")
256   * @param minValue       The minimum value for any item in this stream.
257   *                       Values less than this will be represented as "minValue-"
258   * @param maxValue       The maximum value for any item in this stream.
259   *                       Values greater than this will be represented as "maxValue+"
260   * @param zeroValue      The zero value for this stream
261   * @param defaultValue   The default value for this stream
262   * @param stringPre      A string to prefix values (e.g. "Used: ")
263   * @param stringPost     A string to suffix values (e.g. " bytes.")
264   * @param presentation   How a stream value is to be presented.
265   * @param paintStyle     How the value is to be painted.
266   * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
267   * @param colour         The default colour for tiles of this stream
268   * @param summary        Is a summary enabled?
269   * @see IntStream
270   *
271   * @return A concrete VM-specific IntStream instance.
272   */
273  public abstract IntStream newGCspyIntStream(
274      AbstractDriver driver,
275      String name,
276      int minValue,
277      int maxValue,
278      int zeroValue,
279      int defaultValue,
280      String stringPre,
281      String stringPost,
282      int presentation,
283      int paintStyle,
284      int indexMaxStream,
285      Color colour,
286      boolean summary);
287
288  /**
289   * Create a new ByteStream instance using the appropriate
290   * VM-specific concrete ByteStream sub-class.
291   *
292   * @param driver        The driver that owns this Stream
293   * @param name           The name of the stream (e.g. "Used space")
294   * @param minValue       The minimum value for any item in this stream.
295   *                       Values less than this will be represented as "minValue-"
296   * @param maxValue       The maximum value for any item in this stream.
297   *                       Values greater than this will be represented as "maxValue+"
298   * @param zeroValue      The zero value for this stream
299   * @param defaultValue   The default value for this stream
300   * @param stringPre      A string to prefix values (e.g. "Used: ")
301   * @param stringPost     A string to suffix values (e.g. " bytes.")
302   * @param presentation   How a stream value is to be presented.
303   * @param paintStyle     How the value is to be painted.
304   * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
305   * @param colour         The default colour for tiles of this stream
306   * @param summary        Is a summary enabled?
307   * @see IntStream
308   *
309   * @return A concrete VM-specific ByteStream instance.
310   */
311  public abstract ByteStream newGCspyByteStream(
312      AbstractDriver driver,
313      String name,
314      byte minValue,
315      byte maxValue,
316      byte zeroValue,
317      byte defaultValue,
318      String stringPre,
319      String stringPost,
320      int presentation,
321      int paintStyle,
322      int indexMaxStream,
323      Color colour,
324      boolean summary);
325
326  /**
327   * Create a new ShortStream instance using the appropriate
328   * VM-specific concrete ShortStream sub-class.
329   *
330   * @param driver        The driver that owns this Stream
331   * @param name           The name of the stream (e.g. "Used space")
332   * @param minValue       The minimum value for any item in this stream.
333   *                       Values less than this will be represented as "minValue-"
334   * @param maxValue       The maximum value for any item in this stream.
335   *                       Values greater than this will be represented as "maxValue+"
336   * @param zeroValue      The zero value for this stream
337   * @param defaultValue   The default value for this stream
338   * @param stringPre      A string to prefix values (e.g. "Used: ")
339   * @param stringPost     A string to suffix values (e.g. " bytes.")
340   * @param presentation   How a stream value is to be presented.
341   * @param paintStyle     How the value is to be painted.
342   * @param indexMaxStream The index of the maximum stream if the presentation is *_VAR.
343   * @param colour         The default colour for tiles of this stream
344   * @param summary        Is a summary enabled?
345   * @see IntStream
346   *
347   * @return A concrete VM-specific ShortStream instance.
348   */
349  public abstract ShortStream newGCspyShortStream(
350      AbstractDriver driver,
351      String name,
352      short minValue,
353      short maxValue,
354      short zeroValue,
355      short defaultValue,
356      String stringPre,
357      String stringPost,
358      int presentation,
359      int paintStyle,
360      int indexMaxStream,
361      Color colour,
362      boolean summary);
363}