https://codereview.appspot.com/98510044/diff/200001/src/pkg/runtime/iface.go File src/pkg/runtime/iface.go (right): https://codereview.appspot.com/98510044/diff/200001/src/pkg/runtime/iface.go#newcode16 src/pkg/runtime/iface.go:16: var ifaceLock lock what does this guard? (I know ...
10 years, 8 months ago
(2014-08-04 17:45:40 UTC)
#3
On Mon, Aug 4, 2014 at 10:45 AM, <bradfitz@golang.org> wrote: > > https://codereview.appspot.com/98510044/diff/200001/src/ > pkg/runtime/iface.go ...
10 years, 8 months ago
(2014-08-06 21:57:32 UTC)
#6
On Mon, Aug 4, 2014 at 10:45 AM, <bradfitz@golang.org> wrote:
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go
> File src/pkg/runtime/iface.go (right):
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode16
> src/pkg/runtime/iface.go:16: var ifaceLock lock
> what does this guard? (I know this is just porting from iface.goc where
> it also didn't have comments, but maybe in the rewrite to Go we can
> change styles and document things?)
>
>
Done.
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode37
> src/pkg/runtime/iface.go:37: panic(&TypeAssertionError{"", *typ._string,
> *inter._string, *i.name})
> optional comment, as this is low-level code anyway, but in code reviews,
> we normally tell people not to use untagged struct literals when the
> struct has multiple fields of the same type. In this case, 4 strings.
> because then if the struct is rearranged, this continues to compile
> silently.
>
>
Let me convert to tagged literals as a separate CL. For this CL we can
just verify that the list is the same, in a separate CL we can verify that
the right names are given to the right parts.
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode49
> src/pkg/runtime/iface.go:49: var locked int
> could be a bool now instead of int
>
>
You mean like
for _, locked := range [2]bool{false,true}?
I'm not sure it is worth it.
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode109
> src/pkg/runtime/iface.go:109: panic(&TypeAssertionError{"",
> *typ._string, *inter._string, *iname})
> likewise
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode277
> src/pkg/runtime/iface.go:277: panic(&TypeAssertionError{"", "",
> *inter._string, ""})
> this might actually be shorter with a tagged struct
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode372
> src/pkg/runtime/iface.go:372: panic(&TypeAssertionError{"", "",
> *inter._string, ""})
> likewise
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode386
> src/pkg/runtime/iface.go:386: ok = false
> unnecessary. already zero.
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode393
> src/pkg/runtime/iface.go:393: ok = false
> also unnecessary
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode410
> src/pkg/runtime/iface.go:410: panic(&TypeAssertionError{"", "",
> *inter._string, ""})
> tagged
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode428
> src/pkg/runtime/iface.go:428: if *t._string == *p2._type._string {
> this seems new and an unnecessary cost? or was it there before
> somewhere?
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode452
> src/pkg/runtime/iface.go:452: if *p1.tab._type._string ==
> *p2.tab._type._string {
> likewise. leftover debugging?
>
>
Thanks, deleted those two.
> https://codereview.appspot.com/98510044/
>
On Mon, Aug 4, 2014 at 7:29 PM, <dave@cheney.net> wrote: > > https://codereview.appspot.com/98510044/diff/200001/src/ > pkg/runtime/iface.go ...
10 years, 8 months ago
(2014-08-06 22:03:47 UTC)
#7
On Mon, Aug 4, 2014 at 7:29 PM, <dave@cheney.net> wrote:
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go
> File src/pkg/runtime/iface.go (right):
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode161
> src/pkg/runtime/iface.go:161: memmove(x, elem, size)
> newobject zeroes the memory returned by x, when we overwrite it with
> elem. Is there a non zeroing version available ?
>
>
Not at the moment. The problem is we run GC at the end of a malloc, so if
GC happened to trigger during allocation it would see an uninitialized
object. Perhaps we could get around that by having a malloc+init call for
use by the runtime.
We have an allocator to get uninitialized memory (rawmem + friends), but it
returns unscannable memory. We can't use that here (in general, at least).
Add it to the list of optimizations to be done.
> https://codereview.appspot.com/98510044/
>
On Tue, Aug 5, 2014 at 1:52 AM, <dvyukov@google.com> wrote: > > https://codereview.appspot.com/98510044/diff/200001/src/ > pkg/runtime/iface.go ...
10 years, 8 months ago
(2014-08-06 22:10:07 UTC)
#8
On Tue, Aug 5, 2014 at 1:52 AM, <dvyukov@google.com> wrote:
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go
> File src/pkg/runtime/iface.go (right):
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode15
> src/pkg/runtime/iface.go:15: var hash [hashSize]*itab
> var (
> ...
> )
>
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode21
> src/pkg/runtime/iface.go:21: type fInterface interface {
> can't we continue to use iface/eface?
> we already have these types in zruntime_defs, and you seems to just cast
> fInterface to iface in all functions
> there are lots of code that uses iface/eface naming, and it looks like a
> good and simple naming convention to me
>
>
This is the place where we can't use iface or eface, as we're declaring an
interface whose data element might not be a pointer.
> https://codereview.appspot.com/98510044/diff/200001/src/
> pkg/runtime/iface.go#newcode116
> src/pkg/runtime/iface.go:116: panic("invalid itab locking")
> I see that we panic in C code as well, but this really must be gothrow.
>
>
Fixed.
> https://codereview.appspot.com/98510044/
>
On Wed, Aug 6, 2014 at 2:57 PM, Keith Randall <khr@google.com> wrote: > > > ...
10 years, 8 months ago
(2014-08-06 22:21:49 UTC)
#10
On Wed, Aug 6, 2014 at 2:57 PM, Keith Randall <khr@google.com> wrote:
>
>
>
> On Mon, Aug 4, 2014 at 10:45 AM, <bradfitz@golang.org> wrote:
>
>>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go
>> File src/pkg/runtime/iface.go (right):
>>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go#newcode16
>> src/pkg/runtime/iface.go:16: var ifaceLock lock
>> what does this guard? (I know this is just porting from iface.goc where
>> it also didn't have comments, but maybe in the rewrite to Go we can
>> change styles and document things?)
>>
>>
> Done.
>
>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go#newcode37
>> src/pkg/runtime/iface.go:37: panic(&TypeAssertionError{"", *typ._string,
>> *inter._string, *i.name})
>> optional comment, as this is low-level code anyway, but in code reviews,
>> we normally tell people not to use untagged struct literals when the
>> struct has multiple fields of the same type. In this case, 4 strings.
>> because then if the struct is rearranged, this continues to compile
>> silently.
>>
>>
> Let me convert to tagged literals as a separate CL. For this CL we can
> just verify that the list is the same, in a separate CL we can verify that
> the right names are given to the right parts.
>
>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go#newcode49
>> src/pkg/runtime/iface.go:49: var locked int
>> could be a bool now instead of int
>>
>>
> You mean like
> for _, locked := range [2]bool{false,true}?
> I'm not sure it is worth it.
>
Yeah. I think it's more readable (especially not having to read those != 0
and wonder what other values it may take), but I write almost exclusively
in Go.
I figure we might as well use the language if we get to use it now.
But I don't care that much.
I think I'll leave it as is. It gets called during most type conversions and ...
10 years, 8 months ago
(2014-08-06 22:35:46 UTC)
#11
I think I'll leave it as is. It gets called during most type conversions
and I don't want to initialize and then load from a [2]bool when the index
already has the right value.
After checking this in I'll try it the Go way and if there's no performance
degredation we can use it.
On Wed, Aug 6, 2014 at 3:21 PM, Brad Fitzpatrick <bradfitz@golang.org>
wrote:
>
>
>
> On Wed, Aug 6, 2014 at 2:57 PM, Keith Randall <khr@google.com> wrote:
>
>>
>>
>>
>> On Mon, Aug 4, 2014 at 10:45 AM, <bradfitz@golang.org> wrote:
>>
>>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go
>>> File src/pkg/runtime/iface.go (right):
>>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go#newcode16
>>> src/pkg/runtime/iface.go:16: var ifaceLock lock
>>> what does this guard? (I know this is just porting from iface.goc where
>>> it also didn't have comments, but maybe in the rewrite to Go we can
>>> change styles and document things?)
>>>
>>>
>> Done.
>>
>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go#newcode37
>>> src/pkg/runtime/iface.go:37: panic(&TypeAssertionError{"", *typ._string,
>>> *inter._string, *i.name})
>>> optional comment, as this is low-level code anyway, but in code reviews,
>>> we normally tell people not to use untagged struct literals when the
>>> struct has multiple fields of the same type. In this case, 4 strings.
>>> because then if the struct is rearranged, this continues to compile
>>> silently.
>>>
>>>
>> Let me convert to tagged literals as a separate CL. For this CL we can
>> just verify that the list is the same, in a separate CL we can verify that
>> the right names are given to the right parts.
>>
>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go#newcode49
>>> src/pkg/runtime/iface.go:49: var locked int
>>> could be a bool now instead of int
>>>
>>>
>> You mean like
>> for _, locked := range [2]bool{false,true}?
>> I'm not sure it is worth it.
>>
>
> Yeah. I think it's more readable (especially not having to read those != 0
> and wonder what other values it may take), but I write almost exclusively
> in Go.
>
> I figure we might as well use the language if we get to use it now.
>
> But I don't care that much.
>
>
Thanks for your reply. Would you be able to add a short comment just above ...
10 years, 8 months ago
(2014-08-06 22:55:37 UTC)
#12
Thanks for your reply. Would you be able to add a short comment just above
that line to capture this as a TODO? I don't think it warrants an issue
being opened to track it.
On 7 Aug 2014 08:03, "Keith Randall" <khr@google.com> wrote:
>
>
>
> On Mon, Aug 4, 2014 at 7:29 PM, <dave@cheney.net> wrote:
>
>>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go
>> File src/pkg/runtime/iface.go (right):
>>
>> https://codereview.appspot.com/98510044/diff/200001/src/
>> pkg/runtime/iface.go#newcode161
>> src/pkg/runtime/iface.go:161: memmove(x, elem, size)
>> newobject zeroes the memory returned by x, when we overwrite it with
>> elem. Is there a non zeroing version available ?
>>
>>
> Not at the moment. The problem is we run GC at the end of a malloc, so if
> GC happened to trigger during allocation it would see an uninitialized
> object. Perhaps we could get around that by having a malloc+init call for
> use by the runtime.
>
> We have an allocator to get uninitialized memory (rawmem + friends), but
> it returns unscannable memory. We can't use that here (in general, at
> least).
>
> Add it to the list of optimizations to be done.
>
>
>> https://codereview.appspot.com/98510044/
>>
>
>
Dmitry, could you take a final look? On Wed, Aug 6, 2014 at 3:55 PM, ...
10 years, 8 months ago
(2014-08-07 19:45:38 UTC)
#13
Dmitry, could you take a final look?
On Wed, Aug 6, 2014 at 3:55 PM, Dave Cheney <dave@cheney.net> wrote:
> Thanks for your reply. Would you be able to add a short comment just above
> that line to capture this as a TODO? I don't think it warrants an issue
> being opened to track it.
> On 7 Aug 2014 08:03, "Keith Randall" <khr@google.com> wrote:
>
>>
>>
>>
>> On Mon, Aug 4, 2014 at 7:29 PM, <dave@cheney.net> wrote:
>>
>>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go
>>> File src/pkg/runtime/iface.go (right):
>>>
>>> https://codereview.appspot.com/98510044/diff/200001/src/
>>> pkg/runtime/iface.go#newcode161
>>> src/pkg/runtime/iface.go:161: memmove(x, elem, size)
>>> newobject zeroes the memory returned by x, when we overwrite it with
>>> elem. Is there a non zeroing version available ?
>>>
>>>
>> Not at the moment. The problem is we run GC at the end of a malloc, so
>> if GC happened to trigger during allocation it would see an uninitialized
>> object. Perhaps we could get around that by having a malloc+init call for
>> use by the runtime.
>>
>> We have an allocator to get uninitialized memory (rawmem + friends), but
>> it returns unscannable memory. We can't use that here (in general, at
>> least).
>>
>> Add it to the list of optimizations to be done.
>>
>>
>>> https://codereview.appspot.com/98510044/
>>>
>>
>>
Persistentalloc needs to move to the M stack. I'll do that in a separate CL. ...
10 years, 8 months ago
(2014-08-07 20:45:39 UTC)
#16
Persistentalloc needs to move to the M stack. I'll do that in a separate
CL.
On Thu, Aug 7, 2014 at 1:27 PM, <dvyukov@google.com> wrote:
> it LGTM if I am missing something regarding persistentalloc, and it
> actually works
>
> https://codereview.appspot.com/98510044/
>
OK, then LGTM with the gothrow fix and sync But I am concerned that compiler ...
10 years, 8 months ago
(2014-08-07 20:47:38 UTC)
#17
OK, then LGTM with the gothrow fix and sync
But I am concerned that compiler does not complain about broken
NOSPLIT. Either the pragma does not work or the pragma is broken.
On Fri, Aug 8, 2014 at 12:45 AM, Keith Randall <khr@google.com> wrote:
> Persistentalloc needs to move to the M stack. I'll do that in a separate
> CL.
>
>
>
> On Thu, Aug 7, 2014 at 1:27 PM, <dvyukov@google.com> wrote:
>>
>> it LGTM if I am missing something regarding persistentalloc, and it
>> actually works
>>
>> https://codereview.appspot.com/98510044/
>
>
NOSPLIT is not enforced recursively. NOSPLIT functions can call non-NOSPLIT functions. The compiler only checks ...
10 years, 8 months ago
(2014-08-07 20:52:17 UTC)
#18
NOSPLIT is not enforced recursively. NOSPLIT functions can call
non-NOSPLIT functions. The compiler only checks that NOSPLIT call chains
use a bounded amount of stack.
On Thu, Aug 7, 2014 at 1:47 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> OK, then LGTM with the gothrow fix and sync
> But I am concerned that compiler does not complain about broken
> NOSPLIT. Either the pragma does not work or the pragma is broken.
>
>
> On Fri, Aug 8, 2014 at 12:45 AM, Keith Randall <khr@google.com> wrote:
> > Persistentalloc needs to move to the M stack. I'll do that in a separate
> > CL.
> >
> >
> >
> > On Thu, Aug 7, 2014 at 1:27 PM, <dvyukov@google.com> wrote:
> >>
> >> it LGTM if I am missing something regarding persistentalloc, and it
> >> actually works
> >>
> >> https://codereview.appspot.com/98510044/
> >
> >
>
*** Submitted as https://code.google.com/p/go/source/detail?r=94a57b1af785 *** runtime: convert interface routines from C to Go. LGTM=dvyukov R=golang-codereviews, ...
10 years, 8 months ago
(2014-08-07 21:00:51 UTC)
#19
Issue 98510044: code review 98510044: runtime: convert interface routines from C to Go.
(Closed)
Created 10 years, 11 months ago by khr
Modified 10 years, 8 months ago
Reviewers:
Base URL:
Comments: 19