Skip to content

Commit

Permalink
pass args as single item
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jul 17, 2024
1 parent 2e5fb8e commit a1ca324
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 276 deletions.
4 changes: 2 additions & 2 deletions crates/turbo-tasks-macros/src/derive/task_input_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
_ => return Err(anyhow::anyhow!("invalid discriminant for {}", stringify!(#ident))),
})
},
_ => Err(anyhow::anyhow!("invalid task input type, expected list")),
_ => Err(anyhow::anyhow!("invalid task input type, expected list (enum)")),
}
},
quote! {
Expand Down Expand Up @@ -155,7 +155,7 @@ pub fn derive_task_input(input: TokenStream) -> TokenStream {
#try_from_expansion
Ok(#ident #destructuring)
},
_ => Err(anyhow::anyhow!("invalid task input type, expected list")),
_ => Err(anyhow::anyhow!("invalid task input type, expected list (struct)")),
}
},
quote! {
Expand Down
6 changes: 3 additions & 3 deletions crates/turbo-tasks-macros/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl TurboFn {
*#trait_type_id_ident,
std::borrow::Cow::Borrowed(stringify!(#ident)),
#converted_this,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand All @@ -352,7 +352,7 @@ impl TurboFn {
turbo_tasks::dynamic_this_call(
*#native_function_id_ident,
#converted_this,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand All @@ -363,7 +363,7 @@ impl TurboFn {
<#output as turbo_tasks::task::TaskOutput>::try_from_raw_vc(
turbo_tasks::dynamic_call(
*#native_function_id_ident,
vec![#converted_inputs],
turbo_tasks::TaskInput::into_concrete((#converted_inputs)),
)
)
}
Expand Down
8 changes: 4 additions & 4 deletions crates/turbo-tasks-memory/src/memory_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,20 @@ impl Backend for MemoryBackend {
PersistentTaskType::ResolveNative {
fn_type: function_id,
this: _,
args: _,
arg: _,
}
| PersistentTaskType::Native {
fn_type: function_id,
this: _,
args: _,
arg: _,
} => {
stats.increment_cache_hit(*function_id);
}
PersistentTaskType::ResolveTrait {
trait_type,
method_name: name,
this,
args: _,
arg: _,
} => {
// HACK: Resolve the this argument (`self`) in order to attribute the cache hit
// to the concrete trait implementation, rather than the dynamic trait method.
Expand Down Expand Up @@ -595,7 +595,7 @@ impl Backend for MemoryBackend {
PersistentTaskType::Native {
fn_type: function_id,
this: _,
args: _,
arg: _,
} => {
stats.increment_cache_miss(*function_id);
}
Expand Down
12 changes: 6 additions & 6 deletions crates/turbo-tasks-memory/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,14 @@ impl Task {
PersistentTaskType::Native {
fn_type: native_fn,
this: _,
args: _,
arg: _,
} => {
format!("[{}] {}", id, registry::get_function(*native_fn).name)
}
PersistentTaskType::ResolveNative {
fn_type: native_fn,
this: _,
args: _,
arg: _,
} => {
format!(
"[{}] [resolve] {}",
Expand All @@ -606,7 +606,7 @@ impl Task {
trait_type,
method_name: fn_name,
this: _,
args: _,
arg: _,
} => {
format!(
"[{}] [resolve trait] {} in trait {}",
Expand Down Expand Up @@ -757,7 +757,7 @@ impl Task {
PersistentTaskType::Native {
fn_type: native_fn,
this,
args: inputs,
arg: inputs,
} => {
let func = registry::get_function(*native_fn);
let span = func.span();
Expand All @@ -770,7 +770,7 @@ impl Task {
PersistentTaskType::ResolveNative {
fn_type: ref native_fn_id,
this,
args: inputs,
arg: inputs,
} => {
let native_fn_id = *native_fn_id;
let func = registry::get_function(native_fn_id);
Expand All @@ -791,7 +791,7 @@ impl Task {
trait_type: trait_type_id,
method_name: name,
this,
args: inputs,
arg: inputs,
} => {
let trait_type_id = *trait_type_id;
let trait_type = registry::get_trait(trait_type_id);
Expand Down
18 changes: 9 additions & 9 deletions crates/turbo-tasks-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ impl VcStorage {
&self,
func: turbo_tasks::FunctionId,
this_arg: Option<RawVc>,
inputs: Vec<turbo_tasks::ConcreteTaskInput>,
arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
let this = self.this.upgrade().unwrap();
let func = registry::get_function(func).bind(this_arg, &inputs);
let func = registry::get_function(func).bind(this_arg, &arg);
let handle = tokio::runtime::Handle::current();
let future = func();
let i = {
Expand Down Expand Up @@ -84,24 +84,24 @@ impl TurboTasksCallApi for VcStorage {
fn dynamic_call(
&self,
func: turbo_tasks::FunctionId,
inputs: Vec<turbo_tasks::ConcreteTaskInput>,
arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
self.dynamic_call(func, None, inputs)
self.dynamic_call(func, None, arg)
}

fn dynamic_this_call(
&self,
func: turbo_tasks::FunctionId,
this_arg: RawVc,
inputs: Vec<turbo_tasks::ConcreteTaskInput>,
arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
self.dynamic_call(func, Some(this_arg), inputs)
self.dynamic_call(func, Some(this_arg), arg)
}

fn native_call(
&self,
_func: turbo_tasks::FunctionId,
_inputs: Vec<turbo_tasks::ConcreteTaskInput>,
_arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
unreachable!()
}
Expand All @@ -110,7 +110,7 @@ impl TurboTasksCallApi for VcStorage {
&self,
_func: turbo_tasks::FunctionId,
_this: RawVc,
_inputs: Vec<turbo_tasks::ConcreteTaskInput>,
_arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
unreachable!()
}
Expand All @@ -120,7 +120,7 @@ impl TurboTasksCallApi for VcStorage {
_trait_type: turbo_tasks::TraitTypeId,
_trait_fn_name: Cow<'static, str>,
_this: RawVc,
_inputs: Vec<turbo_tasks::ConcreteTaskInput>,
_arg: turbo_tasks::ConcreteTaskInput,
) -> RawVc {
unreachable!()
}
Expand Down
Loading

0 comments on commit a1ca324

Please sign in to comment.