S390: Printf format specifier for size_t

GCC on S390 31-bit treats size_t as 'long unsigned int', which
is incompatible with %d format specifier that expects an 'int'.
Introduce a new V8 SIZET PREFIX to use %zd instead.

R=danno@chromium.org,jkummerow@chromium.org,jochen@chromium.org,jyan@ca.ibm.com,michael_dawson@ca.ibm.com,mbrandy@us.ibm.com,yangguo@chromium.org

BUG=

Review URL: https://codereview.chromium.org/1782293002

Cr-Commit-Position: refs/heads/master@{#34724}
This commit is contained in:
joransiu 2016-03-11 07:09:15 -08:00 committed by Commit bot
parent d1e3b72ede
commit 59267a08f1
4 changed files with 18 additions and 7 deletions

View File

@ -282,6 +282,15 @@ inline void USE(T) { }
#define V8PRIuPTR "lxu"
#endif
// GCC on S390 31-bit expands 'size_t' to 'long unsigned int'
// instead of 'int', resulting in compilation errors with %d.
// The printf format specifier needs to be %zd instead.
#if V8_HOST_ARCH_S390 && !V8_HOST_ARCH_64_BIT
#define V8_SIZET_PREFIX "z"
#else
#define V8_SIZET_PREFIX ""
#endif
// The following macro works on both 32 and 64-bit platforms.
// Usage: instead of writing 0x1234567890123456
// write V8_2PART_UINT64_C(0x12345678,90123456);

View File

@ -1224,7 +1224,8 @@ void GlobalHandles::PrintStats() {
}
PrintF("Global Handle Statistics:\n");
PrintF(" allocated memory = %" V8_PTR_PREFIX "dB\n", sizeof(Node) * total);
PrintF(" allocated memory = %" V8_SIZET_PREFIX V8_PTR_PREFIX "dB\n",
total * sizeof(Node));
PrintF(" # weak = %d\n", weak);
PrintF(" # pending = %d\n", pending);
PrintF(" # near_death = %d\n", near_death);

View File

@ -42,7 +42,8 @@ void GCIdleTimeAction::Print() {
void GCIdleTimeHeapState::Print() {
PrintF("contexts_disposed=%d ", contexts_disposed);
PrintF("contexts_disposal_rate=%f ", contexts_disposal_rate);
PrintF("size_of_objects=%" V8_PTR_PREFIX "d ", size_of_objects);
PrintF("size_of_objects=%" V8_SIZET_PREFIX V8_PTR_PREFIX "d ",
size_of_objects);
PrintF("incremental_marking_stopped=%d ", incremental_marking_stopped);
}

View File

@ -71,15 +71,15 @@ void Serializer::OutputStatistics(const char* name) {
for (int space = 0; space < kNumberOfPreallocatedSpaces; space++) {
size_t s = pending_chunk_[space];
for (uint32_t chunk_size : completed_chunks_[space]) s += chunk_size;
PrintF("%16" V8_PTR_PREFIX "d", s);
PrintF("%16" V8_SIZET_PREFIX V8_PTR_PREFIX "d", s);
}
PrintF("%16d\n", large_objects_total_size_);
#ifdef OBJECT_PRINT
PrintF(" Instance types (count and bytes):\n");
#define PRINT_INSTANCE_TYPE(Name) \
if (instance_type_count_[Name]) { \
PrintF("%10d %10" V8_PTR_PREFIX "d %s\n", instance_type_count_[Name], \
instance_type_size_[Name], #Name); \
#define PRINT_INSTANCE_TYPE(Name) \
if (instance_type_count_[Name]) { \
PrintF("%10d %10" V8_SIZET_PREFIX V8_PTR_PREFIX "d %s\n", \
instance_type_count_[Name], instance_type_size_[Name], #Name); \
}
INSTANCE_TYPE_LIST(PRINT_INSTANCE_TYPE)
#undef PRINT_INSTANCE_TYPE