use of org.mmtk.harness.vm.Factory in project JikesRVM by JikesRVM.
the class Harness method init.
/**
* Start up the harness, including creating the global plan and constraints,
* and starting off the collector threads.
*
* After calling this it is possible to begin creating mutator threads.
* @param args Command-line arguments
*/
public static void init(String... args) {
initialized = true;
/* Always use the harness factory */
System.setProperty("mmtk.hostjvm", Factory.class.getCanonicalName());
/* Options used for configuring the plan to use */
final ArrayList<String> newArgs = new ArrayList<String>();
for (String arg : args) {
if (!options.process(arg))
newArgs.add(arg);
}
/* If we're using the baseHeap mechanism, override initHeap and maxheap */
if (baseHeapSize() != 0 && initHeap.getPages() == initHeap.getDefaultPages()) {
applyHeapScaling();
}
trace.apply();
gcEvery.apply();
org.mmtk.harness.scheduler.Scheduler.init();
for (Address watchAddr : watchAddress.getAddresses()) {
System.err.printf("Setting watch at %s%n", watchAddr);
SimulatedMemory.addWatch(watchAddr);
}
/*
* Perform MMTk initialization in a minimal environment, specifically to
* give it a per-thread 'Log' object
*/
MMTkThread m = new MMTkThread() {
@Override
public void run() {
try {
/* Get MMTk breathing */
ActivePlan.init(PlanSpecificConfig.planClass(plan.getValue()));
/* Override some defaults */
Options.noFinalizer.setValue(true);
Options.variableSizeHeap.setValue(false);
/* Process command line options */
for (String arg : newArgs) {
if (!options.process(arg)) {
throw new RuntimeException("Invalid option '" + arg + "'");
}
}
ActivePlan.plan.enableAllocation();
if (org.mmtk.utility.options.Options.verbose.getValue() > 0) {
System.err.printf("[Harness] Configuring heap size [%4.2fMB..%4.2fMB]%n", initHeap.getBytes().toLong() / MB, maxHeap.getBytes().toLong() / MB);
}
HeapGrowthManager.boot(initHeap.getBytes(), maxHeap.getBytes());
/* Check options */
assert Options.noFinalizer.getValue() : "noFinalizer must be true";
/* Finish starting up MMTk */
ActivePlan.plan.processOptions();
ActivePlan.plan.enableCollection();
ActivePlan.plan.fullyBooted();
checkSpaces();
Log.flush();
} catch (Throwable e) {
e.printStackTrace();
Main.exitWithFailure();
}
}
};
m.start();
try {
m.join();
} catch (InterruptedException e) {
}
org.mmtk.harness.scheduler.Scheduler.initCollectors();
for (int value : watchObject.getValue()) {
System.out.printf("Setting watch for object %d%n", value);
org.mmtk.harness.vm.ObjectModel.watchObject(value);
}
/* Add exit handler to print yield stats */
if (policyStats.getValue()) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
AbstractPolicy.printStats();
}
});
}
}
Aggregations