/o Regexps create org.joni.ByteCodeMachine for each evaluation
--------------------------------------------------------------
Key: JRUBY-3406
URL: http://jira.codehaus.org/browse/JRUBY-3406
Project: JRuby
Issue Type: Bug
Components: Compiler
Environment: jruby 1.1.7 (ruby 1.8.6 patchlevel 114) (2009-01-12 rev
8695) [x86_64-java]
jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-02-16 rev 9184) [x86_64-java]
Reporter: Kornelius Kalnbach
Priority: Minor
Consider the following code:
i = 0
10000.times do
/#{i += 1}/o === ""
end
p i
Although the expression inside the regexp is only evaluated once (as the /o
modifier dictates), JRuby creates a org.joni.ByteCodeMachine object each time
it uses it:
(without /o)
$ jruby -J-Xrunhprof -e 'i = 0; 10000.times { /#{i += 1}/ === "" }; p i' &&
grep org.joni.ByteCodeMachine java.hprof.txt | grep '%'
10000
Dumping Java heap ... allocation sites ... done.
8 2.68% 51.04% 434112 2261 1920000 10000 306676
org.joni.ByteCodeMachine
(with /o)
$ jruby -J-Xrunhprof -e 'i = 0; 10000.times { /#{i += 1}/o === "" }; p i' &&
grep org.joni.ByteCodeMachine java.hprof.txt | grep '%'
1
Dumping Java heap ... allocation sites ... done.
1 17.12% 17.12% 881280 4590 1920000 10000 306693
org.joni.ByteCodeMachine
2788 0.01% 93.63% 720 1 720 1 306690
org.joni.ByteCodeMachine
MRI doesn't behave like this when I tested it (using GC.disable /
ObjectSpace.each_object.)
This was originally considered to be a bug in the CodeRay ruby library, as
reported here: http://redmine.rubychan.de/issues/show/66
I hope you can find the issue.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email