Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wks committed Nov 5, 2024
1 parent 7433a2a commit 6c946ae
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/plan/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::scheduler::gc_work::{ProcessEdgesWork, SlotOf};
use crate::scheduler::{GCWorker, WorkBucketStage};
#[cfg(debug_assertions)]
use crate::util::log;
use crate::util::ObjectReference;
use crate::vm::SlotVisitor;
Expand Down
1 change: 1 addition & 0 deletions src/util/copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::policy::copyspace::CopySpaceCopyContext;
use crate::policy::immix::ImmixSpace;
use crate::policy::immix::{ImmixCopyContext, ImmixHybridCopyContext};
use crate::policy::space::Space;
#[cfg(debug_assertions)]
use crate::util::log;
use crate::util::object_forwarding;
use crate::util::opaque_pointer::VMWorkerThread;
Expand Down
56 changes: 34 additions & 22 deletions src/util/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,43 @@ use the_log_crate;

pub(crate) use the_log_crate::{error, info, warn};

cfg_if::cfg_if! {
if #[cfg(all(not(debug_assertions), not(feature = "hot_log")))] {
// If it is release build and the feature "hot_log" is not enabled,
// then we define verbose logs as no-op in release build.
/// Whether logs of DEBUG and TRACE levels are enabled.
/// In debug build, they are always enabled.
/// In release build, they are not enabled unless the "hot_log" Cargo feature is enabled.
pub(crate) const HOT_LOG_ENABLED: bool = cfg!(any(not(debug_assertions), feature = "hot_log"));

/// The `log::debug!` macro is disabled in release build.
/// Use the "hot_log" feature to enable.
macro_rules! debug {
($($arg:tt)+) => {}
/// A wrapper of the `debug!` macro in the `log` crate.
/// Does nothing if [`HOT_LOG_ENABLED`] is false.
macro_rules! debug {
(target: $target:expr, $($arg:tt)+) => {
if $crate::util::log::HOT_LOG_ENABLED {
the_log_crate::debug!(target: $target, $($arg)+)
}

/// The `log::trace!` macro is disabled in release build.
/// Use the "hot_log" feature to enable.
macro_rules! trace {
($($arg:tt)+) => {}
};
($($arg:tt)+) => {
if $crate::util::log::HOT_LOG_ENABLED {
the_log_crate::debug!($($arg)+)
}
}
}

// By default, a macro has no path-based scope.
// The following allows other modules to access the macros with `crate::util::log::debug`
// and `crate::util::log::trace`.
pub(crate) use debug;
pub(crate) use trace;

} else {
// Otherwise simply import the macros from the `log` crate.
pub(crate) use the_log_crate::{debug, trace};
/// A wrapper of the `trace!` macro in the `log` crate.
/// Does nothing if [`HOT_LOG_ENABLED`] is false.
macro_rules! trace {
(target: $target:expr, $($arg:tt)+) => {
if $crate::util::log::HOT_LOG_ENABLED {
the_log_crate::trace!(target: $target, $($arg)+)
}
};
($($arg:tt)+) => {
if $crate::util::log::HOT_LOG_ENABLED {
the_log_crate::trace!($($arg)+)
}
}
}

// By default, a macro has no path-based scope.
// The following allows other modules to access the macros with `crate::util::log::debug`
// and `crate::util::log::trace`.
pub(crate) use debug;
pub(crate) use trace;
1 change: 0 additions & 1 deletion src/vm/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub trait SlotVisitor<SL: Slot> {
/// This lets us use closures as SlotVisitor.
impl<SL: Slot, F: FnMut(SL)> SlotVisitor<SL> for F {
fn visit_slot(&mut self, slot: SL) {
#[cfg(debug_assertions)]
log::trace!(
"(FunctionClosure) Visit slot {:?} (pointing to {:?})",
slot,
Expand Down

0 comments on commit 6c946ae

Please sign in to comment.