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 { ...@@ -238,7 +238,7 @@ class RuntimeCallStatEntries {
return count_ < other.count_; return count_ < other.count_;
} }
void Print(std::ostream& os) { V8_NOINLINE void Print(std::ostream& os) {
os.precision(2); os.precision(2);
os << std::fixed << std::setprecision(2); os << std::fixed << std::setprecision(2);
os << std::setw(50) << name_; os << std::setw(50) << name_;
...@@ -249,7 +249,8 @@ class RuntimeCallStatEntries { ...@@ -249,7 +249,8 @@ class RuntimeCallStatEntries {
os << std::endl; 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) { if (total_time.InMicroseconds() == 0) {
time_percent_ = 0; time_percent_ = 0;
} else { } else {
......
...@@ -483,7 +483,7 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms, ...@@ -483,7 +483,7 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
struct RuntimeCallCounter { struct RuntimeCallCounter {
explicit RuntimeCallCounter(const char* name) : name(name) {} explicit RuntimeCallCounter(const char* name) : name(name) {}
void Reset(); V8_NOINLINE void Reset();
V8_NOINLINE void Dump(std::stringstream& out); V8_NOINLINE void Dump(std::stringstream& out);
const char* name; const char* name;
...@@ -798,8 +798,8 @@ class RuntimeCallStats { ...@@ -798,8 +798,8 @@ class RuntimeCallStats {
CounterId counter_id); CounterId counter_id);
void Reset(); void Reset();
V8_NOINLINE void Print(std::ostream& os); void Print(std::ostream& os);
V8_NOINLINE std::string Dump(); std::string Dump();
RuntimeCallStats() { RuntimeCallStats() {
Reset(); Reset();
......
...@@ -52,55 +52,59 @@ V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array, ...@@ -52,55 +52,59 @@ V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array,
stream << "]"; 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) { void ObjectStats::PrintJSON(const char* key) {
double time = isolate()->time_millis_since_init(); double time = isolate()->time_millis_since_init();
int gc_count = heap()->gc_count(); 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 // gc_descriptor
PrintF("{ "); PrintF("{ ");
PRINT_KEY_AND_ID(); PrintKeyAndId(key, gc_count);
PrintF("\"type\": \"gc_descriptor\", \"time\": %f }\n", time); PrintF("\"type\": \"gc_descriptor\", \"time\": %f }\n", time);
// bucket_sizes // bucket_sizes
PrintF("{ "); PrintF("{ ");
PRINT_KEY_AND_ID(); PrintKeyAndId(key, gc_count);
PrintF("\"type\": \"bucket_sizes\", \"sizes\": [ "); PrintF("\"type\": \"bucket_sizes\", \"sizes\": [ ");
for (int i = 0; i < kNumberOfBuckets; i++) { for (int i = 0; i < kNumberOfBuckets; i++) {
PrintF("%d", 1 << (kFirstBucketShift + i)); PrintF("%d", 1 << (kFirstBucketShift + i));
if (i != (kNumberOfBuckets - 1)) PrintF(", "); if (i != (kNumberOfBuckets - 1)) PrintF(", ");
} }
PrintF(" ] }\n"); 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 INSTANCE_TYPE_WRAPPER(name) \
#define CODE_KIND_WRAPPER(name) \ PrintInstanceTypeJSON(key, gc_count, #name, name);
PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \ #define CODE_KIND_WRAPPER(name) \
FIRST_CODE_KIND_SUB_TYPE + Code::name) PrintInstanceTypeJSON(key, gc_count, "*CODE_" #name, \
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \ FIRST_CODE_KIND_SUB_TYPE + Code::name);
PRINT_INSTANCE_TYPE_DATA("*FIXED_ARRAY_" #name, \ #define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
FIRST_FIXED_ARRAY_SUB_TYPE + name) PrintInstanceTypeJSON(key, gc_count, "*FIXED_ARRAY_" #name, \
#define CODE_AGE_WRAPPER(name) \ FIRST_FIXED_ARRAY_SUB_TYPE + name);
PRINT_INSTANCE_TYPE_DATA( \ #define CODE_AGE_WRAPPER(name) \
"*CODE_AGE_" #name, \ PrintInstanceTypeJSON( \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge) key, gc_count, "*CODE_AGE_" #name, \
FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge);
INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER) INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER)
CODE_KIND_LIST(CODE_KIND_WRAPPER) CODE_KIND_LIST(CODE_KIND_WRAPPER)
...@@ -115,6 +119,20 @@ void ObjectStats::PrintJSON(const char* key) { ...@@ -115,6 +119,20 @@ void ObjectStats::PrintJSON(const char* key) {
#undef PRINT_KEY_AND_ID #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) { void ObjectStats::Dump(std::stringstream& stream) {
double time = isolate()->time_millis_since_init(); double time = isolate()->time_millis_since_init();
int gc_count = heap()->gc_count(); int gc_count = heap()->gc_count();
...@@ -131,29 +149,19 @@ void ObjectStats::Dump(std::stringstream& stream) { ...@@ -131,29 +149,19 @@ void ObjectStats::Dump(std::stringstream& stream) {
stream << "],"; stream << "],";
stream << "\"type_data\":{"; stream << "\"type_data\":{";
#define PRINT_INSTANCE_TYPE_DATA(name, index) \ #define INSTANCE_TYPE_WRAPPER(name) DumpInstanceTypeData(stream, #name, name);
stream << "\"" << name << "\":{"; \ #define CODE_KIND_WRAPPER(name) \
stream << "\"type\":" << static_cast<int>(index) << ","; \ DumpInstanceTypeData(stream, "*CODE_" #name, \
stream << "\"overall\":" << object_sizes_[index] << ","; \ FIRST_CODE_KIND_SUB_TYPE + Code::name);
stream << "\"count\":" << object_counts_[index] << ","; \
stream << "\"over_allocated\":" << over_allocated_[index] << ","; \ #define FIXED_ARRAY_SUB_INSTANCE_TYPE_WRAPPER(name) \
stream << "\"histogram\":"; \ DumpInstanceTypeData(stream, "*FIXED_ARRAY_" #name, \
DumpJSONArray(stream, size_histogram_[index], kNumberOfBuckets); \ FIRST_FIXED_ARRAY_SUB_TYPE + name);
stream << ",\"over_allocated_histogram\":"; \
DumpJSONArray(stream, over_allocated_histogram_[index], kNumberOfBuckets); \
stream << "},";
#define INSTANCE_TYPE_WRAPPER(name) PRINT_INSTANCE_TYPE_DATA(#name, name) #define CODE_AGE_WRAPPER(name) \
#define CODE_KIND_WRAPPER(name) \ DumpInstanceTypeData( \
PRINT_INSTANCE_TYPE_DATA("*CODE_" #name, \ stream, "*CODE_AGE_" #name, \
FIRST_CODE_KIND_SUB_TYPE + Code::name) FIRST_CODE_AGE_SUB_TYPE + Code::k##name##CodeAge - Code::kFirstCodeAge);
#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)
INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER); INSTANCE_TYPE_LIST(INSTANCE_TYPE_WRAPPER);
CODE_KIND_LIST(CODE_KIND_WRAPPER); CODE_KIND_LIST(CODE_KIND_WRAPPER);
......
...@@ -100,6 +100,14 @@ class ObjectStats { ...@@ -100,6 +100,14 @@ class ObjectStats {
static const int kLastBucket = 1 << kLastBucketShift; static const int kLastBucket = 1 << kLastBucketShift;
static const int kNumberOfBuckets = kLastBucketShift - kFirstBucketShift + 1; 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) { int HistogramIndexFromSize(size_t size) {
if (size == 0) return 0; if (size == 0) return 0;
int idx = static_cast<int>(base::ieee754::log2(static_cast<double>(size))) - 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