You make a very good point! My bad on that bit.
<excuses>
I did say <cite>I think...</cite>
What do you expect at a Perl site? Java expertise :8^)...
</excuses>
Being serious for a moment, if Javac is 'doing the right thing' on that line, that just means that it's memory overhead on recursive subroutines must be even worse than I thought. 4,000 -v- 2,000,000 recursions before blowing the stack is a mind-boggling 500 times less efficient in terms of memory/stack management. I guess I was looking for a rational explanation.
Note: I have made no attempt to verify the numbers
Update:I have confirmed that your assertion is true when using javac from jdk1.3.1 as follows
import java.io.PrintStream;
class dupme
{
public dupme(int i)
{
// 0 0:aload_0
// 1 1:invokespecial #1 <Method void Object()>
// 2 4:getstatic #2 <Field PrintStream System.out>
// 3 7:new #3 <Class StringBuffer>
// 4 10:dup
// 5 11:invokespecial #4 <Method void StringBuffer()>
// 6 14:ldc1 #5 <String "I am '">
// 7 16:invokevirtual #6 <Method StringBuffer StringBuffe
+r.append(String)>
// 8 19:iload_1
// 9 20:invokevirtual #7 <Method StringBuffer StringBuffe
+r.append(int)>
// 10 23:ldc1 #8 <String "'!">
// 11 25:invokevirtual #6 <Method StringBuffer StringBuffe
+r.append(String)>
// 12 28:invokevirtual #9 <Method String StringBuffer.toSt
+ring()>
// 13 31:invokevirtual #10 <Method void PrintStream.println
+(String)>
// 14 34:new #11 <Class dupme>
// 15 37:dup
// 16 38:iload_1
// 17 39:iconst_1
// 18 40:iadd
// 19 41:invokespecial #12 <Method void dupme(int)>
// 20 44:astore_2
// 21 45:return
}
}
Well It's better than the Abottoire, but Yorkshire!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|