Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(398)

Issue 7357046: code review 7357046: go/types: support for customizable Alignof, Sizeof (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years ago by gri
Modified:
11 years, 10 months ago
Reviewers:
adonovan
CC:
golang-dev
Visibility:
Public.

Description

go/types: support for customizable Alignof, Sizeof (Offsetof is a function of Alignof and Sizeof.) - removed IntSize, PtrSize from Context (set Sizeof instead) - GcImporter needs a Context now (it needs to have access to Sizeof/Alignof) - removed exported Size field from Basic (use Sizeof) - added Offset to Field - added Alignment, Size to Struct

Patch Set 1 #

Patch Set 2 : diff -r a81ef8e0cc05 https://code.google.com/p/go #

Patch Set 3 : diff -r a81ef8e0cc05 https://code.google.com/p/go #

Patch Set 4 : diff -r a81ef8e0cc05 https://code.google.com/p/go #

Patch Set 5 : diff -r a81ef8e0cc05 https://code.google.com/p/go #

Patch Set 6 : diff -r 28d951917340 https://code.google.com/p/go/ #

Patch Set 7 : diff -r 28d951917340 https://code.google.com/p/go/ #

Patch Set 8 : diff -r 28d951917340 https://code.google.com/p/go/ #

Total comments: 14

Patch Set 9 : diff -r 592fa6bfc380 https://code.google.com/p/go/ #

Patch Set 10 : diff -r 592fa6bfc380 https://code.google.com/p/go/ #

Patch Set 11 : diff -r 592fa6bfc380 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+244 lines, -105 lines) Patch
M src/pkg/exp/ssa/builder.go View 1 2 3 4 5 6 7 8 1 chunk +1 line, -7 lines 0 comments Download
M src/pkg/exp/ssa/importer.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/types/api.go View 1 2 3 4 5 6 7 8 9 4 chunks +27 lines, -28 lines 0 comments Download
M src/pkg/go/types/builtins.go View 1 2 3 4 5 6 7 8 9 3 chunks +99 lines, -26 lines 0 comments Download
M src/pkg/go/types/check.go View 1 2 3 4 5 1 chunk +3 lines, -1 line 0 comments Download
M src/pkg/go/types/check_test.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/types/const.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/types/expr.go View 1 2 3 4 5 6 7 8 9 5 chunks +42 lines, -11 lines 0 comments Download
M src/pkg/go/types/gcimporter.go View 1 2 3 4 5 7 chunks +8 lines, -6 lines 0 comments Download
M src/pkg/go/types/gcimporter_test.go View 1 2 3 4 5 2 chunks +2 lines, -2 lines 0 comments Download
M src/pkg/go/types/operand.go View 1 9 chunks +17 lines, -13 lines 0 comments Download
M src/pkg/go/types/predicates.go View 1 2 chunks +5 lines, -5 lines 0 comments Download
M src/pkg/go/types/resolver_test.go View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/go/types/testdata/builtins.src View 1 2 3 4 5 6 7 8 9 4 chunks +31 lines, -0 lines 0 comments Download
M src/pkg/go/types/types.go View 1 2 3 4 5 2 chunks +5 lines, -2 lines 0 comments Download

Messages

Total messages: 6
gri
Hello adonovan@google.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go/
12 years ago (2013-02-20 07:32:58 UTC) #1
adonovan
LGTM https://codereview.appspot.com/7357046/diff/6002/src/pkg/exp/ssa/builder.go File src/pkg/exp/ssa/builder.go (right): https://codereview.appspot.com/7357046/diff/6002/src/pkg/exp/ssa/builder.go#newcode165 src/pkg/exp/ssa/builder.go:165: // TODO(adonovan): permit the client to specify these ...
12 years ago (2013-02-20 15:41:22 UTC) #2
gri
https://codereview.appspot.com/7357046/diff/6002/src/pkg/exp/ssa/builder.go File src/pkg/exp/ssa/builder.go (right): https://codereview.appspot.com/7357046/diff/6002/src/pkg/exp/ssa/builder.go#newcode165 src/pkg/exp/ssa/builder.go:165: // TODO(adonovan): permit the client to specify these On ...
12 years ago (2013-02-20 18:16:13 UTC) #3
gri
*** Submitted as https://code.google.com/p/go/source/detail?r=abd0feffdac3 *** go/types: support for customizable Alignof, Sizeof (Offsetof is a function ...
12 years ago (2013-02-20 19:10:22 UTC) #4
adonovan
LGTM (pair-reviewed) https://codereview.appspot.com/7357046/diff/6002/src/pkg/go/types/builtins.go File src/pkg/go/types/builtins.go (right): https://codereview.appspot.com/7357046/diff/6002/src/pkg/go/types/builtins.go#newcode325 src/pkg/go/types/builtins.go:325: case _Offsetof: On 2013/02/20 18:16:13, gri wrote: ...
11 years, 10 months ago (2013-05-09 21:53:58 UTC) #5
gri
11 years, 10 months ago (2013-05-09 22:05:21 UTC) #6
Message was sent while issue was closed.
https://codereview.appspot.com/7357046/diff/6002/src/pkg/go/types/builtins.go
File src/pkg/go/types/builtins.go (right):

https://codereview.appspot.com/7357046/diff/6002/src/pkg/go/types/builtins.go...
src/pkg/go/types/builtins.go:325: case _Offsetof:
On 2013/05/09 21:53:58, adonovan wrote:
> On 2013/02/20 18:16:13, gri wrote:
> > On 2013/02/20 15:41:22, adonovan wrote:
> > > Curious: when this is so clearly a special form, why do we try to make it
> look
> > > it library function?  Also, I can see that using it is potentially
> > nonportable,
> > > but is it really unsafe?
> > 
> > Built-in functions are the mechanism we have in Go for special situations.
> It's
> > non-portable, and perhaps not unsafe, but still, the very same program using
> > unsafe.Offsetof may compile on one platform, and not on the other (say, the
> > result constant could be used in a expression that results in a div-zero
> compile
> > time error dep. on offset value). Package unsafe seems as good as any other
> > special case, and unsafe we have.
> 
> Well, I can determine sizeof(x) even in the supposedly portable (safe) parts
of
> the language. :)  
> 
> My point was that the operands to sizeof, offsetof and alignof are not values
> but types (or struct/fieldname pairs) so they are even more special than
append,
> which could in principle have a (polymorphic) type in some hypothetical future
> release.  So these things need compiler support, yet are not in the global
> namespace.   
> 
> Is putting them in "unsafe" a namespace pollution issue?

Not really. It's just a design decision. In some sense, all the size operations
are "safe" but at the same time they are (likely) not often used unless in
conjunction with unsafe pointer operations. Arguably, it would be nice to have
sizeof w/o the need to import unsafe. One argument one might make that it
exposes implementation details and thus makes code non-portable (I am aware that
this is not a very sharp argument).
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b