Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: tools/clang/blink_gc_plugin/process-graph.py

Issue 401613002: clang/blink_gc_plugin: Replace 'WebCore' with 'blink' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse, os, sys, json, subprocess, pickle, StringIO 6 import argparse, os, sys, json, subprocess, pickle, StringIO
7 7
8 parser = argparse.ArgumentParser( 8 parser = argparse.ArgumentParser(
9 description = 9 description =
10 "Process the Blink points-to graph generated by the Blink GC plugin.") 10 "Process the Blink points-to graph generated by the Blink GC plugin.")
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if current.cost < dst.cost: 250 if current.cost < dst.cost:
251 dst.cost = current.cost + 1 251 dst.cost = current.cost + 1
252 dst.path = e 252 dst.path = e
253 minlist.append(dst) 253 minlist.append(dst)
254 254
255 def detect_cycles(): 255 def detect_cycles():
256 for root_edge in roots: 256 for root_edge in roots:
257 reset_graph() 257 reset_graph()
258 # Mark ignored classes as already visited 258 # Mark ignored classes as already visited
259 for ignore in args.ignore_classes: 259 for ignore in args.ignore_classes:
260 name = ignore.find("::") > 0 and ignore or ("WebCore::" + ignore) 260 name = ignore.find("::") > 0 and ignore or ("blink::" + ignore)
261 node = graph.get(name) 261 node = graph.get(name)
262 if node: 262 if node:
263 node.visited = True 263 node.visited = True
264 src = graph[root_edge.src] 264 src = graph[root_edge.src]
265 dst = graph.get(root_edge.dst) 265 dst = graph.get(root_edge.dst)
266 if src.visited: 266 if src.visited:
267 continue 267 continue
268 if root_edge.dst == "WTF::String": 268 if root_edge.dst == "WTF::String":
269 continue 269 continue
270 if dst is None: 270 if dst is None:
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if not line or line.startswith('Found'): 337 if not line or line.startswith('Found'):
338 if len(block) > 0: 338 if len(block) > 0:
339 ignored_cycles.append(block) 339 ignored_cycles.append(block)
340 block = [] 340 block = []
341 else: 341 else:
342 block += l 342 block += l
343 if len(block) > 0: 343 if len(block) > 0:
344 ignored_cycles.append(block) 344 ignored_cycles.append(block)
345 345
346 gc_bases = ( 346 gc_bases = (
347 'WebCore::GarbageCollected', 347 'blink::GarbageCollected',
348 'WebCore::GarbageCollectedFinalized', 348 'blink::GarbageCollectedFinalized',
349 'WebCore::GarbageCollectedMixin', 349 'blink::GarbageCollectedMixin',
350 ) 350 )
351 ref_bases = ( 351 ref_bases = (
352 'WTF::RefCounted', 352 'WTF::RefCounted',
353 'WTF::ThreadSafeRefCounted', 353 'WTF::ThreadSafeRefCounted',
354 ) 354 )
355 gcref_bases = ( 355 gcref_bases = (
356 'WebCore::RefCountedGarbageCollected', 356 'blink::RefCountedGarbageCollected',
357 'WebCore::ThreadSafeRefCountedGarbageCollected', 357 'blink::ThreadSafeRefCountedGarbageCollected',
358 ) 358 )
359 ref_mixins = ( 359 ref_mixins = (
360 'WebCore::EventTarget', 360 'blink::EventTarget',
361 'WebCore::EventTargetWithInlineData', 361 'blink::EventTargetWithInlineData',
362 'WebCore::ActiveDOMObject', 362 'blink::ActiveDOMObject',
363 ) 363 )
364 364
365 def print_stats(): 365 def print_stats():
366 gcref_managed = [] 366 gcref_managed = []
367 ref_managed = [] 367 ref_managed = []
368 gc_managed = [] 368 gc_managed = []
369 hierarchies = [] 369 hierarchies = []
370 370
371 for node in graph.itervalues(): 371 for node in graph.itervalues():
372 node.update_counts() 372 node.update_counts()
(...skipping 20 matching lines...) Expand all
393 hierarchies.append((base, stats)) 393 hierarchies.append((base, stats))
394 394
395 print "\nHierarchies in transition (RefCountedGarbageCollected):" 395 print "\nHierarchies in transition (RefCountedGarbageCollected):"
396 hierarchies.sort(key=lambda (n,s): -s['classes']) 396 hierarchies.sort(key=lambda (n,s): -s['classes'])
397 for (node, stats) in hierarchies: 397 for (node, stats) in hierarchies:
398 total = stats['mem'] + stats['ref'] + stats['raw'] 398 total = stats['mem'] + stats['ref'] + stats['raw']
399 print ( 399 print (
400 "%s %3d%% of %-30s: %3d cls, %3d mem, %3d ref, %3d raw, %3d ref-mixins" % 400 "%s %3d%% of %-30s: %3d cls, %3d mem, %3d ref, %3d raw, %3d ref-mixins" %
401 (stats['ref'] == 0 and stats['ref-mixins'] == 0 and "*" or " ", 401 (stats['ref'] == 0 and stats['ref-mixins'] == 0 and "*" or " ",
402 total == 0 and 100 or stats['mem'] * 100 / total, 402 total == 0 and 100 or stats['mem'] * 100 / total,
403 node.name.replace('WebCore::', ''), 403 node.name.replace('blink::', ''),
404 stats['classes'], 404 stats['classes'],
405 stats['mem'], 405 stats['mem'],
406 stats['ref'], 406 stats['ref'],
407 stats['raw'], 407 stats['raw'],
408 stats['ref-mixins'], 408 stats['ref-mixins'],
409 )) 409 ))
410 410
411 def hierarchy_stats(node, stats): 411 def hierarchy_stats(node, stats):
412 if not node: return 412 if not node: return
413 stats['classes'] += 1 413 stats['classes'] += 1
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 detect_cycles() 455 detect_cycles()
456 if args.print_stats: 456 if args.print_stats:
457 log("Printing statistics") 457 log("Printing statistics")
458 print_stats() 458 print_stats()
459 if reported_error(): 459 if reported_error():
460 return 1 460 return 1
461 return 0 461 return 0
462 462
463 if __name__ == '__main__': 463 if __name__ == '__main__':
464 sys.exit(main()) 464 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/clang/blink_gc_plugin/RecordInfo.cpp ('k') | tools/clang/blink_gc_plugin/tests/base_requires_tracing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698