| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2012 the V8 project authors. All rights reserved. | 3 # Copyright 2012 the V8 project authors. All rights reserved. |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 _ARCH_TO_POINTER_TYPE_MAP = { | 358 _ARCH_TO_POINTER_TYPE_MAP = { |
| 359 "ia32": ctypes.c_uint32, | 359 "ia32": ctypes.c_uint32, |
| 360 "arm": ctypes.c_uint32, | 360 "arm": ctypes.c_uint32, |
| 361 "mips": ctypes.c_uint32, | 361 "mips": ctypes.c_uint32, |
| 362 "x64": ctypes.c_uint64, | 362 "x64": ctypes.c_uint64, |
| 363 "arm64": ctypes.c_uint64 | 363 "arm64": ctypes.c_uint64 |
| 364 } | 364 } |
| 365 | 365 |
| 366 _CODE_CREATE_TAG = "C" | 366 _CODE_CREATE_TAG = "C" |
| 367 _CODE_MOVE_TAG = "M" | 367 _CODE_MOVE_TAG = "M" |
| 368 _CODE_DELETE_TAG = "D" | |
| 369 _SNAPSHOT_POSITION_TAG = "P" | 368 _SNAPSHOT_POSITION_TAG = "P" |
| 370 _CODE_MOVING_GC_TAG = "G" | 369 _CODE_MOVING_GC_TAG = "G" |
| 371 | 370 |
| 372 def __init__(self, log_name, code_map, snapshot_pos_to_name): | 371 def __init__(self, log_name, code_map, snapshot_pos_to_name): |
| 373 self.log_file = open(log_name, "r") | 372 self.log_file = open(log_name, "r") |
| 374 self.log = mmap.mmap(self.log_file.fileno(), 0, mmap.MAP_PRIVATE) | 373 self.log = mmap.mmap(self.log_file.fileno(), 0, mmap.MAP_PRIVATE) |
| 375 self.log_pos = 0 | 374 self.log_pos = 0 |
| 376 self.code_map = code_map | 375 self.code_map = code_map |
| 377 self.snapshot_pos_to_name = snapshot_pos_to_name | 376 self.snapshot_pos_to_name = snapshot_pos_to_name |
| 378 self.address_to_snapshot_name = {} | 377 self.address_to_snapshot_name = {} |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 continue | 451 continue |
| 453 assert code.start_address == old_start_address, \ | 452 assert code.start_address == old_start_address, \ |
| 454 "Inexact move address %x for %s" % (old_start_address, code) | 453 "Inexact move address %x for %s" % (old_start_address, code) |
| 455 self.code_map.Remove(code) | 454 self.code_map.Remove(code) |
| 456 size = code.end_address - code.start_address | 455 size = code.end_address - code.start_address |
| 457 code.start_address = new_start_address | 456 code.start_address = new_start_address |
| 458 code.end_address = new_start_address + size | 457 code.end_address = new_start_address + size |
| 459 self.code_map.Add(code) | 458 self.code_map.Add(code) |
| 460 continue | 459 continue |
| 461 | 460 |
| 462 if tag == LogReader._CODE_DELETE_TAG: | |
| 463 event = self.code_delete_struct.from_buffer(self.log, self.log_pos) | |
| 464 self.log_pos += ctypes.sizeof(event) | |
| 465 old_start_address = event.address | |
| 466 code = self.code_map.Find(old_start_address) | |
| 467 if not code: | |
| 468 print >>sys.stderr, "Warning: Not found %x" % old_start_address | |
| 469 continue | |
| 470 assert code.start_address == old_start_address, \ | |
| 471 "Inexact delete address %x for %s" % (old_start_address, code) | |
| 472 self.code_map.Remove(code) | |
| 473 continue | |
| 474 | |
| 475 if tag == LogReader._SNAPSHOT_POSITION_TAG: | 461 if tag == LogReader._SNAPSHOT_POSITION_TAG: |
| 476 event = self.snapshot_position_struct.from_buffer(self.log, | 462 event = self.snapshot_position_struct.from_buffer(self.log, |
| 477 self.log_pos) | 463 self.log_pos) |
| 478 self.log_pos += ctypes.sizeof(event) | 464 self.log_pos += ctypes.sizeof(event) |
| 479 start_address = event.address | 465 start_address = event.address |
| 480 snapshot_pos = event.position | 466 snapshot_pos = event.position |
| 481 if snapshot_pos in self.snapshot_pos_to_name: | 467 if snapshot_pos in self.snapshot_pos_to_name: |
| 482 self.address_to_snapshot_name[start_address] = \ | 468 self.address_to_snapshot_name[start_address] = \ |
| 483 self.snapshot_pos_to_name[snapshot_pos] | 469 self.snapshot_pos_to_name[snapshot_pos] |
| 484 continue | 470 continue |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") | 1046 PrintTicks(optimized_ticks, ticks, "ticks in optimized code") |
| 1061 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") | 1047 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code") |
| 1062 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") | 1048 PrintTicks(v8_internal_ticks, ticks, "ticks in v8::internal::*") |
| 1063 print "%10d total symbols" % len([c for c in code_map.AllCode()]) | 1049 print "%10d total symbols" % len([c for c in code_map.AllCode()]) |
| 1064 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) | 1050 print "%10d used symbols" % len([c for c in code_map.UsedCode()]) |
| 1065 print "%9.2fs library processing time" % mmap_time | 1051 print "%9.2fs library processing time" % mmap_time |
| 1066 print "%9.2fs tick processing time" % sample_time | 1052 print "%9.2fs tick processing time" % sample_time |
| 1067 | 1053 |
| 1068 log_reader.Dispose() | 1054 log_reader.Dispose() |
| 1069 trace_reader.Dispose() | 1055 trace_reader.Dispose() |
| OLD | NEW |