feat(runtime): implement shared transactional memcard with async saves
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
This commit is contained in:
@@ -65,6 +65,7 @@ pub enum LifecycleRole {
|
||||
None = 0,
|
||||
BeforePause = 1,
|
||||
BeforeResume = 2,
|
||||
MemcardBoot = 3,
|
||||
}
|
||||
impl TryFrom<u8> for LifecycleRole {
|
||||
type Error = E;
|
||||
@@ -73,6 +74,7 @@ impl TryFrom<u8> for LifecycleRole {
|
||||
0 => Ok(Self::None),
|
||||
1 => Ok(Self::BeforePause),
|
||||
2 => Ok(Self::BeforeResume),
|
||||
3 => Ok(Self::MemcardBoot),
|
||||
_ => Err(E::new(C::InvalidRegistry, R::LifecycleRole)),
|
||||
}
|
||||
}
|
||||
@@ -254,7 +256,7 @@ pub struct FunctionLayout {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Registry {
|
||||
lifecycle_hooks: [Option<FunctionId>; 2],
|
||||
lifecycle_hooks: [Option<FunctionId>; 3],
|
||||
declarations: RegistryDeclarations,
|
||||
layouts: Vec<TypeLayout>,
|
||||
functions: Vec<FunctionLayout>,
|
||||
@@ -267,6 +269,7 @@ impl Registry {
|
||||
LifecycleRole::None => None,
|
||||
LifecycleRole::BeforePause => self.lifecycle_hooks[0],
|
||||
LifecycleRole::BeforeResume => self.lifecycle_hooks[1],
|
||||
LifecycleRole::MemcardBoot => self.lifecycle_hooks[2],
|
||||
}
|
||||
}
|
||||
pub fn declarations(&self) -> &RegistryDeclarations {
|
||||
@@ -376,16 +379,25 @@ impl Registry {
|
||||
});
|
||||
}
|
||||
}
|
||||
let mut lifecycle_hooks = [None; 2];
|
||||
let mut lifecycle_hooks = [None; 3];
|
||||
let mut functions = b.vector(d.functions.len(), Q::RegistryBytes)?;
|
||||
let mut ranges = b.vector(d.functions.len(), Q::TemporaryBytes)?;
|
||||
for (i, f) in d.functions.iter().enumerate() {
|
||||
b.work(1)?;
|
||||
if f.lifecycle_role != LifecycleRole::None {
|
||||
let invalid = i == 0
|
||||
|| !f.signature.parameters.is_empty()
|
||||
|| !f.signature.results.is_empty()
|
||||
|| !f.captures.is_empty();
|
||||
let signature_valid = if f.lifecycle_role == LifecycleRole::MemcardBoot {
|
||||
f.signature.parameters.len() == 1
|
||||
&& f.signature.results.len() == 1
|
||||
&& d.types
|
||||
.get(f.signature.parameters[0].type_id.0 as usize)
|
||||
.is_some_and(|t| t.kind == TypeKind::Builtin(BuiltinId::INT64))
|
||||
&& d.types
|
||||
.get(f.signature.results[0].0 as usize)
|
||||
.is_some_and(|t| t.kind == TypeKind::Builtin(BuiltinId::INT32))
|
||||
} else {
|
||||
f.signature.parameters.is_empty() && f.signature.results.is_empty()
|
||||
};
|
||||
let invalid = i == 0 || !signature_valid || !f.captures.is_empty();
|
||||
if invalid {
|
||||
return Err(E::new(C::InvalidEntrypoint, R::LifecycleSignature)
|
||||
.in_section(1)
|
||||
|
||||
Reference in New Issue
Block a user