Util::string_printf should do printf style argument checking

I made a mistake adding persistent target cache to
TranslatorX64::getUsage that would have been caught.

Also adds the persistent target cache stat.
Esse commit está contido em:
mwilliams
2013-04-10 09:19:01 -07:00
commit de Sara Golemon
commit dd56c6821f
5 arquivos alterados com 34 adições e 22 exclusões
+2 -2
Ver Arquivo
@@ -99,8 +99,8 @@ __thread void* tl_targetCaches = nullptr;
static_assert(kConditionFlagsOff + sizeof(ssize_t) <= 64,
"kConditionFlagsOff too large");
size_t s_frontier = kConditionFlagsOff + 64;
static size_t s_persistent_frontier = 0;
static size_t s_persistent_start = 0;
size_t s_persistent_frontier = 0;
size_t s_persistent_start = 0;
static size_t s_next_bit;
static size_t s_bits_to_go;
static int s_tc_fd;
+2
Ver Arquivo
@@ -40,6 +40,8 @@ void flush();
*/
extern __thread void* tl_targetCaches;
extern size_t s_frontier;
extern size_t s_persistent_frontier;
extern size_t s_persistent_start;
static const int kConditionFlagsOff = 0;
+7 -2
Ver Arquivo
@@ -12207,6 +12207,8 @@ std::string TranslatorX64::getUsage() {
size_t stubsUsage = astubs.code.frontier - astubs.code.base;
size_t dataUsage = m_globalData.frontier - m_globalData.base;
size_t tcUsage = TargetCache::s_frontier;
size_t persistentUsage =
TargetCache::s_persistent_frontier - TargetCache::s_persistent_start;
Util::string_printf(
usage,
"tx64: %9zd bytes (%" PRId64 "%%) in ahot.code\n"
@@ -12215,7 +12217,8 @@ std::string TranslatorX64::getUsage() {
"tx64: %9zd bytes (%" PRId64 "%%) in a.code from ir\n"
"tx64: %9zd bytes (%" PRId64 "%%) in astubs.code from ir\n"
"tx64: %9zd bytes (%" PRId64 "%%) in m_globalData\n"
"tx64: %9zd bytes (%" PRId64 "%%) in targetCache\n",
"tx64: %9zd bytes (%" PRId64 "%%) in targetCache\n"
"tx64: %9zd bytes (%" PRId64 "%%) in persistentCache\n",
aHotUsage, 100 * aHotUsage / ahot.code.size,
aUsage, 100 * aUsage / a.code.size,
stubsUsage, 100 * stubsUsage / astubs.code.size,
@@ -12223,7 +12226,9 @@ std::string TranslatorX64::getUsage() {
m_irAstubsUsage, 100 * m_irAstubsUsage / astubs.code.size,
dataUsage, 100 * dataUsage / m_globalData.size,
tcUsage,
100 * tcUsage / RuntimeOption::EvalJitTargetCacheSize);
400 * tcUsage / RuntimeOption::EvalJitTargetCacheSize / 3,
persistentUsage,
400 * persistentUsage / RuntimeOption::EvalJitTargetCacheSize);
return usage;
}
-17
Ver Arquivo
@@ -499,23 +499,6 @@ struct file_closer {
}
};
///////////////////////////////////////////////////////////////////////////////
// Non-gcc compat
#define ATTRIBUTE_UNUSED __attribute__((unused))
#define ATTRIBUTE_NORETURN __attribute__((noreturn))
#ifndef ATTRIBUTE_PRINTF
#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 6
#define ATTRIBUTE_PRINTF(a1,a2) __attribute__((__format__ (__printf__, a1, a2)))
#else
#define ATTRIBUTE_PRINTF(a1,a2)
#endif
#endif
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __ICC >= 1200 || __GNUC__ > 4
#define ATTRIBUTE_COLD __attribute__((cold))
#else
#define ATTRIBUTE_COLD
#endif
///////////////////////////////////////////////////////////////////////////////
/*
+23 -1
Ver Arquivo
@@ -36,6 +36,27 @@
namespace HPHP { namespace Util {
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Non-gcc compat
#ifndef __GNUC__
#define __attribute__(x)
#endif
#define ATTRIBUTE_UNUSED __attribute__((unused))
#define ATTRIBUTE_NORETURN __attribute__((noreturn))
#ifndef ATTRIBUTE_PRINTF
#if __GNUC__ > 2 || __GNUC__ == 2 && __GNUC_MINOR__ > 6
#define ATTRIBUTE_PRINTF(a1,a2) __attribute__((__format__ (__printf__, a1, a2)))
#else
#define ATTRIBUTE_PRINTF(a1,a2)
#endif
#endif
#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __ICC >= 1200 || __GNUC__ > 4
#define ATTRIBUTE_COLD __attribute__((cold))
#else
#define ATTRIBUTE_COLD
#endif
#define ALWAYS_INLINE __attribute__((always_inline))
#define NEVER_INLINE __attribute__((noinline))
#define INLINE_SINGLE_CALLER ALWAYS_INLINE
@@ -231,7 +252,8 @@ const void *buffer_append(const void *buf1, int size1,
/**
* printf into a std::string.
*/
void string_printf(std::string &msg, const char *fmt, ...);
void string_printf(std::string &msg,
const char *fmt, ...) ATTRIBUTE_PRINTF(2,3);
void string_vsnprintf(std::string &msg, const char *fmt, va_list ap);
/**