Why is LuaJIT so good?

Mike Pall has talked about this in a few places: http://article.gmane.org/gmane.comp.lang.lua.general/58908 http://lambda-the-ultimate.org/node/3851 http://www.reddit.com/user/mikemike As with every performant system, the answer in the end comes down to two things: algorithms and engineering. LuaJIT uses advanced compilation techniques, and it also has a very finely engineered implementation. For example, when the fancy compilation techniques can’t handle a … Read more

JIT vs Interpreters

First thing first: With JVM, both interpreter and compiler (the JVM compiler and not the source-code compiler like javac) produce native code (aka Machine language code for the underlying physical CPU like x86) from byte code. What’s the difference then: The difference is in how they generate the native code, how optimized it is as … Read more

Why does a recursive call cause StackOverflow at different stack depths?

I think it may be ASLR at work. You can turn off DEP to test this theory. See here for a C# utility class to check memory information: https://stackoverflow.com/a/8716410/552139 By the way, with this tool, I found that the difference between the maximum and minimum stack size is around 2 KiB, which is half a … Read more

What are the advantages of just-in-time compilation versus ahead-of-time compilation?

Greater portability: The deliverable (byte-code) stays portable At the same time, more platform-specific: Because the JIT-compilation takes place on the same system that the code runs, it can be very, very fine-tuned for that particular system. If you do ahead-of-time compilation (and still want to ship the same package to everyone), you have to compromise. … Read more

What exactly does -XX:-TieredCompilation do?

-XX:-TieredCompilation disables intermediate compilation tiers (1, 2, 3), so that a method is either interpreted or compiled at the maximum optimization level (C2). As a side effect TieredCompilation flag also changes the number of compiler threads, the compilation policy and the default code cache size. Note that with TieredCompilation disabled there will be less compiler … Read more

Is it possible to write a JIT compiler (to native code) entirely in a managed .NET language

And for the full proof of concept here is a fully capable translation of Rasmus’ approach to JIT into F# open System open System.Runtime.InteropServices type AllocationType = | COMMIT=0x1000u type MemoryProtection = | EXECUTE_READWRITE=0x40u type FreeType = | DECOMMIT = 0x4000u [<DllImport(“kernel32.dll”, SetLastError=true)>] extern IntPtr VirtualAlloc(IntPtr lpAddress, UIntPtr dwSize, AllocationType flAllocationType, MemoryProtection flProtect); [<DllImport(“kernel32.dll”, SetLastError=true)>] … Read more

Why are operators so much slower than method calls? (structs are slower only on older JITs)

I’m getting very different results, much less dramatic. But didn’t use the test runner, I pasted the code into a console mode app. The 5% result is ~87% in 32-bit mode, ~100% in 64-bit mode when I try it. Alignment is critical on doubles, the .NET runtime can only promise an alignment of 4 on … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)