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: document emitptrargsmap onebitwalktype1 calls #24648

Open
josharian opened this issue Apr 2, 2018 · 3 comments
Open

cmd/compile: document emitptrargsmap onebitwalktype1 calls #24648

josharian opened this issue Apr 2, 2018 · 3 comments
Assignees
Milestone

Comments

@josharian
Copy link
Contributor

@josharian josharian commented Apr 2, 2018

Perhaps I'm missing something, but this sequence of calls in emitptrargsmap looks suspect:

	if fn.IsMethod() {
		onebitwalktype1(fn.Type.Recvs(), 0, bv)
	}
	if fn.Type.NumParams() > 0 {
		onebitwalktype1(fn.Type.Params(), 0, bv)
	}

If I'm reading it correctly, this will overwrite the Recvs bitmap with the Params bitmap.

Also, after emitting that bitmap, we do:

	if fn.Type.NumResults() > 0 {
		onebitwalktype1(fn.Type.Results(), 0, bv)
		off = dbvec(lsym, off, bv)
	}

But we don't clear bv first, so any set bits from recvs/params will still be set.

emitptrargsmap is only called from assembly functions, which are unlikely to have methods and which are often nosplit, which is possibly why this hasn't caused visible problems yet (?).

cc @mdempsky -- does this code look right to you, and if so, what am I missing?

@josharian josharian added this to the Go1.11 milestone Apr 2, 2018
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jun 30, 2018

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jul 2, 2018

I think that code is fine.

We create that bitmap to implement GO_ARGS and GO_RESULTS_INITIALIZED from runtime/funcdata.h. The first bitmap (recvs+params) is to represent at function entry (when only params are live), and the second bitmap (recvs+params+results) is to represent once the results have been initialized within the assembly code.

It's okay to call them all like that because function parameter fields have their Xoffsets set according to their frame offset.

@mdempsky mdempsky closed this Jul 2, 2018
@josharian
Copy link
Contributor Author

@josharian josharian commented Jul 16, 2018

Thanks, @mdempsky. We should add a comment in the code; re-opening this for a doc fix in 1.12.

@josharian josharian reopened this Jul 16, 2018
@josharian josharian changed the title cmd/compile: emitptrargsmap looks buggy cmd/compile: document emitptrargsmap onebitwalktype1 calls Jul 16, 2018
@josharian josharian modified the milestones: Go1.11, Go1.12 Jul 16, 2018
@josharian josharian added the NeedsFix label Jul 16, 2018
@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.