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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/ignition/linux_perf_bytecode_annotate_test.py
diff --git a/tools/ignition/linux_perf_bytecode_annotate_test.py b/tools/ignition/linux_perf_bytecode_annotate_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..15abbeda08b70466c820d1cda67be0d257ecc527
--- /dev/null
+++ b/tools/ignition/linux_perf_bytecode_annotate_test.py
@@ -0,0 +1,85 @@
+# Copyright 2016 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import StringIO
+import unittest
+import linux_perf_bytecode_annotate as bytecode_annotate
+
+
+PERF_SCRIPT_OUTPUT = """
+# This line is a comment
+# This should be ignored too
+#
+# cdefab01 aRandomSymbol::Name(to, be, ignored)
+
+ 00000000 firstSymbol
+ 00000123 secondSymbol
+
+ 01234567 foo
+ abcdef76 BytecodeHandler:bar+0x12
+ 76543210 baz
+ abcdef76 BytecodeHandler:bar+0x16
+ 76543210 baz
+
+ 01234567 foo
+ abcdef76 BytecodeHandler:foo+0x1
+ 76543210 baz
+ abcdef76 BytecodeHandler:bar+0x2
+ 76543210 bar
+
+ abcdef76 BytecodeHandler:bar+0x19
+
+ abcdef76 BytecodeHandler:bar+0x12
+
+ abcdef76 BytecodeHandler:bar+0x12
+"""
+
+
+D8_CODEGEN_OUTPUT = """
+kind = BYTECODE_HANDLER
+name = foo
+compiler = turbofan
+Instructions (size = 3)
+0x3101394a3c0 0 55 push rbp
+0x3101394a3c1 1 ffe3 jmp rbx
+
+kind = BYTECODE_HANDLER
+name = bar
+compiler = turbofan
+Instructions (size = 5)
+0x3101394b3c0 0 55 push rbp
+0x3101394b3c1 1 4883c428 REX.W addq rsp,0x28
+# Unexpected comment
+0x3101394b3c5 5 ffe3 jmp rbx
+
+kind = BYTECODE_HANDLER
+name = baz
+compiler = turbofan
+Instructions (size = 5)
+0x3101394c3c0 0 55 push rbp
+0x3101394c3c1 1 4883c428 REX.W addq rsp,0x28
+0x3101394c3c5 5 ffe3 jmp rbx
+"""
+
+
+class LinuxPerfBytecodeAnnotateTest(unittest.TestCase):
+
+ def test_bytecode_offset_generator(self):
+ perf_stream = StringIO.StringIO(PERF_SCRIPT_OUTPUT)
+ offsets = list(
+ bytecode_annotate.bytecode_offset_generator(perf_stream, "bar"))
+ self.assertListEqual(offsets, [18, 25, 18, 18])
+
+ def test_bytecode_disassembly_generator(self):
+ codegen_stream = StringIO.StringIO(D8_CODEGEN_OUTPUT)
+ disassembly = list(
+ bytecode_annotate.bytecode_disassembly_generator(codegen_stream, "bar"))
+ self.assertListEqual(disassembly, [
+ "0x3101394b3c0 0 55 push rbp",
+ "0x3101394b3c1 1 4883c428 REX.W addq rsp,0x28",
+ "0x3101394b3c5 5 ffe3 jmp rbx"])
+
+
+if __name__ == "__main__":
+ unittest.main()
« 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