SleelaVMCreator.sleela
lib/vm/creator/SleelaVMCreator.sleela · 173 line(s) · sleela
<< lib/vm/creator/SleelaVMCreator.sleela
SLeeLa VM Creator — construction coordinator.
Definition: Defines SleelaVMCreator, the entry point of the VM Creator Edition.
It reads a VM configuration, selects one SLVM generation from the generation
catalog, and produces a LIVE, runnable Secondary Sleela VM (lib/vm/SLVM) that
runs on the native Sleela VM substrate (lib/cpu/SLSleelaVM). It then hosts a
chosen Sleela CPU model (any SLCPURuntime / SL<ARCH>CPU) as that VM's
executor and runs a C, C++, Java, or Sleela program through the CPU — the
full Creator -> SLVM -> Sleela CPU -> program stack, in one object.
This is the bridge the Creator package previously only described in prose:
earlier generation classes (SleelaVMCore .. SLVMSovereign) are build-artifact
contracts; SleelaVMCreator is what actually instantiates and boots the SLVM
runtime and drives a guest CPU on it.
Construction model (realized):
configuration -> generation catalog -> create() boots SLVM
-> hostCpu(cpu) nests the Sleela CPU on the SLVM substrate
-> run(workload) compiles+maps a C/C++/Java/Sleela program and executes
Family: vm.creator. Composes SleelaVMGenerationCatalog; builds SLVM; hosts
SLCPURuntime; runs SLWorkload (SLCPUResource-bounded). >>
#sleela 2.5
material;
class SleelaVMCreator {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10550;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-09";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
SleelaVMGenerationCatalog catalog;
< selected SLVM generation (0 = /impl Core .. 11 Sovereign) >
int generation;
< catalog name for the generation >
String formalName;
< the live Secondary VM this creator built >
SLVM vm;
int heapWords;
int memoryWords;
< 1 => grant direct DMA to the built VM/CPU/program >
int dmaOption;
< 1 => grant native GPU access >
int gpuOption;
< 1 => build the VM to run on real host RAM >
int nativeRamOption;
void configure() {
catalog = new SleelaVMGenerationCatalog();
generation = 0;
formalName = "Core";
heapWords = 1 << 16;
memoryWords = 1 << 16;
dmaOption = 0; gpuOption = 0; nativeRamOption = 0;
}
< Size the VM the creator will build (optional; sensible defaults otherwise). >
void sizeVM(int heap, int memory) { heapWords = heap; memoryWords = memory; }
< Select a generation by version; validated against the catalog. >
boolean selectGeneration(int version) {
if (!catalog.validateVersion(version)) { return false; }
generation = version;
formalName = catalog.nameForVersion(version);
return true;
}
< Build and boot a LIVE Secondary Sleela VM for the selected generation. >
< This is the step the Creator README called "VM artifact" — here it is an >
< actual runnable SLVM instance, not just a packaged build plan. >
SLVM create() {
vm = new SLVM();
vm.configure(formalName);
< run on real host RAM >
if (nativeRamOption == 1) { vm.useNativeRam(); }
vm.boot(heapWords, memoryWords);
< apply opted-in acceleration >
if (dmaOption == 1) { vm.enableDMA(); }
if (gpuOption == 1) { vm.enableGPU(); }
return vm;
}
< apply opted-in acceleration >
if (dmaOption == 1) { vm.enableDMA(); }
if (gpuOption == 1) { vm.enableGPU(); }
return vm;
}
< Optional capabilities: request direct DMA and/or native GPU access for the >
< built VM. Call before create()/run() so the hosted CPU and its program get >
< them. These correspond to the DMA and GPU feature bits (SleelaVMFeatureBits). >
void requestDMA() { dmaOption = 1; if (vm != null) { vm.enableDMA(); } }
void requestGPU() { gpuOption = 1; if (vm != null) { vm.enableGPU(); } }
boolean dmaRequested() { return dmaOption == 1; }
boolean gpuRequested() { return gpuOption == 1; }
< Native-RAM option: build the VM to run on REAL host RAM instead of the >
< simulated store — for running outside simulation for procedural layment. >
< Call before create()/run(). Corresponds to the NATIVE_RAM feature bit. >
void requestNativeRam() { nativeRamOption = 1; }
boolean nativeRamRequested() { return nativeRamOption == 1; }
< Optional capabilities: request direct DMA and/or native GPU access for the >
< built VM. Call before create()/run() so the hosted CPU and its program get >
< them. These correspond to the DMA and GPU feature bits (SleelaVMFeatureBits). >
void requestDMA() { dmaOption = 1; if (vm != null) { vm.enableDMA(); } }
void requestGPU() { gpuOption = 1; if (vm != null) { vm.enableGPU(); } }
boolean dmaRequested() { return dmaOption == 1; }
boolean gpuRequested() { return gpuOption == 1; }
< Host a Sleela CPU model as the VM's executor (nested on the SLVM substrate). >
void installExecutor(SLCPURuntime cpu) {
if (vm == null) { create(); }
vm.hostCpu(cpu);
}
< Run a C / C++ / Java / Sleela program through the hosted CPU under the SLVM. >
< Returns the observable output. The whole stack — Creator built the SLVM, the >
< SLVM hosts the CPU, the CPU executes the program — resolves in this call. >
int runProgram(SLWorkload work, int budget) {
if (vm == null) { return -1; }
return vm.runGuestWorkload(work, budget);
}
< Convenience: do the entire stack in one call. >
< creator.run(generationVersion, cpu, workload, budget) >
int run(int version, SLCPURuntime cpu, SLWorkload work, int budget) {
selectGeneration(version);
create();
installExecutor(cpu);
return runProgram(work, budget);
}
SLVM builtVM() { return vm; }
int selectedGeneration(){ return generation; }
String generationName() { return formalName; }
boolean ready() { return vm != null && vm.active(); }
}