Lines Matching defs:Code
8 # * Redistributions of source code must retain the above copyright
84 class Code(object):
85 """Code object."""
94 self.id = Code._id
95 Code._id += 1
106 self.codetype = Code.OPTIMIZED
108 self.codetype = Code.FULL_CODEGEN
110 self.codetype = Code.V8INTERNAL
112 self.codetype = Code.UNKNOWN
208 """Group of adjacent code objects."""
230 def Add(self, code):
231 self.code_objects.append(code)
233 def Remove(self, code):
234 self.code_objects.remove(code)
238 for i, code in enumerate(code_objects):
239 if code.start_address <= pc < code.end_address:
240 code_objects[0], code_objects[i] = code, code_objects[0]
241 return code
249 """Code object map."""
256 def Add(self, code, max_pages=-1):
257 page_id = CodePage.PageId(code.start_address)
258 limit_id = CodePage.PageId(code.end_address + CodePage.SIZE - 1)
264 max_pages, code.name, code.origin)
271 page.Add(code)
274 self.min_address = min(self.min_address, code.start_address)
275 self.max_address = max(self.max_address, code.end_address)
277 def Remove(self, code):
278 page_id = CodePage.PageId(code.start_address)
279 limit_id = CodePage.PageId(code.end_address + CodePage.SIZE - 1)
286 page.Remove(code)
293 for code in page:
294 if CodePage.PageAddress(code.start_address) == page.address:
295 yield code
298 for code in self.AllCode():
299 if code.IsUsed():
300 yield code
303 for code in self.AllCode():
304 print code
316 """Generic info about generated code objects."""
327 r"snapshot-code-name,(\d+),\"(.*)\"")
417 code = Code(name, start_address, end_address, origin, origin_offset)
420 if not (conficting_code.start_address == code.start_address and
421 conficting_code.end_address == code.end_address):
424 LogReader._HandleCodeConflict(conficting_code, code)
426 # attempts to reconstruct code log from the snapshot.
428 # "Warning: Skipping duplicate code log entry %s" % code
430 self.code_map.Add(code)
439 # Skip useless code move entries.
441 code = self.code_map.Find(old_start_address)
442 if not code:
445 assert code.start_address == old_start_address, \
446 "Inexact move address %x for %s" % (old_start_address, code)
447 self.code_map.Remove(code)
448 size = code.end_address - code.start_address
449 code.start_address = new_start_address
450 code.end_address = new_start_address + size
451 self.code_map.Add(code)
458 code = self.code_map.Find(old_start_address)
459 if not code:
462 assert code.start_address == old_start_address, \
463 "Inexact delete address %x for %s" % (old_start_address, code)
464 self.code_map.Remove(code)
494 "Conficting code
497 # Code object may be shared by a few functions. Collect the full
748 if line.find("CODE") != -1:
776 code_map.Add(Code(name, start_address, start_address + size,
804 code = None
811 if code:
812 code.end_address = start_address
813 code_map.Add(code, 16)
814 code = Code(name, start_address, end_address, "kernel", 0)
820 used_code = [code for code in code_map.UsedCode()]
822 for i, code in enumerate(used_code):
823 code_ticks = code.self_ticks
825 code.FullName(), code.origin)
827 code.PrintAnnotated(arch, options)
840 for code in code_map.UsedCode():
841 if code.self_ticks < 10:
843 print "n%d [shape=box,label=\"%s\"];" % (code.id, code.name)
844 if code.callee_ticks:
845 for callee, ticks in code.callee_ticks.iteritems():
846 print "n%d -> n%d [label=\"%d\"];" % (code.id, callee.id, ticks)
938 print "Generated code architecture: %s" % log_reader.arch
942 # Process the code and trace logs.
963 code = code_map.Find(sample.ip)
964 if code:
965 code.Tick(sample.ip)
966 if code.codetype == Code.OPTIMIZED:
968 elif code.codetype == Code.FULL_CODEGEN:
970 elif code.codetype == Code.V8INTERNAL:
974 if not library_repo.Tick(sample.ip) and not code:
980 if code:
981 code)
982 code = caller_code
1003 PrintTicks(optimized_ticks, ticks, "ticks in optimized code")
1004 PrintTicks(generated_ticks, ticks, "ticks in other lazily compiled code")