Skip to content

Commit 0278981

Browse files
committed
internal/bisect: add 'q' hash option for quiet hash behavior switching
This is intended for the specific case of 'fmahash=qn' where someone wants to disable fma without all the hash-search-handshake output. There are cases where arm64, ppc64, and s390x users might want to do this. Change-Id: Iaf46c68a00d7c9f7f82fd98a4548b72610f84bed Reviewed-on: https://go-review.googlesource.com/c/go/+/503776 Run-TryBot: David Chase <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 98617fd commit 0278981

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/internal/bisect/bisect.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,20 @@ func New(pattern string) (*Matcher, error) {
198198

199199
m := new(Matcher)
200200

201-
// Allow multiple v, so that “bisect cmd vPATTERN” can force verbose all the time.
202201
p := pattern
202+
// Special case for leading 'q' so that 'qn' quietly disables, e.g. fmahash=qn to disable fma
203+
// Any instance of 'v' disables 'q'.
204+
if len(p) > 0 && p[0] == 'q' {
205+
m.quiet = true
206+
p = p[1:]
207+
if p == "" {
208+
return nil, &parseError{"invalid pattern syntax: " + pattern}
209+
}
210+
}
211+
// Allow multiple v, so that “bisect cmd vPATTERN” can force verbose all the time.
203212
for len(p) > 0 && p[0] == 'v' {
204213
m.verbose = true
214+
m.quiet = false
205215
p = p[1:]
206216
if p == "" {
207217
return nil, &parseError{"invalid pattern syntax: " + pattern}
@@ -297,7 +307,8 @@ func New(pattern string) (*Matcher, error) {
297307
// A Matcher is the parsed, compiled form of a PATTERN string.
298308
// The nil *Matcher is valid: it has all changes enabled but none reported.
299309
type Matcher struct {
300-
verbose bool
310+
verbose bool // annotate reporting with human-helpful information
311+
quiet bool // disables all reporting. reset if verbose is true. use case is -d=fmahash=qn
301312
enable bool // when true, list is for “enable and report” (when false, “disable and report”)
302313
list []cond // conditions; later ones win over earlier ones
303314
dedup atomicPointerDedup
@@ -339,20 +350,19 @@ func (m *Matcher) ShouldEnable(id uint64) bool {
339350
if m == nil {
340351
return true
341352
}
342-
for i := len(m.list) - 1; i >= 0; i-- {
343-
c := &m.list[i]
344-
if id&c.mask == c.bits {
345-
return c.result == m.enable
346-
}
347-
}
348-
return false == m.enable
353+
return m.matchResult(id) == m.enable
349354
}
350355

351356
// ShouldPrint reports whether to print identifying information about the change with the given id.
352357
func (m *Matcher) ShouldPrint(id uint64) bool {
353-
if m == nil {
358+
if m == nil || m.quiet {
354359
return false
355360
}
361+
return m.matchResult(id)
362+
}
363+
364+
// matchResult returns the result from the first condition that matches id.
365+
func (m *Matcher) matchResult(id uint64) bool {
356366
for i := len(m.list) - 1; i >= 0; i-- {
357367
c := &m.list[i]
358368
if id&c.mask == c.bits {

0 commit comments

Comments
 (0)