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: don't call efacethash if we don't need it #7222

Closed
randall77 opened this issue Jan 28, 2014 · 7 comments
Closed

cmd/compile: don't call efacethash if we don't need it #7222

randall77 opened this issue Jan 28, 2014 · 7 comments
Labels
FrozenDueToAge Performance Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@randall77
Copy link
Contributor

func foo(e interface{}) error {
    switch x := e.(type) {
    case error:
        return x
    }
    return nil
}

We call efacethash only to throw the result away.  We should only call this function
(and equivalently ifacethash) only if we need the result (for binary search over types?).

0000000000400c00 <main.foo>:
  400c00:       64 48 8b 0c 25 f0 ff    mov    %fs:0xfffffffffffffff0,%rcx
  400c07:       ff ff 
  400c09:       48 3b 21                cmp    (%rcx),%rsp
  400c0c:       77 07                   ja     400c15 <main.foo+0x15>
  400c0e:       e8 6d bd 01 00          callq  41c980 <runtime.morestack32>
  400c13:       eb eb                   jmp    400c00 <main.foo>
  400c15:       48 83 ec 40             sub    $0x40,%rsp
  400c19:       48 8b 4c 24 48          mov    0x48(%rsp),%rcx
  400c1e:       48 8b 44 24 50          mov    0x50(%rsp),%rax
  400c23:       48 89 4c 24 30          mov    %rcx,0x30(%rsp)
  400c28:       48 89 0c 24             mov    %rcx,(%rsp)
  400c2c:       48 89 44 24 38          mov    %rax,0x38(%rsp)
  400c31:       48 89 44 24 08          mov    %rax,0x8(%rsp)
  400c36:       e8 45 3c 00 00          callq  404880 <runtime.efacethash>
  400c3b:       8b 5c 24 10             mov    0x10(%rsp),%ebx
  400c3f:       48 c7 04 24 80 27 42    movq   $0x422780,(%rsp)
  400c46:       00 
  400c47:       48 8b 5c 24 30          mov    0x30(%rsp),%rbx
  400c4c:       48 89 5c 24 08          mov    %rbx,0x8(%rsp)
  400c51:       48 8b 5c 24 38          mov    0x38(%rsp),%rbx
  400c56:       48 89 5c 24 10          mov    %rbx,0x10(%rsp)
  400c5b:       e8 80 37 00 00          callq  4043e0 <runtime.assertE2I2>
  400c60:       48 8b 54 24 18          mov    0x18(%rsp),%rdx
  400c65:       48 8b 4c 24 20          mov    0x20(%rsp),%rcx
  400c6a:       48 0f b6 5c 24 28       movzbq 0x28(%rsp),%rbx
  400c70:       80 fb 00                cmp    $0x0,%bl
  400c73:       74 0f                   je     400c84 <main.foo+0x84>
  400c75:       48 89 54 24 58          mov    %rdx,0x58(%rsp)
  400c7a:       48 89 4c 24 60          mov    %rcx,0x60(%rsp)
  400c7f:       48 83 c4 40             add    $0x40,%rsp
  400c83:       c3                      retq   
  400c84:       48 c7 44 24 58 00 00    movq   $0x0,0x58(%rsp)
  400c8b:       00 00 
  400c8d:       48 c7 44 24 60 00 00    movq   $0x0,0x60(%rsp)
  400c94:       00 00 
  400c96:       48 83 c4 40             add    $0x40,%rsp
  400c9a:       c3                      retq
@remyoudompheng
Copy link
Contributor

Comment 1:

Maybe the compiler should simply inline this.

@randall77
Copy link
Contributor Author

Comment 2:

That would be fine also.

@davecheney
Copy link
Contributor

Comment 3:

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Apr 3, 2014

Comment 4:

Labels changed: added suggested, removed release-go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Apr 3, 2014

Comment 5:

Labels changed: added release-none.

@griesemer
Copy link
Contributor

Comment 6:

Labels changed: added repo-main.

@randall77 randall77 added accepted Suggested Issues that may be good for new contributors looking for work to do. Performance labels Oct 1, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: don't call efacethash if we don't need it cmd/compile: don't call efacethash if we don't need it Jun 8, 2015
@randall77
Copy link
Contributor Author

@golang golang locked and limited conversation to collaborators Mar 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Performance Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

6 participants