Revert of Fix printf formats (patchset #4 id:60001 of https://codereview.chromium.org/1877453002/ )

Reason for revert:
Breaks gc mole:
https://build.chromium.org/p/client.v8/builders/V8%20Linux/builds/9421

Original issue's description:
> Fix printf formats
>
> The usage of __attribute__((format(x, y)) was either wrong or missing from multiple functions, leading to erroneous formats. This CL:
>
>  - Imports PRINTF_FORMAT macro from Chrome's src/base/compiler-specific.h.
>  - Uses it appropriately.
>  - Imports Chrome's base/format_macros.h mainly to fix size_t formats (further cleanup could be done).
>  - Fixes a bunch of incorrect formats.
>
> Original CL: https://codereview.chromium.org/1869433004
> Reverted in: https://codereview.chromium.org/1867383002
>
> R= jochen@chromium.org
> TBR= bmeurer@chromium.org, yangguo@chromium.org, ahaas@chromium.org
>
> Committed: https://crrev.com/bf505329288e1b75bab0e6800371a9aac40fa5cc
> Cr-Commit-Position: refs/heads/master@{#35394}

TBR=jochen@chromium.org,ahaas@chromium.org,bmeurer@chromium.org,yangguo@chromium.org,jfb@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: refs/heads/master@{#35396}
This commit is contained in:
machenbach 2016-04-11 10:28:33 -07:00 committed by Commit bot
parent 9336f4cc6d
commit df826bf50f
40 changed files with 261 additions and 350 deletions

View File

@ -1798,7 +1798,6 @@ source_set("v8_libbase") {
"src/base/division-by-constant.cc",
"src/base/division-by-constant.h",
"src/base/flags.h",
"src/base/format-macros.h",
"src/base/functional.cc",
"src/base/functional.h",
"src/base/iterator.h",

View File

@ -14,7 +14,6 @@
#include "src/arm64/disasm-arm64.h"
#include "src/arm64/instrument-arm64.h"
#include "src/assembler.h"
#include "src/base/compiler-specific.h"
#include "src/globals.h"
#include "src/utils.h"
@ -795,7 +794,7 @@ class Simulator : public DecoderVisitor {
// Output stream.
FILE* stream_;
PrintDisassembler* print_disasm_;
void PRINTF_FORMAT(2, 3) TraceSim(const char* format, ...);
void PRINTF_METHOD_CHECKING TraceSim(const char* format, ...);
// Instrumentation.
Instrument* instrument_;

View File

@ -1055,8 +1055,7 @@ void PrettyPrinter::PrintLiteral(Handle<Object> value, bool quote) {
if (object->IsJSFunction()) {
Print("JS-Function");
} else if (object->IsJSArray()) {
Print("JS-array[%u]",
Smi::cast(JSArray::cast(object)->length())->value());
Print("JS-array[%u]", JSArray::cast(object)->length());
} else if (object->IsJSObject()) {
Print("JS-Object");
} else {
@ -1146,7 +1145,7 @@ void AstPrinter::PrintIndented(const char* txt) {
for (int i = 0; i < indent_; i++) {
Print(". ");
}
Print("%s", txt);
Print(txt);
}
@ -1523,7 +1522,7 @@ void AstPrinter::VisitRegExpLiteral(RegExpLiteral* node) {
if (node->flags() & RegExp::kSticky) buf[i++] = 'y';
buf[i] = '\0';
PrintIndented("FLAGS ");
Print("%s", buf.start());
Print(buf.start());
Print("\n");
}

View File

@ -7,7 +7,6 @@
#include "src/allocation.h"
#include "src/ast/ast.h"
#include "src/base/compiler-specific.h"
namespace v8 {
namespace internal {
@ -21,7 +20,7 @@ class CallPrinter : public AstVisitor {
// string. The result string is alive as long as the CallPrinter is alive.
const char* Print(FunctionLiteral* program, int position);
void PRINTF_FORMAT(2, 3) Print(const char* format, ...);
void Print(const char* format, ...);
void Find(AstNode* node, bool print = false);
@ -63,7 +62,7 @@ class PrettyPrinter: public AstVisitor {
const char* PrintExpression(FunctionLiteral* program);
const char* PrintProgram(FunctionLiteral* program);
void PRINTF_FORMAT(2, 3) Print(const char* format, ...);
void Print(const char* format, ...);
// Print a node to stdout.
static void PrintOut(Isolate* isolate, AstNode* node);

View File

@ -26,17 +26,6 @@
#define WARN_UNUSED_RESULT /* NOT SUPPORTED */
#endif
// Tell the compiler a function is using a printf-style format string.
// |format_param| is the one-based index of the format string parameter;
// |dots_param| is the one-based index of the "..." parameter.
// For v*printf functions (which take a va_list), pass 0 for dots_param.
// (This is undocumented but matches what the system C headers do.)
#if defined(__GNUC__)
#define PRINTF_FORMAT(format_param, dots_param) \
__attribute__((format(printf, format_param, dots_param)))
#else
#define PRINTF_FORMAT(format_param, dots_param)
#endif
// The C++ standard requires that static const members have an out-of-class
// definition (in a single compilation unit), but MSVC chokes on this (when

View File

@ -1,97 +0,0 @@
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_FORMAT_MACROS_H_
#define BASE_FORMAT_MACROS_H_
// This file defines the format macros for some integer types.
// To print a 64-bit value in a portable way:
// int64_t value;
// printf("xyz:%" PRId64, value);
// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
//
// 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>
#include "src/base/build_config.h"
#if defined(V8_OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \
!defined(PRId64)
#error "inttypes.h has already been included before this header file, but "
#error "without __STDC_FORMAT_MACROS defined."
#endif
#if defined(V8_OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
#include <inttypes.h>
#if defined(V8_OS_POSIX)
// GCC will concatenate wide and narrow strings correctly, so nothing needs to
// be done here.
#define WidePRId64 PRId64
#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
// for formatting those types.
#if defined(V8_OS_MACOSX)
#if defined(V8_HOST_ARCH_64_BIT)
#if !defined(PRIdNS)
#define PRIdNS "ld"
#endif
#if !defined(PRIuNS)
#define PRIuNS "lu"
#endif
#if !defined(PRIxNS)
#define PRIxNS "lx"
#endif
#else // defined(V8_HOST_ARCH_64_BIT)
#if !defined(PRIdNS)
#define PRIdNS "d"
#endif
#if !defined(PRIuNS)
#define PRIuNS "u"
#endif
#if !defined(PRIxNS)
#define PRIxNS "x"
#endif
#endif
#endif // defined(V8_OS_MACOSX)
#else // V8_OS_WIN
#if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
#error "inttypes.h provided by win toolchain should define these."
#endif
#define WidePRId64 L"I64d"
#define WidePRIu64 L"I64u"
#define WidePRIx64 L"I64x"
#if !defined(PRIuS)
#define PRIuS "Iu"
#endif
#endif
#endif // BASE_FORMAT_MACROS_H_

View File

@ -10,10 +10,9 @@
#include <string>
#include "src/base/build_config.h"
#include "src/base/compiler-specific.h"
extern "C" PRINTF_FORMAT(3, 4) V8_NORETURN
void V8_Fatal(const char* file, int line, const char* format, ...);
extern "C" V8_NORETURN void V8_Fatal(const char* file, int line,
const char* format, ...);
extern "C" void V8_RuntimeError(const char* file, int line,
const char* message);

View File

@ -5,8 +5,13 @@
#ifndef V8_BASE_MACROS_H_
#define V8_BASE_MACROS_H_
#include <stddef.h>
#include <stdint.h>
#include <cstring>
#include "src/base/build_config.h"
#include "src/base/compiler-specific.h"
#include "src/base/format-macros.h"
#include "src/base/logging.h"
@ -269,27 +274,23 @@ inline void USE(T) { }
#define V8PRIdPTR V8_PTR_PREFIX "d"
#define V8PRIuPTR V8_PTR_PREFIX "u"
// ptrdiff_t is 't' according to the standard, but MSVC uses 'I'.
#if V8_CC_MSVC
#define V8PRIxPTRDIFF "Ix"
#define V8PRIdPTRDIFF "Id"
#define V8PRIuPTRDIFF "Iu"
#else
#define V8PRIxPTRDIFF "tx"
#define V8PRIdPTRDIFF "td"
#define V8PRIuPTRDIFF "tu"
#endif
// Fix for Mac OS X defining uintptr_t as "unsigned long":
#if V8_OS_MACOSX
#undef V8PRIxPTR
#define V8PRIxPTR "lx"
#undef V8PRIdPTR
#define V8PRIdPTR "ld"
#undef V8PRIuPTR
#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

@ -26,7 +26,6 @@
#include <vector>
#include "src/base/build_config.h"
#include "src/base/compiler-specific.h"
#include "src/base/platform/mutex.h"
#include "src/base/platform/semaphore.h"
@ -155,19 +154,18 @@ class OS {
// Print output to console. This is mostly used for debugging output.
// On platforms that has standard terminal output, the output
// should go to stdout.
static PRINTF_FORMAT(1, 2) void Print(const char* format, ...);
static PRINTF_FORMAT(1, 0) void VPrint(const char* format, va_list args);
static void Print(const char* format, ...);
static void VPrint(const char* format, va_list args);
// Print output to a file. This is mostly used for debugging output.
static PRINTF_FORMAT(2, 3) void FPrint(FILE* out, const char* format, ...);
static PRINTF_FORMAT(2, 0) void VFPrint(FILE* out, const char* format,
va_list args);
static void FPrint(FILE* out, const char* format, ...);
static void VFPrint(FILE* out, const char* format, va_list args);
// Print error output to console. This is mostly used for error message
// output. On platforms that has standard terminal output, the output
// should go to stderr.
static PRINTF_FORMAT(1, 2) void PrintError(const char* format, ...);
static PRINTF_FORMAT(1, 0) void VPrintError(const char* format, va_list args);
static void PrintError(const char* format, ...);
static void VPrintError(const char* format, va_list args);
// Allocate/Free memory used by JS heap. Pages are readable/writable, but
// they are not guaranteed to be executable unless 'executable' is true.
@ -224,10 +222,11 @@ class OS {
// Safe formatting print. Ensures that str is always null-terminated.
// Returns the number of chars written, or -1 if output was truncated.
static PRINTF_FORMAT(3, 4) int SNPrintF(char* str, int length,
const char* format, ...);
static PRINTF_FORMAT(3, 0) int VSNPrintF(char* str, int length,
const char* format, va_list args);
static int SNPrintF(char* str, int length, const char* format, ...);
static int VSNPrintF(char* str,
int length,
const char* format,
va_list args);
static char* StrChr(char* str, int c);
static void StrNCpy(char* dest, int length, const char* src, size_t n);

View File

@ -66,8 +66,9 @@ static void WriteLine(std::ostream& os, const char* name,
double size_percent =
static_cast<double>(stats.total_allocated_bytes_ * 100) /
static_cast<double>(total_stats.total_allocated_bytes_);
base::OS::SNPrintF(buffer, kBufferSize, "%28s %10.3f (%5.1f%%) %10" PRIuS
" (%5.1f%%) %10" PRIuS " %10" PRIuS,
base::OS::SNPrintF(buffer, kBufferSize,
"%28s %10.3f (%5.1f%%) "
"%10u (%5.1f%%) %10u %10u",
name, ms, percent, stats.total_allocated_bytes_,
size_percent, stats.max_allocated_bytes_,
stats.absolute_max_allocated_bytes_);

View File

@ -5,7 +5,6 @@
#ifndef V8_CRANKSHAFT_HYDROGEN_RANGE_ANALYSIS_H_
#define V8_CRANKSHAFT_HYDROGEN_RANGE_ANALYSIS_H_
#include "src/base/compiler-specific.h"
#include "src/crankshaft/hydrogen.h"
namespace v8 {
@ -22,7 +21,7 @@ class HRangeAnalysisPhase : public HPhase {
void Run();
private:
PRINTF_FORMAT(2, 3) void TraceRange(const char* msg, ...);
void TraceRange(const char* msg, ...);
void InferControlFlowRange(HCompareNumericAndBranch* test,
HBasicBlock* dest);
void UpdateControlFlowRange(Token::Value op, HValue* value, HValue* other);

View File

@ -6,7 +6,6 @@
#define V8_CRANKSHAFT_LITHIUM_ALLOCATOR_H_
#include "src/allocation.h"
#include "src/base/compiler-specific.h"
#include "src/crankshaft/compilation-phase.h"
#include "src/crankshaft/lithium.h"
#include "src/zone.h"
@ -328,7 +327,7 @@ class LAllocator BASE_EMBEDDED {
public:
LAllocator(int first_virtual_register, HGraph* graph);
static PRINTF_FORMAT(1, 2) void TraceAlloc(const char* msg, ...);
static void TraceAlloc(const char* msg, ...);
// Checks whether the value of a given virtual register is tagged.
bool HasTaggedValue(int virtual_register) const;

View File

@ -35,7 +35,7 @@ class LCodeGenBase BASE_EMBEDDED {
LPlatformChunk* chunk() const { return chunk_; }
HGraph* graph() const;
void PRINTF_FORMAT(2, 3) Comment(const char* format, ...);
void FPRINTF_CHECKING Comment(const char* format, ...);
void DeoptComment(const Deoptimizer::DeoptInfo& deopt_info);
static Deoptimizer::DeoptInfo MakeDeoptInfo(
LInstruction* instr, Deoptimizer::DeoptReason deopt_reason);

View File

@ -109,9 +109,10 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
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 %4" V8PRIdPTR,
reinterpret_cast<intptr_t>(ptr),
ptr - begin);
pc += sizeof(ptr);
} else {
decode_buffer[0] = '\0';
@ -146,7 +147,7 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
}
// Instruction address and instruction offset.
out.AddFormatted("%p %4" V8PRIdPTRDIFF " ", prev_pc, prev_pc - begin);
out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin);
// Instruction.
out.AddFormatted("%s", decode_buffer.start());
@ -170,11 +171,9 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
RelocInfo::Mode rmode = relocinfo.rmode();
if (RelocInfo::IsPosition(rmode)) {
if (RelocInfo::IsStatementPosition(rmode)) {
out.AddFormatted(" ;; debug: statement %" V8PRIdPTR,
relocinfo.data());
out.AddFormatted(" ;; debug: statement %d", relocinfo.data());
} else {
out.AddFormatted(" ;; debug: position %" V8PRIdPTR,
relocinfo.data());
out.AddFormatted(" ;; debug: position %d", relocinfo.data());
}
} else if (rmode == RelocInfo::DEOPT_REASON) {
Deoptimizer::DeoptReason reason =

View File

@ -888,7 +888,7 @@ void ObjectGroupsTracer::PrintInternalFields(JSObject* js_object) {
}
void ObjectGroupsTracer::PrintObjectGroup(ObjectGroup* group) {
PrintIsolate(isolate_, "ObjectGroup (size: %" PRIuS ")\n", group->length);
PrintIsolate(isolate_, "ObjectGroup (size: %lu)\n", group->length);
Object*** objects = group->objects;
for (size_t i = 0; i < group->length; ++i) {
@ -898,7 +898,7 @@ void ObjectGroupsTracer::PrintObjectGroup(ObjectGroup* group) {
}
void ObjectGroupsTracer::PrintImplicitRefGroup(ImplicitRefGroup* group) {
PrintIsolate(isolate_, "ImplicitRefGroup (children count: %" PRIuS ")\n",
PrintIsolate(isolate_, "ImplicitRefGroup (children count: %lu)\n",
group->length);
PrintIsolate(isolate_, " - Parent: ");
PrintObject(*(group->parent));
@ -1223,7 +1223,8 @@ void GlobalHandles::PrintStats() {
}
PrintF("Global Handle Statistics:\n");
PrintF(" allocated memory = %" PRIuS "B\n", total * sizeof(Node));
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

@ -41,7 +41,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=%" PRIuS " ", 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

@ -411,7 +411,7 @@ void GCTracer::Output(const char* format, ...) const {
void GCTracer::Print() const {
if (FLAG_trace_gc) {
PrintIsolate(heap_->isolate(), "%s", "");
PrintIsolate(heap_->isolate(), "");
}
Output("%8.0f ms: ", heap_->isolate()->time_millis_since_init());
@ -480,20 +480,20 @@ void GCTracer::PrintNVP() const {
"steps_count=%d "
"steps_took=%.1f "
"scavenge_throughput=%.f "
"total_size_before=%" V8PRIdPTR
" "
"total_size_after=%" V8PRIdPTR
" "
"holes_size_before=%" V8PRIdPTR
" "
"holes_size_after=%" V8PRIdPTR
" "
"allocated=%" V8PRIdPTR
" "
"promoted=%" V8PRIdPTR
" "
"semi_space_copied=%" V8PRIdPTR
" "
"total_size_before=%" V8_PTR_PREFIX
"d "
"total_size_after=%" V8_PTR_PREFIX
"d "
"holes_size_before=%" V8_PTR_PREFIX
"d "
"holes_size_after=%" V8_PTR_PREFIX
"d "
"allocated=%" V8_PTR_PREFIX
"d "
"promoted=%" V8_PTR_PREFIX
"d "
"semi_space_copied=%" V8_PTR_PREFIX
"d "
"nodes_died_in_new=%d "
"nodes_copied_in_new=%d "
"nodes_promoted=%d "
@ -586,20 +586,20 @@ void GCTracer::PrintNVP() const {
"finalization_steps_took=%.1f "
"finalization_longest_step=%.1f "
"incremental_marking_throughput=%.f "
"total_size_before=%" V8PRIdPTR
" "
"total_size_after=%" V8PRIdPTR
" "
"holes_size_before=%" V8PRIdPTR
" "
"holes_size_after=%" V8PRIdPTR
" "
"allocated=%" V8PRIdPTR
" "
"promoted=%" V8PRIdPTR
" "
"semi_space_copied=%" V8PRIdPTR
" "
"total_size_before=%" V8_PTR_PREFIX
"d "
"total_size_after=%" V8_PTR_PREFIX
"d "
"holes_size_before=%" V8_PTR_PREFIX
"d "
"holes_size_after=%" V8_PTR_PREFIX
"d "
"allocated=%" V8_PTR_PREFIX
"d "
"promoted=%" V8_PTR_PREFIX
"d "
"semi_space_copied=%" V8_PTR_PREFIX
"d "
"nodes_died_in_new=%d "
"nodes_copied_in_new=%d "
"nodes_promoted=%d "

View File

@ -5,7 +5,6 @@
#ifndef V8_HEAP_GC_TRACER_H_
#define V8_HEAP_GC_TRACER_H_
#include "src/base/compiler-specific.h"
#include "src/base/platform/platform.h"
#include "src/counters.h"
#include "src/globals.h"
@ -384,7 +383,7 @@ class GCTracer {
// Prints a line and also adds it to the heap's ring buffer so that
// it can be included in later crash dumps.
void PRINTF_FORMAT(2, 3) Output(const char* format, ...) const;
void Output(const char* format, ...) const;
void ClearMarkCompactStatistics() {
cumulative_incremental_marking_steps_ = 0;

View File

@ -343,59 +343,61 @@ void Heap::ReportStatisticsBeforeGC() {
void Heap::PrintShortHeapStatistics() {
if (!FLAG_trace_gc_verbose) return;
PrintIsolate(isolate_, "Memory allocator, used: %6" V8PRIdPTR
" KB, available: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "Memory allocator, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX "d KB\n",
memory_allocator()->Size() / KB,
memory_allocator()->Available() / KB);
PrintIsolate(isolate_, "New space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "New space, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
new_space_.Size() / KB, new_space_.Available() / KB,
new_space_.CommittedMemory() / KB);
PrintIsolate(isolate_, "Old space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "Old space, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
old_space_->SizeOfObjects() / KB, old_space_->Available() / KB,
old_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Code space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "Code space, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
code_space_->SizeOfObjects() / KB, code_space_->Available() / KB,
code_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Map space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "Map space, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
map_space_->SizeOfObjects() / KB, map_space_->Available() / KB,
map_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "Large object space, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "Large object space, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
lo_space_->SizeOfObjects() / KB, lo_space_->Available() / KB,
lo_space_->CommittedMemory() / KB);
PrintIsolate(isolate_, "All spaces, used: %6" V8PRIdPTR
" KB"
", available: %6" V8PRIdPTR
" KB"
", committed: %6" V8PRIdPTR " KB\n",
PrintIsolate(isolate_, "All spaces, used: %6" V8_PTR_PREFIX
"d KB"
", available: %6" V8_PTR_PREFIX
"d KB"
", committed: %6" V8_PTR_PREFIX "d KB\n",
this->SizeOfObjects() / KB, this->Available() / KB,
this->CommittedMemory() / KB);
PrintIsolate(
isolate_, "External memory reported: %6" V8PRIdPTR " KB\n",
isolate_, "External memory reported: %6" V8_PTR_PREFIX "d KB\n",
static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB));
PrintIsolate(isolate_, "Total time spent in GC : %.1f ms\n",
total_gc_time_ms_);
}
// TODO(1238405): Combine the infrastructure for --heap-stats and
// --log-gc to avoid the complicated preprocessor and flag testing.
void Heap::ReportStatisticsAfterGC() {
@ -4482,7 +4484,7 @@ void Heap::ReportHeapStatistics(const char* title) {
USE(title);
PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title,
gc_count_);
PrintF("old_generation_allocation_limit_ %" V8PRIdPTR "\n",
PrintF("old_generation_allocation_limit_ %" V8_PTR_PREFIX "d\n",
old_generation_allocation_limit_);
PrintF("\n");
@ -5149,8 +5151,8 @@ void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size,
CalculateOldGenerationAllocationLimit(factor, old_gen_size);
if (FLAG_trace_gc_verbose) {
PrintIsolate(isolate_, "Grow: old size: %" V8PRIdPTR
" KB, new limit: %" V8PRIdPTR " KB (%.1f)\n",
PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX
"d KB, new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n",
old_gen_size / KB, old_generation_allocation_limit_ / KB,
factor);
}
@ -5164,10 +5166,10 @@ void Heap::DampenOldGenerationAllocationLimit(intptr_t old_gen_size,
intptr_t limit = CalculateOldGenerationAllocationLimit(factor, old_gen_size);
if (limit < old_generation_allocation_limit_) {
if (FLAG_trace_gc_verbose) {
PrintIsolate(isolate_,
"Dampen: old size: %" V8PRIdPTR " KB, old limit: %" V8PRIdPTR
" KB, "
"new limit: %" V8PRIdPTR " KB (%.1f)\n",
PrintIsolate(isolate_, "Dampen: old size: %" V8_PTR_PREFIX
"d KB, old limit: %" V8_PTR_PREFIX
"d KB, "
"new limit: %" V8_PTR_PREFIX "d KB (%.1f)\n",
old_gen_size / KB, old_generation_allocation_limit_ / KB,
limit / KB, factor);
}
@ -5392,7 +5394,7 @@ void Heap::TearDown() {
PrintF("max_gc_pause=%.1f ", get_max_gc_pause());
PrintF("total_gc_time=%.1f ", total_gc_time_ms_);
PrintF("min_in_mutator=%.1f ", get_min_in_mutator());
PrintF("max_alive_after_gc=%" V8PRIdPTR " ", get_max_alive_after_gc());
PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc());
PrintF("total_marking_time=%.1f ", tracer()->cumulative_marking_duration());
PrintF("total_sweeping_time=%.1f ",
tracer()->cumulative_sweeping_duration());
@ -5401,17 +5403,17 @@ void Heap::TearDown() {
if (FLAG_print_max_heap_committed) {
PrintF("\n");
PrintF("maximum_committed_by_heap=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_heap=%" V8_PTR_PREFIX "d ",
MaximumCommittedMemory());
PrintF("maximum_committed_by_new_space=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_new_space=%" V8_PTR_PREFIX "d ",
new_space_.MaximumCommittedMemory());
PrintF("maximum_committed_by_old_space=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_old_space=%" V8_PTR_PREFIX "d ",
old_space_->MaximumCommittedMemory());
PrintF("maximum_committed_by_code_space=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_code_space=%" V8_PTR_PREFIX "d ",
code_space_->MaximumCommittedMemory());
PrintF("maximum_committed_by_map_space=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_map_space=%" V8_PTR_PREFIX "d ",
map_space_->MaximumCommittedMemory());
PrintF("maximum_committed_by_lo_space=%" V8PRIdPTR " ",
PrintF("maximum_committed_by_lo_space=%" V8_PTR_PREFIX "d ",
lo_space_->MaximumCommittedMemory());
PrintF("\n\n");
}

View File

@ -759,8 +759,8 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
if (FLAG_trace_fragmentation_verbose) {
PrintIsolate(isolate(),
"compaction-selection-page: space=%s free_bytes_page=%d "
"fragmentation_limit_kb=%" V8PRIdPTR
" fragmentation_limit_percent=%d sum_compaction_kb=%d "
"fragmentation_limit_kb=%d fragmentation_limit_percent=%d "
"sum_compaction_kb=%d "
"compaction_limit_kb=%d\n",
AllocationSpaceName(space->identity()), free_bytes / KB,
free_bytes_threshold / KB, target_fragmentation_percent,
@ -3142,10 +3142,11 @@ void MarkCompactCollector::EvacuatePagesInParallel() {
delete[] evacuators;
if (FLAG_trace_evacuation) {
PrintIsolate(isolate(),
"%8.0f ms: evacuation-summary: parallel=%s pages=%d "
"aborted=%d wanted_tasks=%d tasks=%d cores=%" PRIuS
" live_bytes=%" V8PRIdPTR " compaction_speed=%.f\n",
PrintIsolate(
isolate(),
"%8.0f ms: evacuation-summary: parallel=%s pages=%d aborted=%d "
"wanted_tasks=%d tasks=%d cores=%d live_bytes=%" V8_PTR_PREFIX
"d compaction_speed=%.f\n",
isolate()->time_millis_since_init(),
FLAG_parallel_compaction ? "yes" : "no", job.NumberOfPages(),
abandoned_pages, wanted_num_tasks, job.NumberOfTasks(),

View File

@ -882,7 +882,10 @@ void MemoryAllocator::RemoveMemoryAllocationCallback(
void MemoryAllocator::ReportStatistics() {
intptr_t size = Size();
float pct = static_cast<float>(capacity_ - size) / capacity_;
PrintF(" capacity: %" V8PRIdPTR ", used: %" V8PRIdPTR
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", used: %" V8_PTR_PREFIX
"d"
", available: %%%d\n\n",
capacity_, size, static_cast<int>(pct * 100));
}
@ -2059,7 +2062,9 @@ void NewSpace::ReportStatistics() {
#ifdef DEBUG
if (FLAG_heap_stats) {
float pct = static_cast<float>(Available()) / TotalCapacity();
PrintF(" capacity: %" V8PRIdPTR ", available: %" V8PRIdPTR ", %%%d\n",
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", available: %" V8_PTR_PREFIX "d, %%%d\n",
TotalCapacity(), Available(), static_cast<int>(pct * 100));
PrintF("\n Object Histogram:\n");
for (int i = 0; i <= LAST_TYPE; i++) {
@ -2785,8 +2790,11 @@ void PagedSpace::CollectCodeStatistics() {
void PagedSpace::ReportStatistics() {
int pct = static_cast<int>(Available() * 100 / Capacity());
PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR
", available: %" V8PRIdPTR ", %%%d\n",
PrintF(" capacity: %" V8_PTR_PREFIX
"d"
", waste: %" V8_PTR_PREFIX
"d"
", available: %" V8_PTR_PREFIX "d, %%%d\n",
Capacity(), Waste(), Available(), pct);
if (heap()->mark_compact_collector()->sweeping_in_progress()) {
@ -3082,7 +3090,7 @@ void LargeObjectSpace::Print() {
void LargeObjectSpace::ReportStatistics() {
PrintF(" size: %" V8PRIdPTR "\n", size_);
PrintF(" size: %" V8_PTR_PREFIX "d\n", size_);
int num_objects = 0;
ClearHistograms(heap()->isolate());
LargeObjectIterator it(this);
@ -3093,7 +3101,7 @@ void LargeObjectSpace::ReportStatistics() {
PrintF(
" number of objects %d, "
"size of objects %" V8PRIdPTR "\n",
"size of objects %" V8_PTR_PREFIX "d\n",
num_objects, objects_size_);
if (num_objects > 0) ReportHistogram(heap()->isolate(), false);
}

View File

@ -8,7 +8,6 @@
#if V8_TARGET_ARCH_IA32
#include "src/base/compiler-specific.h"
#include "src/disasm.h"
namespace disasm {
@ -390,7 +389,8 @@ class DisassemblerIA32 {
int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start);
int RegisterFPUInstruction(int escape_opcode, byte modrm_byte);
int AVXInstruction(byte* data);
PRINTF_FORMAT(2, 3) void AppendToBuffer(const char* format, ...);
void AppendToBuffer(const char* format, ...);
void UnimplementedInstruction() {
if (abort_on_unimplemented_) {
@ -1274,7 +1274,7 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
const InstructionDesc& idesc = instruction_table_->Get(*data);
switch (idesc.type) {
case ZERO_OPERANDS_INSTR:
AppendToBuffer("%s", idesc.mnem);
AppendToBuffer(idesc.mnem);
data++;
break;

View File

@ -2924,7 +2924,7 @@ void Isolate::CheckDetachedContextsAfterGC() {
DCHECK(detached_contexts->get(i + 1)->IsWeakCell());
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
if (mark_sweeps > 3) {
PrintF("detached context %p\n survived %d GCs (leak?)\n",
PrintF("detached context 0x%p\n survived %d GCs (leak?)\n",
static_cast<void*>(cell->value()), mark_sweeps);
}
}

View File

@ -164,7 +164,11 @@ void Log::MessageBuilder::Append(String* str) {
}
}
void Log::MessageBuilder::AppendAddress(Address addr) { Append("%p", addr); }
void Log::MessageBuilder::AppendAddress(Address addr) {
Append("0x%" V8PRIxPTR, addr);
}
void Log::MessageBuilder::AppendSymbolName(Symbol* symbol) {
DCHECK(symbol);

View File

@ -10,7 +10,6 @@
#include <cstdarg>
#include "src/allocation.h"
#include "src/base/compiler-specific.h"
#include "src/base/platform/mutex.h"
#include "src/flags.h"
@ -63,10 +62,10 @@ class Log {
~MessageBuilder() { }
// Append string data to the log message.
void PRINTF_FORMAT(2, 3) Append(const char* format, ...);
void Append(const char* format, ...);
// Append string data to the log message.
void PRINTF_FORMAT(2, 0) AppendVA(const char* format, va_list args);
void AppendVA(const char* format, va_list args);
// Append a character to the log message.
void Append(const char c);

View File

@ -284,11 +284,12 @@ void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
return;
}
base::OS::FPrint(perf_output_handle_, "%p %x %.*s\n",
code->instruction_start(), code->instruction_size(), length,
name);
base::OS::FPrint(perf_output_handle_, "%llx %x %.*s\n",
reinterpret_cast<uint64_t>(code->instruction_start()),
code->instruction_size(), length, name);
}
// Low-level logging support.
#define LL_LOG(Call) if (ll_logger_) ll_logger_->Call;
@ -788,7 +789,7 @@ void Logger::UncheckedIntEvent(const char* name, int value) {
void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) {
if (!log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,%" V8PRIdPTR, name, value);
msg.Append("%s,%" V8_PTR_PREFIX "d", name, value);
msg.WriteToLogFile();
}
@ -796,7 +797,7 @@ void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) {
void Logger::HandleEvent(const char* name, Object** location) {
if (!log_->IsEnabled() || !FLAG_log_handles) return;
Log::MessageBuilder msg(log_);
msg.Append("%s,%p", name, location);
msg.Append("%s,0x%" V8PRIxPTR, name, location);
msg.WriteToLogFile();
}
@ -837,7 +838,7 @@ void Logger::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) {
if (!log_->IsEnabled() || !FLAG_log_internal_timer_events) return;
Log::MessageBuilder msg(log_);
int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds());
msg.Append("code-deopt,%d,%d", since_epoch, code->CodeSize());
msg.Append("code-deopt,%ld,%d", since_epoch, code->CodeSize());
msg.WriteToLogFile();
}
@ -847,7 +848,7 @@ void Logger::CurrentTimeEvent() {
DCHECK(FLAG_log_timer_events || FLAG_prof_cpp);
Log::MessageBuilder msg(log_);
int since_epoch = static_cast<int>(timer_.Elapsed().InMicroseconds());
msg.Append("current-time,%d", since_epoch);
msg.Append("current-time,%ld", since_epoch);
msg.WriteToLogFile();
}
@ -1007,7 +1008,8 @@ void Logger::ApiEntryCall(const char* name) {
void Logger::NewEvent(const char* name, void* object, size_t size) {
if (!log_->IsEnabled() || !FLAG_log) return;
Log::MessageBuilder msg(log_);
msg.Append("new,%s,%p,%u", name, object, static_cast<unsigned int>(size));
msg.Append("new,%s,0x%" V8PRIxPTR ",%u", name, object,
static_cast<unsigned int>(size));
msg.WriteToLogFile();
}
@ -1015,7 +1017,7 @@ void Logger::NewEvent(const char* name, void* object, size_t size) {
void Logger::DeleteEvent(const char* name, void* object) {
if (!log_->IsEnabled() || !FLAG_log) return;
Log::MessageBuilder msg(log_);
msg.Append("delete,%s,%p", name, object);
msg.Append("delete,%s,0x%" V8PRIxPTR, name, object);
msg.WriteToLogFile();
}
@ -1035,12 +1037,12 @@ void Logger::CallbackEventInternal(const char* prefix, Name* name,
} else {
Symbol* symbol = Symbol::cast(name);
if (symbol->name()->IsUndefined()) {
msg.Append(",1,symbol(hash %x)", symbol->Hash());
msg.Append(",1,symbol(hash %x)", prefix, symbol->Hash());
} else {
base::SmartArrayPointer<char> str =
String::cast(symbol->name())
->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
msg.Append(",1,symbol(\"%s%s\" hash %x)", prefix, str.get(),
msg.Append(",1,symbol(\"%s\" hash %x)", prefix, str.get(),
symbol->Hash());
}
}
@ -1384,7 +1386,7 @@ void Logger::TickEvent(TickSample* sample, bool overflow) {
Log::MessageBuilder msg(log_);
msg.Append("%s,", kLogEventsNames[TICK_EVENT]);
msg.AppendAddress(sample->pc);
msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds()));
msg.Append(",%ld", static_cast<int>(timer_.Elapsed().InMicroseconds()));
if (sample->has_external_callback) {
msg.Append(",1,");
msg.AppendAddress(sample->external_callback_entry);

View File

@ -8,7 +8,6 @@
#include <string>
#include "src/allocation.h"
#include "src/base/compiler-specific.h"
#include "src/base/platform/elapsed-timer.h"
#include "src/base/platform/platform.h"
#include "src/objects.h"
@ -355,7 +354,7 @@ class Logger {
// Emits a profiler tick event. Used by the profiler thread.
void TickEvent(TickSample* sample, bool overflow);
PRINTF_FORMAT(2, 3) void ApiEvent(const char* format, ...);
void ApiEvent(const char* name, ...);
// Logs a StringEvent regardless of whether FLAG_log is true.
void UncheckedStringEvent(const char* name, const char* value);

View File

@ -149,7 +149,8 @@ void AddressToTraceMap::Clear() {
void AddressToTraceMap::Print() {
PrintF("[AddressToTraceMap (%" PRIuS "): \n", ranges_.size());
PrintF("[AddressToTraceMap (%" V8_SIZET_PREFIX V8PRIuPTR "): \n",
ranges_.size());
for (RangeMap::iterator it = ranges_.begin(); it != ranges_.end(); ++it) {
PrintF("[%p - %p] => %u\n", it->second.start, it->first,
it->second.trace_node_id);

View File

@ -2247,8 +2247,8 @@ HeapEntry* BasicHeapEntriesAllocator::AllocateEntry(HeapThing ptr) {
intptr_t elements = info->GetElementCount();
intptr_t size = info->GetSizeInBytes();
const char* name = elements != -1
? names_->GetFormatted("%s / %" V8PRIdPTR " entries",
info->GetLabel(), elements)
? names_->GetFormatted(
"%s / %" V8_PTR_PREFIX "d entries", info->GetLabel(), elements)
: names_->GetCopy(info->GetLabel());
return snapshot_->AddEntry(
entries_type_,

View File

@ -229,13 +229,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: %d 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: %d.\n",
indent + 10, "", info.stack[index].script_id,
info.stack[index].position);
}

View File

@ -6,7 +6,6 @@
#define V8_PROFILER_STRINGS_STORAGE_H_
#include "src/allocation.h"
#include "src/base/compiler-specific.h"
#include "src/hashmap.h"
namespace v8 {
@ -20,8 +19,7 @@ class StringsStorage {
~StringsStorage();
const char* GetCopy(const char* src);
PRINTF_FORMAT(2, 3) const char* GetFormatted(const char* format, ...);
PRINTF_FORMAT(2, 0)
const char* GetFormatted(const char* format, ...);
const char* GetVFormatted(const char* format, va_list args);
const char* GetName(Name* name);
const char* GetName(int index);

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" PRIuS, 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" PRIuS " %s\n", instance_type_count_[Name], \
instance_type_size_[Name], #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

View File

@ -13,7 +13,6 @@
#include "include/v8.h"
#include "src/allocation.h"
#include "src/base/bits.h"
#include "src/base/compiler-specific.h"
#include "src/base/logging.h"
#include "src/base/macros.h"
#include "src/base/platform/platform.h"
@ -909,21 +908,42 @@ class TokenDispenserForFinally {
// ----------------------------------------------------------------------------
// I/O support.
#if __GNUC__ >= 4
// On gcc we can ask the compiler to check the types of %d-style format
// specifiers and their associated arguments. TODO(erikcorry) fix this
// so it works on MacOSX.
#if defined(__MACH__) && defined(__APPLE__)
#define PRINTF_CHECKING
#define FPRINTF_CHECKING
#define PRINTF_METHOD_CHECKING
#define FPRINTF_METHOD_CHECKING
#else // MacOsX.
#define PRINTF_CHECKING __attribute__ ((format (printf, 1, 2)))
#define FPRINTF_CHECKING __attribute__ ((format (printf, 2, 3)))
#define PRINTF_METHOD_CHECKING __attribute__ ((format (printf, 2, 3)))
#define FPRINTF_METHOD_CHECKING __attribute__ ((format (printf, 3, 4)))
#endif
#else
#define PRINTF_CHECKING
#define FPRINTF_CHECKING
#define PRINTF_METHOD_CHECKING
#define FPRINTF_METHOD_CHECKING
#endif
// Our version of printf().
void PRINTF_FORMAT(1, 2) PrintF(const char* format, ...);
void PRINTF_FORMAT(2, 3) PrintF(FILE* out, const char* format, ...);
void PRINTF_CHECKING PrintF(const char* format, ...);
void FPRINTF_CHECKING PrintF(FILE* out, const char* format, ...);
// Prepends the current process ID to the output.
void PRINTF_FORMAT(1, 2) PrintPID(const char* format, ...);
void PRINTF_CHECKING PrintPID(const char* format, ...);
// Prepends the current process ID and given isolate pointer to the output.
void PRINTF_FORMAT(2, 3) PrintIsolate(void* isolate, const char* format, ...);
void PrintIsolate(void* isolate, const char* format, ...);
// Safe formatting print. Ensures that str is always null-terminated.
// Returns the number of chars written, or -1 if output was truncated.
int PRINTF_FORMAT(2, 3) SNPrintF(Vector<char> str, const char* format, ...);
int PRINTF_FORMAT(2, 0)
VSNPrintF(Vector<char> str, const char* format, va_list args);
int FPRINTF_CHECKING SNPrintF(Vector<char> str, const char* format, ...);
int VSNPrintF(Vector<char> str, const char* format, va_list args);
void StrNCpy(Vector<char> dest, const char* src, size_t n);
@ -1426,11 +1446,10 @@ class StringBuilder : public SimpleStringBuilder {
StringBuilder(char* buffer, int size) : SimpleStringBuilder(buffer, size) { }
// Add formatted contents to the builder just like printf().
void PRINTF_FORMAT(2, 3) AddFormatted(const char* format, ...);
void AddFormatted(const char* format, ...);
// Add formatted contents like printf based on a va_list.
void PRINTF_FORMAT(2, 0) AddFormattedList(const char* format, va_list list);
void AddFormattedList(const char* format, va_list list);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder);
};

View File

@ -5,11 +5,9 @@
#ifndef V8_WASM_DECODER_H_
#define V8_WASM_DECODER_H_
#include "src/base/compiler-specific.h"
#include "src/base/smart-pointers.h"
#include "src/flags.h"
#include "src/signature.h"
#include "src/utils.h"
#include "src/wasm/wasm-result.h"
#include "src/zone-containers.h"
@ -49,7 +47,7 @@ class Decoder {
inline bool check(const byte* base, int offset, int length, const char* msg) {
DCHECK_GE(base, start_);
if ((base + offset + length) > limit_) {
error(base, base + offset, "%s", msg);
error(base, base + offset, msg);
return false;
}
return true;
@ -260,13 +258,12 @@ class Decoder {
}
}
void error(const char* msg) { error(pc_, nullptr, "%s", msg); }
void error(const char* msg) { error(pc_, nullptr, msg); }
void error(const byte* pc, const char* msg) { error(pc, nullptr, "%s", msg); }
void error(const byte* pc, const char* msg) { error(pc, nullptr, msg); }
// Sets internal error state.
void PRINTF_FORMAT(4, 5)
error(const byte* pc, const byte* pt, const char* format, ...) {
void error(const byte* pc, const byte* pt, const char* format, ...) {
if (ok()) {
#if DEBUG
if (FLAG_wasm_break_on_decoder_error) {
@ -395,7 +392,7 @@ class Decoder {
return 0;
}
if ((b & 0x80) != 0) {
error(base, ptr, "%s", msg);
error(base, ptr, msg);
return 0;
}
}

View File

@ -5,7 +5,6 @@
#ifndef V8_WASM_RESULT_H_
#define V8_WASM_RESULT_H_
#include "src/base/compiler-specific.h"
#include "src/base/smart-pointers.h"
#include "src/globals.h"
@ -94,13 +93,13 @@ class ErrorThrower {
ErrorThrower(Isolate* isolate, const char* context)
: isolate_(isolate), context_(context), error_(false) {}
PRINTF_FORMAT(2, 3) void Error(const char* fmt, ...);
void Error(const char* fmt, ...);
template <typename T>
void Failed(const char* error, Result<T>& result) {
std::ostringstream str;
str << error << result;
return Error("%s", str.str().c_str());
return Error(str.str().c_str());
}
bool error() const { return error_; }

View File

@ -8,7 +8,6 @@
#if V8_TARGET_ARCH_X64
#include "src/base/compiler-specific.h"
#include "src/base/lazy-instance.h"
#include "src/disasm.h"
@ -480,7 +479,7 @@ class DisassemblerX64 {
int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start);
int RegisterFPUInstruction(int escape_opcode, byte modrm_byte);
int AVXInstruction(byte* data);
PRINTF_FORMAT(2, 3) void AppendToBuffer(const char* format, ...);
void AppendToBuffer(const char* format, ...);
void UnimplementedInstruction() {
if (abort_on_unimplemented_) {
@ -619,7 +618,7 @@ int DisassemblerX64::PrintImmediate(byte* data, OperandSize size) {
value = 0; // Initialize variables on all paths to satisfy the compiler.
count = 0;
}
AppendToBuffer("%" PRIx64, value);
AppendToBuffer("%" V8_PTR_PREFIX "x", value);
return count;
}
@ -2000,7 +1999,7 @@ int DisassemblerX64::InstructionDecode(v8::internal::Vector<char> out_buffer,
if (rex_w()) AppendToBuffer("REX.W ");
AppendToBuffer("%s%c", idesc.mnem, operand_size_code());
} else {
AppendToBuffer("%s%c", idesc.mnem, operand_size_code());
AppendToBuffer("%s", idesc.mnem, operand_size_code());
}
data++;
break;
@ -2335,7 +2334,9 @@ int DisassemblerX64::InstructionDecode(v8::internal::Vector<char> out_buffer,
default:
UNREACHABLE();
}
AppendToBuffer("test%c rax,0x%" PRIx64, operand_size_code(), value);
AppendToBuffer("test%c rax,0x%" V8_PTR_PREFIX "x",
operand_size_code(),
value);
break;
}
case 0xD1: // fall through

View File

@ -8,7 +8,6 @@
#if V8_TARGET_ARCH_X87
#include "src/base/compiler-specific.h"
#include "src/disasm.h"
namespace disasm {
@ -326,7 +325,8 @@ class DisassemblerX87 {
int FPUInstruction(byte* data);
int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start);
int RegisterFPUInstruction(int escape_opcode, byte modrm_byte);
PRINTF_FORMAT(2, 3) void AppendToBuffer(const char* format, ...);
void AppendToBuffer(const char* format, ...);
void UnimplementedInstruction() {
if (abort_on_unimplemented_) {
@ -948,7 +948,7 @@ int DisassemblerX87::InstructionDecode(v8::internal::Vector<char> out_buffer,
const InstructionDesc& idesc = instruction_table_->Get(*data);
switch (idesc.type) {
case ZERO_OPERANDS_INSTR:
AppendToBuffer("%s", idesc.mnem);
AppendToBuffer(idesc.mnem);
data++;
break;

View File

@ -2293,20 +2293,16 @@ TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
// on the heap.
if (size_of_objects_1 > size_of_objects_2) {
intptr_t delta = size_of_objects_1 - size_of_objects_2;
PrintF("Heap::SizeOfObjects: %" V8PRIdPTR
", "
"Iterator: %" V8PRIdPTR
", "
"delta: %" V8PRIdPTR "\n",
PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
"Iterator: %" V8_PTR_PREFIX "d, "
"delta: %" V8_PTR_PREFIX "d\n",
size_of_objects_1, size_of_objects_2, delta);
CHECK_GT(size_of_objects_1 / 20, delta);
} else {
intptr_t delta = size_of_objects_2 - size_of_objects_1;
PrintF("Heap::SizeOfObjects: %" V8PRIdPTR
", "
"Iterator: %" V8PRIdPTR
", "
"delta: %" V8PRIdPTR "\n",
PrintF("Heap::SizeOfObjects: %" V8_PTR_PREFIX "d, "
"Iterator: %" V8_PTR_PREFIX "d, "
"delta: %" V8_PTR_PREFIX "d\n",
size_of_objects_1, size_of_objects_2, delta);
CHECK_GT(size_of_objects_2 / 20, delta);
}

View File

@ -375,8 +375,9 @@ TEST(LogCallbacks) {
ObjMethod1_entry = *FUNCTION_ENTRYPOINT_ADDRESS(ObjMethod1_entry);
#endif
i::EmbeddedVector<char, 100> ref_data;
i::SNPrintF(ref_data, "code-creation,Callback,-2,%p,1,\"method1\"",
ObjMethod1_entry);
i::SNPrintF(ref_data,
"code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"method1\"",
reinterpret_cast<intptr_t>(ObjMethod1_entry));
CHECK(StrNStr(log.start(), ref_data.start(), log.length()));
log.Dispose();
@ -428,8 +429,8 @@ TEST(LogAccessorCallbacks) {
#endif
EmbeddedVector<char, 100> prop1_getter_record;
i::SNPrintF(prop1_getter_record,
"code-creation,Callback,-2,%p,1,\"get prop1\"",
Prop1Getter_entry);
"code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop1\"",
reinterpret_cast<intptr_t>(Prop1Getter_entry));
CHECK(StrNStr(log.start(), prop1_getter_record.start(), log.length()));
Address Prop1Setter_entry = reinterpret_cast<Address>(Prop1Setter);
@ -438,8 +439,8 @@ TEST(LogAccessorCallbacks) {
#endif
EmbeddedVector<char, 100> prop1_setter_record;
i::SNPrintF(prop1_setter_record,
"code-creation,Callback,-2,%p,1,\"set prop1\"",
Prop1Setter_entry);
"code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"set prop1\"",
reinterpret_cast<intptr_t>(Prop1Setter_entry));
CHECK(StrNStr(log.start(), prop1_setter_record.start(), log.length()));
Address Prop2Getter_entry = reinterpret_cast<Address>(Prop2Getter);
@ -448,8 +449,8 @@ TEST(LogAccessorCallbacks) {
#endif
EmbeddedVector<char, 100> prop2_getter_record;
i::SNPrintF(prop2_getter_record,
"code-creation,Callback,-2,%p,1,\"get prop2\"",
Prop2Getter_entry);
"code-creation,Callback,-2,0x%" V8PRIxPTR ",1,\"get prop2\"",
reinterpret_cast<intptr_t>(Prop2Getter_entry));
CHECK(StrNStr(log.start(), prop2_getter_record.start(), log.length()));
log.Dispose();
}

View File

@ -1629,7 +1629,6 @@
'../../src/base/division-by-constant.cc',
'../../src/base/division-by-constant.h',
'../../src/base/flags.h',
'../../src/base/format-macros.h',
'../../src/base/functional.cc',
'../../src/base/functional.h',
'../../src/base/iterator.h',