@@ -24,8 +24,8 @@ binned by the mapping defined within `instruction_categories`.
24
24
"""
25
25
function instruction_mnemonics (path:: AbstractString , platform:: AbstractPlatform )
26
26
# The outputs we are calculating
27
- counts = Dict (k => 0 for k in keys (instruction_categories))
28
- mnemonics = String[]
27
+ counts = Dict {SubString{String}, Int} (k => 0 for k in keys (instruction_categories))
28
+ mnemonics = Set {SubString{ String}} ()
29
29
30
30
ur = preferred_runner ()(
31
31
abspath (dirname (path));
@@ -44,15 +44,22 @@ function instruction_mnemonics(path::AbstractString, platform::AbstractPlatform)
44
44
run_interactive (ur, ` /bin/bash -c "$(objdump_cmd) "` ; stdout = output, stderr = devnull )
45
45
seekstart (output)
46
46
47
- for line in eachline (output)
47
+ @time for line in eachline (output)
48
+ isempty (line) && continue
49
+
48
50
# First, ensure that this line of output is 3 fields long at least
49
- fields = filter (x -> ! isempty (strip (x)), split (line, ' \t ' ))
50
- if length (fields) < 3
51
- continue
51
+ @static if VERSION >= v " 1.7.0-DEV.35"
52
+ count (' \t ' , line) != 2 && continue
53
+ else
54
+ count (== (' \t ' ), line) != 2 && continue
52
55
end
53
-
54
56
# Grab the mnemonic for this line as the first word of the 3rd field
55
- m = split (fields[3 ])[1 ]
57
+ idx = findlast (' \t ' , line)
58
+ s = SubString (line, idx+ 1 )
59
+ space = findfirst (' ' , s)
60
+ space === nothing && (space = lastindex (s))
61
+ m = SubString (s, 1 , space- 1 )
62
+
56
63
push! (mnemonics, m)
57
64
58
65
# For each mnemonic, find it in mnemonics_by_category, if we can, and
0 commit comments