Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

use rb_str_free for freeing string in parse.y #87

Closed
wants to merge 1 commit into
from

Conversation

3 participants

Firstly, it is cosmetic cleanup.
Secondly, I could not understand, why, but it gives minor performance gain for rendering some rails page (about 1%)

Owner

nurse commented Jan 23, 2012

It is because of optimization.
objdump -d parse.o differs as following.

Before:
000000000000f67a <dispose_string>:
f67a: 55 push %rbp
f67b: 48 89 e5 mov %rsp,%rbp
f67e: 48 83 ec 10 sub $0x10,%rsp
f682: 48 89 7d f8 mov %rdi,-0x8(%rbp)
f686: 48 8b 45 f8 mov -0x8(%rbp),%rax
f68a: 48 8b 00 mov (%rax),%rax
f68d: 25 00 20 00 00 and $0x2000,%eax
f692: 48 85 c0 test %rax,%rax
f695: 74 2b je f6c2 <dispose_string+0x48>
f697: 48 8b 45 f8 mov -0x8(%rbp),%rax
f69b: 48 8b 00 mov (%rax),%rax
f69e: 25 00 20 00 00 and $0x2000,%eax
f6a3: 48 85 c0 test %rax,%rax
f6a6: 75 0a jne f6b2 <dispose_string+0x38>
f6a8: 48 8b 45 f8 mov -0x8(%rbp),%rax
f6ac: 48 83 c0 10 add $0x10,%rax
f6b0: eb 08 jmp f6ba <dispose_string+0x40>
f6b2: 48 8b 45 f8 mov -0x8(%rbp),%rax
f6b6: 48 8b 40 18 mov 0x18(%rax),%rax
f6ba: 48 89 c7 mov %rax,%rdi
f6bd: e8 00 00 00 00 callq f6c2 <dispose_string+0x48>
f6c2: 48 8b 45 f8 mov -0x8(%rbp),%rax
f6c6: 48 89 c7 mov %rax,%rdi
f6c9: e8 00 00 00 00 callq f6ce <dispose_string+0x54>
f6ce: c9 leaveq
f6cf: c3 retq

After:
000000000000f67a <dispose_string>:
f67a: 55 push %rbp
f67b: 48 89 e5 mov %rsp,%rbp
f67e: 48 83 ec 10 sub $0x10,%rsp
f682: 48 89 7d f8 mov %rdi,-0x8(%rbp)
f686: 48 8b 45 f8 mov -0x8(%rbp),%rax
f68a: 48 89 c7 mov %rax,%rdi
f68d: e8 00 00 00 00 callq f692 <dispose_string+0x18>
f692: 48 8b 45 f8 mov -0x8(%rbp),%rax
f696: 48 89 c7 mov %rax,%rdi
f699: e8 00 00 00 00 callq f69e <dispose_string+0x24>
f69e: c9 leaveq
f69f: c3 retq

Member

zzak commented Nov 18, 2012

Closed, please refer to Bug #7389 on redmine

@zzak zzak closed this Nov 18, 2012

nurse added a commit that referenced this pull request Jan 11, 2013

* string.c (dispose_string): use rb_str_free for freeing string in
  parse.y. by Sokolov Yura <funny.falcon@gmail.com>
  #87 fix GH-87

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

tenderlove pushed a commit to tenderlove/ruby that referenced this pull request Jan 24, 2014

* string.c (dispose_string): use rb_str_free for freeing string in
  parse.y. by Sokolov Yura <funny.falcon@gmail.com>
  ruby#87 fix GH-87

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment