• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37599

16 Aug 2023 01:53AM UTC coverage: 86.427% (-1.1%) from 87.526%
#37599

push

local

web-flow
Change heap-size-hint in test processes to total memory (#50922)

It seems this is causing macos to hang because the shown free memory is
generally very small.

xref: JuliaLang/julia#50673

73086 of 84564 relevant lines covered (86.43%)

32342958.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.54
/stdlib/InteractiveUtils/src/codeview.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
# highlighting settings
4
const highlighting = Dict{Symbol, Bool}(
5
    :warntype => true,
6
    :llvm => true,
7
    :native => true,
8
)
9

10
const llstyle = Dict{Symbol, Tuple{Bool, Union{Symbol, Int}}}(
11
    :default     => (false, :normal), # e.g. comma, equal sign, unknown token
12
    :comment     => (false, :light_black),
13
    :label       => (false, :light_red),
14
    :instruction => ( true, :light_cyan),
15
    :type        => (false, :cyan),
16
    :number      => (false, :yellow),
17
    :bracket     => (false, :yellow),
18
    :variable    => (false, :normal), # e.g. variable, register
19
    :keyword     => (false, :light_magenta),
20
    :funcname    => (false, :light_yellow),
21
)
22

23
function printstyled_ll(io::IO, x, s::Symbol, trailing_spaces="")
×
24
    printstyled(io, x, bold=llstyle[s][1], color=llstyle[s][2])
×
25
    print(io, trailing_spaces)
×
26
end
27

28
# displaying type warnings
29

30
function warntype_type_printer(io::IO; @nospecialize(type), used::Bool, show_type::Bool=true, _...)
166✔
31
    (show_type && used) || return nothing
116✔
32
    str = "::$type"
50✔
33
    if !highlighting[:warntype]
50✔
34
        print(io, str)
×
35
    elseif type isa Union && is_expected_union(type)
50✔
36
        Base.emphasize(io, str, Base.warn_color()) # more mild user notification
4✔
37
    elseif type isa Type && (!Base.isdispatchelem(type) || type == Core.Box)
90✔
38
        Base.emphasize(io, str)
×
39
    else
40
        Base.printstyled(io, str, color=:cyan) # show the "good" type
46✔
41
    end
42
    return nothing
50✔
43
end
44

45
# True if one can be pretty certain that the compiler handles this union well,
46
# i.e. must be small with concrete types.
47
function is_expected_union(u::Union)
4✔
48
    Base.unionlen(u) < 4 || return false
4✔
49
    for x in Base.uniontypes(u)
4✔
50
        if !Base.isdispatchelem(x) || x == Core.Box
16✔
51
            return false
×
52
        end
53
    end
12✔
54
    return true
4✔
55
end
56

57
"""
58
    code_warntype([io::IO], f, types; debuginfo=:default)
59

60
Prints lowered and type-inferred ASTs for the methods matching the given generic function
61
and type signature to `io` which defaults to `stdout`. The ASTs are annotated in such a way
62
as to cause "non-leaf" types which may be problematic for performance to be emphasized
63
(if color is available, displayed in red). This serves as a warning of potential type instability.
64

65
Not all non-leaf types are particularly problematic for performance, and the performance
66
characteristics of a particular type is an implementation detail of the compiler.
67
`code_warntype` will err on the side of coloring types red if they might be a performance
68
concern, so some types may be colored red even if they do not impact performance.
69
Small unions of concrete types are usually not a concern, so these are highlighted in yellow.
70

71
Keyword argument `debuginfo` may be one of `:source` or `:none` (default), to specify the verbosity of code comments.
72

73
See [`@code_warntype`](@ref man-code-warntype) for more information.
74
"""
75
function code_warntype(io::IO, @nospecialize(f), @nospecialize(t=Base.default_tt(f));
4✔
76
                       debuginfo::Symbol=:default, optimize::Bool=false, kwargs...)
77
    debuginfo = Base.IRShow.debuginfo(debuginfo)
2✔
78
    lineprinter = Base.IRShow.__debuginfo[debuginfo]
2✔
79
    for (src, rettype) in code_typed(f, t; optimize, kwargs...)
2✔
80
        if !(src isa Core.CodeInfo)
2✔
81
            println(io, src)
×
82
            println(io, "  failed to infer")
×
83
            continue
×
84
        end
85
        lambda_io::IOContext = io
2✔
86
        p = src.parent
2✔
87
        nargs::Int = 0
2✔
88
        if p isa Core.MethodInstance
2✔
89
            println(io, p)
2✔
90
            print(io, "  from ")
2✔
91
            println(io, p.def)
2✔
92
            p.def isa Method && (nargs = p.def.nargs)
4✔
93
            if !isempty(p.sparam_vals)
2✔
94
                println(io, "Static Parameters")
×
95
                sig = p.def.sig
×
96
                warn_color = Base.warn_color() # more mild user notification
×
97
                for i = 1:length(p.sparam_vals)
×
98
                    sig = sig::UnionAll
×
99
                    name = sig.var.name
×
100
                    val = p.sparam_vals[i]
×
101
                    print_highlighted(io::IO, v::String, color::Symbol) =
×
102
                        if highlighting[:warntype]
103
                            Base.printstyled(io, v; color)
×
104
                        else
105
                            Base.print(io, v)
×
106
                        end
107
                    if val isa TypeVar
×
108
                        if val.lb === Union{}
×
109
                            print(io, "  ", name, " <: ")
×
110
                            print_highlighted(io, "$(val.ub)", warn_color)
×
111
                        elseif val.ub === Any
×
112
                            print(io, "  ", sig.var.name, " >: ")
×
113
                            print_highlighted(io, "$(val.lb)", warn_color)
×
114
                        else
115
                            print(io, "  ")
×
116
                            print_highlighted(io, "$(val.lb)", warn_color)
×
117
                            print(io, " <: ", sig.var.name, " <: ")
×
118
                            print_highlighted(io, "$(val.ub)", warn_color)
×
119
                        end
120
                    elseif val isa typeof(Vararg)
×
121
                        print(io, "  ", name, "::")
×
122
                        print_highlighted(io, "Int", warn_color)
×
123
                    else
124
                        print(io, "  ", sig.var.name, " = ")
×
125
                        print_highlighted(io, "$(val)", :cyan) # show the "good" type
×
126
                    end
127
                    println(io)
×
128
                    sig = sig.body
×
129
                end
×
130
            end
131
        end
132
        if src.slotnames !== nothing
2✔
133
            slotnames = Base.sourceinfo_slotnames(src)
2✔
134
            lambda_io = IOContext(lambda_io, :SOURCE_SLOTNAMES => slotnames)
2✔
135
            slottypes = src.slottypes
2✔
136
            nargs > 0 && println(io, "Arguments")
2✔
137
            for i = 1:length(slotnames)
4✔
138
                if i == nargs + 1
12✔
139
                    println(io, "Locals")
2✔
140
                end
141
                print(io, "  ", slotnames[i])
12✔
142
                if isa(slottypes, Vector{Any})
12✔
143
                    warntype_type_printer(io; type=slottypes[i], used=true)
12✔
144
                end
145
                println(io)
12✔
146
            end
22✔
147
        end
148
        print(io, "Body")
2✔
149
        warntype_type_printer(io; type=rettype, used=true)
2✔
150
        println(io)
2✔
151
        irshow_config = Base.IRShow.IRShowConfig(lineprinter(src), warntype_type_printer)
2✔
152
        Base.IRShow.show_ir(lambda_io, src, irshow_config)
2✔
153
        println(io)
2✔
154
    end
4✔
155
    nothing
2✔
156
end
157
code_warntype(@nospecialize(f), @nospecialize(t=Base.default_tt(f)); kwargs...) =
×
158
    code_warntype(stdout, f, t; kwargs...)
159

160
import Base.CodegenParams
161

162
const GENERIC_SIG_WARNING = "; WARNING: This code may not match what actually runs.\n"
163
const OC_MISMATCH_WARNING =
164
"""
165
; WARNING: The pre-inferred opaque closure is not callable with the given arguments
166
;          and will error on dispatch with this signature.
167
"""
168

169
# Printing code representations in IR and assembly
170

171
function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrapper::Bool,
30✔
172
                        raw::Bool, dump_module::Bool, syntax::Symbol,
173
                        optimize::Bool, debuginfo::Symbol, binary::Bool)
