Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix double printing in StressLog and simplify stresslog macros #105420

Merged
merged 10 commits into from
Jul 25, 2024
Prev Previous commit
Next Next commit
Move specializations out of StressLog and StressLogMsg
  • Loading branch information
jkoritzinsky committed Jul 24, 2024
commit 153251dd9a6c20cb003fcefdc7185da889dca370
28 changes: 14 additions & 14 deletions src/coreclr/gc/env/gcenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,6 @@ struct StressLogMsg
return (void*)(size_t)arg;
}

template<>
void* ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* ConvertArgument(double arg) = delete;
#endif

StressLogMsg(const char* format) : m_cArgs(0), m_format(format)
{
}
Expand All @@ -206,6 +192,20 @@ struct StressLogMsg
}
};

template<>
void* StressLogMsg::ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* StressLogMsg::ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* StressLogMsg::ConvertArgument(double arg) = delete;
#endif

class StressLog
{
public:
Expand Down
29 changes: 15 additions & 14 deletions src/coreclr/inc/stresslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,6 @@ class StressLog {
return (void*)(size_t)arg;
}

template<>
void* ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* ConvertArgument(double arg) = delete;
#endif

// Support functions for STRESS_LOG_VA
// We disable the warning "conversion from 'type' to 'type' of greater size" since everything will
// end up on the stack, and LogMsg will know the size of the variable based on the format string.
Expand Down Expand Up @@ -384,6 +370,21 @@ typedef USHORT
static StressLog theLog; // We only have one log, and this is it
};


template<>
void* StressLog::ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* StressLog::ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* StressLog::ConvertArgument(double arg) = delete;
#endif

#ifndef STRESS_LOG_ANALYZER
typedef Holder<CRITSEC_COOKIE, StressLog::Enter, StressLog::Leave, 0, CompareDefault<CRITSEC_COOKIE>> StressLogLockHolder;
#endif //!STRESS_LOG_ANALYZER
Expand Down
28 changes: 14 additions & 14 deletions src/coreclr/nativeaot/Runtime/inc/stressLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,6 @@ class StressLog {
return (void*)(size_t)arg;
}

template<>
void* ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* ConvertArgument(double arg) = delete;
#endif

template<typename... Ts>
static void LogMsgOL(const char* format, Ts... args)
{
Expand Down Expand Up @@ -358,6 +344,20 @@ class StressLog {
};


template<>
void* StressLog::ConvertArgument(float arg) = delete;

#if TARGET_64BIT
template<>
void* StressLog::ConvertArgument(double arg)
{
return (void*)(size_t)(*((uint64_t*)&arg));
}
#else
template<>
void* StressLog::ConvertArgument(double arg) = delete;
#endif

//==========================================================================================
// Private classes
//
Expand Down