Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
writebarrier.go104 linesDownload Raw Back to codegen
1// asmcheck2 3// Copyright 2023 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7package codegen8 9func combine2string(p *[2]string, a, b string) {10	// amd64:`.*runtime[.]gcWriteBarrier4\(SB\)`11	// arm64:`.*runtime[.]gcWriteBarrier4\(SB\)`12	p[0] = a13	// amd64:-`.*runtime[.]gcWriteBarrier`14	// arm64:-`.*runtime[.]gcWriteBarrier`15	p[1] = b16}17 18func combine4string(p *[4]string, a, b, c, d string) {19	// amd64:`.*runtime[.]gcWriteBarrier8\(SB\)`20	// arm64:`.*runtime[.]gcWriteBarrier8\(SB\)`21	p[0] = a22	// amd64:-`.*runtime[.]gcWriteBarrier`23	// arm64:-`.*runtime[.]gcWriteBarrier`24	p[1] = b25	// amd64:-`.*runtime[.]gcWriteBarrier`26	// arm64:-`.*runtime[.]gcWriteBarrier`27	p[2] = c28	// amd64:-`.*runtime[.]gcWriteBarrier`29	// arm64:-`.*runtime[.]gcWriteBarrier`30	p[3] = d31}32 33func combine2slice(p *[2][]byte, a, b []byte) {34	// amd64:`.*runtime[.]gcWriteBarrier4\(SB\)`35	// arm64:`.*runtime[.]gcWriteBarrier4\(SB\)`36	p[0] = a37	// amd64:-`.*runtime[.]gcWriteBarrier`38	// arm64:-`.*runtime[.]gcWriteBarrier`39	p[1] = b40}41 42func combine4slice(p *[4][]byte, a, b, c, d []byte) {43	// amd64:`.*runtime[.]gcWriteBarrier8\(SB\)`44	// arm64:`.*runtime[.]gcWriteBarrier8\(SB\)`45	p[0] = a46	// amd64:-`.*runtime[.]gcWriteBarrier`47	// arm64:-`.*runtime[.]gcWriteBarrier`48	p[1] = b49	// amd64:-`.*runtime[.]gcWriteBarrier`50	// arm64:-`.*runtime[.]gcWriteBarrier`51	p[2] = c52	// amd64:-`.*runtime[.]gcWriteBarrier`53	// arm64:-`.*runtime[.]gcWriteBarrier`54	p[3] = d55}56 57func trickyWriteNil(p *int, q **int) {58	if p == nil {59		// We change "= p" to "= 0" in the prove pass, which60		// means we have one less pointer that needs to go61		// into the write barrier buffer.62		// amd64:`.*runtime[.]gcWriteBarrier1`63		*q = p64	}65}66 67type S struct {68	a, b string69	c    *int70}71 72var g1, g2 *int73 74func issue71228(dst *S, ptr *int) {75	// Make sure that the non-write-barrier write.76	// "sp.c = ptr" happens before the large write77	// barrier "*dst = *sp". We approximate testing78	// that by ensuring that two global variable write79	// barriers aren't combined.80	_ = *dst81	var s S82	sp := &s83	//amd64:`.*runtime[.]gcWriteBarrier1`84	g1 = nil85	sp.c = ptr // outside of any write barrier86	//amd64:`.*runtime[.]gcWriteBarrier1`87	g2 = nil88	//amd64:`.*runtime[.]wbMove`89	*dst = *sp90}91 92func writeDouble(p *[2]*int, x, y *int) {93	// arm64: `LDP\s`, `STP\s\(R[0-9]+, R[0-9]+\), \(`,94	p[0] = x95	// arm64: `STP\s\(R[0-9]+, R[0-9]+\), 16\(`,96	p[1] = y97}98 99func writeDoubleNil(p *[2]*int) {100	// arm64: `LDP\s`, `STP\s\(R[0-9]+, R[0-9]+\),`, `STP\s\(ZR, ZR\),`101	p[0] = nil102	p[1] = nil103}104 
codekingpro/portable-devtools · Team Ai