174
        params = CodegenParams(debug_info_kind=Cint(0),
30✔
175
                               safepoint_on_entry=raw, gcstack_arg=raw)
176
        _dump_function(f, t, native, wrapper, raw, dump_module, syntax,
30✔
177
                       optimize, debuginfo, binary, params)
178
end
179
function _dump_function(@nospecialize(f), @nospecialize(t), native::Bool, wrapper::Bool,
67✔
180
                        raw::Bool, dump_module::Bool, syntax::Symbol,
181
                        optimize::Bool, debuginfo::Symbol, binary::Bool, params::CodegenParams)
182
    ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
67✔
183
    if isa(f, Core.Builtin)
63✔
184
        throw(ArgumentError("argument is not a generic function"))
×
185
    end
186
    warning = ""
63✔
187
    # get the MethodInstance for the method match
188
    if !isa(f, Core.OpaqueClosure)
63✔
189
        world = Base.get_world_counter()
63✔
190
        match = Base._which(signature_type(f, t); world)
63✔
191
        mi = Core.Compiler.specialize_method(match)
63✔
192
        # TODO: use jl_is_cacheable_sig instead of isdispatchtuple
193
        isdispatchtuple(mi.specTypes) || (warning = GENERIC_SIG_WARNING)
63✔
194
    else
