Commit 0fbc34d5 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[cleanup] Replace %PRIuS by %zu

The 'z' length modifier for {size_t} in format strings was introduced
with C99, hence it is available in all environments we support.

R=jgruber@chromium.org, mlippautz@chromium.org

Bug: v8:9183
Change-Id: I1bc2abec3f9c7b38186128202fef4719853de7d4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1613243Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61536}
parent b8c97dd2
......@@ -137,7 +137,7 @@ void ReportCompilationSuccess(Handle<Script> script, int position,
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
EmbeddedVector<char, 100> text;
int length = SNPrintF(
text, "success, asm->wasm: %0.3f ms, compile: %0.3f ms, %" PRIuS " bytes",
text, "success, asm->wasm: %0.3f ms, compile: %0.3f ms, %zu bytes",
translate_time, compile_time, module_size);
CHECK_NE(-1, length);
text.Truncate(length);
......@@ -264,7 +264,7 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
if (FLAG_trace_asm_parser) {
PrintF(
"[asm.js translation successful: time=%0.3fms, "
"translate_zone=%" PRIuS "KB, compile_zone+=%" PRIuS "KB]\n",
"translate_zone=%zuKB, compile_zone+=%zuKB]\n",
translate_time_, translate_zone_size_ / KB, compile_zone_size / KB);
}
return SUCCEEDED;
......
......@@ -15,11 +15,6 @@
// For wide strings, prepend "Wide" to the macro:
// int64_t value;
// StringPrintf(L"xyz: %" WidePRId64, value);
//
// To print a size_t value in a portable way:
// size_t size;
// printf("xyz: %" PRIuS, size);
// The "u" in the macro corresponds to %u, and S is for "size".
#include <stddef.h>
#include <stdint.h>
......@@ -46,10 +41,6 @@
#define WidePRIu64 PRIu64
#define WidePRIx64 PRIx64
#if !defined(PRIuS)
#define PRIuS "zu"
#endif
// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
// architectures and Apple does not provides standard format macros and
// recommends casting. This has many drawbacks, so instead define macros
......@@ -88,10 +79,6 @@
#define WidePRIu64 L"I64u"
#define WidePRIx64 L"I64x"
#if !defined(PRIuS)
#define PRIuS "Iu"
#endif
#endif
#endif // V8_BASE_FORMAT_MACROS_H_
......@@ -73,15 +73,15 @@ static void WriteLine(std::ostream& os, bool machine_format, const char* name,
static_cast<double>(total_stats.total_allocated_bytes_);
if (machine_format) {
base::OS::SNPrintF(buffer, kBufferSize,
"\"%s_time\"=%.3f\n\"%s_space\"=%" PRIuS, name, ms, name,
"\"%s_time\"=%.3f\n\"%s_space\"=%zu", name, ms, name,
stats.total_allocated_bytes_);
os << buffer;
} else {
base::OS::SNPrintF(
buffer, kBufferSize,
"%34s %10.3f (%5.1f%%) %10" PRIuS " (%5.1f%%) %10" PRIuS " %10" PRIuS,
name, ms, percent, stats.total_allocated_bytes_, size_percent,
stats.max_allocated_bytes_, stats.absolute_max_allocated_bytes_);
base::OS::SNPrintF(buffer, kBufferSize,
"%34s %10.3f (%5.1f%%) %10zu (%5.1f%%) %10zu %10zu",
name, ms, percent, stats.total_allocated_bytes_,
size_percent, stats.max_allocated_bytes_,
stats.absolute_max_allocated_bytes_);
os << buffer;
if (!stats.function_name_.empty()) {
......
......@@ -311,9 +311,9 @@ static int DecodeIt(Isolate* isolate, ExternalReferenceEncoder* ref_encoder,
it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) {
// raw pointer embedded in code stream, e.g., jump table
byte* ptr = *reinterpret_cast<byte**>(pc);
SNPrintF(
decode_buffer, "%08" V8PRIxPTR " jump table entry %4" PRIuS,
reinterpret_cast<intptr_t>(ptr), static_cast<size_t>(ptr - begin));
SNPrintF(decode_buffer, "%08" V8PRIxPTR " jump table entry %4zu",
reinterpret_cast<intptr_t>(ptr),
static_cast<size_t>(ptr - begin));
pc += sizeof(ptr);
} else {
decode_buffer[0] = '\0';
......
......@@ -1278,7 +1278,7 @@ void GlobalHandles::PrintStats() {
}
PrintF("Global Handle Statistics:\n");
PrintF(" allocated memory = %" PRIuS "B\n", total * sizeof(Node));
PrintF(" allocated memory = %zuB\n", total * sizeof(Node));
PrintF(" # weak = %d\n", weak);
PrintF(" # pending = %d\n", pending);
PrintF(" # near_death = %d\n", near_death);
......
......@@ -20,7 +20,7 @@ const size_t GCIdleTimeHandler::kMinTimeForOverApproximatingWeakClosureInMs = 1;
void GCIdleTimeHeapState::Print() {
PrintF("contexts_disposed=%d ", contexts_disposed);
PrintF("contexts_disposal_rate=%f ", contexts_disposal_rate);
PrintF("size_of_objects=%" PRIuS " ", size_of_objects);
PrintF("size_of_objects=%zu ", size_of_objects);
PrintF("incremental_marking_stopped=%d ", incremental_marking_stopped);
}
......
......@@ -530,20 +530,13 @@ void GCTracer::PrintNVP() const {
"incremental.steps_count=%d "
"incremental.steps_took=%.1f "
"scavenge_throughput=%.f "
"total_size_before=%" PRIuS
" "
"total_size_after=%" PRIuS
" "
"holes_size_before=%" PRIuS
" "
"holes_size_after=%" PRIuS
" "
"allocated=%" PRIuS
" "
"promoted=%" PRIuS
" "
"semi_space_copied=%" PRIuS
" "
"total_size_before=%zu "
"total_size_after=%zu "
"holes_size_before=%zu "
"holes_size_after=%zu "
"allocated=%zu "
"promoted=%zu "
"semi_space_copied=%zu "
"nodes_died_in_new=%d "
"nodes_copied_in_new=%d "
"nodes_promoted=%d "
......@@ -726,20 +719,13 @@ void GCTracer::PrintNVP() const {
"background.array_buffer_free=%.2f "
"background.store_buffer=%.2f "
"background.unmapper=%.1f "
"total_size_before=%" PRIuS
" "
"total_size_after=%" PRIuS
" "
"holes_size_before=%" PRIuS
" "
"holes_size_after=%" PRIuS
" "
"allocated=%" PRIuS
" "
"promoted=%" PRIuS
" "
"semi_space_copied=%" PRIuS
" "
"total_size_before=%zu "
"total_size_after=%zu "
"holes_size_before=%zu "
"holes_size_after=%zu "
"allocated=%zu "
"promoted=%zu "
"semi_space_copied=%zu "
"nodes_died_in_new=%d "
"nodes_copied_in_new=%d "
"nodes_promoted=%d "
......
......@@ -107,7 +107,7 @@ size_t MemoryController::CalculateAllocationLimit(
if (FLAG_trace_gc_verbose) {
Isolate::FromHeap(heap_)->PrintWithTimestamp(
"%s Limit: old size: %" PRIuS " KB, new limit: %" PRIuS " KB (%.1f)\n",
"%s Limit: old size: %zu KB, new limit: %zu KB (%.1f)\n",
ControllerName(), curr_size / KB, result / KB, factor);
}
......
......@@ -364,95 +364,76 @@ void Heap::SetGCState(HeapState state) {
void Heap::PrintShortHeapStatistics() {
if (!FLAG_trace_gc_verbose) return;
PrintIsolate(isolate_,
"Memory allocator, used: %6" PRIuS
" KB,"
" available: %6" PRIuS " KB\n",
"Memory allocator, used: %6zu KB,"
" available: %6zu KB\n",
memory_allocator()->Size() / KB,
memory_allocator()->Available() / KB);
PrintIsolate(isolate_,
"Read-only space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"Read-only space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
read_only_space_->Size() / KB,
read_only_space_->Available() / KB,
read_only_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"New space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"New space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
new_space_->Size() / KB, new_space_->Available() / KB,
new_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"New large object space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"New large object space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
new_lo_space_->SizeOfObjects() / KB,
new_lo_space_->Available() / KB,
new_lo_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Old space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"Old space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
old_space_->SizeOfObjects() / KB, old_space_->Available() / KB,
old_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Code space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS "KB\n",
"Code space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
code_space_->SizeOfObjects() / KB, code_space_->Available() / KB,
code_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Map space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"Map space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
map_space_->SizeOfObjects() / KB, map_space_->Available() / KB,
map_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Large object space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"Large object space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
lo_space_->CommittedMemory() / KB);
PrintIsolate(isolate_,
"Code large object space, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS " KB\n",
"Code large object space, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
code_lo_space_->SizeOfObjects() / KB,
code_lo_space_->Available() / KB,
code_lo_space_->CommittedMemory() / KB);
ReadOnlySpace* const ro_space = read_only_space_;
PrintIsolate(isolate_,
"All spaces, used: %6" PRIuS
" KB"
", available: %6" PRIuS
" KB"
", committed: %6" PRIuS "KB\n",
"All spaces, used: %6zu KB"
", available: %6zu KB"
", committed: %6zu KB\n",
(this->SizeOfObjects() + ro_space->SizeOfObjects()) / KB,
(this->Available() + ro_space->Available()) / KB,
(this->CommittedMemory() + ro_space->CommittedMemory()) / KB);
PrintIsolate(isolate_,
"Unmapper buffering %zu chunks of committed: %6" PRIuS " KB\n",
"Unmapper buffering %zu chunks of committed: %6zu KB\n",
memory_allocator()->unmapper()->NumberOfCommittedChunks(),
CommittedMemoryOfUnmapper() / KB);
PrintIsolate(isolate_, "External memory reported: %6" PRId64 " KB\n",
isolate()->isolate_data()->external_memory_ / KB);
PrintIsolate(isolate_, "Backing store memory: %6" PRIuS " KB\n",
PrintIsolate(isolate_, "Backing store memory: %6zu KB\n",
backing_store_bytes_ / KB);
PrintIsolate(isolate_, "External memory global %zu KB\n",
external_memory_callback_() / KB);
......@@ -2159,9 +2140,9 @@ void Heap::ComputeFastPromotionMode() {
!ShouldReduceMemory() && new_space_->IsAtMaximumCapacity() &&
survived_in_new_space >= kMinPromotedPercentForFastPromotionMode;
if (FLAG_trace_gc_verbose && !FLAG_trace_gc_ignore_scavenger) {
PrintIsolate(
isolate(), "Fast promotion mode: %s survival rate: %" PRIuS "%%\n",
fast_promotion_mode_ ? "true" : "false", survived_in_new_space);
PrintIsolate(isolate(), "Fast promotion mode: %s survival rate: %zu%%\n",
fast_promotion_mode_ ? "true" : "false",
survived_in_new_space);
}
}
......@@ -4215,7 +4196,7 @@ void Heap::ConfigureHeap(size_t max_semi_space_size_in_kb,
if (FLAG_trace_gc) {
PrintIsolate(isolate_,
"Min semi-space size cannot be more than the maximum "
"semi-space size of %" PRIuS " MB\n",
"semi-space size of %zu MB\n",
max_semi_space_size_ / MB);
}
} else {
......
......@@ -926,8 +926,8 @@ void IncrementalMarking::ScheduleBytesToMarkBasedOnTime(double time_ms) {
if (FLAG_trace_incremental_marking) {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Scheduled %" PRIuS
"KB to mark based on time delta %.1fms\n",
"[IncrementalMarking] Scheduled %zuKB to mark based on time delta "
"%.1fms\n",
bytes_to_mark / KB, delta_ms);
}
}
......@@ -1028,9 +1028,8 @@ void IncrementalMarking::ScheduleBytesToMarkBasedOnAllocation() {
if (FLAG_trace_incremental_marking) {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Scheduled %" PRIuS
"KB to mark based on allocation (progress="
"%" PRIuS "KB, allocation=%" PRIuS "KB)\n",
"[IncrementalMarking] Scheduled %zuKB to mark based on allocation "
"(progress=%zuKB, allocation=%zuKB)\n",
bytes_to_mark / KB, progress_bytes / KB, allocation_bytes / KB);
}
}
......@@ -1048,7 +1047,7 @@ void IncrementalMarking::FetchBytesMarkedConcurrently() {
}
if (FLAG_trace_incremental_marking) {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Marked %" PRIuS "KB on background threads\n",
"[IncrementalMarking] Marked %zuKB on background threads\n",
heap_->concurrent_marking()->TotalMarkedBytes() / KB);
}
}
......@@ -1059,11 +1058,11 @@ size_t IncrementalMarking::ComputeStepSizeInBytes(StepOrigin step_origin) {
if (FLAG_trace_incremental_marking) {
if (scheduled_bytes_to_mark_ > bytes_marked_) {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Marker is %" PRIuS "KB behind schedule\n",
"[IncrementalMarking] Marker is %zuKB behind schedule\n",
(scheduled_bytes_to_mark_ - bytes_marked_) / KB);
} else {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Marker is %" PRIuS "KB ahead of schedule\n",
"[IncrementalMarking] Marker is %zuKB ahead of schedule\n",
(bytes_marked_ - scheduled_bytes_to_mark_) / KB);
}
}
......@@ -1171,7 +1170,7 @@ StepResult IncrementalMarking::V8Step(double max_step_size_in_ms,
heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed);
if (FLAG_trace_incremental_marking) {
heap_->isolate()->PrintWithTimestamp(
"[IncrementalMarking] Step %s %" PRIuS "KB (%" PRIuS "KB) in %.1f\n",
"[IncrementalMarking] Step %s %zuKB (%zuKB) in %.1f\n",
step_origin == StepOrigin::kV8 ? "in v8" : "in task",
bytes_processed / KB, bytes_to_process / KB, duration);
}
......
......@@ -732,8 +732,8 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
if (FLAG_trace_fragmentation_verbose) {
PrintIsolate(isolate(),
"compaction-selection-page: space=%s free_bytes_page=%zu "
"fragmentation_limit_kb=%" PRIuS
" fragmentation_limit_percent=%d sum_compaction_kb=%zu "
"fragmentation_limit_kb=%zu "
"fragmentation_limit_percent=%d sum_compaction_kb=%zu "
"compaction_limit_kb=%zu\n",
space->name(), free_bytes / KB, free_bytes_threshold / KB,
target_fragmentation_percent, total_live_bytes / KB,
......
......@@ -2790,8 +2790,7 @@ class VerboseAccountingAllocator : public AccountingAllocator {
"\"time\": %f, "
"\"ptr\": \"%p\", "
"\"name\": \"%s\", "
"\"size\": %" PRIuS
","
"\"size\": %zu,"
"\"nesting\": %zu}\n",
type, reinterpret_cast<void*>(heap_->isolate()),
heap_->isolate()->time_millis_since_init(),
......@@ -2808,7 +2807,7 @@ class VerboseAccountingAllocator : public AccountingAllocator {
"\"type\": \"zone\", "
"\"isolate\": \"%p\", "
"\"time\": %f, "
"\"allocated\": %" PRIuS "}\n",
"\"allocated\": %zu}\n",
reinterpret_cast<void*>(heap_->isolate()), time, malloced);
}
......
......@@ -136,7 +136,7 @@ void AddressToTraceMap::Clear() {
void AddressToTraceMap::Print() {
PrintF("[AddressToTraceMap (%" PRIuS "): \n", ranges_.size());
PrintF("[AddressToTraceMap (%zu): \n", ranges_.size());
for (RangeMap::iterator it = ranges_.begin(); it != ranges_.end(); ++it) {
PrintF("[%p - %p] => %u\n", reinterpret_cast<void*>(it->second.start),
reinterpret_cast<void*>(it->first), it->second.trace_node_id);
......
......@@ -104,7 +104,7 @@ void HeapEntry::SetNamedAutoIndexReference(HeapGraphEdge::Type type,
void HeapEntry::Print(
const char* prefix, const char* edge_name, int max_depth, int indent) {
STATIC_ASSERT(sizeof(unsigned) == sizeof(id()));
base::OS::Print("%6" PRIuS " @%6u %*c %s%s: ", self_size(), id(), indent, ' ',
base::OS::Print("%6zu @%6u %*c %s%s: ", self_size(), id(), indent, ' ',
prefix, edge_name);
if (type() != kString) {
base::OS::Print("%s %.40s\n", TypeAsString(), name_);
......
......@@ -325,13 +325,12 @@ void ProfileNode::Print(int indent) {
base::OS::Print("\n");
for (size_t i = 0; i < deopt_infos_.size(); ++i) {
CpuProfileDeoptInfo& info = deopt_infos_[i];
base::OS::Print("%*s;;; deopted at script_id: %d position: %" PRIuS
" with reason '%s'.\n",
indent + 10, "", info.stack[0].script_id,
info.stack[0].position, info.deopt_reason);
base::OS::Print(
"%*s;;; deopted at script_id: %d position: %zu with reason '%s'.\n",
indent + 10, "", info.stack[0].script_id, info.stack[0].position,
info.deopt_reason);
for (size_t index = 1; index < info.stack.size(); ++index) {
base::OS::Print("%*s;;; Inline point: script_id %d position: %" PRIuS
".\n",
base::OS::Print("%*s;;; Inline point: script_id %d position: %zu.\n",
indent + 10, "", info.stack[index].script_id,
info.stack[index].position);
}
......
......@@ -144,7 +144,7 @@ void SerializerAllocator::OutputStatistics() {
for (int space = FIRST_SPACE; space < kNumberOfPreallocatedSpaces; space++) {
size_t s = pending_chunk_[space];
for (uint32_t chunk_size : completed_chunks_[space]) s += chunk_size;
PrintF("%16" PRIuS, s);
PrintF("%16zu", s);
}
STATIC_ASSERT(MAP_SPACE == kNumberOfPreallocatedSpaces);
......
......@@ -75,8 +75,7 @@ void Serializer::OutputStatistics(const char* name) {
#define PRINT_INSTANCE_TYPE(Name) \
for (int space = 0; space < LAST_SPACE; ++space) { \
if (instance_type_count_[space][Name]) { \
PrintF("%10d %10" PRIuS " %-10s %s\n", \
instance_type_count_[space][Name], \
PrintF("%10d %10zu %-10s %s\n", instance_type_count_[space][Name], \
instance_type_size_[space][Name], \
Heap::GetSpaceName(static_cast<AllocationSpace>(space)), #Name); \
} \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment