0b83be906c
We add two things: * --print_instruction_stats makes compiler dump per IL instruction size breakdown (how many bytes of code were produced from specific instruction kinds). This was largely implemented by kustermann@ in https://codereview.chromium.org/2584613002/ and this CL does only few changes to the original implementation, namely more uniform handling of slow-path code and puts statistics object into RawInstructions (which has free space due to alignment) instead of RawCode. * --print_instructions_sizes_to=symbols.json makes compiler dump per Instruction object size breakdown into a JSON file. This JSON file can later be processed with pkg/vm/tool/run_binary_size_analysis.dart script to produce interactive binary size diagram similar to runtime/third_party/binary_size tool. Change-Id: Ied4965b9a0a91b3025eefbe981ecd47cdcf782d6 Reviewed-on: https://dart-review.googlesource.com/50501 Commit-Queue: Vyacheslav Egorov <vegorov@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
104 lines
2.3 KiB
C++
104 lines
2.3 KiB
C++
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_VM_COMPILER_BACKEND_CODE_STATISTICS_H_
|
|
#define RUNTIME_VM_COMPILER_BACKEND_CODE_STATISTICS_H_
|
|
|
|
#include "vm/compiler/assembler/assembler.h"
|
|
#include "vm/compiler/backend/il.h"
|
|
#include "vm/object.h"
|
|
|
|
namespace dart {
|
|
|
|
class CombinedCodeStatistics {
|
|
public:
|
|
// clang-format off
|
|
enum EntryCounter {
|
|
#define DO(type) kTag##type,
|
|
FOR_EACH_INSTRUCTION(DO)
|
|
#undef DO
|
|
|
|
#define DO(type) kTag##type##SlowPath,
|
|
FOR_EACH_INSTRUCTION(DO)
|
|
#undef DO
|
|
|
|
kTagAssertAssignableParameterCheck,
|
|
kTagAssertAssignableInsertedByFrontend,
|
|
kTagAssertAssignableFromSource,
|
|
|
|
kTagCheckedEntry,
|
|
kTagIntrinsics,
|
|
|
|
kNumEntries,
|
|
};
|
|
// clang-format on
|
|
|
|
CombinedCodeStatistics();
|
|
|
|
void Begin(Instruction* instruction);
|
|
void End(Instruction* instruction);
|
|
|
|
void DumpStatistics();
|
|
|
|
static EntryCounter SlowPathCounterFor(Instruction::Tag tag) {
|
|
return static_cast<CombinedCodeStatistics::EntryCounter>(
|
|
CombinedCodeStatistics::kTagGraphEntrySlowPath + tag);
|
|
}
|
|
|
|
private:
|
|
friend class CodeStatistics;
|
|
|
|
static int CompareEntries(const void* a, const void* b);
|
|
|
|
typedef struct {
|
|
const char* name;
|
|
intptr_t bytes;
|
|
intptr_t count;
|
|
} Entry;
|
|
|
|
Entry entries_[kNumEntries];
|
|
intptr_t unaccounted_bytes_;
|
|
intptr_t alignment_bytes_;
|
|
intptr_t object_header_bytes_;
|
|
intptr_t return_const_count_;
|
|
intptr_t return_const_with_load_field_count_;
|
|
};
|
|
|
|
class CodeStatistics {
|
|
public:
|
|
explicit CodeStatistics(Assembler* assembler);
|
|
|
|
void Begin(Instruction* instruction);
|
|
void End(Instruction* instruction);
|
|
|
|
void SpecialBegin(intptr_t tag);
|
|
void SpecialEnd(intptr_t tag);
|
|
|
|
void AppendTo(CombinedCodeStatistics* stat);
|
|
|
|
void Finalize();
|
|
|
|
private:
|
|
static const int kStackSize = 8;
|
|
|
|
Assembler* assembler_;
|
|
|
|
typedef struct {
|
|
intptr_t bytes;
|
|
intptr_t count;
|
|
} Entry;
|
|
|
|
Entry entries_[CombinedCodeStatistics::kNumEntries];
|
|
intptr_t instruction_bytes_;
|
|
intptr_t unaccounted_bytes_;
|
|
intptr_t alignment_bytes_;
|
|
|
|
intptr_t stack_[kStackSize];
|
|
intptr_t stack_index_;
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_COMPILER_BACKEND_CODE_STATISTICS_H_
|