Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
7b52536c
Unverified
Commit
7b52536c
authored
Apr 17, 2026
by
Luke Sandberg
Committed by
GitHub
Apr 17, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename MagicAny (#92918)
s/MagicAny/DynTaskInputs/ essentially
parent
1464f8f1
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
146 additions
and
130 deletions
+146
-130
mod.rs
turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
+3
-3
mod.rs
...k/crates/turbo-tasks-backend/src/backend/operation/mod.rs
+3
-3
backing_storage.rs
turbopack/crates/turbo-tasks-backend/src/backing_storage.rs
+4
-4
kv_backing_storage.rs
...pack/crates/turbo-tasks-backend/src/kv_backing_storage.rs
+2
-2
func.rs
turbopack/crates/turbo-tasks-macros/src/func.rs
+8
-8
lib.rs
turbopack/crates/turbo-tasks-testing/src/lib.rs
+6
-6
backend.rs
turbopack/crates/turbo-tasks/src/backend.rs
+9
-9
dyn_task_inputs.rs
turbopack/crates/turbo-tasks/src/dyn_task_inputs.rs
+30
-30
lib.rs
turbopack/crates/turbo-tasks/src/lib.rs
+4
-2
macro_helpers.rs
turbopack/crates/turbo-tasks/src/macro_helpers.rs
+1
-1
manager.rs
turbopack/crates/turbo-tasks/src/manager.rs
+12
-12
native_function.rs
turbopack/crates/turbo-tasks/src/native_function.rs
+40
-26
function.rs
turbopack/crates/turbo-tasks/src/task/function.rs
+14
-14
local_task.rs
turbopack/crates/turbo-tasks/src/task/local_task.rs
+7
-7
task_input.rs
turbopack/crates/turbo-tasks/src/task/task_input.rs
+2
-2
value_type.rs
turbopack/crates/turbo-tasks/src/value_type.rs
+1
-1
No files found.
turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
View file @
7b52536c
...
@@ -28,7 +28,7 @@ use tracing::{Span, trace_span};
...
@@ -28,7 +28,7 @@ use tracing::{Span, trace_span};
use
turbo_bincode
::{
TurboBincodeBuffer
,
new_turbo_bincode_decoder
,
new_turbo_bincode_encoder
};
use
turbo_bincode
::{
TurboBincodeBuffer
,
new_turbo_bincode_decoder
,
new_turbo_bincode_encoder
};
use
turbo_tasks
::{
use
turbo_tasks
::{
CellId
,
FxDashMap
,
RawVc
,
ReadCellOptions
,
ReadCellTracking
,
ReadConsistency
,
CellId
,
FxDashMap
,
RawVc
,
ReadCellOptions
,
ReadCellTracking
,
ReadConsistency
,
ReadOutputOptions
,
ReadTracking
,
SharedReference
,
Stack
MagicAny
,
TRANSIENT_TASK_BIT
,
ReadOutputOptions
,
ReadTracking
,
SharedReference
,
Stack
DynTaskInputs
,
TRANSIENT_TASK_BIT
,
TaskExecutionReason
,
TaskId
,
TaskPersistence
,
TaskPriority
,
TraitTypeId
,
TurboTasksBackendApi
,
TaskExecutionReason
,
TaskId
,
TaskPersistence
,
TaskPriority
,
TraitTypeId
,
TurboTasksBackendApi
,
TurboTasksPanic
,
ValueTypeId
,
TurboTasksPanic
,
ValueTypeId
,
backend
::{
backend
::{
...
@@ -1510,7 +1510,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
...
@@ -1510,7 +1510,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
parent_task
:
Option
<
TaskId
>
,
parent_task
:
Option
<
TaskId
>
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
TurboTasksBackend
<
B
>>
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
TurboTasksBackend
<
B
>>
,
...
@@ -3449,7 +3449,7 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
...
@@ -3449,7 +3449,7 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
parent_task
:
Option
<
TaskId
>
,
parent_task
:
Option
<
TaskId
>
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
Self
>
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
Self
>
,
...
...
turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs
View file @
7b52536c
...
@@ -18,7 +18,7 @@ use tracing::info_span;
...
@@ -18,7 +18,7 @@ use tracing::info_span;
#[cfg(feature
=
"trace_prepare_tasks"
)]
#[cfg(feature
=
"trace_prepare_tasks"
)]
use
tracing
::
trace_span
;
use
tracing
::
trace_span
;
use
turbo_tasks
::{
use
turbo_tasks
::{
CellId
,
FxIndexMap
,
MagicAny
,
RawVc
,
TaskExecutionReason
,
TaskId
,
TaskPriority
,
CellId
,
DynTaskInputs
,
FxIndexMap
,
RawVc
,
TaskExecutionReason
,
TaskId
,
TaskPriority
,
TurboTasksBackendApi
,
TurboTasksCallApi
,
TypedSharedReference
,
backend
::
CachedTaskType
,
TurboTasksBackendApi
,
TurboTasksCallApi
,
TypedSharedReference
,
backend
::
CachedTaskType
,
macro_helpers
::
NativeFunction
,
macro_helpers
::
NativeFunction
,
};
};
...
@@ -110,7 +110,7 @@ pub trait ExecuteContext<'e>: Sized {
...
@@ -110,7 +110,7 @@ pub trait ExecuteContext<'e>: Sized {
&
mut
self
,
&
mut
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
Option
<
(
TaskId
,
Arc
<
CachedTaskType
>
)
>
;
)
->
Option
<
(
TaskId
,
Arc
<
CachedTaskType
>
)
>
;
}
}
...
@@ -982,7 +982,7 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> {
...
@@ -982,7 +982,7 @@ impl<'e, B: BackingStorage> ExecuteContext<'e> for ExecuteContextImpl<'e, B> {
&
mut
self
,
&
mut
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
Option
<
(
TaskId
,
Arc
<
CachedTaskType
>
)
>
{
)
->
Option
<
(
TaskId
,
Arc
<
CachedTaskType
>
)
>
{
if
!
self
.backend
.should_restore
()
{
if
!
self
.backend
.should_restore
()
{
return
None
;
return
None
;
...
...
turbopack/crates/turbo-tasks-backend/src/backing_storage.rs
View file @
7b52536c
...
@@ -5,7 +5,7 @@ use either::Either;
...
@@ -5,7 +5,7 @@ use either::Either;
use
smallvec
::
SmallVec
;
use
smallvec
::
SmallVec
;
use
turbo_bincode
::
TurboBincodeBuffer
;
use
turbo_bincode
::
TurboBincodeBuffer
;
use
turbo_tasks
::{
use
turbo_tasks
::{
MagicAny
,
RawVc
,
TaskId
,
backend
::
CachedTaskType
,
macro_helpers
::
NativeFunction
,
DynTaskInputs
,
RawVc
,
TaskId
,
backend
::
CachedTaskType
,
macro_helpers
::
NativeFunction
,
};
};
use
turbo_tasks_hash
::
Xxh3Hash64Hasher
;
use
turbo_tasks_hash
::
Xxh3Hash64Hasher
;
...
@@ -52,7 +52,7 @@ pub fn compute_task_type_hash(task_type: &CachedTaskType) -> TaskTypeHash {
...
@@ -52,7 +52,7 @@ pub fn compute_task_type_hash(task_type: &CachedTaskType) -> TaskTypeHash {
pub
fn
compute_task_type_hash_from_components
(
pub
fn
compute_task_type_hash_from_components
(
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
TaskTypeHash
{
)
->
TaskTypeHash
{
let
mut
hasher
=
Xxh3Hash64Hasher
::
new
();
let
mut
hasher
=
Xxh3Hash64Hasher
::
new
();
CachedTaskType
::
hash_encode_components
(
native_fn
,
this
,
arg
,
&
mut
hasher
);
CachedTaskType
::
hash_encode_components
(
native_fn
,
this
,
arg
,
&
mut
hasher
);
...
@@ -103,7 +103,7 @@ pub trait BackingStorageSealed: 'static + Send + Sync {
...
@@ -103,7 +103,7 @@ pub trait BackingStorageSealed: 'static + Send + Sync {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
;
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
;
/// Looks up and decodes persisted data for a single task, updating the provided storage with
/// Looks up and decodes persisted data for a single task, updating the provided storage with
/// data from the database in the given category.
/// data from the database in the given category.
...
@@ -174,7 +174,7 @@ where
...
@@ -174,7 +174,7 @@ where
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
{
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
{
either
::
for_both!
(
self
,
this_impl
=>
this_impl
.lookup_task_candidates
(
native_fn
,
this
,
arg
))
either
::
for_both!
(
self
,
this_impl
=>
this_impl
.lookup_task_candidates
(
native_fn
,
this
,
arg
))
}
}
...
...
turbopack/crates/turbo-tasks-backend/src/kv_backing_storage.rs
View file @
7b52536c
...
@@ -9,7 +9,7 @@ use anyhow::{Context, Result};
...
@@ -9,7 +9,7 @@ use anyhow::{Context, Result};
use
smallvec
::
SmallVec
;
use
smallvec
::
SmallVec
;
use
turbo_bincode
::{
new_turbo_bincode_decoder
,
turbo_bincode_decode
,
turbo_bincode_encode
};
use
turbo_bincode
::{
new_turbo_bincode_decoder
,
turbo_bincode_decode
,
turbo_bincode_encode
};
use
turbo_tasks
::{
use
turbo_tasks
::{
MagicAny
,
RawVc
,
TaskId
,
DynTaskInputs
,
RawVc
,
TaskId
,
macro_helpers
::
NativeFunction
,
macro_helpers
::
NativeFunction
,
panic_hooks
::{
PanicHookGuard
,
register_panic_hook
},
panic_hooks
::{
PanicHookGuard
,
register_panic_hook
},
parallel
,
parallel
,
...
@@ -302,7 +302,7 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
...
@@ -302,7 +302,7 @@ impl<T: KeyValueDatabase + Send + Sync + 'static> BackingStorageSealed
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
{
)
->
Result
<
SmallVec
<
[
TaskId
;
1
]
>>
{
let
inner
=
&*
self
.inner
;
let
inner
=
&*
self
.inner
;
if
inner
.database
.is_empty
()
{
if
inner
.database
.is_empty
()
{
...
...
turbopack/crates/turbo-tasks-macros/src/func.rs
View file @
7b52536c
...
@@ -452,20 +452,20 @@ impl TurboFn<'_> {
...
@@ -452,20 +452,20 @@ impl TurboFn<'_> {
let
exposed_input_types
:
Vec
<
_
>
=
self
.exposed_input_types
()
.collect
();
let
exposed_input_types
:
Vec
<
_
>
=
self
.exposed_input_types
()
.collect
();
return
Some
(
FilterTraitCallArgsTokens
{
return
Some
(
FilterTraitCallArgsTokens
{
filter_owned
:
quote!
{
filter_owned
:
quote!
{
|
arg
:
&
mut
dyn
turbo_tasks
::
Stack
MagicAny
|
{
|
arg
:
&
mut
dyn
turbo_tasks
::
Stack
DynTaskInputs
|
{
let
(
#
(
#
exposed_input_idents
,)
*
)
=
let
(
#
(
#
exposed_input_idents
,)
*
)
=
turbo_tasks
::
macro_helpers
turbo_tasks
::
macro_helpers
::
downcast_stack_args_owned
::
<
(
#
(
#
exposed_input_types
,)
*
)
>
(
arg
);
::
downcast_stack_args_owned
::
<
(
#
(
#
exposed_input_types
,)
*
)
>
(
arg
);
turbo_tasks
::
Owned
MagicAny
::
new
(
turbo_tasks
::
Owned
StackDynTaskInputs
::
new
(
::
std
::
boxed
::
Box
::
new
((
#
(
#
inline_input_idents
,)
*
))
::
std
::
boxed
::
Box
::
new
((
#
(
#
inline_input_idents
,)
*
))
)
)
}
}
},
},
filter_and_resolve
:
quote!
{
filter_and_resolve
:
quote!
{
|
magic_any
|
{
|
dyn_task_inputs
:
&
dyn
turbo_tasks
::
DynTaskInputs
|
{
Box
::
pin
(
async
move
{
Box
::
pin
(
async
move
{
let
(
#
(
#
exposed_input_idents
,)
*
)
=
turbo_tasks
::
macro_helpers
let
(
#
(
#
exposed_input_idents
,)
*
)
=
turbo_tasks
::
macro_helpers
::
downcast_args_ref
::
<
(
#
(
#
exposed_input_types
,)
*
)
>
(
magic_any
);
::
downcast_args_ref
::
<
(
#
(
#
exposed_input_types
,)
*
)
>
(
dyn_task_inputs
);
let
resolved
=
(
#
(
let
resolved
=
(
#
(
<
_
as
turbo_tasks
::
TaskInput
>
::
resolve_input
(
<
_
as
turbo_tasks
::
TaskInput
>
::
resolve_input
(
#
inline_input_idents
#
inline_input_idents
...
@@ -473,7 +473,7 @@ impl TurboFn<'_> {
...
@@ -473,7 +473,7 @@ impl TurboFn<'_> {
)
*
);
)
*
);
Ok
(
Ok
(
::
std
::
boxed
::
Box
::
new
(
resolved
)
::
std
::
boxed
::
Box
::
new
(
resolved
)
as
::
std
::
boxed
::
Box
<
dyn
turbo_tasks
::
MagicAny
>
as
::
std
::
boxed
::
Box
<
dyn
turbo_tasks
::
DynTaskInputs
>
)
)
})
})
}
}
...
@@ -558,7 +558,7 @@ impl TurboFn<'_> {
...
@@ -558,7 +558,7 @@ impl TurboFn<'_> {
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
this
=
#
converted_this
;
let
this
=
#
converted_this
;
let
persistence
=
#
persistence
;
let
persistence
=
#
persistence
;
let
mut
arg
=
turbo_tasks
::
Stack
MagicAny
Slot
::
new
(
inputs
);
let
mut
arg
=
turbo_tasks
::
Stack
DynTaskInputs
Slot
::
new
(
inputs
);
static
TRAIT_METHOD
:
turbo_tasks
::
macro_helpers
::
Lazy
<&
'static
turbo_tasks
::
TraitMethod
>
=
static
TRAIT_METHOD
:
turbo_tasks
::
macro_helpers
::
Lazy
<&
'static
turbo_tasks
::
TraitMethod
>
=
turbo_tasks
::
macro_helpers
::
Lazy
::
new
(||
#
trait_type_ident
.get
(
stringify!
(
#
ident
)));
turbo_tasks
::
macro_helpers
::
Lazy
::
new
(||
#
trait_type_ident
.get
(
stringify!
(
#
ident
)));
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
...
@@ -588,7 +588,7 @@ impl TurboFn<'_> {
...
@@ -588,7 +588,7 @@ impl TurboFn<'_> {
let
this
=
#
converted_this
;
let
this
=
#
converted_this
;
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
persistence
=
#
persistence
;
let
persistence
=
#
persistence
;
let
mut
arg
=
turbo_tasks
::
Stack
MagicAny
Slot
::
new
(
inputs
);
let
mut
arg
=
turbo_tasks
::
Stack
DynTaskInputs
Slot
::
new
(
inputs
);
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
turbo_tasks
::
dynamic_call
(
turbo_tasks
::
dynamic_call
(
&
#
native_function_ident
,
&
#
native_function_ident
,
...
@@ -606,7 +606,7 @@ impl TurboFn<'_> {
...
@@ -606,7 +606,7 @@ impl TurboFn<'_> {
#
assertions
#
assertions
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
inputs
=
(
#
(
#
inputs
,)
*
);
let
persistence
=
#
persistence
;
let
persistence
=
#
persistence
;
let
mut
arg
=
turbo_tasks
::
Stack
MagicAny
Slot
::
new
(
inputs
);
let
mut
arg
=
turbo_tasks
::
Stack
DynTaskInputs
Slot
::
new
(
inputs
);
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
<
#
output
as
turbo_tasks
::
task
::
TaskOutput
>
::
try_from_raw_vc
(
turbo_tasks
::
dynamic_call
(
turbo_tasks
::
dynamic_call
(
&
#
native_function_ident
,
&
#
native_function_ident
,
...
...
turbopack/crates/turbo-tasks-testing/src/lib.rs
View file @
7b52536c
...
@@ -17,8 +17,8 @@ use rustc_hash::FxHashMap;
...
@@ -17,8 +17,8 @@ use rustc_hash::FxHashMap;
use
smallvec
::
SmallVec
;
use
smallvec
::
SmallVec
;
use
tokio
::
sync
::
mpsc
::
Receiver
;
use
tokio
::
sync
::
mpsc
::
Receiver
;
use
turbo_tasks
::{
use
turbo_tasks
::{
CellId
,
ExecutionId
,
InvalidationReason
,
LocalTaskId
,
MagicAny
,
RawVc
,
ReadCellOptions
,
CellId
,
DynTaskInputs
,
ExecutionId
,
InvalidationReason
,
LocalTaskId
,
RawVc
,
ReadCellOptions
,
ReadOutputOptions
,
Stack
MagicAny
,
TaskId
,
TaskPersistence
,
TraitTypeId
,
TurboTasksApi
,
ReadOutputOptions
,
Stack
DynTaskInputs
,
TaskId
,
TaskPersistence
,
TraitTypeId
,
TurboTasksApi
,
TurboTasksCallApi
,
TurboTasksCallApi
,
backend
::{
CellContent
,
TaskCollectiblesMap
,
TypedCellContent
,
VerificationMode
},
backend
::{
CellContent
,
TaskCollectiblesMap
,
TypedCellContent
,
VerificationMode
},
event
::{
Event
,
EventListener
},
event
::{
Event
,
EventListener
},
...
@@ -48,7 +48,7 @@ impl VcStorage {
...
@@ -48,7 +48,7 @@ impl VcStorage {
&
self
,
&
self
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
this_arg
:
Option
<
RawVc
>
,
this_arg
:
Option
<
RawVc
>
,
arg
:
Box
<
dyn
MagicAny
>
,
arg
:
Box
<
dyn
DynTaskInputs
>
,
)
->
RawVc
{
)
->
RawVc
{
let
this
=
self
.this
.upgrade
()
.unwrap
();
let
this
=
self
.this
.upgrade
()
.unwrap
();
let
handle
=
tokio
::
runtime
::
Handle
::
current
();
let
handle
=
tokio
::
runtime
::
Handle
::
current
();
...
@@ -97,7 +97,7 @@ impl TurboTasksCallApi for VcStorage {
...
@@ -97,7 +97,7 @@ impl TurboTasksCallApi for VcStorage {
&
self
,
&
self
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
_persistence
:
TaskPersistence
,
_persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
self
.dynamic_call
(
func
,
this
,
arg
.take_box
())
self
.dynamic_call
(
func
,
this
,
arg
.take_box
())
...
@@ -106,7 +106,7 @@ impl TurboTasksCallApi for VcStorage {
...
@@ -106,7 +106,7 @@ impl TurboTasksCallApi for VcStorage {
&
self
,
&
self
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
func
:
&
'static
turbo_tasks
::
macro_helpers
::
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
_persistence
:
TaskPersistence
,
_persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
self
.dynamic_call
(
func
,
this
,
arg
.take_box
())
self
.dynamic_call
(
func
,
this
,
arg
.take_box
())
...
@@ -116,7 +116,7 @@ impl TurboTasksCallApi for VcStorage {
...
@@ -116,7 +116,7 @@ impl TurboTasksCallApi for VcStorage {
&
self
,
&
self
,
_trait_type
:
&
'static
turbo_tasks
::
TraitMethod
,
_trait_type
:
&
'static
turbo_tasks
::
TraitMethod
,
_this
:
RawVc
,
_this
:
RawVc
,
_arg
:
&
mut
dyn
Stack
MagicAny
,
_arg
:
&
mut
dyn
Stack
DynTaskInputs
,
_persistence
:
TaskPersistence
,
_persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
unreachable!
()
unreachable!
()
...
...
turbopack/crates/turbo-tasks/src/backend.rs
View file @
7b52536c
...
@@ -31,9 +31,9 @@ use crate::{
...
@@ -31,9 +31,9 @@ use crate::{
RawVc
,
ReadCellOptions
,
ReadOutputOptions
,
ReadRef
,
SharedReference
,
TaskId
,
TaskIdSet
,
RawVc
,
ReadCellOptions
,
ReadOutputOptions
,
ReadRef
,
SharedReference
,
TaskId
,
TaskIdSet
,
TaskPriority
,
TraitRef
,
TraitTypeId
,
TurboTasksCallApi
,
TurboTasksPanic
,
ValueTypeId
,
TaskPriority
,
TraitRef
,
TraitTypeId
,
TurboTasksCallApi
,
TurboTasksPanic
,
ValueTypeId
,
VcValueTrait
,
VcValueType
,
VcValueTrait
,
VcValueType
,
dyn_task_inputs
::{
DynTaskInputs
,
StackDynTaskInputs
},
event
::
EventListener
,
event
::
EventListener
,
macro_helpers
::
NativeFunction
,
macro_helpers
::
NativeFunction
,
magic_any
::{
MagicAny
,
StackMagicAny
},
manager
::{
TaskPersistence
,
TurboTasksBackendApi
},
manager
::{
TaskPersistence
,
TurboTasksBackendApi
},
raw_vc
::
CellId
,
raw_vc
::
CellId
,
registry
,
registry
,
...
@@ -80,7 +80,7 @@ impl Debug for TransientTaskType {
...
@@ -80,7 +80,7 @@ impl Debug for TransientTaskType {
pub
struct
CachedTaskType
{
pub
struct
CachedTaskType
{
pub
native_fn
:
&
'static
NativeFunction
,
pub
native_fn
:
&
'static
NativeFunction
,
pub
this
:
Option
<
RawVc
>
,
pub
this
:
Option
<
RawVc
>
,
pub
arg
:
Box
<
dyn
MagicAny
>
,
pub
arg
:
Box
<
dyn
DynTaskInputs
>
,
}
}
impl
CachedTaskType
{
impl
CachedTaskType
{
...
@@ -163,7 +163,7 @@ impl CachedTaskType {
...
@@ -163,7 +163,7 @@ impl CachedTaskType {
hasher
:
&
impl
BuildHasher
,
hasher
:
&
impl
BuildHasher
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
u64
{
)
->
u64
{
use
std
::
hash
::
Hasher
;
use
std
::
hash
::
Hasher
;
let
mut
state
=
hasher
.build_hasher
();
let
mut
state
=
hasher
.build_hasher
();
...
@@ -180,7 +180,7 @@ impl CachedTaskType {
...
@@ -180,7 +180,7 @@ impl CachedTaskType {
pub
fn
hash_encode_components
<
H
:
DeterministicHasher
>
(
pub
fn
hash_encode_components
<
H
:
DeterministicHasher
>
(
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
hasher
:
&
mut
H
,
hasher
:
&
mut
H
,
)
{
)
{
let
fn_id
=
registry
::
get_function_id
(
native_fn
);
let
fn_id
=
registry
::
get_function_id
(
native_fn
);
...
@@ -197,7 +197,7 @@ impl CachedTaskType {
...
@@ -197,7 +197,7 @@ impl CachedTaskType {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
)
->
bool
{
)
->
bool
{
std
::
ptr
::
eq
(
self
.native_fn
,
native_fn
)
&&
self
.this
==
this
&&
&*
self
.arg
==
arg
std
::
ptr
::
eq
(
self
.native_fn
,
native_fn
)
&&
self
.this
==
this
&&
&*
self
.arg
==
arg
}
}
...
@@ -655,7 +655,7 @@ pub trait Backend: Sync + Send {
...
@@ -655,7 +655,7 @@ pub trait Backend: Sync + Send {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
parent_task
:
Option
<
TaskId
>
,
parent_task
:
Option
<
TaskId
>
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
Self
>
,
turbo_tasks
:
&
dyn
TurboTasksBackendApi
<
Self
>
,
...
@@ -708,8 +708,8 @@ mod cached_task_type_tests {
...
@@ -708,8 +708,8 @@ mod cached_task_type_tests {
use
crate
::{
use
crate
::{
RawVc
,
TaskId
,
RawVc
,
TaskId
,
backend
::
CachedTaskType
,
backend
::
CachedTaskType
,
dyn_task_inputs
::
DynTaskInputs
,
macro_helpers
::{
ArgMeta
,
NativeFunction
,
into_task_fn
},
macro_helpers
::{
ArgMeta
,
NativeFunction
,
into_task_fn
},
magic_any
::
MagicAny
,
};
};
// Two distinct static NativeFunctions for testing pointer-based identity.
// Two distinct static NativeFunctions for testing pointer-based identity.
...
@@ -740,8 +740,8 @@ mod cached_task_type_tests {
...
@@ -740,8 +740,8 @@ mod cached_task_type_tests {
rs
.hash_one
(
task
)
rs
.hash_one
(
task
)
}
}
/// Build an arg `Box<dyn
MagicAny
>` for `(i32,)`.
/// Build an arg `Box<dyn
DynTaskInputs
>` for `(i32,)`.
fn
make_arg
(
value
:
i32
)
->
Box
<
dyn
MagicAny
>
{
fn
make_arg
(
value
:
i32
)
->
Box
<
dyn
DynTaskInputs
>
{
Box
::
new
((
value
,))
Box
::
new
((
value
,))
}
}
...
...
turbopack/crates/turbo-tasks/src/
magic_any
.rs
→
turbopack/crates/turbo-tasks/src/
dyn_task_inputs
.rs
View file @
7b52536c
...
@@ -10,24 +10,24 @@ use turbo_dyn_eq_hash::{
...
@@ -10,24 +10,24 @@ use turbo_dyn_eq_hash::{
use
crate
::
trace
::
TraceRawVcs
;
use
crate
::
trace
::
TraceRawVcs
;
pub
trait
MagicAny
:
Debug
+
DynEq
+
DynHash
+
TraceRawVcs
+
Send
+
Sync
+
'static
{
pub
trait
DynTaskInputs
:
Debug
+
DynEq
+
DynHash
+
TraceRawVcs
+
Send
+
Sync
+
'static
{
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
fn
magic
_type_name
(
&
self
)
->
&
'static
str
;
fn
dyn
_type_name
(
&
self
)
->
&
'static
str
;
}
}
impl
<
T
>
MagicAny
for
T
impl
<
T
>
DynTaskInputs
for
T
where
where
T
:
Debug
+
Eq
+
Hash
+
Send
+
Sync
+
TraceRawVcs
+
'static
,
T
:
Debug
+
Eq
+
Hash
+
Send
+
Sync
+
TraceRawVcs
+
'static
,
{
{
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
fn
magic
_type_name
(
&
self
)
->
&
'static
str
{
fn
dyn
_type_name
(
&
self
)
->
&
'static
str
{
std
::
any
::
type_name
::
<
T
>
()
std
::
any
::
type_name
::
<
T
>
()
}
}
}
}
impl_partial_eq_for_dyn!
(
dyn
MagicAny
);
impl_partial_eq_for_dyn!
(
dyn
DynTaskInputs
);
impl_eq_for_dyn!
(
dyn
MagicAny
);
impl_eq_for_dyn!
(
dyn
DynTaskInputs
);
impl_hash_for_dyn!
(
dyn
MagicAny
);
impl_hash_for_dyn!
(
dyn
DynTaskInputs
);
pub
fn
any_as_encode
<
T
:
Any
>
(
this
:
&
dyn
Any
)
->
&
T
{
pub
fn
any_as_encode
<
T
:
Any
>
(
this
:
&
dyn
Any
)
->
&
T
{
if
let
Some
(
enc
)
=
this
.downcast_ref
::
<
T
>
()
{
if
let
Some
(
enc
)
=
this
.downcast_ref
::
<
T
>
()
{
...
@@ -42,14 +42,14 @@ pub fn any_as_encode<T: Any>(this: &dyn Any) -> &T {
...
@@ -42,14 +42,14 @@ pub fn any_as_encode<T: Any>(this: &dyn Any) -> &T {
/// A trait for task arguments that may reside on the stack.
/// A trait for task arguments that may reside on the stack.
///
///
/// This enables deferred boxing: on the cache-hit path (~85%), we only borrow
/// This enables deferred boxing: on the cache-hit path (~85%), we only borrow
/// the argument via [`as_ref`](Stack
MagicAny
::as_ref) for hash/equality lookups,
/// the argument via [`as_ref`](Stack
DynTaskInputs
::as_ref) for hash/equality lookups,
/// avoiding any heap allocation. On cache miss, [`take_box`](Stack
MagicAny
::take_box)
/// avoiding any heap allocation. On cache miss, [`take_box`](Stack
DynTaskInputs
::take_box)
/// moves the value into a `Box` with zero clones.
/// moves the value into a `Box` with zero clones.
pub
trait
Stack
MagicAny
{
pub
trait
Stack
DynTaskInputs
{
/// Borrow the argument as a type-erased reference (for cache lookup).
/// Borrow the argument as a type-erased reference (for cache lookup).
fn
as_ref
(
&
self
)
->
&
dyn
MagicAny
;
fn
as_ref
(
&
self
)
->
&
dyn
DynTaskInputs
;
/// Move the argument out into a heap-allocated Box (panics if already taken).
/// Move the argument out into a heap-allocated Box (panics if already taken).
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
MagicAny
>
;
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
DynTaskInputs
>
;
/// Downcast to `&mut dyn Any` for concrete type recovery without boxing.
/// Downcast to `&mut dyn Any` for concrete type recovery without boxing.
fn
as_any_mut
(
&
mut
self
)
->
&
mut
dyn
Any
;
fn
as_any_mut
(
&
mut
self
)
->
&
mut
dyn
Any
;
}
}
...
@@ -57,13 +57,13 @@ pub trait StackMagicAny {
...
@@ -57,13 +57,13 @@ pub trait StackMagicAny {
/// Stack-resident slot wrapping a concrete typed value.
/// Stack-resident slot wrapping a concrete typed value.
///
///
/// Created by macro-generated callsites. The value starts in `Some` on the
/// Created by macro-generated callsites. The value starts in `Some` on the
/// stack; [`take_box`](Stack
MagicAny
::take_box) moves it to the heap on cache miss.
/// stack; [`take_box`](Stack
DynTaskInputs
::take_box) moves it to the heap on cache miss.
#[repr(transparent)]
#[repr(transparent)]
pub
struct
Stack
MagicAny
Slot
<
T
>
{
pub
struct
Stack
DynTaskInputs
Slot
<
T
>
{
slot
:
Option
<
T
>
,
slot
:
Option
<
T
>
,
}
}
impl
<
T
>
Stack
MagicAny
Slot
<
T
>
{
impl
<
T
>
Stack
DynTaskInputs
Slot
<
T
>
{
#[inline]
#[inline]
pub
fn
new
(
value
:
T
)
->
Self
{
pub
fn
new
(
value
:
T
)
->
Self
{
Self
{
slot
:
Some
(
value
)
}
Self
{
slot
:
Some
(
value
)
}
...
@@ -73,24 +73,24 @@ impl<T> StackMagicAnySlot<T> {
...
@@ -73,24 +73,24 @@ impl<T> StackMagicAnySlot<T> {
pub
fn
take
(
&
mut
self
)
->
T
{
pub
fn
take
(
&
mut
self
)
->
T
{
self
.slot
self
.slot
.take
()
.take
()
.expect
(
"Stack
MagicAny
Slot::take called after value was already taken"
)
.expect
(
"Stack
DynTaskInputs
Slot::take called after value was already taken"
)
}
}
}
}
impl
<
T
:
MagicAny
>
StackMagicAny
for
StackMagicAny
Slot
<
T
>
{
impl
<
T
:
DynTaskInputs
>
StackDynTaskInputs
for
StackDynTaskInputs
Slot
<
T
>
{
#[inline]
#[inline]
fn
as_ref
(
&
self
)
->
&
dyn
MagicAny
{
fn
as_ref
(
&
self
)
->
&
dyn
DynTaskInputs
{
self
.slot
self
.slot
.as_ref
()
.as_ref
()
.expect
(
"Stack
MagicAny
Slot::as_ref called after take_box"
)
.expect
(
"Stack
DynTaskInputs
Slot::as_ref called after take_box"
)
}
}
#[inline]
#[inline]
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
MagicAny
>
{
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
DynTaskInputs
>
{
Box
::
new
(
Box
::
new
(
self
.slot
self
.slot
.take
()
.take
()
.expect
(
"Stack
MagicAny
Slot::take_box called twice"
),
.expect
(
"Stack
DynTaskInputs
Slot::take_box called twice"
),
)
)
}
}
...
@@ -101,31 +101,31 @@ impl<T: MagicAny> StackMagicAny for StackMagicAnySlot<T> {
...
@@ -101,31 +101,31 @@ impl<T: MagicAny> StackMagicAny for StackMagicAnySlot<T> {
}
}
/// Adapter for an already-boxed value (e.g., from async resolution tasks).
/// Adapter for an already-boxed value (e.g., from async resolution tasks).
pub
struct
Owned
MagicAny
{
pub
struct
Owned
StackDynTaskInputs
{
slot
:
Option
<
Box
<
dyn
MagicAny
>>
,
slot
:
Option
<
Box
<
dyn
DynTaskInputs
>>
,
}
}
impl
Owned
MagicAny
{
impl
Owned
StackDynTaskInputs
{
#[inline]
#[inline]
pub
fn
new
(
value
:
Box
<
dyn
MagicAny
>
)
->
Self
{
pub
fn
new
(
value
:
Box
<
dyn
DynTaskInputs
>
)
->
Self
{
Self
{
slot
:
Some
(
value
)
}
Self
{
slot
:
Some
(
value
)
}
}
}
}
}
impl
Stack
MagicAny
for
OwnedMagicAny
{
impl
Stack
DynTaskInputs
for
OwnedStackDynTaskInputs
{
#[inline]
#[inline]
fn
as_ref
(
&
self
)
->
&
dyn
MagicAny
{
fn
as_ref
(
&
self
)
->
&
dyn
DynTaskInputs
{
&**
self
&**
self
.slot
.slot
.as_ref
()
.as_ref
()
.expect
(
"Owned
MagicAny
::as_ref called after take_box"
)
.expect
(
"Owned
StackDynTaskInputs
::as_ref called after take_box"
)
}
}
#[inline]
#[inline]
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
MagicAny
>
{
fn
take_box
(
&
mut
self
)
->
Box
<
dyn
DynTaskInputs
>
{
self
.slot
self
.slot
.take
()
.take
()
.expect
(
"Owned
MagicAny
::take_box called twice"
)
.expect
(
"Owned
StackDynTaskInputs
::take_box called twice"
)
}
}
#[inline]
#[inline]
...
...
turbopack/crates/turbo-tasks/src/lib.rs
View file @
7b52536c
...
@@ -19,6 +19,7 @@ pub mod debug;
...
@@ -19,6 +19,7 @@ pub mod debug;
#[doc
=
include_str
!
(
"../FORMATTING.md"
)]
#[doc
=
include_str
!
(
"../FORMATTING.md"
)]
pub
mod
display
;
pub
mod
display
;
pub
mod
duration_span
;
pub
mod
duration_span
;
mod
dyn_task_inputs
;
mod
effect
;
mod
effect
;
mod
error
;
mod
error
;
pub
mod
event
;
pub
mod
event
;
...
@@ -30,7 +31,6 @@ mod join_iter_ext;
...
@@ -30,7 +31,6 @@ mod join_iter_ext;
pub
mod
keyed
;
pub
mod
keyed
;
#[doc(hidden)]
#[doc(hidden)]
pub
mod
macro_helpers
;
pub
mod
macro_helpers
;
mod
magic_any
;
mod
manager
;
mod
manager
;
pub
mod
mapped_read_ref
;
pub
mod
mapped_read_ref
;
mod
marker_trait
;
mod
marker_trait
;
...
@@ -75,6 +75,9 @@ pub use crate::{
...
@@ -75,6 +75,9 @@ pub use crate::{
collectibles
::
CollectiblesSource
,
collectibles
::
CollectiblesSource
,
completion
::{
Completion
,
Completions
},
completion
::{
Completion
,
Completions
},
display
::{
ValueToString
,
ValueToStringRef
},
display
::{
ValueToString
,
ValueToStringRef
},
dyn_task_inputs
::{
DynTaskInputs
,
OwnedStackDynTaskInputs
,
StackDynTaskInputs
,
StackDynTaskInputsSlot
,
},
effect
::{
Effect
,
EffectError
,
EffectStateStorage
,
Effects
,
emit_effect
,
take_effects
},
effect
::{
Effect
,
EffectError
,
EffectStateStorage
,
Effects
,
emit_effect
,
take_effects
},
error
::
PrettyPrintError
,
error
::
PrettyPrintError
,
id
::{
ExecutionId
,
LocalTaskId
,
TRANSIENT_TASK_BIT
,
TaskId
,
TraitTypeId
,
ValueTypeId
},
id
::{
ExecutionId
,
LocalTaskId
,
TRANSIENT_TASK_BIT
,
TaskId
,
TraitTypeId
,
ValueTypeId
},
...
@@ -83,7 +86,6 @@ pub use crate::{
...
@@ -83,7 +86,6 @@ pub use crate::{
get_invalidator
,
get_invalidator
,
},
},
join_iter_ext
::{
JoinIterExt
,
TryFlatJoinIterExt
,
TryJoinIterExt
},
join_iter_ext
::{
JoinIterExt
,
TryFlatJoinIterExt
,
TryJoinIterExt
},
magic_any
::{
MagicAny
,
OwnedMagicAny
,
StackMagicAny
,
StackMagicAnySlot
},
manager
::{
manager
::{
CurrentCellRef
,
ReadCellTracking
,
ReadConsistency
,
ReadTracking
,
TaskPersistence
,
CurrentCellRef
,
ReadCellTracking
,
ReadConsistency
,
ReadTracking
,
TaskPersistence
,
TaskPriority
,
TurboTasks
,
TurboTasksApi
,
TurboTasksBackendApi
,
TurboTasksCallApi
,
Unused
,
TaskPriority
,
TurboTasks
,
TurboTasksApi
,
TurboTasksBackendApi
,
TurboTasksCallApi
,
Unused
,
...
...
turbopack/crates/turbo-tasks/src/macro_helpers.rs
View file @
7b52536c
...
@@ -16,9 +16,9 @@ use crate::{
...
@@ -16,9 +16,9 @@ use crate::{
ValueTypeId
,
ValueTypeId
,
};
};
pub
use
crate
::{
pub
use
crate
::{
dyn_task_inputs
::
DynTaskInputs
,
global_name_for_method
,
global_name_for_scope
,
global_name_for_trait_method
,
global_name_for_method
,
global_name_for_scope
,
global_name_for_trait_method
,
global_name_for_trait_method_impl
,
global_name_for_type
,
inventory_submit
,
global_name_for_trait_method_impl
,
global_name_for_type
,
inventory_submit
,
magic_any
::
MagicAny
,
manager
::{
find_cell_by_id
,
find_cell_by_type
,
spawn_detached_for_testing
},
manager
::{
find_cell_by_id
,
find_cell_by_type
,
spawn_detached_for_testing
},
native_function
::{
native_function
::{
ArgMeta
,
NativeFunction
,
VTABLE_DEFAULT
,
downcast_args_owned
,
downcast_args_ref
,
ArgMeta
,
NativeFunction
,
VTABLE_DEFAULT
,
downcast_args_owned
,
downcast_args_ref
,
...
...
turbopack/crates/turbo-tasks/src/manager.rs
View file @
7b52536c
...
@@ -33,12 +33,12 @@ use crate::{
...
@@ -33,12 +33,12 @@ use crate::{
TurboTasksExecutionError
,
TypedCellContent
,
VerificationMode
,
TurboTasksExecutionError
,
TypedCellContent
,
VerificationMode
,
},
},
capture_future
::
CaptureFuture
,
capture_future
::
CaptureFuture
,
dyn_task_inputs
::
StackDynTaskInputs
,
event
::{
Event
,
EventListener
},
event
::{
Event
,
EventListener
},
id
::{
ExecutionId
,
LocalTaskId
,
TRANSIENT_TASK_BIT
,
TraitTypeId
},
id
::{
ExecutionId
,
LocalTaskId
,
TRANSIENT_TASK_BIT
,
TraitTypeId
},
id_factory
::
IdFactoryWithReuse
,
id_factory
::
IdFactoryWithReuse
,
keyed
::
KeyedEq
,
keyed
::
KeyedEq
,
macro_helpers
::
NativeFunction
,
macro_helpers
::
NativeFunction
,
magic_any
::
StackMagicAny
,
message_queue
::{
CompilationEvent
,
CompilationEventQueue
},
message_queue
::{
CompilationEvent
,
CompilationEventQueue
},
priority_runner
::{
Executor
,
JoinHandle
,
PriorityRunner
},
priority_runner
::{
Executor
,
JoinHandle
,
PriorityRunner
},
raw_vc
::{
CellId
,
RawVc
},
raw_vc
::{
CellId
,
RawVc
},
...
@@ -59,7 +59,7 @@ pub trait TurboTasksCallApi: Sync + Send {
...
@@ -59,7 +59,7 @@ pub trait TurboTasksCallApi: Sync + Send {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
;
)
->
RawVc
;
/// Call a native function with arguments.
/// Call a native function with arguments.
...
@@ -68,7 +68,7 @@ pub trait TurboTasksCallApi: Sync + Send {
...
@@ -68,7 +68,7 @@ pub trait TurboTasksCallApi: Sync + Send {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
;
)
->
RawVc
;
/// Calls a trait method with arguments. First input is the `self` object.
/// Calls a trait method with arguments. First input is the `self` object.
...
@@ -77,7 +77,7 @@ pub trait TurboTasksCallApi: Sync + Send {
...
@@ -77,7 +77,7 @@ pub trait TurboTasksCallApi: Sync + Send {
&
self
,
&
self
,
trait_method
:
&
'static
TraitMethod
,
trait_method
:
&
'static
TraitMethod
,
this
:
RawVc
,
this
:
RawVc
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
;
)
->
RawVc
;
...
@@ -791,7 +791,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
...
@@ -791,7 +791,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
RawVc
::
TaskOutput
(
self
.backend
.get_or_create_task
(
RawVc
::
TaskOutput
(
self
.backend
.get_or_create_task
(
...
@@ -808,7 +808,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
...
@@ -808,7 +808,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
if
this
.is_none_or
(|
this
|
this
.is_resolved
())
if
this
.is_none_or
(|
this
|
this
.is_resolved
())
...
@@ -830,7 +830,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
...
@@ -830,7 +830,7 @@ impl<B: Backend + 'static> TurboTasks<B> {
&
self
,
&
self
,
trait_method
:
&
'static
TraitMethod
,
trait_method
:
&
'static
TraitMethod
,
this
:
RawVc
,
this
:
RawVc
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
// avoid creating a wrapper task if self is already resolved
// avoid creating a wrapper task if self is already resolved
...
@@ -1360,7 +1360,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
...
@@ -1360,7 +1360,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
self
.dynamic_call
(
native_fn
,
this
,
arg
,
persistence
)
self
.dynamic_call
(
native_fn
,
this
,
arg
,
persistence
)
...
@@ -1369,7 +1369,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
...
@@ -1369,7 +1369,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
&
self
,
&
self
,
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
self
.native_call
(
native_fn
,
this
,
arg
,
persistence
)
self
.native_call
(
native_fn
,
this
,
arg
,
persistence
)
...
@@ -1378,7 +1378,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
...
@@ -1378,7 +1378,7 @@ impl<B: Backend + 'static> TurboTasksCallApi for TurboTasks<B> {
&
self
,
&
self
,
trait_method
:
&
'static
TraitMethod
,
trait_method
:
&
'static
TraitMethod
,
this
:
RawVc
,
this
:
RawVc
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
self
.trait_call
(
trait_method
,
this
,
arg
,
persistence
)
self
.trait_call
(
trait_method
,
this
,
arg
,
persistence
)
...
@@ -1837,7 +1837,7 @@ pub async fn run_once_with_reason<T: Send + 'static>(
...
@@ -1837,7 +1837,7 @@ pub async fn run_once_with_reason<T: Send + 'static>(
pub
fn
dynamic_call
(
pub
fn
dynamic_call
(
func
:
&
'static
NativeFunction
,
func
:
&
'static
NativeFunction
,
this
:
Option
<
RawVc
>
,
this
:
Option
<
RawVc
>
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
with_turbo_tasks
(|
tt
|
tt
.dynamic_call
(
func
,
this
,
arg
,
persistence
))
with_turbo_tasks
(|
tt
|
tt
.dynamic_call
(
func
,
this
,
arg
,
persistence
))
...
@@ -1847,7 +1847,7 @@ pub fn dynamic_call(
...
@@ -1847,7 +1847,7 @@ pub fn dynamic_call(
pub
fn
trait_call
(
pub
fn
trait_call
(
trait_method
:
&
'static
TraitMethod
,
trait_method
:
&
'static
TraitMethod
,
this
:
RawVc
,
this
:
RawVc
,
arg
:
&
mut
dyn
Stack
MagicAny
,
arg
:
&
mut
dyn
Stack
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
)
->
RawVc
{
)
->
RawVc
{
with_turbo_tasks
(|
tt
|
tt
.trait_call
(
trait_method
,
this
,
arg
,
persistence
))
with_turbo_tasks
(|
tt
|
tt
.trait_call
(
trait_method
,
this
,
arg
,
persistence
))
...
...
turbopack/crates/turbo-tasks/src/native_function.rs
View file @
7b52536c
...
@@ -9,19 +9,23 @@ use turbo_tasks_hash::DeterministicHasher;
...
@@ -9,19 +9,23 @@ use turbo_tasks_hash::DeterministicHasher;
use
crate
::{
use
crate
::{
RawVc
,
TaskExecutionReason
,
TaskInput
,
TaskPersistence
,
TaskPriority
,
RawVc
,
TaskExecutionReason
,
TaskInput
,
TaskPersistence
,
TaskPriority
,
dyn_task_inputs
::{
DynTaskInputs
,
OwnedStackDynTaskInputs
,
StackDynTaskInputs
,
StackDynTaskInputsSlot
,
any_as_encode
,
},
macro_helpers
::
into_task_fn
,
macro_helpers
::
into_task_fn
,
magic_any
::{
MagicAny
,
OwnedMagicAny
,
StackMagicAny
,
StackMagicAnySlot
,
any_as_encode
},
registry
::{
RegistryType
,
turbo_registry
},
registry
::{
RegistryType
,
turbo_registry
},
task
::{
TaskFn
,
TaskFnInputs
,
function
::
NativeTaskFuture
},
task
::{
TaskFn
,
TaskFnInputs
,
function
::
NativeTaskFuture
},
};
};
type
ResolveFuture
<
'a
>
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
Box
<
dyn
MagicAny
>>>
+
Send
+
'a
>>
;
type
ResolveFuture
<
'a
>
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
Box
<
dyn
DynTaskInputs
>>>
+
Send
+
'a
>>
;
type
ResolveFunctor
=
for
<
'a
>
fn
(
&
'a
dyn
MagicAny
)
->
ResolveFuture
<
'a
>
;
type
ResolveFunctor
=
for
<
'a
>
fn
(
&
'a
dyn
DynTaskInputs
)
->
ResolveFuture
<
'a
>
;
type
IsResolvedFunctor
=
fn
(
&
dyn
MagicAny
)
->
bool
;
type
IsResolvedFunctor
=
fn
(
&
dyn
DynTaskInputs
)
->
bool
;
#[doc(hidden)]
#[doc(hidden)]
pub
type
FilterOwnedArgsFunctor
=
for
<
'a
>
fn
(
&
'a
mut
dyn
StackMagicAny
)
->
OwnedMagicAny
;
pub
type
FilterOwnedArgsFunctor
=
for
<
'a
>
fn
(
&
'a
mut
dyn
StackDynTaskInputs
)
->
OwnedStackDynTaskInputs
;
#[doc(hidden)]
#[doc(hidden)]
pub
type
FilterAndResolveFunctor
=
ResolveFunctor
;
pub
type
FilterAndResolveFunctor
=
ResolveFunctor
;
...
@@ -32,7 +36,7 @@ pub type AnyHashEncodeFn = fn(&dyn Any, &mut dyn DeterministicHasher);
...
@@ -32,7 +36,7 @@ pub type AnyHashEncodeFn = fn(&dyn Any, &mut dyn DeterministicHasher);
pub
struct
ArgMeta
{
pub
struct
ArgMeta
{
// TODO: This should be an `Option` with `None` for transient tasks. We can skip some codegen.
// TODO: This should be an `Option` with `None` for transient tasks. We can skip some codegen.
pub
bincode
:
(
AnyEncodeFn
,
AnyDecodeFn
<
Box
<
dyn
MagicAny
>>
),
pub
bincode
:
(
AnyEncodeFn
,
AnyDecodeFn
<
Box
<
dyn
DynTaskInputs
>>
),
/// Encodes the argument directly to a hasher, avoiding buffer allocation.
/// Encodes the argument directly to a hasher, avoiding buffer allocation.
/// Uses the same encoding logic as bincode but writes to a [`DeterministicHasher`].
/// Uses the same encoding logic as bincode but writes to a [`DeterministicHasher`].
pub
hash_encode
:
AnyHashEncodeFn
,
pub
hash_encode
:
AnyHashEncodeFn
,
...
@@ -45,10 +49,11 @@ pub struct ArgMeta {
...
@@ -45,10 +49,11 @@ pub struct ArgMeta {
/// resolution in a single operation. `None` when all arguments are used (no filtering needed),
/// resolution in a single operation. `None` when all arguments are used (no filtering needed),
/// in which case the caller should use [`resolve`](ArgMeta::resolve) directly.
/// in which case the caller should use [`resolve`](ArgMeta::resolve) directly.
//
//
// When filtering a `&dyn MagicAny` while running a resolution task, we can't return a filtered
// When filtering a `&dyn DynTaskInputs` while running a resolution task, we can't return a
// `&dyn MagicAny`, we'd be forced to return a `Box<dyn MagicAny>`. However, the next thing we
// filtered `&dyn DynTaskInputs`, we'd be forced to return a `Box<dyn DynTaskInputs>`.
// do is resolution, which also accepts a `&dyn MagicAny` and returns a `Box<dyn MagicAny>`.
// However, the next thing we do is resolution, which also accepts a `&dyn DynTaskInputs`
// This functor combines the two operations to avoid extra cloning.
// and returns a `Box<dyn DynTaskInputs>`. This functor combines the two operations to
// avoid extra cloning.
filter_and_resolve
:
Option
<
FilterAndResolveFunctor
>
,
filter_and_resolve
:
Option
<
FilterAndResolveFunctor
>
,
}
}
...
@@ -112,15 +117,18 @@ impl ArgMeta {
...
@@ -112,15 +117,18 @@ impl ArgMeta {
}
}
}
}
pub
fn
is_resolved
(
&
self
,
value
:
&
dyn
MagicAny
)
->
bool
{
pub
fn
is_resolved
(
&
self
,
value
:
&
dyn
DynTaskInputs
)
->
bool
{
(
self
.is_resolved
)(
value
)
(
self
.is_resolved
)(
value
)
}
}
pub
async
fn
resolve
(
&
self
,
value
:
&
dyn
MagicAny
)
->
Result
<
Box
<
dyn
MagicAny
>>
{
pub
async
fn
resolve
(
&
self
,
value
:
&
dyn
DynTaskInputs
)
->
Result
<
Box
<
dyn
DynTaskInputs
>>
{
(
self
.resolve
)(
value
)
.await
(
self
.resolve
)(
value
)
.await
}
}
pub
async
fn
filter_and_resolve
(
&
self
,
args
:
&
dyn
MagicAny
)
->
Result
<
Box
<
dyn
MagicAny
>>
{
pub
async
fn
filter_and_resolve
(
&
self
,
args
:
&
dyn
DynTaskInputs
,
)
->
Result
<
Box
<
dyn
DynTaskInputs
>>
{
if
let
Some
(
filter_and_resolve
)
=
self
.filter_and_resolve
{
if
let
Some
(
filter_and_resolve
)
=
self
.filter_and_resolve
{
(
filter_and_resolve
)(
args
)
.await
(
filter_and_resolve
)(
args
)
.await
}
else
{
}
else
{
...
@@ -129,11 +137,13 @@ impl ArgMeta {
...
@@ -129,11 +137,13 @@ impl ArgMeta {
}
}
}
}
fn
resolve_functor_impl
<
T
:
MagicAny
+
TaskInput
>
(
value
:
&
dyn
MagicAny
)
->
ResolveFuture
<
'_
>
{
fn
resolve_functor_impl
<
T
:
DynTaskInputs
+
TaskInput
>
(
value
:
&
dyn
DynTaskInputs
,
)
->
ResolveFuture
<
'_
>
{
Box
::
pin
(
async
move
{
Box
::
pin
(
async
move
{
let
value
=
downcast_args_ref
::
<
T
>
(
value
);
let
value
=
downcast_args_ref
::
<
T
>
(
value
);
let
resolved
=
value
.resolve_input
()
.await
?
;
let
resolved
=
value
.resolve_input
()
.await
?
;
Ok
(
Box
::
new
(
resolved
)
as
Box
<
dyn
MagicAny
>
)
Ok
(
Box
::
new
(
resolved
)
as
Box
<
dyn
DynTaskInputs
>
)
})
})
}
}
...
@@ -143,9 +153,9 @@ pub fn debug_downcast_args_error_msg(expected: &str, actual: &str) -> String {
...
@@ -143,9 +153,9 @@ pub fn debug_downcast_args_error_msg(expected: &str, actual: &str) -> String {
format!
(
"Invalid argument type, expected {expected} got {actual}"
)
format!
(
"Invalid argument type, expected {expected} got {actual}"
)
}
}
pub
fn
downcast_args_owned
<
T
:
MagicAny
>
(
args
:
Box
<
dyn
MagicAny
>
)
->
Box
<
T
>
{
pub
fn
downcast_args_owned
<
T
:
DynTaskInputs
>
(
args
:
Box
<
dyn
DynTaskInputs
>
)
->
Box
<
T
>
{
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
let
args_type_name
=
args
.
magic
_type_name
();
let
args_type_name
=
args
.
dyn
_type_name
();
(
args
as
Box
<
dyn
Any
>
)
(
args
as
Box
<
dyn
Any
>
)
.downcast
::
<
T
>
()
.downcast
::
<
T
>
()
...
@@ -161,14 +171,14 @@ pub fn downcast_args_owned<T: MagicAny>(args: Box<dyn MagicAny>) -> Box<T> {
...
@@ -161,14 +171,14 @@ pub fn downcast_args_owned<T: MagicAny>(args: Box<dyn MagicAny>) -> Box<T> {
.unwrap
()
.unwrap
()
}
}
pub
fn
downcast_args_ref
<
T
:
MagicAny
>
(
args
:
&
dyn
MagicAny
)
->
&
T
{
pub
fn
downcast_args_ref
<
T
:
DynTaskInputs
>
(
args
:
&
dyn
DynTaskInputs
)
->
&
T
{
(
args
as
&
dyn
Any
)
(
args
as
&
dyn
Any
)
.downcast_ref
::
<
T
>
()
.downcast_ref
::
<
T
>
()
.ok_or_else
(||
{
.ok_or_else
(||
{
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
return
anyhow
::
anyhow!
(
debug_downcast_args_error_msg
(
return
anyhow
::
anyhow!
(
debug_downcast_args_error_msg
(
std
::
any
::
type_name
::
<
T
>
(),
std
::
any
::
type_name
::
<
T
>
(),
args
.
magic
_type_name
(),
args
.
dyn
_type_name
(),
));
));
#[cfg(not(debug_assertions))]
#[cfg(not(debug_assertions))]
return
anyhow
::
anyhow!
(
"Invalid argument type"
);
return
anyhow
::
anyhow!
(
"Invalid argument type"
);
...
@@ -176,15 +186,15 @@ pub fn downcast_args_ref<T: MagicAny>(args: &dyn MagicAny) -> &T {
...
@@ -176,15 +186,15 @@ pub fn downcast_args_ref<T: MagicAny>(args: &dyn MagicAny) -> &T {
.unwrap
()
.unwrap
()
}
}
/// Downcast a `&mut dyn Stack
MagicAny` to a concrete [`StackMagicAnySlot<T>`] and take the value
/// Downcast a `&mut dyn Stack
DynTaskInputs` to a concrete [`StackDynTaskInputsSlot<T>`] and
///
out, avoiding the intermediate heap allocation that `take_box` + `downcast_args_owned` would
///
take the value out, avoiding the intermediate heap allocation that `take_box` +
/// require.
///
`downcast_args_owned` would
require.
pub
fn
downcast_stack_args_owned
<
T
:
MagicAny
>
(
args
:
&
mut
dyn
StackMagicAny
)
->
T
{
pub
fn
downcast_stack_args_owned
<
T
:
DynTaskInputs
>
(
args
:
&
mut
dyn
StackDynTaskInputs
)
->
T
{
args
.as_any_mut
()
args
.as_any_mut
()
.downcast_mut
::
<
Stack
MagicAny
Slot
<
T
>>
()
.downcast_mut
::
<
Stack
DynTaskInputs
Slot
<
T
>>
()
.unwrap_or_else
(||
{
.unwrap_or_else
(||
{
panic!
(
panic!
(
"downcast_stack_args_owned::<{}> called with incorrect Stack
MagicAny
type"
,
"downcast_stack_args_owned::<{}> called with incorrect Stack
DynTaskInputs
type"
,
std
::
any
::
type_name
::
<
T
>
(),
std
::
any
::
type_name
::
<
T
>
(),
)
)
})
})
...
@@ -249,7 +259,11 @@ impl NativeFunction {
...
@@ -249,7 +259,11 @@ impl NativeFunction {
}
}
/// Executed the function
/// Executed the function
pub
fn
execute
(
&
'static
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
)
->
NativeTaskFuture
{
pub
fn
execute
(
&
'static
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
DynTaskInputs
,
)
->
NativeTaskFuture
{
match
(
self
.implementation
)
.functor
(
this
,
arg
)
{
match
(
self
.implementation
)
.functor
(
this
,
arg
)
{
Ok
(
functor
)
=>
functor
,
Ok
(
functor
)
=>
functor
,
Err
(
err
)
=>
Box
::
pin
(
async
{
Err
(
err
)
}),
Err
(
err
)
=>
Box
::
pin
(
async
{
Err
(
err
)
}),
...
...
turbopack/crates/turbo-tasks/src/task/function.rs
View file @
7b52536c
...
@@ -26,12 +26,12 @@ use std::{future::Future, marker::PhantomData, pin::Pin};
...
@@ -26,12 +26,12 @@ use std::{future::Future, marker::PhantomData, pin::Pin};
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
super
::{
TaskInput
,
TaskOutput
};
use
super
::{
TaskInput
,
TaskOutput
};
use
crate
::{
RawVc
,
Vc
,
VcRead
,
VcValueType
,
magic_any
::
MagicAny
};
use
crate
::{
RawVc
,
Vc
,
VcRead
,
VcValueType
,
dyn_task_inputs
::
DynTaskInputs
};
pub
type
NativeTaskFuture
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
RawVc
>>
+
Send
>>
;
pub
type
NativeTaskFuture
=
Pin
<
Box
<
dyn
Future
<
Output
=
Result
<
RawVc
>>
+
Send
>>
;
pub
trait
TaskFn
:
Send
+
Sync
+
'static
{
pub
trait
TaskFn
:
Send
+
Sync
+
'static
{
fn
functor
(
&
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
;
fn
functor
(
&
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
;
}
}
/// A trait for `TaskFn` implementations that allows task inputs to be extracted as a type.
/// A trait for `TaskFn` implementations that allows task inputs to be extracted as a type.
...
@@ -81,7 +81,7 @@ where
...
@@ -81,7 +81,7 @@ where
Mode
:
TaskFnMode
,
Mode
:
TaskFnMode
,
Inputs
:
TaskInputs
,
Inputs
:
TaskInputs
,
{
{
fn
functor
(
&
self
,
_this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
_this
:
Option
<
RawVc
>
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
TaskFnInputFunction
::
functor
(
&
self
.task_fn
,
arg
)
TaskFnInputFunction
::
functor
(
&
self
.task_fn
,
arg
)
}
}
}
}
...
@@ -114,7 +114,7 @@ where
...
@@ -114,7 +114,7 @@ where
This
:
Sync
+
Send
+
'static
,
This
:
Sync
+
Send
+
'static
,
Inputs
:
TaskInputs
,
Inputs
:
TaskInputs
,
{
{
fn
functor
(
&
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
Some
(
this
)
=
this
else
{
let
Some
(
this
)
=
this
else
{
panic!
(
"Method needs a `self` argument"
);
panic!
(
"Method needs a `self` argument"
);
};
};
...
@@ -136,7 +136,7 @@ where
...
@@ -136,7 +136,7 @@ where
pub
trait
TaskFnInputFunction
<
Mode
:
TaskFnMode
,
Inputs
:
TaskInputs
>
:
pub
trait
TaskFnInputFunction
<
Mode
:
TaskFnMode
,
Inputs
:
TaskInputs
>
:
Send
+
Sync
+
Clone
+
'static
Send
+
Sync
+
Clone
+
'static
{
{
fn
functor
(
&
self
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
;
fn
functor
(
&
self
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
;
}
}
#[doc(hidden)]
#[doc(hidden)]
...
@@ -146,7 +146,7 @@ pub trait TaskFnInputFunctionWithThis<
...
@@ -146,7 +146,7 @@ pub trait TaskFnInputFunctionWithThis<
Inputs
:
TaskInputs
,
Inputs
:
TaskInputs
,
>
:
Send
+
Sync
+
Clone
+
'static
>
:
Send
+
Sync
+
Clone
+
'static
{
{
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
;
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
;
}
}
pub
trait
TaskInputs
:
Send
+
Sync
+
'static
{}
pub
trait
TaskInputs
:
Send
+
Sync
+
'static
{}
...
@@ -184,13 +184,13 @@ macro_rules! task_inputs_impl {
...
@@ -184,13 +184,13 @@ macro_rules! task_inputs_impl {
/// This helper function for `task_fn_impl!()` reduces the amount of code inside the macro, and
/// This helper function for `task_fn_impl!()` reduces the amount of code inside the macro, and
/// gives the compiler more chances to dedupe monomorphized code across small functions with less
/// gives the compiler more chances to dedupe monomorphized code across small functions with less
/// typevars.
/// typevars.
fn
get_args
<
T
:
MagicAny
+
Clone
>
(
arg
:
&
dyn
MagicAny
)
->
Result
<
T
>
{
fn
get_args
<
T
:
DynTaskInputs
+
Clone
>
(
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
T
>
{
let
value
=
(
arg
as
&
dyn
std
::
any
::
Any
)
.downcast_ref
::
<
T
>
()
.cloned
();
let
value
=
(
arg
as
&
dyn
std
::
any
::
Any
)
.downcast_ref
::
<
T
>
()
.cloned
();
#[cfg(debug_assertions)]
#[cfg(debug_assertions)]
return
anyhow
::
Context
::
with_context
(
value
,
||
{
return
anyhow
::
Context
::
with_context
(
value
,
||
{
crate
::
native_function
::
debug_downcast_args_error_msg
(
crate
::
native_function
::
debug_downcast_args_error_msg
(
std
::
any
::
type_name
::
<
T
>
(),
std
::
any
::
type_name
::
<
T
>
(),
arg
.
magic
_type_name
(),
arg
.
dyn
_type_name
(),
)
)
});
});
#[cfg(not(debug_assertions))]
#[cfg(not(debug_assertions))]
...
@@ -211,7 +211,7 @@ macro_rules! task_fn_impl {
...
@@ -211,7 +211,7 @@ macro_rules! task_fn_impl {
Output
:
TaskOutput
+
'static
,
Output
:
TaskOutput
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
Ok
(
Box
::
pin
(
async
move
{
Ok
(
Box
::
pin
(
async
move
{
...
@@ -229,7 +229,7 @@ macro_rules! task_fn_impl {
...
@@ -229,7 +229,7 @@ macro_rules! task_fn_impl {
Output
:
TaskOutput
+
'static
,
Output
:
TaskOutput
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
Ok
(
Box
::
pin
(
async
move
{
Ok
(
Box
::
pin
(
async
move
{
...
@@ -247,7 +247,7 @@ macro_rules! task_fn_impl {
...
@@ -247,7 +247,7 @@ macro_rules! task_fn_impl {
Output
:
TaskOutput
+
'static
,
Output
:
TaskOutput
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
...
@@ -268,7 +268,7 @@ macro_rules! task_fn_impl {
...
@@ -268,7 +268,7 @@ macro_rules! task_fn_impl {
Output
:
TaskOutput
+
'static
,
Output
:
TaskOutput
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
...
@@ -301,7 +301,7 @@ macro_rules! task_fn_impl {
...
@@ -301,7 +301,7 @@ macro_rules! task_fn_impl {
F
:
for
<
'a
>
$async_fn_trait
<&
'a
Recv
,
$
(
$arg
,)
*>
+
Clone
+
Send
+
Sync
+
'static
,
F
:
for
<
'a
>
$async_fn_trait
<&
'a
Recv
,
$
(
$arg
,)
*>
+
Clone
+
Send
+
Sync
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
...
@@ -321,7 +321,7 @@ macro_rules! task_fn_impl {
...
@@ -321,7 +321,7 @@ macro_rules! task_fn_impl {
F
:
$async_fn_trait
<
Vc
<
Recv
>
,
$
(
$arg
,)
*>
+
Clone
+
Send
+
Sync
+
'static
,
F
:
$async_fn_trait
<
Vc
<
Recv
>
,
$
(
$arg
,)
*>
+
Clone
+
Send
+
Sync
+
'static
,
{
{
#[allow(non_snake_case)]
#[allow(non_snake_case)]
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
)
->
Result
<
NativeTaskFuture
>
{
fn
functor
(
&
self
,
this
:
RawVc
,
arg
:
&
dyn
DynTaskInputs
)
->
Result
<
NativeTaskFuture
>
{
let
task_fn
=
self
.clone
();
let
task_fn
=
self
.clone
();
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
recv
=
Vc
::
<
Recv
>
::
from
(
this
);
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
let
(
$
(
$arg
,)
*
)
=
get_args
::
<
(
$
(
$arg
,)
*
)
>
(
arg
)
?
;
...
...
turbopack/crates/turbo-tasks/src/task/local_task.rs
View file @
7b52536c
...
@@ -3,8 +3,8 @@ use std::{fmt, sync::Arc};
...
@@ -3,8 +3,8 @@ use std::{fmt, sync::Arc};
use
anyhow
::{
Result
,
bail
};
use
anyhow
::{
Result
,
bail
};
use
crate
::{
use
crate
::{
CellId
,
MagicAny
,
OutputContent
,
OwnedMagicAny
,
RawVc
,
TaskPersistence
,
TraitMethod
,
CellId
,
DynTaskInputs
,
OutputContent
,
OwnedStackDynTaskInputs
,
RawVc
,
TaskPersistence
,
TurboTasksBackendApi
,
ValueTypeId
,
backend
::
Backend
,
event
::
Event
,
T
raitMethod
,
T
urboTasksBackendApi
,
ValueTypeId
,
backend
::
Backend
,
event
::
Event
,
macro_helpers
::
NativeFunction
,
registry
,
macro_helpers
::
NativeFunction
,
registry
,
};
};
...
@@ -18,7 +18,7 @@ pub struct LocalTaskSpec {
...
@@ -18,7 +18,7 @@ pub struct LocalTaskSpec {
/// The self value, will always be present for `ResolveTrait` tasks and is optional otherwise
/// The self value, will always be present for `ResolveTrait` tasks and is optional otherwise
pub
(
crate
)
this
:
Option
<
RawVc
>
,
pub
(
crate
)
this
:
Option
<
RawVc
>
,
/// Function arguments
/// Function arguments
pub
(
crate
)
arg
:
Box
<
dyn
MagicAny
>
,
pub
(
crate
)
arg
:
Box
<
dyn
DynTaskInputs
>
,
pub
(
crate
)
task_type
:
LocalTaskType
,
pub
(
crate
)
task_type
:
LocalTaskType
,
}
}
...
@@ -53,7 +53,7 @@ impl LocalTaskType {
...
@@ -53,7 +53,7 @@ impl LocalTaskType {
pub
(
crate
)
async
fn
run_resolve_native
<
B
:
Backend
+
'static
>
(
pub
(
crate
)
async
fn
run_resolve_native
<
B
:
Backend
+
'static
>
(
native_fn
:
&
'static
NativeFunction
,
native_fn
:
&
'static
NativeFunction
,
mut
this
:
Option
<
RawVc
>
,
mut
this
:
Option
<
RawVc
>
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
turbo_tasks
:
Arc
<
dyn
TurboTasksBackendApi
<
B
>>
,
turbo_tasks
:
Arc
<
dyn
TurboTasksBackendApi
<
B
>>
,
)
->
Result
<
RawVc
>
{
)
->
Result
<
RawVc
>
{
...
@@ -61,14 +61,14 @@ impl LocalTaskType {
...
@@ -61,14 +61,14 @@ impl LocalTaskType {
*
this
=
this
.resolve
()
.await
?
;
*
this
=
this
.resolve
()
.await
?
;
}
}
let
arg
=
native_fn
.arg_meta
.resolve
(
arg
)
.await
?
;
let
arg
=
native_fn
.arg_meta
.resolve
(
arg
)
.await
?
;
let
mut
arg
=
Owned
MagicAny
::
new
(
arg
);
let
mut
arg
=
Owned
StackDynTaskInputs
::
new
(
arg
);
Ok
(
turbo_tasks
.native_call
(
native_fn
,
this
,
&
mut
arg
,
persistence
))
Ok
(
turbo_tasks
.native_call
(
native_fn
,
this
,
&
mut
arg
,
persistence
))
}
}
/// Implementation of the LocalTaskType::ResolveTrait task.
/// Implementation of the LocalTaskType::ResolveTrait task.
pub
(
crate
)
async
fn
run_resolve_trait
<
B
:
Backend
+
'static
>
(
pub
(
crate
)
async
fn
run_resolve_trait
<
B
:
Backend
+
'static
>
(
trait_method
:
&
'static
TraitMethod
,
trait_method
:
&
'static
TraitMethod
,
this
:
RawVc
,
this
:
RawVc
,
arg
:
&
dyn
MagicAny
,
arg
:
&
dyn
DynTaskInputs
,
persistence
:
TaskPersistence
,
persistence
:
TaskPersistence
,
turbo_tasks
:
Arc
<
dyn
TurboTasksBackendApi
<
B
>>
,
turbo_tasks
:
Arc
<
dyn
TurboTasksBackendApi
<
B
>>
,
)
->
Result
<
RawVc
>
{
)
->
Result
<
RawVc
>
{
...
@@ -79,7 +79,7 @@ impl LocalTaskType {
...
@@ -79,7 +79,7 @@ impl LocalTaskType {
let
native_fn
=
Self
::
resolve_trait_method_from_value
(
trait_method
,
type_id
)
?
;
let
native_fn
=
Self
::
resolve_trait_method_from_value
(
trait_method
,
type_id
)
?
;
let
arg
=
native_fn
.arg_meta
.filter_and_resolve
(
arg
)
.await
?
;
let
arg
=
native_fn
.arg_meta
.filter_and_resolve
(
arg
)
.await
?
;
let
mut
arg
=
Owned
MagicAny
::
new
(
arg
);
let
mut
arg
=
Owned
StackDynTaskInputs
::
new
(
arg
);
Ok
(
turbo_tasks
.native_call
(
native_fn
,
Some
(
this
),
&
mut
arg
,
persistence
))
Ok
(
turbo_tasks
.native_call
(
native_fn
,
Some
(
this
),
&
mut
arg
,
persistence
))
}
}
...
...
turbopack/crates/turbo-tasks/src/task/task_input.rs
View file @
7b52536c
...
@@ -24,7 +24,7 @@ use turbo_tasks_hash::HashAlgorithm;
...
@@ -24,7 +24,7 @@ use turbo_tasks_hash::HashAlgorithm;
// name directly.
// name directly.
use
crate
as
turbo_tasks
;
use
crate
as
turbo_tasks
;
use
crate
::{
use
crate
::{
MagicAny
,
ReadRef
,
ResolvedVc
,
TaskId
,
TransientInstance
,
TransientValue
,
ValueTypeId
,
Vc
,
DynTaskInputs
,
ReadRef
,
ResolvedVc
,
TaskId
,
TransientInstance
,
TransientValue
,
ValueTypeId
,
Vc
,
trace
::
TraceRawVcs
,
trace
::
TraceRawVcs
,
};
};
...
@@ -284,7 +284,7 @@ where
...
@@ -284,7 +284,7 @@ where
impl
<
T
>
TaskInput
for
TransientValue
<
T
>
impl
<
T
>
TaskInput
for
TransientValue
<
T
>
where
where
T
:
MagicAny
+
Clone
+
Debug
+
Hash
+
Eq
+
TraceRawVcs
+
'static
,
T
:
DynTaskInputs
+
Clone
+
Debug
+
Hash
+
Eq
+
TraceRawVcs
+
'static
,
{
{
fn
is_transient
(
&
self
)
->
bool
{
fn
is_transient
(
&
self
)
->
bool
{
true
true
...
...
turbopack/crates/turbo-tasks/src/value_type.rs
View file @
7b52536c
...
@@ -11,9 +11,9 @@ use turbo_bincode::{AnyDecodeFn, AnyEncodeFn};
...
@@ -11,9 +11,9 @@ use turbo_bincode::{AnyDecodeFn, AnyEncodeFn};
use
crate
::{
use
crate
::{
RawVc
,
SharedReference
,
TaskPriority
,
VcValueType
,
RawVc
,
SharedReference
,
TaskPriority
,
VcValueType
,
dyn_task_inputs
::
any_as_encode
,
id
::
TraitTypeId
,
id
::
TraitTypeId
,
macro_helpers
::{
CollectableTraitMethods
,
NativeFunction
},
macro_helpers
::{
CollectableTraitMethods
,
NativeFunction
},
magic_any
::
any_as_encode
,
registry
::{
RegistryType
,
get_trait_type_id
,
trait_type_count
,
turbo_registry
},
registry
::{
RegistryType
,
get_trait_type_id
,
trait_type_count
,
turbo_registry
},
task
::
shared_reference
::
TypedSharedReference
,
task
::
shared_reference
::
TypedSharedReference
,
vc
::
VcCellMode
,
vc
::
VcCellMode
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment