@@ -13,7 +13,8 @@ use serde::{Deserialize, Serialize};
13
13
use tracing:: Instrument ;
14
14
use turbo_rcstr:: RcStr ;
15
15
use turbo_tasks:: {
16
- debug:: ValueDebugFormat , trace:: TraceRawVcs , NonLocalValue , ResolvedVc , TryJoinIterExt , Vc ,
16
+ debug:: ValueDebugFormat , trace:: TraceRawVcs , NonLocalValue , ResolvedVc , TaskInput ,
17
+ TryJoinIterExt , Vc ,
17
18
} ;
18
19
19
20
use crate :: {
@@ -24,13 +25,16 @@ use crate::{
24
25
SingleModuleGraphNode ,
25
26
} ,
26
27
} ;
27
-
28
28
#[ derive(
29
29
Clone , Debug , Default , PartialEq , Serialize , Deserialize , TraceRawVcs , ValueDebugFormat ,
30
30
) ]
31
31
pub struct RoaringBitmapWrapper ( #[ turbo_tasks( trace_ignore) ] RoaringBitmap ) ;
32
32
33
33
impl RoaringBitmapWrapper {
34
+ pub fn new ( value : RoaringBitmap ) -> RoaringBitmapWrapper {
35
+ RoaringBitmapWrapper ( value)
36
+ }
37
+
34
38
/// Whether `self` contains bits that are not in `other`
35
39
///
36
40
/// The existing `is_superset` method also returns true for equal sets
@@ -42,6 +46,11 @@ impl RoaringBitmapWrapper {
42
46
self . 0
43
47
}
44
48
}
49
+ impl TaskInput for RoaringBitmapWrapper {
50
+ fn is_transient ( & self ) -> bool {
51
+ false
52
+ }
53
+ }
45
54
unsafe impl NonLocalValue for RoaringBitmapWrapper { }
46
55
47
56
// RoaringBitmap doesn't impl Eq: https://github.com/RoaringBitmap/roaring-rs/issues/302
@@ -77,8 +86,32 @@ impl Hash for RoaringBitmapWrapper {
77
86
}
78
87
79
88
#[ turbo_tasks:: value( transparent) ]
89
+ pub struct RoaringBitmapWrapperCell ( RoaringBitmapWrapper ) ;
90
+
91
+ #[ turbo_tasks:: value]
80
92
pub struct ChunkGroupInfo ( FxHashMap < ResolvedVc < Box < dyn Module > > , RoaringBitmapWrapper > ) ;
81
93
94
+ #[ turbo_tasks:: value_impl]
95
+ impl ChunkGroupInfo {
96
+ #[ turbo_tasks:: function]
97
+ pub fn get ( & self , module : ResolvedVc < Box < dyn Module > > ) -> Result < Vc < RoaringBitmapWrapperCell > > {
98
+ Ok ( Vc :: cell ( self . get_individual ( module) ?. clone ( ) ) )
99
+ }
100
+ }
101
+
102
+ impl ChunkGroupInfo {
103
+ pub fn get_individual (
104
+ & self ,
105
+ module : ResolvedVc < Box < dyn Module > > ,
106
+ ) -> Result < & RoaringBitmapWrapper > {
107
+ if let Some ( chunk_group) = self . 0 . get ( & module) {
108
+ Ok ( chunk_group)
109
+ } else {
110
+ anyhow:: bail!( "Module has no chunk group info" ) ;
111
+ }
112
+ }
113
+ }
114
+
82
115
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
83
116
enum ChunkGroup {
84
117
/// e.g. a page
@@ -349,7 +382,7 @@ pub async fn compute_chunk_group_info(graph: &ModuleGraph) -> Result<Vc<ChunkGro
349
382
span. record ( "visit_count" , visit_count) ;
350
383
span. record ( "chunk_group_count" , next_chunk_group_id) ;
351
384
352
- Ok ( Vc :: cell ( module_chunk_groups) )
385
+ Ok ( ChunkGroupInfo ( module_chunk_groups) . cell ( ) )
353
386
}
354
387
. instrument ( span_outer)
355
388
. await
0 commit comments