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: inline simple E2T conversions #8422

Closed
dvyukov opened this issue Jul 25, 2014 · 3 comments
Closed

cmd/compile: inline simple E2T conversions #8422

dvyukov opened this issue Jul 25, 2014 · 3 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Jul 25, 2014

In the following program:

package main
func main() {
    _ = foo().(int)
}
func foo() interface{} {
    return 42
}

compiler calls runtime.assertE2T which calls assertE2Tret which calls copyout.
Compiler should inline this conversion. All is needed is:

if(sizeof(T) == sizeof(void*) && eface.type == targetType)
  return eface.word;
else
  return runtime.assertE2T(eface);
@rsc
Copy link
Contributor

rsc commented Aug 5, 2014

Comment 1:

I don't believe these kinds of optimizations are worthwhile unless the function call is
avoided entirely. That's not possible here. Probably not worth doing.
Certainly not until the compiler is written in Go.

@dvyukov
Copy link
Member Author

dvyukov commented Aug 5, 2014

Comment 2:

I don't understand. The function is called only in case of panic, so it can be
considered not called at all. Most of the time we just compare type word with constant
and that's it.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: inline simple E2T conversions cmd/compile: inline simple E2T conversions Jun 8, 2015
@gopherbot
Copy link

CL https://golang.org/cl/32313 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants