Unverified Commit 76a15d8d authored by Luke Sandberg's avatar Luke Sandberg Committed by GitHub

fix(turbo-tasks-backend): use correct TaskDataCategory for is_immutable check (#88331)

## Fix task immutability check by using correct TaskDataCategory

### What?
This PR fixes a bug in the task immutability check by ensuring we use `TaskDataCategory::Meta` instead of `TaskDataCategory::Data` when checking if dependent tasks are immutable.

### Why?
The immutable flag is stored in the Meta category, but we were incorrectly checking the Data category. This could prevent us from reading the immutable flag if Meta hadn't been restored for the task.

### How?
- Changed the category from `TaskDataCategory::Data` to `TaskDataCategory::Meta` when reading tasks where we needed `immutability`
- Added a clarifying comment explaining why we use the Meta category
- Moved the `is_immutable()` implementation from `TaskGuardImpl` to the `TaskGuard` trait with a default implementation that uses `has_key(&CachedDataItemKey::Immutable {})` which enforces correct access modes
parent 17acc812
......@@ -2133,7 +2133,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
if let Some(dependencies) = task_dependencies_for_immutable
&& dependencies
.iter()
.all(|&task_id| ctx.task(task_id, TaskDataCategory::Data).is_immutable())
.all(|&task_id| ctx.task(task_id, TaskDataCategory::Meta).is_immutable())
{
is_now_immutable = true;
}
......
......@@ -662,7 +662,9 @@ pub trait TaskGuard: Debug {
/// Only returns Some once per task.
/// It returns a set of tasks and which info is needed.
fn prefetch(&mut self) -> Option<FxIndexMap<TaskId, TaskDataCategory>>;
fn is_immutable(&self) -> bool;
fn is_immutable(&self) -> bool {
self.has_key(&CachedDataItemKey::Immutable {})
}
fn is_dirty(&self) -> bool {
get!(self, Dirty).is_some_and(|dirtyness| match dirtyness {
Dirtyness::Dirty => true,
......@@ -1007,10 +1009,6 @@ impl<B: BackingStorage> TaskGuard for TaskGuardImpl<'_, B> {
.collect::<FxIndexMap<_, _>>();
(map.len() > 1).then_some(map)
}
fn is_immutable(&self) -> bool {
self.task.contains_key(&CachedDataItemKey::Immutable {})
}
}
macro_rules! impl_operation {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment