Mark debug functions cold.

This commit is contained in:
Stephen Chung 2022-09-27 08:52:39 +08:00
parent 20d4b71591
commit 25476d1cea
16 changed files with 42 additions and 7 deletions

View File

@ -42,6 +42,8 @@ impl Default for AST {
}
impl fmt::Debug for AST {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut fp = f.debug_struct("AST");

View File

@ -117,6 +117,8 @@ pub struct FnCallHashes {
}
impl fmt::Debug for FnCallHashes {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[cfg(not(feature = "no_function"))]
if self.script != 0 {
@ -199,6 +201,8 @@ pub struct FnCallExpr {
}
impl fmt::Debug for FnCallExpr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut ff = f.debug_struct("FnCallExpr");
#[cfg(not(feature = "no_module"))]
@ -294,7 +298,8 @@ impl<F: Float> DerefMut for FloatWrapper<F> {
#[cfg(not(feature = "no_float"))]
impl<F: Float + fmt::Debug> fmt::Debug for FloatWrapper<F> {
#[inline(always)]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
@ -448,6 +453,8 @@ impl Default for Expr {
}
impl fmt::Debug for Expr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut display_pos = format!(" @ {:?}", self.start_position());

View File

@ -20,6 +20,8 @@ pub struct Ident {
}
impl fmt::Debug for Ident {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.name)?;
self.pos.debug_print(f)

View File

@ -29,6 +29,8 @@ pub struct Namespace {
}
impl fmt::Debug for Namespace {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_empty() {
return f.write_str("NONE");

View File

@ -106,6 +106,8 @@ impl OpAssignment {
}
impl fmt::Debug for OpAssignment {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_op_assignment() {
f.debug_struct("OpAssignment")
@ -178,7 +180,8 @@ pub enum RangeCase {
}
impl fmt::Debug for RangeCase {
#[inline]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ExclusiveInt(r, n) => write!(f, "{}..{} => {}", r.start, r.end, n),
@ -454,6 +457,8 @@ impl AsMut<[Stmt]> for StmtBlock {
}
impl fmt::Debug for StmtBlock {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("Block")?;
fmt::Debug::fmt(&self.block, f)?;

View File

@ -150,7 +150,8 @@ pub struct Engine {
}
impl fmt::Debug for Engine {
#[inline]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("Engine");

View File

@ -354,7 +354,8 @@ impl<K: Into<crate::ImmutableString>, M: Into<crate::Shared<crate::Module>>> Ext
}
impl fmt::Debug for GlobalRuntimeState<'_> {
#[inline]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_struct("GlobalRuntimeState");

View File

@ -27,6 +27,8 @@ pub enum CallableFunction {
}
impl fmt::Debug for CallableFunction {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Pure(..) => write!(f, "NativePureFunction"),

View File

@ -202,6 +202,8 @@ impl Default for Module {
}
impl fmt::Debug for Module {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut d = f.debug_struct("Module");

View File

@ -47,6 +47,8 @@ pub struct StepRange<T: Debug + Copy + PartialOrd> {
}
impl<T: Debug + Copy + PartialOrd> Debug for StepRange<T> {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple(&format!("StepRange<{}>", type_name::<T>()))
.field(&self.from)

View File

@ -241,6 +241,8 @@ impl fmt::Display for Position {
}
impl fmt::Debug for Position {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_none() {
f.write_str("none")
@ -333,7 +335,6 @@ impl Span {
}
impl fmt::Display for Span {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let _f = f;
@ -360,6 +361,8 @@ impl fmt::Display for Span {
}
impl fmt::Debug for Span {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}

View File

@ -17,6 +17,8 @@ pub struct CustomTypeInfo {
pub struct CustomTypesCollection(BTreeMap<Identifier, CustomTypeInfo>);
impl fmt::Debug for CustomTypesCollection {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("CustomTypesCollection ")?;
f.debug_map().entries(self.0.iter()).finish()

View File

@ -507,6 +507,8 @@ impl fmt::Display for Dynamic {
}
impl fmt::Debug for Dynamic {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.0 {
Union::Unit(ref v, ..) => fmt::Debug::fmt(v, f),

View File

@ -23,6 +23,8 @@ pub struct FnPtr {
}
impl fmt::Debug for FnPtr {
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if self.is_curried() {
self.curry

View File

@ -197,7 +197,8 @@ impl fmt::Display for ImmutableString {
}
impl fmt::Debug for ImmutableString {
#[inline(always)]
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(self.as_str(), f)
}

View File

@ -81,7 +81,6 @@ pub struct Scope<'a, const N: usize = SCOPE_ENTRIES_INLINED> {
}
impl fmt::Display for Scope<'_> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
for (i, (name, constant, value)) in self.iter_raw().enumerate() {
#[cfg(not(feature = "no_closure"))]