Skip to content

Commit 1d5b6e2

Browse files
committed
Move tools into their own repo
0 parents  commit 1d5b6e2

6 files changed

+1037
-0
lines changed

CountInstr.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/python3
2+
3+
# Copyright 2020 the V8 project authors. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
import sys
8+
import re
9+
import subprocess
10+
from collections import Counter
11+
import argparse
12+
from prettytable import PrettyTable
13+
14+
def Count(sub):
15+
couts = Counter()
16+
for line in sub.stdout:
17+
split = line.strip().decode('utf-8').split()
18+
if("0x" not in split[0]):
19+
continue
20+
if(len(split) >= 4):
21+
couts.update([split[2]])
22+
cout = couts.items()
23+
cout = list(cout)
24+
cout.sort(key=lambda x: x[1], reverse=True)
25+
26+
num = 0
27+
for key, value in couts.items():
28+
num += value
29+
30+
return num, cout
31+
32+
def ArgsInit():
33+
parser = argparse.ArgumentParser()
34+
parser.add_argument('arch1', help="The path of an architecture executable d8.")
35+
parser.add_argument('arch2', help="The path of an architecture executable d8.")
36+
parser.add_argument('d8_object', nargs='+', help="The path to the target of d8 operation")
37+
args, unknown = parser.parse_known_args()
38+
return args, unknown
39+
40+
41+
def Compare(arch1, arch2):
42+
summary = PrettyTable(["Summary", arch1[2], arch2[2]])
43+
summary.add_row(["count", arch1[0], arch2[0]])
44+
print(summary)
45+
46+
x = PrettyTable(["arch1_instr","arch1_ratio","arch1_count","arch2_instr","arch2_ratio","arch2_count"])
47+
for n, v in zip(arch1[1], arch2[1]):
48+
row = [n[0], "{:.2%}".format(float(n[1]) / arch1[0]),n[1]]
49+
row.extend([v[0], "{:.2%}".format(float(v[1]) / arch2[0]), v[1]])
50+
x.add_row(row)
51+
print(x)
52+
53+
if __name__ == "__main__":
54+
args, run_args = ArgsInit()
55+
run_args.append("--trace-sim")
56+
run_args.insert(0, args.arch1)
57+
run_args.extend(args.d8_object)
58+
sub = subprocess.Popen(
59+
run_args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
60+
risv = (Count(sub))+tuple(["arch1"])
61+
62+
run_args[0] = args.arch2
63+
sub = subprocess.Popen(
64+
run_args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
65+
mips64el = (Count(sub))+tuple(["arhc2"])
66+
Compare(risv, mips64el)
67+
pass

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# V8 RISC-V Tools
2+
3+
This directory is for tools developed specifically for the development of the
4+
RISC-V backend.
5+
6+
## analyze.py
7+
8+
This is a simple tool to parse debug output from the RISC-V assembler and
9+
simulator to generate information useful for debugging.
10+
11+
Current features:
12+
* Call stack
13+
14+
To use the tool, first execute your test with the flags `--print-all-code` and
15+
`--trace-sim`, dumping the output to a file. Then execute this tool, passing
16+
it that dump file and it will generate the call stack to stdout.
17+
```bash
18+
$ cctest --print-all-code -trace-sim test-interpreter-intrinsics/Call &> out
19+
$ analyze.py out
20+
```
21+
22+
The full usage information can be printed using `--help`:
23+
```
24+
usage: analyze.py [-h] [--inline] [--target TARGET] [--print-host-calls]
25+
[--fp]
26+
logfile
27+
28+
positional arguments:
29+
logfile
30+
31+
optional arguments:
32+
-h, --help show this help message and exit
33+
--inline Print comments inline with trace
34+
--target TARGET Specify the target architecture
35+
--print-host-calls Print info about calls to host functions
36+
--fp Print floating point arguments and return values
37+
```

0 commit comments

Comments
 (0)