Comments on: Never rely on tail recursion elimination http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/ Stuff Ron Gross Finds Interesting Sun, 02 Aug 2015 11:03:35 +0000 hourly 1 https://wordpress.org/?v=4.5.3 By: Tomer Gabel http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1270 Fri, 06 Feb 2009 12:52:01 +0000 http://v1.ripper234.com/?p=925#comment-1270 In that case, I’m (badly) surprised. I’ll try to do some more research on the subject.

]]>
By: ripper234 http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1267 Fri, 06 Feb 2009 06:46:33 +0000 http://v1.ripper234.com/?p=925#comment-1267 Yes you can.

]]>
By: Tomer Gabel http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1261 Thu, 05 Feb 2009 17:27:09 +0000 http://v1.ripper234.com/?p=925#comment-1261 Can I assume you’ve compiled for RELEASE?

]]>
By: ripper234 http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1260 Thu, 05 Feb 2009 17:25:24 +0000 http://v1.ripper234.com/?p=925#comment-1260 I went to said location, viewed it with reflector, and this is what it shows.
I don’t really have the will to open IDA now, but running the example proves my point.

]]>
By: Tomer Gabel http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1259 Thu, 05 Feb 2009 17:13:50 +0000 http://v1.ripper234.com/?p=925#comment-1259 That’s not an ngen image – I’m talking native code, here. Try C:\Windows\assembly\NativeImages_v2.0.50727_32, I think that’s where ngen’d assemblies go.

]]>
By: ripper234 http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1255 Thu, 05 Feb 2009 08:56:42 +0000 http://v1.ripper234.com/?p=925#comment-1255 NGen does’t help.

.method private hidebysig static void Foo(int32 i) cil managed
{
    .maxstack 8
    L_0000: ldarg.0 
    L_0001: ldc.i4 0xf4240
    L_0006: bne.un.s L_0009
    L_0008: ret 
    L_0009: ldarg.0 
    L_000a: ldc.i4.s 100
    L_000c: rem 
    L_000d: brtrue.s L_0015
    L_000f: ldarg.0 
    L_0010: call void [mscorlib]System.Console::WriteLine(int32)
    L_0015: ldarg.0 
    L_0016: ldc.i4.1 
    L_0017: add 
    L_0018: call void StackOverflow.Program::Foo(int32)
    L_001d: ret 
}
]]>
By: ripper234 http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1226 Tue, 03 Feb 2009 09:11:59 +0000 http://v1.ripper234.com/?p=925#comment-1226 I’ve read somewhere that NGen doesn’t help. Will verify. The JIT obviously didn’t optimize it away because it did throw a StackOverflowException.

]]>
By: Tomer Gabel http://v1.ripper234.com/p/never-rely-on-tail-recursion-elimination/comment-page-1/#comment-1213 Mon, 02 Feb 2009 18:38:37 +0000 http://v1.ripper234.com/?p=925#comment-1213 Inconclusive: try NGen’ing the compiled assembly and check the generated native code. CSC performs almost no optimizations; nearly everything is done in the JIT.

]]>