Black Lives Matter. Support the Equal Justice Initiative.

Source file test/inline_sync.go

Documentation: test

     1  // +build !nacl,!386,!wasm,!arm,!gcflags_noopt
     2  // errorcheck -0 -m
     3  
     4  // Copyright 2019 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  // Test, using compiler diagnostic flags, that inlining of functions
     9  // imported from the sync package is working.
    10  // Compiles but does not run.
    11  
    12  // FIXME: This test is disabled on architectures where atomic operations
    13  // are function calls rather than intrinsics, since this prevents inlining
    14  // of the sync fast paths. This test should be re-enabled once the problem
    15  // is solved.
    16  
    17  package foo
    18  
    19  import (
    20  	"sync"
    21  )
    22  
    23  var mutex *sync.Mutex
    24  
    25  func small5() { // ERROR "can inline small5"
    26  	// the Unlock fast path should be inlined
    27  	mutex.Unlock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Unlock"
    28  }
    29  
    30  func small6() { // ERROR "can inline small6"
    31  	// the Lock fast path should be inlined
    32  	mutex.Lock() // ERROR "inlining call to sync\.\(\*Mutex\)\.Lock"
    33  }
    34  
    35  var once *sync.Once
    36  
    37  func small7() { // ERROR "can inline small7"
    38          // the Do fast path should be inlined
    39          once.Do(small5) // ERROR "inlining call to sync\.\(\*Once\)\.Do"
    40  }
    41  
    42  var rwmutex *sync.RWMutex
    43  
    44  func small8() { // ERROR "can inline small8"
    45          // the RUnlock fast path should be inlined
    46          rwmutex.RUnlock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RUnlock"
    47  }
    48  
    49  func small9() { // ERROR "can inline small9"
    50          // the RLock fast path should be inlined
    51          rwmutex.RLock() // ERROR "inlining call to sync\.\(\*RWMutex\)\.RLock"
    52  }
    53  
    54  

View as plain text