TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ahead-of-Time Compilation

128 pointsby hittarukiover 8 years ago

14 comments

KMagover 8 years ago
This is great news, though it initially only supports Linux x86-64 and is decades late for Java desktop apps (and not having non-blocking I&#x2F;O until Java 1.4 was shameful for a language explicitly targeted and a pervasively networked ecosystem.)<p>In their &quot;tiered mode&quot;, they put sampling instrumentation into the native code, and if they detect a hotspot, regenerate fully instrumented native code from bytecode using the C1 (fast) JIT, which then allows the C2 JIT to do its full optimizations on the code as if AoT were not involved.<p>Since the invention of tracing JITs, I&#x27;ve often wondered why languages don&#x27;t package together a compact serialized SSA form such as LLVM bitcode or SafeTSA along with storing functions as lists of pointers to space-optimized compilations of extended basic blocks (strait-line code), similar to how some Forth compilers generate threaded code. A threaded code dispatcher over these strait-line segments of native code would have minimal overhead, and when a simple SIGPROF lightweight sampler detected a hotspot, a tracing version of the dispatcher could collect a trace, and then generate native code from the visited traces using the stored SSA for the basic blocks.<p>In this way, they&#x27;d have a light-weight tracing JIT for re-optimizing native code.
评论 #12616893 未加载
评论 #12616850 未加载
评论 #12616607 未加载
评论 #12616751 未加载
taspeotisover 8 years ago
I can&#x27;t see anywhere in the linked issue that indicates AOT compilation is coming to Java 9, or even coming at all. The issue demonstrates nothing more than an intent to bring it to OpenJDK, and the issue seems to be very nascent? It was only created a fortnight ago.<p>Lest the title is changed:<p><pre><code> AOT compilation is coming to Java 9 (java.net) 18 points by hittaruki 37 minutes ago</code></pre>
评论 #12616500 未加载
评论 #12616625 未加载
alblueover 8 years ago
Slightly off topic but if you are interested in how HotSpot compiles to native code I gave a presentation at JavaOne:<p><a href="http:&#x2F;&#x2F;alblue.bandlem.com&#x2F;2016&#x2F;09&#x2F;javaone-hotspot.html" rel="nofollow">http:&#x2F;&#x2F;alblue.bandlem.com&#x2F;2016&#x2F;09&#x2F;javaone-hotspot.html</a><p>The presentation wasn&#x27;t recorded but there is a video recorded from a DocklandsLJC event which is on InfoQ:<p><a href="https:&#x2F;&#x2F;www.infoq.com&#x2F;presentations&#x2F;hotspot-memory-data-structures" rel="nofollow">https:&#x2F;&#x2F;www.infoq.com&#x2F;presentations&#x2F;hotspot-memory-data-stru...</a>
avborover 8 years ago
I&#x27;m not familiar enough with compilers, but why would an ahead of time compiler perform worse than a just in time compiler in a static language? I think I&#x27;d understand if it was a dynamic language, because you can&#x27;t know the types for sure until you start running the program, but are similar issues present for Java?
评论 #12616512 未加载
评论 #12616534 未加载
评论 #12616523 未加载
评论 #12616504 未加载
评论 #12617338 未加载
BuckRogersover 8 years ago
Why was Java ever JIT&#x27;d rather than natively compiled anyway? I hate to stick my neck out and even ask this but I never understood why you&#x27;d want to JIT or interpret when you can just natively compile to a binary. It seems like Go has gone &quot;back&quot; to the future on this one and in general their toolchain approach to me looked like the way.<p>I always got the sense the world is waiting for a statically typed Python that compiles to native code with Go&#x27;s CPU performance. I suppose Nim might fit that bill but a shame it doesn&#x27;t have compatibility with Python&#x27;s or even the extent of a language like Go&#x27;s libraries. And if possible, an imperative language that interfaces with OTP.<p>And that said, I can see why Erlang&#x2F;Elixir wouldn&#x27;t make as much sense or even work with native code AOT compilation due to it&#x27;s feature set (thinking stuff like hot code reloading). But I&#x27;ve never grasped why Java or Python were better off with JIT or interpreters than AOT comp. Seems like a type system such as Go&#x27;s is simple enough and allows for good gains in both CPU performance and memory usage. Add in the fact you don&#x27;t need to install anything and less to think about in deploying and it seems to be a no brainer. Please feel free to fill me in on this or where I went wrong..
评论 #12616610 未加载
评论 #12616720 未加载
评论 #12616784 未加载
评论 #12616626 未加载
评论 #12616710 未加载
Cyph0nover 8 years ago
Assuming this comes in Java 9, and compilation of code other `java.base` is possible, will this make Java a more solid competitor to Go? I guess it partly depends on how much they optimize the compiled binary size. Go does a really good job at static compilation, so it will be tough to compete.
评论 #12616874 未加载
评论 #12616768 未加载
评论 #12616545 未加载
评论 #12617020 未加载
jgalt212over 8 years ago
&gt; Infrequently-used Java methods might never be compiled at all, potentially incurring a performance penalty due to repeated interpreted invocations.<p>That sort of makes no sense. How can you incur a real performance hit if the uncompiled method is rarely called?
评论 #12619088 未加载
johnydeppover 8 years ago
That&#x27;s great! Won&#x27;t it make the compiled executable platform specific?
评论 #12617342 未加载
评论 #12616536 未加载
评论 #12616533 未加载
评论 #12616530 未加载
评论 #12616511 未加载
my123over 8 years ago
IKVM, the Java VM for .NET converted Java bytecode to .NET since a while, and crossgen&#x2F;ngen can be used for .NET AOT(Mono also has AOT)
habermanover 8 years ago
How does this interact with classloading?<p>My general impression is that the design of classloaders is pretty actively hostile to making JVM startup fast.
评论 #12616790 未加载
评论 #12616660 未加载
premium-concernover 8 years ago
Is there anything this adds over Scala-native, which seems to be much further ahead already?
评论 #12618089 未加载
saynseditover 8 years ago
not sure why this isn&#x27;t a transparent feature implemented via caching.
评论 #12616562 未加载
评论 #12617374 未加载
_ZeD_over 8 years ago
it&#x27;s a gcj comeback?
singularity2001over 8 years ago
resurrect me when it&#x27;s there <a href="https:&#x2F;&#x2F;github.com&#x2F;search?p=3&amp;q=jaotc&amp;type=Code" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;search?p=3&amp;q=jaotc&amp;type=Code</a>