Skip to content

cmd/compile: get rid of write barrier on slicing #71251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randall77 opened this issue Jan 13, 2025 · 3 comments
Closed

cmd/compile: get rid of write barrier on slicing #71251

randall77 opened this issue Jan 13, 2025 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Implementation Issues describing a semantics-preserving change to the Go implementation. Performance
Milestone

Comments

@randall77
Copy link
Contributor

type S struct {
	a []byte
}

func f(s *S) {
	s.a = s.a[1:]
}

The write barrier in f seems unnecessary. We're always writing back to s.a a pointer to the same object that used to be there.
Noticed while looking at #71246.

@randall77 randall77 added compiler/runtime Issues related to the Go compiler and/or runtime. Performance labels Jan 13, 2025
@randall77 randall77 added this to the Unplanned milestone Jan 13, 2025
@gabyhelp gabyhelp added the Implementation Issues describing a semantics-preserving change to the Go implementation. label Jan 13, 2025
@randall77
Copy link
Contributor Author

Maybe we can't do this? See the comment at #14855 (comment). Russ is afraid that in the presence of races we can't do the pointer write without the write barrier, as we may lose track of some write that happened between the read of s.a.ptr and the write of s.a.ptr+1.

@randall77
Copy link
Contributor Author

Probably a dup of #24314. There's even a CL, CL 105258.
@aclements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Implementation Issues describing a semantics-preserving change to the Go implementation. Performance
Projects
None yet
Development

No branches or pull requests

2 participants