test: cover source rendering caches with suspended owner cycles
This commit is contained in:
@@ -246,3 +246,5 @@ Foreground REPL/events now retain a BeforeInput request while an existing idle l
|
||||
Source layout/paint now validate name-level read observations from Aster: each globals/builtins lookup records its text key and observed presence/value, while dictionary kind checks remain separate. Updating the REPL result `_` or another unread global no longer invalidates these frames solely because the whole globals dictionary version changed. Reading `_` still observes its value; adding a previously missing global correctly invalidates a builtin fallback. Ordinary native dictionary iteration/content reads retain whole-object version dependencies. Measurement cache hits replay their recorded observations into the outer solve; they do not drop dependencies merely because source execution was skipped. Cache observations contain borrowed handles (including object-valued names), add no GC roots, and never write comparison snapshots back into language objects. Invalid-name diagnostics report only identity/key, not captured values. General Block binding and other legacy readers keep their existing conservative object dependencies. See examples/global-dependencies.endor.
|
||||
|
||||
Source layout/paint and measurement caches exclude every presentation's private desktop identity, including the primary desktop captured by shared native visual methods. Per-window bookkeeping must not invalidate another window's source output. This exclusion does not cover managed Window objects, viewport input records, type definitions or business objects; their observed changes remain dependencies.
|
||||
|
||||
The gc-lifecycle example and endor_host regression combine a mounted Page/Block cycle, source measure/paint dependencies and an owner-scoped coroutine suspended on sleep. Closing the tab preserves a referenced Block's workflow; releasing the external Page/Task holders lets normal collection reclaim the cycle before the wait completes. Regression assertions check both the same-program object baseline and weak identities.
|
||||
|
||||
@@ -6175,6 +6175,72 @@ returned = button.dispatch(dispatched)"#,
|
||||
assert!(!session.is_faulted());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_render_caches_do_not_root_a_page_block_waiting_frame_cycle() {
|
||||
let (mut session, _) = ReplSession::load(
|
||||
include_str!("../examples/gc-lifecycle.endor"),
|
||||
"app.main",
|
||||
902,
|
||||
1,
|
||||
)
|
||||
.unwrap();
|
||||
let baseline = session
|
||||
.execute("ui.stats().objects", "app.main")
|
||||
.unwrap()
|
||||
.value;
|
||||
session.execute("mountCycle()", "app.main").unwrap();
|
||||
session.poll_tasks().unwrap();
|
||||
assert_eq!(
|
||||
session.execute("phase.value", "app.main").unwrap().value,
|
||||
"1"
|
||||
);
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("pending.value.status()", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"\"running\""
|
||||
);
|
||||
let globals = session.candidate.globals.unwrap();
|
||||
let Value::Object(holder) = session
|
||||
.candidate
|
||||
.vm
|
||||
.dict_get(globals, &Value::Text("holder".into()))
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("holder")
|
||||
};
|
||||
let Value::Object(page) = session.candidate.vm.get_attr(holder, "value").unwrap() else {
|
||||
panic!("page")
|
||||
};
|
||||
let rect = crate::block::resolve(session.candidate.vm.object_store(), page)
|
||||
.unwrap()
|
||||
.1
|
||||
.children[0]
|
||||
.block;
|
||||
let page_weak = session.candidate.vm.object_store().downgrade(page).unwrap();
|
||||
let rect_weak = session.candidate.vm.object_store().downgrade(rect).unwrap();
|
||||
session.execute("holder.value.close()", "app.main").unwrap();
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("pending.value.status()", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
"\"running\""
|
||||
);
|
||||
session.execute("releaseCycle()", "app.main").unwrap();
|
||||
assert_eq!(
|
||||
session
|
||||
.execute("ui.stats().objects", "app.main")
|
||||
.unwrap()
|
||||
.value,
|
||||
baseline
|
||||
);
|
||||
assert!(session.candidate.vm.upgrade(page_weak).unwrap().is_none());
|
||||
assert!(session.candidate.vm.upgrade(rect_weak).unwrap().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binding_tokens_do_not_retain_hidden_targets_and_compute_is_read_only() {
|
||||
let mut session = ReplSession::new(221).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user