jit

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

雨燕双飞 提交于 2019-11-29 19:42:01
I was trying to figure out hands-on how tail calls are handled by the C# compiler. (Answer: They're not. But the 64bit JIT(s) WILL do TCE (tail call elimination). Restrictions apply .) So I wrote a small test using a recursive call that prints how many times it gets called before the StackOverflowException kills the process. class Program { static void Main(string[] args) { Rec(); } static int sz = 0; static Random r = new Random(); static void Rec() { sz++; //uncomment for faster, more imprecise runs //if (sz % 100 == 0) { //some code to keep this method from being inlined var zz = r.Next();

Why is llvm considered unsuitable for implementing a JIT?

天涯浪子 提交于 2019-11-29 19:36:13
Many dynamic languages implement (or want to implement) a JIT Compiler in order to speed up their execution times. Inevitably, someone from the peanut gallery asks why they don't use LLVM. The answer is often, "LLVM is unsuitable for building a JIT." (For Example, Armin Rigo's comment here. ) Why is LLVM Unsuitable for building a JIT? Note: I know LLVM has its own JIT. If LLVM used to be unsuitable, but now is suitable, please say what changed. I'm not talking about running LLVM Bytecode on the LLVM JIT, I'm talking about using the LLVM libraries to implement a JIT for a dynamic language.

Why is Java faster when using a JIT vs. compiling to machine code?

倖福魔咒の 提交于 2019-11-29 19:05:23
I have heard that Java must use a JIT to be fast. This makes perfect sense when comparing to interpretation, but why can't someone make an ahead-of-time compiler that generates fast Java code? I know about gcj , but I don't think its output is typically faster than Hotspot for example. Are there things about the language that make this difficult? I think it comes down to just these things: Reflection Classloading What am I missing? If I avoid these features, would it be possible to compile Java code once to native machine code and be done? The real killer for any AOT compiler is: Class.forName

Why is 2 * (i * i) faster than 2 * i * i in Java?

一曲冷凌霜 提交于 2019-11-29 18:30:48
The following Java program takes on average between 0.50 secs and 0.55 secs to run: public static void main(String[] args) { long startTime = System.nanoTime(); int n = 0; for (int i = 0; i < 1000000000; i++) { n += 2 * (i * i); } System.out.println((double) (System.nanoTime() - startTime) / 1000000000 + " s"); System.out.println("n = " + n); } If I replace 2 * (i * i) with 2 * i * i , it takes between 0.60 and 0.65 secs to run. How come? I ran each version of the program 15 times, alternating between the two. Here are the results: 2*(i*i) | 2*i*i ----------+---------- 0.5183738 | 0.6246434 0

64bit .NET Performance tuning

六月ゝ 毕业季﹏ 提交于 2019-11-29 18:28:28
问题 I know that .NET is JIT compiled to the architecture you are running on just before the app runs, but does the JIT compiler optimize for 64bit architecture at all? Is there anything that needs to be done or considered when programming an app that will run on a 64bit system ? (i.e. Will using Int64 improve performance and will the JIT compiler automatically make Int64 work on 32bit systems?) 回答1: The 64bit JIT is different from the one for 32bit, so I would expect some differences in the

Layout of .NET value type in memory

梦想的初衷 提交于 2019-11-29 17:33:38
问题 I have the following .NET value types: [StructLayout(LayoutKind.Sequential)] public struct Date { public UInt16 V; } [StructLayout(LayoutKind.Sequential)] public struct StringPair { public String A; public String B; public String C; public Date D; public double V; } I have code that is passing a pointer to a value type to unmanaged code, along with offsets discovered by calling System.Runtime.InteropServices.Marshal.OffsetOf. The unmanaged code is populating the Date and double values. The

Forcing the .NET JIT compiler to generate the most optimized code during application start-up

半城伤御伤魂 提交于 2019-11-29 17:17:22
问题 I'm writing a DSP application in C# (basically a multitrack editor). I've been profiling it for quite some time on different machines and I've noticed some 'curious' things. On my home machine, the first run of the playback loop takes up about 50%-60% of the available time, (I assume it's due to the JIT doing its job), then for the subsequent loops it goes down to a steady 5% consumption. The problem is, if I run the application on a slower computer, the first run takes up more than the

Angular 2 AOT vs JIT

陌路散爱 提交于 2019-11-29 14:34:50
I was just reading Angular 2 AOT documentation and a few questions poped up The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup? The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng

Linking LLVM JIT code to external C++ functions

倾然丶 夕夏残阳落幕 提交于 2019-11-29 11:21:36
问题 I'm writing a LLVM scripting engine that JIT compiles scripting code in a custom language. My problem is that I'm unable to call external functions (even the C99 erf() function is failing). For example if I extern "C" the erf function, extern "C" double erft(double x){ return erf(x); } and create a function with external linkage std::vector<const Type*> Double1(1,Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),Double1,false);

Disable WerFault.exe/“Application Has Stopped Working” crash dialog

半腔热情 提交于 2019-11-29 11:08:09
问题 I have a development tool that's crashing on launch, and I don't get to see any error messages it throws, or get a chance to debug it, because it shows the Windows 7 dialog for crashed programs, where it says "Windows is checking for a solution..." I want to have my old school big ass assert dialog box back, with a big "DEBUG" button. I have JIT completely enabled in Visual Studio's options and settings, so I'm not sure why I'm not getting the option. 回答1: This blog post on raymond.cc