Skip to content

Commit

Permalink
fix(codegen): #[system] should copy attributes to generated functions…
Browse files Browse the repository at this point in the history
… too
  • Loading branch information
SOF3 committed Feb 3, 2024
1 parent 6889590 commit 4cd8d88
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(extract_if)]
#![allow(dead_code)]

use proc_macro::TokenStream;

Expand Down
3 changes: 2 additions & 1 deletion codegen/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result<TokenStream>
return Err(Error::new_spanned(&input.sig.output, "system functions must return unit"));
}

// 1. Parse item-level attributes.
let item = item::Agg::parse(ident, args)?;
let item::Agg { crate_name, name, state_maybe_uninit, deps, .. } = item;

Expand Down Expand Up @@ -384,6 +383,7 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result<TokenStream>
#[automatically_derived]
impl #ident {
#build_fn
#[allow(clippy::too_many_arguments)]
#call_fn
}

Expand All @@ -393,6 +393,7 @@ pub(crate) fn imp(args: TokenStream, input: TokenStream) -> Result<TokenStream>
#impl_referrer_for_local_state

// The actual function is moved here.
#(#other_attrs)*
fn __dynec_original(#(#input_args),*) {
#fn_body
}
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/tracer_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl Parse for Named<AssocFnOpt> {
}
}

#[allow(clippy::enum_variant_names)] // TODO remove this when we add more implementations
#[allow(clippy::enum_variant_names)]
enum AssocFnParamOpt {
LogSkip,
LogElapsedDuration,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2023-11-21
nightly-2024-01-31
20 changes: 11 additions & 9 deletions src/entity/ealloc/recycling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::collections::BTreeSet;
use std::sync::Arc;
use std::{iter, ops};

use parking_lot::Mutex;
use parking_lot::lock_api::ArcMutexGuard;
use parking_lot::{Mutex, RawMutex};

use super::{iter_gaps, Ealloc, Shard, ShardAssigner, Snapshot};
use crate::entity::raw::Atomic;
Expand Down Expand Up @@ -72,7 +73,11 @@ impl<RawT: Raw, T: Recycler<RawT>, S: ShardAssigner> Recycling<RawT, T, S> {
impl<RawT: Raw, T: Recycler<RawT>, S: ShardAssigner> Ealloc for Recycling<RawT, T, S> {
type Raw = RawT;
type AllocHint = T::Hint;
type Shard = impl Shard<Raw = RawT, Hint = T::Hint>;
type Shard = RecyclingShard<
Arc<RawT::Atomic>,
ArcMutexGuard<RawMutex, T>,
ArcMutexGuard<RawMutex, Vec<RawT>>,
>;

fn new(num_shards: usize) -> Self { Self::new_with_shard_assigner(num_shards, S::default()) }

Expand All @@ -81,13 +86,10 @@ impl<RawT: Raw, T: Recycler<RawT>, S: ShardAssigner> Ealloc for Recycling<RawT,

vec.extend(
iter::zip(self.recycler_shards.iter(), self.reuse_queue_shards.iter())
.map(|(recycler, reuse_queue)| -> Self::Shard {
// The return type hint here is used to constrain the TAIT, don't delete it.
RecyclingShard {
global_gauge: Arc::clone(&self.global_gauge),
recycler: Arc::clone(recycler).lock_arc(),
reuse_queue: Arc::clone(reuse_queue).lock_arc(),
}
.map(|(recycler, reuse_queue)| RecyclingShard {
global_gauge: Arc::clone(&self.global_gauge),
recycler: Arc::clone(recycler).lock_arc(),
reuse_queue: Arc::clone(reuse_queue).lock_arc(),
})
.map(f),
);
Expand Down

0 comments on commit 4cd8d88

Please sign in to comment.