TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Java code optimization project

10 点作者 Stasyan超过 15 年前

4 条评论

ramchip超过 15 年前
Looks like they hit a roadblock somewhere: <i>The Java Supercompiler Version 1 is scheduled for completion in late 2003.</i><p>I noticed however that Ben Goertzel is listed under "People". He's an important person in the field of Artificial General Intelligence (like Eliezer who posts here from time to time). I'm not sure if there's a link between this (apparently dead) research project and his AGI project Novamente.
评论 #1003689 未加载
Mathnerd314超过 15 年前
The example with function m in their "white paper" (<a href="http://www.supercompilers.com/white_paper.shtml" rel="nofollow">http://www.supercompilers.com/white_paper.shtml</a>) is still not optimized fully. One first inlines the successive values of y:<p><pre><code> if (x0&#60;=0) y=0; else if (x0&#62;=1) y=1; else { if ((2-3*x0)&#60;=0) y=0; else if ((2-3*x0)&#62;=1) y=1; else { if ((2-3*(2-3*x0))&#60;=0) y=0; else if ((2-3*(2-3*x0))&#62;=1) y=1; else { ... else { y = (2-3*(2-3*(2-3*(2-3*(2-3*x0))))); } } } } } </code></pre> These can be solved for x0.<p><pre><code> if (x0&#60;=0) y=0; else if (x0&#62;=1) y=1; else { if ((2/3)&#60;=x0) y=0; else if ((1/3)&#62;=x0) y=1; else { if (x0&#60;=(4/9)) y=0; else if (x0&#62;=(5/9)) y=1; else { ... else { y = (2-3*(2-3*(2-3*(2-3*(2-3*x0))))); } } } } } </code></pre> Obviously, because floating point arithmetic is not distributive or associative (or exact), the actual constants will be slightly different from 1/3, 2/3, etc.<p>This performs an average of .004 subtractions and multiplications compared to my estimate of .988 for their algorithm.<p>Since this will probably not give strictly matching results for values close to 1/3, 2/3, 4/9, 5/9, etc., this is technically "super optimization" rather than supercompilation.<p>Are there any optimizers you know of that could get this far?
mmastrac超过 15 年前
This is exactly what the Google Web Toolkit compiler does, but outputs Java bytecode rather than taking it into JS.<p>The HotSpot compiler does some of this static analysis at runtime (various forms of devirtualization and type-tightening), but it's far more effective if you feed it into a big vat and keep running optimizations on it until you can eke out anything more.
kaffeinecoma超过 15 年前
I'm kind of curious how this would be practical, from a maintenance viewpoint. Would you then adopt the program's output back as your new "source"? Is the output readable, maintainable?<p>If you end up keeping your original source, and merely compile the output from this thing to get a fast executable, how do you debug stack traces when it crashes?
评论 #1003260 未加载
评论 #1003525 未加载