'''.format(**locals()), file=self.stream)
def render_inline_remarks(self, r, line):
inlining_context = r.DemangledFunctionName
dl = Remark.caller_loc.get(r.Function)
if dl:
link = Remark.make_link(dl['File'], dl['Line'] - 2)
inlining_context = "{r.DemangledFunctionName}".format(**locals())
# Column is the number of characters *including* tabs, keep those and
# replace everything else with spaces.
indent = line[:r.Column - 1]
indent = re.sub('\S', ' ', indent)
print('''
{r.RelativeHotness}
{r.Pass}
{indent}
{r.message}
{inlining_context}
'''.format(**locals()), file=self.stream)
def render(self, line_remarks):
if not self.source_stream:
return
print('''
Line
Hotness
Optimization
Source
Inline Context
''', file=self.stream)
for (linenum, line) in enumerate(self.source_stream.readlines(), start=1):
self.render_source_line(linenum, line)
for remark in line_remarks.get(linenum, []):
self.render_inline_remarks(remark, line)
print('''
''', file=self.stream)
for remark in all_remarks:
self.render_entry(remark)
print('''
''', file=self.stream)
all_remarks = dict()
file_remarks = dict()
for input_file in args.yaml_files:
f = open(input_file)
docs = yaml.load_all(f, Loader=Loader)
for remark in docs:
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue
all_remarks[remark.key] = remark
file_remarks.setdefault(remark.File, dict()).setdefault(remark.Line, []).append(remark)
Remark.max_hotness = max(Remark.max_hotness, remark.Hotness)
# Set up a map between function names and their source location for function where inlining happened
for remark in all_remarks.itervalues():
if type(remark) == Passed and remark.Pass == "inline" and remark.Name == "Inlined":
for arg in remark.Args:
caller = arg.get('Caller')
if caller:
Remark.caller_loc[caller] = arg['DebugLoc']
if Remark.should_display_hotness():
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: r.Hotness, reverse=True)
else:
sorted_remarks = sorted(all_remarks.itervalues(), key=lambda r: (r.File, r.Line, r.Column))
if not os.path.exists(args.output_dir):
os.mkdir(args.output_dir)
for (filename, remarks) in file_remarks.iteritems():
SourceFileRenderer(filename).render(remarks)
IndexRenderer().render(sorted_remarks)
shutil.copy(os.path.join(os.path.dirname(os.path.realpath(__file__)), "style.css"), args.output_dir)