@@ -24,8 +24,8 @@ binned by the mapping defined within `instruction_categories`.
2424"""
2525function instruction_mnemonics (path:: AbstractString , platform:: AbstractPlatform )
2626 # 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}} ()
2929
3030 ur = preferred_runner ()(
3131 abspath (dirname (path));
@@ -44,15 +44,22 @@ function instruction_mnemonics(path::AbstractString, platform::AbstractPlatform)
4444 run_interactive (ur, ` /bin/bash -c "$(objdump_cmd) "` ; stdout = output, stderr = devnull )
4545 seekstart (output)
4646
47- for line in eachline (output)
47+ @time for line in eachline (output)
48+ isempty (line) && continue
49+
4850 # 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
5255 end
53-
5456 # 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+
5663 push! (mnemonics, m)
5764
5865 # For each mnemonic, find it in mnemonics_by_category, if we can, and
0 commit comments