195
        world = UInt64(f.world)
×
196
        if Core.Compiler.is_source_inferred(f.source.source)
×
197
            # OC was constructed from inferred source. There's only one
198
            # specialization and we can't infer anything more precise either.
199
            world = f.source.primary_world
×
200
            mi = f.source.specializations::Core.MethodInstance
×
201
            Core.Compiler.hasintersect(typeof(f).parameters[1], t) || (warning = OC_MISMATCH_WARNING)
×
202
        else
203
            mi = Core.Compiler.specialize_method(f.source, Tuple{typeof(f.captures), t.parameters...}, Core.svec())
×
204
            actual = isdispatchtuple(mi.specTypes)
×
205
            isdispatchtuple(mi.specTypes) || (warning = GENERIC_SIG_WARNING)
×
206
        end
207
    end
208
    # get the code for it
209
    if debuginfo === :default
63✔
210
        debuginfo = :source
24✔
211
    elseif debuginfo !== :source && debuginfo !== :none
39✔
212
        throw(ArgumentError("'debuginfo' must be either :source or :none"))
×
213
    end
214
    if native
63✔
215
        if syntax !== :att && syntax !== :intel
×
216
            throw(ArgumentError("'syntax' must be either :intel or :att"))
×
217
        end
218
        if dump_module
×
219
            # we want module metadata, so use LLVM to generate assembly output
220
            str = _dump_function_native_assembly(mi, world, wrapper, syntax, debuginfo, binary, raw, params)
×
221
        else
222
            # if we don't want the module metadata, just disassemble what our JIT has
223
            str = _dump_function_native_disassembly(mi, world, wrapper, syntax, debuginfo, binary)
×
224
        end
225
    else
226
        str = _dump_function_llvm(mi, world, wrapper, !raw, dump_module, optimize, debuginfo, params)
63✔
227
    end
228
    str = warning * str
63✔
229
    return str
63✔
230
end
231

232
function _dump_function_native_disassembly(mi::Core.MethodInstance, world::UInt,
×
233
                                           wrapper::Bool, syntax::Symbol,
234
                                           debuginfo::Symbol, binary::Bool)
