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
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Documentation NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 2, 2018
@josharian josharian added this to the Go1.11 milestone Apr 2, 2018
@ianlancetaylor
Copy link
Contributor

Ping @mdempsky @randall77

@mdempsky
Copy link
Contributor

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 as completed Jul 2, 2018
@josharian
Copy link
Contributor Author

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 The path to resolution is known, but the work has not been done. 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
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
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. Documentation NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Triage Backlog
Development

No branches or pull requests

6 participants