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

Issue 12147043: code review 12147043: go.tools/ssa: extend debug information to arbitrary ast... (Closed)

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

Description

go.tools/ssa: extend debug information to arbitrary ast.Exprs. CanonicalPos was inadequate since many pairs of instruction share the same pos (e.g. Allocs and Phis). Instead, we generalize the DebugRef instruction to associate not just Idents but Exprs with ssa.Values. We no longer store any DebugRefs for constant expressions, to save space. (The type and value of such expressions can be obtained by other means, at a cost in complexity.) Function.ValueForExpr queries the DebugRef info to return the ssa.Value of a given Expr. Added tests. Also: - the DebugInfo flag is now per package, not global. It must be set between Create and Build phases if desired. - {Value,Instruction}.Pos() documentation updated: we still maintain this information in the instruction stream even in non-debug mode, but we make fewer claims about its invariants. - Go and Defer instructions can now use their respective go/defer token positions (not the call's lparen), so they do. - SelectState: Posn token.Pos indicates the <- position DebugNode ast.Expr is the send stmt or receive expr. - In building SelectStmt, we introduce extra temporaries in debug mode to hold the result of the receive in 'case <-ch' even though this value isn't ordinarily needed. - Use *SelectState (indirectly) since the struct is getting bigger. - Document some missing instructions in doc.go.

Patch Set 1 #

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

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

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

Total comments: 6

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

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

Unified diffs Side-by-side diffs Delta from patch set Stats (+271 lines, -143 lines) Patch
M ssa/builder_test.go View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ssa/create.go View 1 1 chunk +0 lines, -1 line 0 comments Download
M ssa/doc.go View 1 2 3 chunks +9 lines, -8 lines 0 comments Download
M ssa/emit.go View 1 2 1 chunk +14 lines, -8 lines 0 comments Download
M ssa/example_test.go View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M ssa/func.go View 1 2 1 chunk +10 lines, -2 lines 0 comments Download
M ssa/lvalue.go View 1 2 2 chunks +5 lines, -5 lines 0 comments Download
M ssa/print.go View 1 2 2 chunks +9 lines, -2 lines 0 comments Download
M ssa/source.go View 1 2 3 4 5 chunks +36 lines, -74 lines 0 comments Download
M ssa/source_test.go View 1 2 3 4 4 chunks +79 lines, -4 lines 0 comments Download
M ssa/ssa.go View 1 2 14 chunks +54 lines, -32 lines 0 comments Download
M ssa/ssadump.go View 1 2 chunks +3 lines, -2 lines 0 comments Download
M ssa/stdlib_test.go View 1 2 3 2 chunks +4 lines, -2 lines 0 comments Download
A ssa/testdata/valueforexpr.go View 1 2 1 chunk +45 lines, -0 lines 0 comments Download

Messages

Total messages: 4
adonovan
Hello gri@golang.org (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go.tools
12 years, 3 months ago (2013-07-31 16:31:22 UTC) #1
gri
LGTM https://codereview.appspot.com/12147043/diff/8001/ssa/source.go File ssa/source.go (right): https://codereview.appspot.com/12147043/diff/8001/ssa/source.go#newcode140 ssa/source.go:140: e = unparen(e) do this inside the if? ...
12 years, 3 months ago (2013-07-31 16:42:05 UTC) #2
adonovan
https://codereview.appspot.com/12147043/diff/8001/ssa/source.go File ssa/source.go (right): https://codereview.appspot.com/12147043/diff/8001/ssa/source.go#newcode140 ssa/source.go:140: e = unparen(e) On 2013/07/31 16:42:06, gri wrote: > ...
12 years, 3 months ago (2013-07-31 17:10:47 UTC) #3
adonovan
12 years, 3 months ago (2013-07-31 17:13:07 UTC) #4
*** Submitted as
https://code.google.com/p/go/source/detail?r=ad296b71409a&repo=tools ***

go.tools/ssa: extend debug information to arbitrary ast.Exprs.

CanonicalPos was inadequate since many pairs of instruction share the same pos
(e.g. Allocs and Phis).  Instead, we generalize the DebugRef instruction to
associate not just Idents but Exprs with ssa.Values.  

We no longer store any DebugRefs for constant expressions, to save space.  (The
type and value of such expressions can be obtained by other means, at a cost in
complexity.)

Function.ValueForExpr queries the DebugRef info to return the ssa.Value of a
given Expr.

Added tests.

Also:
- the DebugInfo flag is now per package, not global.  
   It must be set between Create and Build phases if desired.
- {Value,Instruction}.Pos() documentation updated: we still maintain
  this information in the instruction stream even in non-debug mode,
  but we make fewer claims about its invariants.
- Go and Defer instructions can now use their respective go/defer
   token positions (not the call's lparen), so they do.
- SelectState:
     Posn token.Pos indicates the <- position
     DebugNode ast.Expr is the send stmt or receive expr.
- In building SelectStmt, we introduce extra temporaries in debug
   mode to hold the result of the receive in 'case <-ch' even though
   this value isn't ordinarily needed.
- Use *SelectState (indirectly) since the struct is getting bigger.
- Document some missing instructions in doc.go.

R=gri
CC=golang-dev
https://codereview.appspot.com/12147043
Sign in to reply to this message.

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