235
    str = @ccall jl_dump_method_asm(mi::Any, world::UInt, false::Bool, wrapper::Bool,
×
236
                                    syntax::Ptr{UInt8}, debuginfo::Ptr{UInt8},
237
                                    binary::Bool)::Ref{String}
238
    return str
×
239
end
240

241
struct LLVMFDump
242
    tsm::Ptr{Cvoid} # opaque
243
    f::Ptr{Cvoid} # opaque
244
end
245

246
function _dump_function_native_assembly(mi::Core.MethodInstance, world::UInt,
×
247
                                        wrapper::Bool, syntax::Symbol, debuginfo::Symbol,
248
                                        binary::Bool, raw::Bool, params::CodegenParams)
249
    llvmf_dump = Ref{LLVMFDump}()
×
250
    @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump},mi::Any, world::UInt, wrapper::Bool,
×
251
                             true::Bool, params::CodegenParams)::Cvoid
252
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
×
253
    str = @ccall jl_dump_function_asm(llvmf_dump::Ptr{LLVMFDump}, false::Bool,
×
254
                                      syntax::Ptr{UInt8}, debuginfo::Ptr{UInt8},
255
                                      binary::Bool, raw::Bool)::Ref{String}
256
    return str
×
257
end
258

259
function _dump_function_llvm(
63✔
260
        mi::Core.MethodInstance, world::UInt, wrapper::Bool,
261
        strip_ir_metadata::Bool, dump_module::Bool,
262
        optimize::Bool, debuginfo::Symbol,
263
        params::CodegenParams)
264
    llvmf_dump = Ref{LLVMFDump}()
63✔
265
    @ccall jl_get_llvmf_defn(llvmf_dump::Ptr{LLVMFDump}, mi::Any, world::UInt,
63✔
266
                             wrapper::Bool, optimize::Bool, params::CodegenParams)::Cvoid
267
    llvmf_dump[].f == C_NULL && error("could not compile the specified method")
63✔
268
    str = @ccall jl_dump_function_ir(llvmf_dump::Ptr{LLVMFDump}, strip_ir_metadata::Bool,
63✔
269
                                     dump_module::Bool, debuginfo::Ptr{UInt8})::Ref{String}
270
    return str
63✔
271
end
272

273
"""
274
    code_llvm([io=stdout,], f, types; raw=false, dump_module=false, optimize=true, debuginfo=:default)
275

276
Prints the LLVM bitcodes generated for running the method matching the given generic
277
function and type signature to `io`.
278

279
If the `optimize` keyword is unset, the code will be shown before LLVM optimizations.
280
All metadata and dbg.* calls are removed from the printed bitcode. For the full IR, set the `raw` keyword to true.
281
To dump the entire module that encapsulates the function (with declarations), set the `dump_module` keyword to true.
282
Keyword argument `debuginfo` may be one of source (default) or none, to specify the verbosity of code comments.
283
"""
284
function code_llvm(io::IO, @nospecialize(f), @nospecialize(types), raw::Bool,
27✔
285
                   dump_module::Bool=false, optimize::Bool=true, debuginfo::Symbol=:default)
286
    d = _dump_function(f, types, false, false, raw, dump_module, :intel, optimize, debuginfo, false)
27✔
287
    if highlighting[:llvm] && get(io, :color, false)::Bool
25✔
288
        print_llvm(io, d)
×
289
    else
290
        print(io, d)
25✔
291
    end
292
end
293
code_llvm(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f)); raw::Bool=false, dump_module::Bool=false, optimize::Bool=true, debuginfo::Symbol=:default) =
54✔
294
    code_llvm(io, f, types, raw, dump_module, optimize, debuginfo)
295
code_llvm(@nospecialize(f), @nospecialize(types=Base.default_tt(f)); raw=false, dump_module=false, optimize=true, debuginfo::Symbol=:default) =
6✔
296
    code_llvm(stdout, f, types; raw, dump_module, optimize, debuginfo)
297

