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

Side by Side Diff: tools/ignition/linux_perf_bytecode_annotate_test.py

Issue 1945673002: [Interpreter] Add a bytecode annotate tool. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « tools/ignition/linux_perf_bytecode_annotate.py ('k') | tools/run-perf.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 the V8 project authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import StringIO
6 import unittest
7 import linux_perf_bytecode_annotate as bytecode_annotate
8
9
10 PERF_SCRIPT_OUTPUT = """
11 # This line is a comment
12 # This should be ignored too
13 #
14 # cdefab01 aRandomSymbol::Name(to, be, ignored)
15
16 00000000 firstSymbol
17 00000123 secondSymbol
18
19 01234567 foo
20 abcdef76 BytecodeHandler:bar+0x12
21 76543210 baz
22 abcdef76 BytecodeHandler:bar+0x16
23 76543210 baz
24
25 01234567 foo
26 abcdef76 BytecodeHandler:foo+0x1
27 76543210 baz
28 abcdef76 BytecodeHandler:bar+0x2
29 76543210 bar
30
31 abcdef76 BytecodeHandler:bar+0x19
32
33 abcdef76 BytecodeHandler:bar+0x12
34
35 abcdef76 BytecodeHandler:bar+0x12
36 """
37
38
39 D8_CODEGEN_OUTPUT = """
40 kind = BYTECODE_HANDLER
41 name = foo
42 compiler = turbofan
43 Instructions (size = 3)
44 0x3101394a3c0 0 55 push rbp
45 0x3101394a3c1 1 ffe3 jmp rbx
46
47 kind = BYTECODE_HANDLER
48 name = bar
49 compiler = turbofan
50 Instructions (size = 5)
51 0x3101394b3c0 0 55 push rbp
52 0x3101394b3c1 1 4883c428 REX.W addq rsp,0x28
53 # Unexpected comment
54 0x3101394b3c5 5 ffe3 jmp rbx
55
56 kind = BYTECODE_HANDLER
57 name = baz
58 compiler = turbofan
59 Instructions (size = 5)
60 0x3101394c3c0 0 55 push rbp
61 0x3101394c3c1 1 4883c428 REX.W addq rsp,0x28
62 0x3101394c3c5 5 ffe3 jmp rbx
63 """
64
65
66 class LinuxPerfBytecodeAnnotateTest(unittest.TestCase):
67
68 def test_bytecode_offset_generator(self):
69 perf_stream = StringIO.StringIO(PERF_SCRIPT_OUTPUT)
70 offsets = list(
71 bytecode_annotate.bytecode_offset_generator(perf_stream, "bar"))
72 self.assertListEqual(offsets, [18, 25, 18, 18])
73
74 def test_bytecode_disassembly_generator(self):
75 codegen_stream = StringIO.StringIO(D8_CODEGEN_OUTPUT)
76 disassembly = list(
77 bytecode_annotate.bytecode_disassembly_generator(codegen_stream, "bar"))
78 self.assertListEqual(disassembly, [
79 "0x3101394b3c0 0 55 push rbp",
80 "0x3101394b3c1 1 4883c428 REX.W addq rsp,0x28",
81 "0x3101394b3c5 5 ffe3 jmp rbx"])
82
83
84 if __name__ == "__main__":
85 unittest.main()
OLDNEW
« no previous file with comments | « tools/ignition/linux_perf_bytecode_annotate.py ('k') | tools/run-perf.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698