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

Unified Diff: tools/tickprocessor.py

Issue 20499: Experimental: merge from bleeding edge 1298:1307. Port the eval... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 11 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/linux-tick-processor.py ('k') | tools/windows-tick-processor.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/tickprocessor.py
===================================================================
--- tools/tickprocessor.py (revision 1322)
+++ tools/tickprocessor.py (working copy)
@@ -25,10 +25,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import csv, splaytree, sys
+import csv, splaytree, sys, re
from operator import itemgetter
+import getopt, os, string
-
class CodeEntry(object):
def __init__(self, start_addr, name):
@@ -56,7 +56,10 @@
def IsSharedLibraryEntry(self):
return False
+ def IsICEntry(self):
+ return False
+
class SharedLibraryEntry(CodeEntry):
def __init__(self, start_addr, name):
@@ -74,6 +77,7 @@
self.size = size
self.assembler = assembler
self.region_ticks = None
+ self.builtin_ic_re = re.compile('^(Keyed)?(Call|Load|Store)IC_')
def Tick(self, pc, stack):
super(JSCodeEntry, self).Tick(pc, stack)
@@ -116,7 +120,11 @@
name = '<anonymous>' + name
return self.type + ': ' + name
+ def IsICEntry(self):
+ return self.type in ('CallIC', 'LoadIC', 'StoreIC') or \
+ (self.type == 'Builtin' and self.builtin_ic_re.match(self.name))
+
class CodeRegion(object):
def __init__(self, start_offset, name):
@@ -159,10 +167,11 @@
# Flag indicating whether to ignore unaccounted ticks in the report
self.ignore_unknown = False
- def ProcessLogfile(self, filename, included_state = None, ignore_unknown = False):
+ def ProcessLogfile(self, filename, included_state = None, ignore_unknown = False, separate_ic = False):
self.log_file = filename
self.included_state = included_state
self.ignore_unknown = ignore_unknown
+ self.separate_ic = separate_ic
try:
logfile = open(filename, 'rb')
@@ -172,7 +181,7 @@
logreader = csv.reader(logfile)
for row in logreader:
if row[0] == 'tick':
- self.ProcessTick(int(row[1], 16), int(row[2], 16), int(row[3]), row[4:])
+ self.ProcessTick(int(row[1], 16), int(row[2], 16), int(row[3]), self.PreprocessStack(row[4:]))
elif row[0] == 'code-creation':
self.ProcessCodeCreation(row[1], int(row[2], 16), int(row[3]), row[4])
elif row[0] == 'code-move':
@@ -261,15 +270,22 @@
return self.js_entries.FindGreatestsLessThan(pc).value
return None
- def ProcessStack(self, stack):
+ def PreprocessStack(self, stack):
+ # remove all non-addresses (e.g. 'overflow') and convert to int
result = []
for frame in stack:
if frame.startswith('0x'):
- entry = self.FindEntry(int(frame, 16))
- if entry != None:
- result.append(entry.ToString())
+ result.append(int(frame, 16))
return result
+ def ProcessStack(self, stack):
+ result = []
+ for frame in stack:
+ entry = self.FindEntry(frame)
+ if entry != None:
+ result.append(entry.ToString())
+ return result
+
def ProcessTick(self, pc, sp, state, stack):
if not self.IncludeTick(pc, sp, state):
self.excluded_number_of_ticks += 1;
@@ -281,7 +297,15 @@
return
if entry.IsSharedLibraryEntry():
self.number_of_library_ticks += 1
- entry.Tick(pc, self.ProcessStack(stack))
+ if entry.IsICEntry() and not self.separate_ic:
+ if len(stack) > 0:
+ caller_pc = stack.pop(0)
+ self.total_number_of_ticks -= 1
+ self.ProcessTick(caller_pc, sp, state, stack)
+ else:
+ self.unaccounted_number_of_ticks += 1
+ else:
+ entry.Tick(pc, self.ProcessStack(stack))
def PrintResults(self):
print('Statistical profiling result from %s, (%d ticks, %d unaccounted, %d excluded).' %
@@ -368,5 +392,54 @@
'call_path' : stack[0] + ' <- ' + stack[1]
})
+
+class CmdLineProcessor(object):
+
+ def __init__(self):
+ self.options = ["js", "gc", "compiler", "other", "ignore-unknown", "separate-ic"]
+ # default values
+ self.state = None
+ self.ignore_unknown = False
+ self.log_file = None
+ self.separate_ic = False
+
+ def ProcessArguments(self):
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "jgco", self.options)
+ except getopt.GetoptError:
+ self.PrintUsageAndExit()
+ for key, value in opts:
+ if key in ("-j", "--js"):
+ self.state = 0
+ if key in ("-g", "--gc"):
+ self.state = 1
+ if key in ("-c", "--compiler"):
+ self.state = 2
+ if key in ("-o", "--other"):
+ self.state = 3
+ if key in ("--ignore-unknown"):
+ self.ignore_unknown = True
+ if key in ("--separate-ic"):
+ self.separate_ic = True
+ self.ProcessRequiredArgs(args)
+
+ def ProcessRequiredArgs(self, args):
+ return
+
+ def GetRequiredArgsNames(self):
+ return
+
+ def PrintUsageAndExit(self):
+ print('Usage: %(script_name)s --{%(opts)s} %(req_opts)s' % {
+ 'script_name': os.path.basename(sys.argv[0]),
+ 'opts': string.join(self.options, ','),
+ 'req_opts': self.GetRequiredArgsNames()
+ })
+ sys.exit(2)
+
+ def RunLogfileProcessing(self, tick_processor):
+ tick_processor.ProcessLogfile(self.log_file, self.state, self.ignore_unknown, self.separate_ic)
+
+
if __name__ == '__main__':
sys.exit('You probably want to run windows-tick-processor.py or linux-tick-processor.py.')
« no previous file with comments | « tools/linux-tick-processor.py ('k') | tools/windows-tick-processor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698