Skip to content
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

cmd/compile: implement global new(T) without calling newobject #29691

Open
josharian opened this issue Jan 11, 2019 · 5 comments
Milestone

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Jan 11, 2019

package p

var x = new(int)

This generates init code to call newobject (including a write barrier, which I thought wasn't supposed to happen any more?). Instead, we should make a BSS int symbol, and then make x contain a relocation to that symbol.

cc @randall77 @mvdan

@josharian josharian added this to the Go1.13 milestone Jan 11, 2019
@randall77

This comment has been minimized.

Copy link
Contributor

@randall77 randall77 commented Jan 11, 2019

No, we still need a write barrier when initializing a global location.

The write barriers I changed recently removes them when initializing the contents of the results of a newobject call. Not sure if you're referring to that.

Yes, we can and should allocate the int statically. Small caveat: watch out for #29068.

@Skarlso

This comment has been minimized.

Copy link
Contributor

@Skarlso Skarlso commented Feb 27, 2019

Hi @josharian! Can I help?

@josharian

This comment has been minimized.

Copy link
Contributor Author

@josharian josharian commented Feb 27, 2019

Go for it. You'll be looking at sinit.go. It's not particularly clear code, even by compiler standards. I recommend writing yourself a few simplified examples to work off of.

@Skarlso

This comment has been minimized.

Copy link
Contributor

@Skarlso Skarlso commented Feb 27, 2019

Sounds lovely. :D But at least I'll learn while trying to figure it out. Which is always good. :)

@Skarlso

This comment has been minimized.

Copy link
Contributor

@Skarlso Skarlso commented Mar 17, 2019

Picking this up now. Sorry, was pre-occupied with another issue on packages. :)

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.