// Load all resources
final Map<String, byte[]> resources = loadSystemResource(piRegistry);
/* Now create the processor */
final BaseVmArchitecture arch = getArchitecture();
final NativeStream os = createNativeStream();
clsMgr = new VmSystemClassLoader(null/*classesURL*/, arch,
new BuildObjectResolver(os, this));
blockedObjects.add(clsMgr);
blockedObjects.add(clsMgr.getSharedStatics());
blockedObjects.add(clsMgr.getSharedStatics().getTable());
blockedObjects.add(clsMgr.getIsolatedStatics());
blockedObjects.add(clsMgr.getIsolatedStatics().getTable());
blockedObjects.add(resources);
clsMgr.setSystemRtJar(resources);
// Initialize the statics table.
initializeStatics(clsMgr.getSharedStatics());
if (debug) {
log("Building in DEBUG mode", Project.MSG_WARN);
}
// Create the VM
final VmImpl vm = new VmImpl(version, arch, clsMgr.getSharedStatics(), debug, clsMgr, piRegistry);
blockedObjects.add(vm);
blockedObjects.add(VmUtils.getVm().getCompiledMethods());
final VmProcessor proc = createProcessor(vm, clsMgr.getSharedStatics(),
clsMgr.getIsolatedStatics());
log("Building for " + proc.getCPUID());
final Label clInitCaller = new Label("$$clInitCaller");
VmType<?> systemClasses[] = VmType.initializeForBootImage(clsMgr);
for (int i = 0; i < systemClasses.length; i++) {
clsMgr.addLoadedClass(systemClasses[i].getName(),
systemClasses[i]);
}
// First copy the native kernel file
if (enableJNasm) {
compileKernel(os, asmSourceInfo);
} else {
copyKernel(os);
}
os.setObjectRef(bootHeapStart);
// Setup a call to our first java method
initImageHeader(os, clInitCaller, vm, piRegistry);
// Create the initial stack
createInitialStack(os, initialStack, initialStackPtr);
/* Now load the classes */
loadClass(VmMethodCode.class);
loadClass(Unsafe.class);
loadClass(VmSystemClassLoader.class);
loadClass(VmType[].class);
loadClass(Vm.class);
loadClass(VirtualMemoryRegion.class).link();
vm.getHeapManager().loadClasses(clsMgr);
loadClass(VmHeapManager.class);
loadClass(VmSharedStatics.class);
loadClass(VmIsolatedStatics.class);
loadClass(VmUtils.getVm().getHeapManager().getClass());
loadClass(HeapHelper.class);
loadClass("org.jnode.vm.HeapHelperImpl");
loadClass(VmUtils.getVm().getCompiledMethods().getClass());
loadClass(VmCompiledCode[].class);
loadSystemClasses(resources.keySet());
/* Now emit the processor */
os.getObjectRef(proc);
/* Let the compilers load its native symbol offsets */
final NativeCodeCompiler[] cmps = arch.getCompilers();
for (int i = 0; i < cmps.length; i++) {
final NativeCodeCompiler cmp = cmps[i];
cmp.initialize(clsMgr);
os.getObjectRef(cmp);
}
/* Let the test compilers load its native symbol offsets */
final NativeCodeCompiler[] testCmps = arch.getTestCompilers();
if (testCmps != null) {
for (int i = 0; i < testCmps.length; i++) {
final NativeCodeCompiler cmp = testCmps[i];
cmp.initialize(clsMgr);
os.getObjectRef(cmp);
}
}
log("Compiling using " + cmps[0].getName() + " and "
+ cmps[cmps.length - 1].getName() + " compilers");
// Initialize the IMT compiler.
arch.getIMTCompiler().initialize(clsMgr);
// Load the jarfile as byte-array
// copyJarFile(blockedObjects, piRegistry);
// Now emit all object images to the actual image