Commit f8654ce9 authored by cbruni's avatar cbruni Committed by Commit bot

Do not inline object-stats functions to reduce binary size.

BUG=chromium:645378

Review-Url: https://codereview.chromium.org/2422143002
Cr-Commit-Position: refs/heads/master@{#40355}
parent 3f6e0a4e
......@@ -238,7 +238,7 @@ class RuntimeCallStatEntries {
return count_ < other.count_;
}
void Print(std::ostream& os) {
V8_NOINLINE void Print(std::ostream& os) {
os.precision(2);
os << std::fixed << std::setprecision(2);
os << std::setw(50) << name_;
......@@ -249,7 +249,8 @@ class RuntimeCallStatEntries {
os << std::endl;
}
void SetTotal(base::TimeDelta total_time, uint64_t total_count) {
V8_NOINLINE void SetTotal(base::TimeDelta total_time,
uint64_t total_count) {
if (total_time.InMicroseconds() == 0) {
time_percent_ = 0;
} else {
......
......@@ -483,7 +483,7 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
struct RuntimeCallCounter {
explicit RuntimeCallCounter(const char* name) : name(name) {}
void Reset();
V8_NOINLINE void Reset();
V8_NOINLINE void Dump(std::stringstream& out);
const char* name;
......@@ -798,8 +798,8 @@ class RuntimeCallStats {
CounterId counter_id);
void Reset();
V8_NOINLINE void Print(std::ostream& os);
V8_NOINLINE std::string Dump();
void Print(std::ostream& os);
std::string Dump();
RuntimeCallStats() {
Reset();
......
......@@ -52,55 +52,59 @@ V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array,
stream << "]";
}
void ObjectStats::PrintKeyAndId(const char* key, int gc_count) {
PrintF("\"isolate\": \"%p\", \"id\": %d, \"key\": \"%s\", ",
reinterpret_cast<void*>(isolate()), gc_count, key);
}
void ObjectStats::PrintInstanceTypeJSON(const char* key, int gc_count,
const char* name, int index) {
PrintF("{ ");
PrintKeyAndId(key, gc_count);
PrintF("\"type\": \"instance_type_data\", ");
PrintF("\"instance_type\": %d, ", index);
PrintF("\"instance_type_name\": \"%s\", ", name);
PrintF("\"overall\": %zu, ", object_sizes_[index]);
PrintF("\"count\": %zu, ", object_counts_[index]);
PrintF("\"over_allocated\": %zu, ", over_allocated_[index]);
PrintF("\"histogram\": ");
PrintJSONArray(size_histogram_[index], kNumberOfBuckets);
PrintF(",");
PrintF("\"over_allocated_histogram\": ");
PrintJSONArray(over_allocated_histogram_[index], kNumberOfBuckets);
PrintF(" }\n");
}
void ObjectStats::PrintJSON(const char* key) {
double time = isolate()->time_millis_since_init();
int gc_count = heap()->gc_count();
#define PRINT_KEY_AND_ID() \
PrintF("\"isolate\": \"%p\", \"id\": %d, \"key\": \"%s\", ", \
reinterpret_cast<void*>(isolate()), gc_count, key);
// gc_descriptor
PrintF("{ ");
PRINT_KEY_AND_ID();
PrintKeyAndId(key, gc_count);
PrintF("\"type\": \"gc_descriptor\", \"time\": %f }\n", time);
// bucket_sizes
PrintF("{ ");
PRINT_KEY_AND_ID();
PrintKeyAndId(key, gc_count);
PrintF("\"type\": \"bucket_sizes\", \"sizes\": [ ");
for (int i = 0; i < kNumberOfBuckets; i++) {
PrintF("%d", 1 << (kFirstBucketShift + i));
if (i != (kNumberOfBuckets - 1)) PrintF(", ");
}
PrintF(" ] }\n");
// instance_type_data
#define PRINT_INSTANCE_TYPE_DATA(name, index) \
PrintF("{ "); \
PRINT_KEY_AND_ID(); \
PrintF("\"type\": \"instance_type_data\", "); \
PrintF("\"instance_type\": %d, ", index); \
PrintF("\"instance_type_name\": \"%s\", ", name); \
PrintF("\"overall\": %zu, ", object_sizes_[index]); \
PrintF("\"count\": %zu, ", object_counts_[index]); \
PrintF("\"over_allocated\": %zu, ", over_allocated_[index]); \
PrintF("\"histogram\": "); \
PrintJSONArray(size_histogram_[index], kNumberOfBuckets); \
PrintF(","); \
PrintF("\"over_allocated_histogram\": "); \
PrintJSONArray(over_allocated_histogram_[index], kNumberOfBuckets); \
PrintF(" }\n");
#define INSTANCE_TYPE_WRAPPER(name) PRINT_INSTANCE_TYPE_DATA(#name, name)
#define CODE_KIND_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \
FIRST_CODE_KIND_SUB_TYPE + Code::name)
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA("*FIXED_ARRAY_" #name, \
FIRST_FIXED_ARRAY_SUB_TYPE + name)
#define CODE_AGE_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA( \
"*CODE_AGE_" #name, \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge)
#define INSTANCE_TYPE_WRAPPER(name) \
PrintInstanceTypeJSON(key, gc_count, #name, name);
#define CODE_KIND_WRAPPER(name) \
PrintInstanceTypeJSON(key, gc_count, "*CODE_" #name, \
FIRST_CODE_KIND_SUB_TYPE + Code::name);
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
PrintInstanceTypeJSON(key, gc_count, "*FIXED_ARRAY_" #name, \
FIRST_FIXED_ARRAY_SUB_TYPE + name);
#define CODE_AGE_WRAPPER(name) \
PrintInstanceTypeJSON( \
key, gc_count, "*CODE_AGE_" #name, \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge);
INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER)
CODE_KIND_LIST(CODE_KIND_WRAPPER)
......@@ -115,6 +119,20 @@ void ObjectStats::PrintJSON(const char* key) {
#undef PRINT_KEY_AND_ID
}
void ObjectStats::DumpInstanceTypeData(std::stringstream& stream,
const char* name, int index) {
stream << "\"" << name << "\":{";
stream << "\"type\":" << static_cast<int>(index) << ",";
stream << "\"overall\":" << object_sizes_[index] << ",";
stream << "\"count\":" << object_counts_[index] << ",";
stream << "\"over_allocated\":" << over_allocated_[index] << ",";
stream << "\"histogram\":";
DumpJSONArray(stream, size_histogram_[index], kNumberOfBuckets);
stream << ",\"over_allocated_histogram\":";
DumpJSONArray(stream, over_allocated_histogram_[index], kNumberOfBuckets);
stream << "},";
}
void ObjectStats::Dump(std::stringstream& stream) {
double time = isolate()->time_millis_since_init();
int gc_count = heap()->gc_count();
......@@ -131,29 +149,19 @@ void ObjectStats::Dump(std::stringstream& stream) {
stream << "],";
stream << "\"type_data\":{";
#define PRINT_INSTANCE_TYPE_DATA(name, index) \
stream << "\"" << name << "\":{"; \
stream << "\"type\":" << static_cast<int>(index) << ","; \
stream << "\"overall\":" << object_sizes_[index] << ","; \
stream << "\"count\":" << object_counts_[index] << ","; \
stream << "\"over_allocated\":" << over_allocated_[index] << ","; \
stream << "\"histogram\":"; \
DumpJSONArray(stream, size_histogram_[index], kNumberOfBuckets); \
stream << ",\"over_allocated_histogram\":"; \
DumpJSONArray(stream, over_allocated_histogram_[index], kNumberOfBuckets); \
stream << "},";
#define INSTANCE_TYPE_WRAPPER(name) DumpInstanceTypeData(stream, #name, name);
#define CODE_KIND_WRAPPER(name) \
DumpInstanceTypeData(stream, "*CODE_" #name, \
FIRST_CODE_KIND_SUB_TYPE + Code::name);
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
DumpInstanceTypeData(stream, "*FIXED_ARRAY_" #name, \
FIRST_FIXED_ARRAY_SUB_TYPE + name);
#define INSTANCE_TYPE_WRAPPER(name) PRINT_INSTANCE_TYPE_DATA(#name, name)
#define CODE_KIND_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \
FIRST_CODE_KIND_SUB_TYPE + Code::name)
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA("*FIXED_ARRAY_" #name, \
FIRST_FIXED_ARRAY_SUB_TYPE + name)
#define CODE_AGE_WRAPPER(name) \
PRINT_INSTANCE_TYPE_DATA( \
"*CODE_AGE_" #name, \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge)
#define CODE_AGE_WRAPPER(name) \
DumpInstanceTypeData( \
stream, "*CODE_AGE_" #name, \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge);
INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER);
CODE_KIND_LIST(CODE_KIND_WRAPPER);
......
......@@ -100,6 +100,14 @@ class ObjectStats {
static const int kLastBucket = 1 << kLastBucketShift;
static const int kNumberOfBuckets = kLastBucketShift - kFirstBucketShift + 1;
void PrintKeyAndId(const char* key, int gc_count);
// The following functions are excluded from inline to reduce the overall
// binary size of VB. On x64 this save around 80KB.
V8_NOINLINE void PrintInstanceTypeJSON(const char* key, int gc_count,
const char* name, int index);
V8_NOINLINE void DumpInstanceTypeData(std::stringstream& stream,
const char* name, int index);
int HistogramIndexFromSize(size_t size) {
if (size == 0) return 0;
int idx = static_cast<int>(base::ieee754::log2(static_cast<double>(size))) -
......
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