298
"""
299
    code_native([io=stdout,], f, types; syntax=:intel, debuginfo=:default, binary=false, dump_module=true)
300

301
Prints the native assembly instructions generated for running the method matching the given
302
generic function and type signature to `io`.
303

304
* Set assembly syntax by setting `syntax` to `:intel` (default) for intel syntax or `:att` for AT&T syntax.
305
* Specify verbosity of code comments by setting `debuginfo` to `:source` (default) or `:none`.
306
* If `binary` is `true`, also print the binary machine code for each instruction precedented by an abbreviated address.
307
* If `dump_module` is `false`, do not print metadata such as rodata or directives.
308
* If `raw` is `false`, uninteresting instructions (like the safepoint function prologue) are elided.
309

310
See also: [`@code_native`](@ref), [`code_llvm`](@ref), [`code_typed`](@ref) and [`code_lowered`](@ref)
311
"""
312
function code_native(io::IO, @nospecialize(f), @nospecialize(types=Base.default_tt(f));
4✔
313
                     dump_module::Bool=true, syntax::Symbol=:intel, raw::Bool=false,
314
                     debuginfo::Symbol=:default, binary::Bool=false)
315
    d = _dump_function(f, types, true, false, raw, dump_module, syntax, true, debuginfo, binary)
2✔
316
    if highlighting[:native] && get(io, :color, false)::Bool
×
317
        print_native(io, d)
×
318
    else
319
        print(io, d)
×
320
    end
321
end
322
code_native(@nospecialize(f), @nospecialize(types=Base.default_tt(f)); dump_module::Bool=true, syntax::Symbol=:intel, raw::Bool=false, debuginfo::Symbol=:default, binary::Bool=false) =
4✔
323
    code_native(stdout, f, types; dump_module, syntax, raw, debuginfo, binary)
324
code_native(::IO, ::Any, ::Symbol) = error("invalid code_native call") # resolve ambiguous call
×
325

326
## colorized IR and assembly printing
327

328
const num_regex = r"^(?:\$?-?\d+|0x[0-9A-Fa-f]+|-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)$"
329

330
function print_llvm(io::IO, code::String)
×
331
    buf = IOBuffer(code)
×
332
    for line in eachline(buf)
×
333
        m = match(r"^(\s*)((?:[^;]|;\")*)(.*)$", line)
×
334
        m === nothing && continue
×
335
        indent, tokens, comment = m.captures
×
336
        print(io, indent)
×
337
        print_llvm_tokens(io, tokens)
×
338
        printstyled_ll(io, comment, :comment)
×
339
        println(io)
×
340
    end
×
341
end
342

343
const llvm_types =
344
    r"^(?:void|half|float|double|x86_\w+|ppc_\w+|label|metadata|type|opaque|token|i\d+)$"
345
const llvm_cond = r"^(?:[ou]?eq|[ou]?ne|[uso][gl][te]|ord|uno)$" # true|false
346

347
function print_llvm_tokens(io, tokens)
×
348
    m = match(r"^((?:[^\s:]+:)?)(\s*)(.*)", tokens)
×
349
    if m !== nothing
×
350
        label, spaces, tokens = m.captures
×
351
        printstyled_ll(io, label, :label, spaces)
×
352
    end
353
    m = match(r"^(%[^\s=]+)(\s*)=(\s*)(.*)", tokens)
×
354
    if m !== nothing
×
355
        result, spaces, spaces2, tokens = m.captures
×
356
        printstyled_ll(io, result, :variable, spaces)
×
357
        printstyled_ll(io, '=', :default, spaces2)
×
358
    end
359
    m = match(r"^([a-z]\w*)(\s*)(.*)", tokens)
×
360
    if m !== nothing
×
361
        inst, spaces, tokens = m.captures
×
362
        iskeyword = occursin(r"^(?:define|declare|type)$", inst) || occursin("=", tokens)
×
363
        printstyled_ll(io, inst, iskeyword ? :keyword : :instruction, spaces)
×
364
    end
