| // Copyright 2018 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // This test makes sure that ambiguously live arguments work correctly. |
| // encourage heap object to be collected, and have its finalizer run. |
| func f(s StkObj, b bool) { |
| // use is required here to prevent the conditional |
| // code above from being executed after the first gc() call. |
| // If b==false, h should be collected here. |
| // If b==true, h should be collected here. |
| runtime.SetFinalizer(s.h, func(h *HeapObj) { |
| // Remember at what phase the heap object was collected. |
| runtime.SetFinalizer(s.h, func(h *HeapObj) { |
| // Remember at what phase the heap object was collected. |