I'm curious that how does compiler recognize runtime.KeepAlive specially?

在 2016年8月26日星期五 UTC+8上午12:04:57,Ian Lance Taylor写道:
>
> On Thu, Aug 25, 2016 at 12:15 AM, Cholerae Hu <chole...@gmail.com 
> <javascript:>> wrote: 
> > Does that mean that only inlined functions will be optimized and any 
> > functions not inlined will not be optimized ? 
>
> I'm not really sure what you are asking. 
>
> A function that is not inlined will not be inlined.  That is 
> sufficient to ensure that runtime.KeepAlive works as intended. 
>
> A function that is not inlined, for whatever reason, will still be 
> optimized as usual. 
>
> Ian 
>
> > 在 2016年8月25日星期四 UTC+8上午11:55:12,Ian Lance Taylor写道: 
> >> 
> >> On Wed, Aug 24, 2016 at 7:06 PM, Cholerae Hu <chole...@gmail.com> 
> wrote: 
> >> > 
> >> > I've read the source of package runtime, and found that 
> >> > runtime.KeepAlive is 
> >> > an empty function. If go compiler can do dead code elimination in the 
> >> > future, how to protect runtime.KeepAlive from being optimized? 
> >> 
> >> The KeepAlive function is marked with the magic go:noinline comment, 
> >> so it can't be inlined. 
> >> 
> >> In any case it seems possible that the compiler will recognize the 
> >> function specially in the future, for greater efficiency. 
> >> 
> >> Ian 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "golang-nuts" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to golang-nuts...@googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to