SLOpcodeWarmer.sleela
lib/opcodes/running/SLOpcodeWarmer.sleela · 105 line(s) · sleela
<< lib/opcodes/running/SLOpcodeWarmer.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLOpcodeWarmer, which warms opcodes and groups ahead of
execution so they are ready to fire the instant they are reached.
Role: "warming" prepares opcodes before they run — arming each one and asking
the VM to pre-stage the next instruction so the first fire of a hot path has
no cold-start cost. A warmer can warm a single opcode, a whole group, or a
group set, and it keeps a tally so the reactive layer can tell whether a
path is warm before gating it in.
Family: opcodes.running. Native VM/OS work crosses an explicit bridge. >>
#sleela 2.5
material;
< Unified SLeeLa standard-library front-end object. >
class SLOpcodeWarmer {
< ---- 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 = 10193;
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-05";
< 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; }
< the VM frame to pre-stage against >
int frame;
< total opcodes warmed >
int warmedOps;
int state;
void configure(int vmFrame) {
frame = vmFrame;
warmedOps = 0;
state = 1;
}
void enable() { state = 1; }
void disable() { state = 0; }
boolean active() { return state == 1; }
int warmedCount() { return warmedOps; }
< Warm one opcode: arm it in SLeeLa and ask the VM to pre-stage its fetch. >
boolean warmOne(SLOpcodeBase op) {
if (!active() || op == null) { return false; }
op.arm();
native sleela_opcode_prestage(frame, op.opcode());
warmedOps = warmedOps + 1;
return true;
}
< Warm a whole group (arms its members and pre-stages each). >
int warmGroup(SLOpcodeGroup group) {
if (!active() || group == null) { return 0; }
int warmed = 0;
for (int i = 0; i < group.size(); i = i + 1) {
if (warmOne(group.at(i))) { warmed = warmed + 1; }
}
group.warm();
return warmed;
}
< Warm every group in a set. >
int warmSet(SLOpcodeGroupSet set) {
if (!active() || set == null) { return 0; }
int warmed = 0;
for (int i = 0; i < set.size(); i = i + 1) {
warmed = warmed + warmGroup(set.at(i));
}
return warmed;
}
}