Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

use rb_str_free for freeing string in parse.y #87

Closed
wants to merge 1 commit into from

3 participants

@funny-falcon

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

@nurse
Owner

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

Before:
000000000000f67a :
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
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
f6a8: 48 8b 45 f8 mov -0x8(%rbp),%rax
f6ac: 48 83 c0 10 add $0x10,%rax
f6b0: eb 08 jmp f6ba
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
f6c2: 48 8b 45 f8 mov -0x8(%rbp),%rax
f6c6: 48 89 c7 mov %rax,%rdi
f6c9: e8 00 00 00 00 callq f6ce
f6ce: c9 leaveq
f6cf: c3 retq

After:
000000000000f67a :
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
f692: 48 8b 45 f8 mov -0x8(%rbp),%rax
f696: 48 89 c7 mov %rax,%rdi
f699: e8 00 00 00 00 callq f69e
f69e: c9 leaveq
f69f: c3 retq

@zzak
Collaborator

Closed, please refer to Bug #7389 on redmine

@zzak zzak closed this
@nurse nurse referenced this pull request from a commit
@nurse nurse * 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
2bcff78
@tenderlove tenderlove referenced this pull request from a commit in tenderlove/ruby
@nurse nurse * 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
d21795c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2012
  1. @funny-falcon
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 3 deletions.
  1. +1 −3 parse.y
View
4 parse.y
@@ -6409,9 +6409,7 @@ parser_regx_options(struct parser_params *parser)
static void
dispose_string(VALUE str)
{
- /* TODO: should use another API? */
- if (RBASIC(str)->flags & RSTRING_NOEMBED)
- xfree(RSTRING_PTR(str));
+ rb_str_free(str);
rb_gc_force_recycle(str);
}
Something went wrong with that request. Please try again.