365

366
    print_llvm_operands(io, tokens)
×
367
end
368

369
function print_llvm_operands(io, tokens)
×
370
    while !isempty(tokens)
×
371
        tokens = print_llvm_operand(io, tokens)
×
372
    end
×
373
    return tokens
×
374
end
375

376
function print_llvm_operand(io, tokens)
×
377
    islabel = false
×
378
    while !isempty(tokens)
×
379
        m = match(r"^,(\s*)(.*)", tokens)
×
380
        if m !== nothing
×
381
            spaces, tokens = m.captures
×
382
            printstyled_ll(io, ',', :default, spaces)
×
383
            break
×
384
        end
385
        m = match(r"^(\*+|=)(\s*)(.*)", tokens)
×
386
        if m !== nothing
×
387
            sym, spaces, tokens = m.captures
×
388
            printstyled_ll(io, sym, :default, spaces)
×
389
            continue
×
390
        end
391
        m = match(r"^(\"[^\"]*\")(\s*)(.*)", tokens)
×
392
        if m !== nothing
×
393
            str, spaces, tokens = m.captures
×
394
            printstyled_ll(io, str, :variable, spaces)
×
395
            continue
×
396
        end
397
        m = match(r"^([({\[<])(\s*)(.*)", tokens)
×
398
        if m !== nothing
×
399
            bracket, spaces, tokens = m.captures
×
400
            printstyled_ll(io, bracket, :bracket, spaces)
×
401
            tokens = print_llvm_operands(io, tokens) # enter
×
402
            continue
×
403
        end
404
        m = match(r"^([)}\]>])(\s*)(.*)", tokens)
×
405
        if m !== nothing
×
406
            bracket, spaces, tokens = m.captures
×
407
            printstyled_ll(io, bracket, :bracket, spaces)
×
408
            break # leave
×
409
        end
410

411
        m = match(r"^([^\s,*=(){}\[\]<>]+)(\s*)(.*)", tokens)
×
412
        m === nothing && break
×
413
        token, spaces, tokens = m.captures
×
414
        if occursin(llvm_types, token)
×
415
            printstyled_ll(io, token, :type)
×
416
            islabel = token == "label"
×
417
        elseif occursin(llvm_cond, token) # condition code is instruction-level
×
418
            printstyled_ll(io, token, :instruction)
×
419
        elseif occursin(num_regex, token)
×
420
            printstyled_ll(io, token, :number)
×
421
        elseif occursin(r"^@.+$", token)
×
422
            printstyled_ll(io, token, :funcname)
×
423
        elseif occursin(r"^%.+$", token)
×
424
            islabel |= occursin(r"^%[^\d].*$", token) & occursin(r"^\]", tokens)
×
425
            printstyled_ll(io, token, islabel ? :label : :variable)
×
426
            islabel = false
×
427
        elseif occursin(r"^[a-z]\w+$", token)
×
428
            printstyled_ll(io, token, :keyword)
×
429
        else
430
            printstyled_ll(io, token, :default)
×
431
        end
432
        print(io, spaces)
×
433
    end
×
434
    return tokens
×
435
end
436

437
function print_native(io::IO, code::String, arch::Symbol=sys_arch_category())
×
438
    archv = Val(arch)
×
439
    buf = IOBuffer(code)
×
440
    for line in eachline(buf)
×
441
        m = match(r"^(\s*)((?:[^;#/]|#\S|;\"|/[^/])*)(.*)$", line)
×
442
        m === nothing && continue
×
443
        indent, tokens, comment = m.captures
×
444
        print(io, indent)
×
445
        print_native_tokens(io, tokens, archv)
×
446
        printstyled_ll(io, comment, :comment)
×
447
        println(io)
×
448
    end
×
449
end
450

451
function sys_arch_category()
×
452
    if Sys.ARCH === :x86_64 || Sys.ARCH === :i686
×
453
        :x86
×
454
    elseif Sys.ARCH === :aarch64 || startswith(string(Sys.ARCH), "arm")
×
455
        :arm
×
456
    else
457
        :unsupported
×
458
    end
459
end
460

461
print_native_tokens(io, line, ::Val) = print(io, line)
×
462

463
const x86_ptr = r"^(?:(?:[xyz]mm|[dq])?word|byte|ptr|offset)$"
464
const avx512flags = r"^(?:z|r[nduz]-sae|sae|1to1?\d)$"
465
const arm_cond = r"^(?:eq|ne|cs|ho|cc|lo|mi|pl|vs|vc|hi|ls|[lg][te]|al|nv)$"
466
const arm_keywords = r"^(?:lsl|lsr|asr|ror|rrx|!|/[zm])$"
467

468
function print_native_tokens(io, tokens, arch::Union{Val{:x86}, Val{:arm}})
×
469
    x86 = arch isa Val{:x86}
×
470
    m = match(r"^((?:[^\s:]+:|\"[^\"]+\":)?)(\s*)(.*)", tokens)
×
471
    if m !== nothing
×
472
        label, spaces, tokens = m.captures
×
473
        printstyled_ll(io, label, :label, spaces)
×
474
    end
475
    haslabel = false
×
476
    m = match(r"^([a-z][\w.]*)(\s*)(.*)", tokens)
×
477
    if m !== nothing
×
478
        instruction, spaces, tokens = m.captures
×
479
        printstyled_ll(io, instruction, :instruction, spaces)
×
480
        haslabel = occursin(r"^(?:bl?|bl?\.\w{2,5}|[ct]bn?z)?$", instruction)
×
481
    end
482

483
    isfuncname = false
×
484
    while !isempty(tokens)
×
485
        m = match(r"^([,:*])(\s*)(.*)", tokens)
×
486
        if m !== nothing
×
487
            sym, spaces, tokens = m.captures
×
488
            printstyled_ll(io, sym, :default, spaces)
×
489
            isfuncname = false
×
490
            continue
×
491
        end
492
        m = match(r"^([(){}\[\]])(\s*)(.*)", tokens)
×
493
        if m !== nothing
×
494
            bracket, spaces, tokens = m.captures
×
495
            printstyled_ll(io, bracket, :bracket, spaces)
×
496
            continue
×
497
        end
498
        m = match(r"^#([0-9a-fx.-]+)(\s*)(.*)", tokens)
×
499
        if !x86 && m !== nothing && occursin(num_regex, m.captures[1])
×
500
            num, spaces, tokens = m.captures
×
501
            printstyled_ll(io, "#" * num, :number, spaces)
×
502
            continue
×
503
        end
504

505
        m = match(r"^([^\s,:*(){}\[\]][^\s,:*/(){}\[\]]*)(\s*)(.*)", tokens)
×
506
        m === nothing && break
×
507
        token, spaces, tokens = m.captures
×
508
        if occursin(num_regex, token)
×
509
            printstyled_ll(io, token, :number)
×
510
        elseif x86 && occursin(x86_ptr, token) || occursin(avx512flags, token)
×
511
            printstyled_ll(io, token, :keyword)
×
512
            isfuncname = token == "offset"
×
513
        elseif !x86 && (occursin(arm_keywords, token) || occursin(arm_cond, token))
×
514
            printstyled_ll(io, token, :keyword)
×
515
        elseif occursin(r"^L.+$", token)
×
516
            printstyled_ll(io, token, :label)
×
517
        elseif occursin(r"^\$.+$", token)
×
518
            printstyled_ll(io, token, :funcname)
×
519
        elseif occursin(r"^%?(?:[a-z][\w.]+|\"[^\"]+\")$", token)
×
520
            islabel = haslabel & !occursin(',', tokens)
×
521
            printstyled_ll(io, token, islabel ? :label : isfuncname ? :funcname : :variable)
×
522
            isfuncname = false
×
523
        else
524
            printstyled_ll(io, token, :default)
×
525
        end
526
        print(io, spaces)
×
527
    end
×
528
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc