Why can a JIT not achieve 110% of native performance? (Assuming that we strip out the compile time and compare like with like.)
The reason I say 110% is that binary code is usually compiled for the
lowest common denominator. So x86 code targets a 386, and Sparc binaries
target UltraSparc v8 or older processors.
The advantage a JIT has is that it knows exactly where it is being
compiled, so in theory can make use of as much hardware assistance as it
can.
Just taking up this point, the answer is yes. This is a very hot subject in the research community right now. Dynamic optimization can improve micro-architectural performance in ways that are not possible with static compilation. Traditional static optimization is limited by factors including dynamically linked libraries, lack of information about the runtime microarchitecture, and unpredictable or phasic application behavior.
This approach is not limited to JITs for languages like Java, it is also being applied to binaries (ie parsing and recompiling machine code). There is a whole slew of work out there on this subject. As we push the architectures harder, dynamic optimization becomes more and more important.
Cheers,
--Steve
Here's a semi-random set of pointers to some recent work. There is a stack more work out there, these are just a few that happen to be at my finger tips. Most of it is available online, just google for it.
@inproceedings{ arnold05collecting,
author = "Matthew Arnold and David Grove",
title = "{Collecting and Exploiting High-Accuracy Call Graph Profiles in Virtual Machines}",
booktitle = "International Symposium on Code Generation and Optimization",
pages = "51-62",
year = "2005" }
@MISC{ klaiber00crusoe,
AUTHOR = {Alexander Klaiber},
TITLE = "{The Technology Behind Crusoe Processors}",
HOWPUBLISHED = {White Paper of Transmeta Corporation},
YEAR = 2000,
MONTH = {January},
URL = {http://www.transmeta.com/pdfs/paper_aklaiber_19jan00.pdf},
CATEGORY = {techdoc,dvs}
}
@inproceedings{bruening03,
author = {Derek Bruening and Timothy Garnett and Saman Amarasinghe},
title = {An infrastructure for adaptive dynamic optimization},
booktitle = {CGO '03: Proceedings of the international symposium on Code generation and optimization},
year = {2003},
isbn = {0-7695-1913-X},
pages = {265--275},
location = {San Francisco, California},
publisher = {IEEE Computer Society},
address = {Washington, DC, USA},
}
@article{kistler03,
author = {Thomas Kistler and Michael Franz},
title = {Continuous program optimization: A case study},
journal = {ACM Trans. Program. Lang. Syst.},
volume = {25},
number = {4},
year = {2003},
issn = {0164-0925},
pages = {500--548},
doi = {http://doi.acm.org/10.1145/778559.778562},
publisher = {ACM Press},
address = {New York, NY, USA},
}
@inproceedings{lu03,
author = {Jiwei Lu and Howard Chen and Rao Fu and Wei-Chung Hsu and Bobbie Othmer and Pen-Chung Yew and Dong-Yuan Chen},
title = {The Performance of Runtime Data Cache Prefetching in a Dynamic Optimization System},
booktitle = {MICRO 36: Proceedings of the 36th Annual IEEE/ACM International Symposium on Microarchitecture},
year = {2003},
isbn = {0-7695-2043-X},
pages = {180},
publisher = {IEEE Computer Society},
address = {Washington, DC, USA},
}
@inproceedings{merten00,
author = {Matthew C. Merten and Andrew R. Trick and Erik M. Nystrom and Ronald D. Barnes and Wen-mei W. Hmu},
title = {A hardware mechanism for dynamic extraction and relayout of program hot spots},
booktitle = {ISCA '00: Proceedings of the 27th annual international symposium on Computer architecture},
year = {2000},
isbn = {1-58113-232-8},
pages = {59--70},
location = {Vancouver, British Columbia, Canada},
doi = {http://doi.acm.org/10.1145/339647.339655},
publisher = {ACM Press},
address = {New York, NY, USA},
}
@inproceedings{rosner04,
author = {Roni Rosner and Yoav Almog and Micha Moffie and Naftali Schwartz and Avi Mendelson},
title = {Power Awareness through Selective Dynamically Optimized Traces},
booktitle = {ISCA '04: Proceedings of the 31st annual international symposium on Computer architecture},
year = {2004},
isbn = {0-7695-2143-6},
pages = {162},
location = {Munchen, Germany},
publisher = {IEEE Computer Society},
address = {Washington, DC, USA},
}
@inproceedings{ arnold00adaptive,
author = "Matthew Arnold and Stephen J. Fink and David Grove and Michael Hind and Peter F. Sweeney",
title = "{Adaptive Optimization in the Jalape{\~n}o JVM}",
booktitle = "Conference on Object-Oriented Programming, Systems, Languages, and Applications",
pages = "47--65",
year = "2000",
url = "citeseer.nj.nec.com/arnold00adaptive.html" }
