In contrast to unmanaged languages like C/C++, Java is more secure because it catches frequent programming errors like null pointer dereferencing, out of bound array accesses or stack overflows. Of course, this security comes at a certain cost and earned Java the reputation of being slow. But current Java implementations are quite smart and can implement many of these checks at virtually zero costs.
Using small and simple examples, this session will demonstrate how the HotSpot virtual machine implements these features, and the JIT compiler magically optimizes away most of the associated overhead. Volker will also look at corner cases where some of the optimizations may fail.
- what is a safepoint;
- why do we need safepoints;
- what does the VM do at safepoints;
- how do we reach a safepoint and how can we implement this efficiently;
- safepoints and JNI/native code (accessing Java objects through handles);
- how can we implement them efficiently or eliminate them;
- using OS signals and page faults when reading/writing from/to 0x0;
- problems with compressed oops (0x0 will be mapped to start of heap);
- field offset must be smaller than page size for implicit null checks;
- some platforms (i.e. ppc64) require traps for null checks.
- stack banging (yellow, red pages, ..);
- problems when calling to native;
- JEP 270: Reserved Stack Areas for Critical Sections.
- If time allows, Volker will also take a look on ArrayBoundChecks.
As always, Volker will provide some small Java programs and use them to demonstrate the above points from Java down to bytecode and assembler.
Volker Simonis, SAP
Volker Simonis works for SAP in the SAP JVM Technology group more than 10 years. He is an OpenJDK contributor from the very beginning and helped SAP and the SAP JVM team to engage in the OpenJDK project. Currently he is the project lead of the OpenJDK PowerPC/AIX and s390x porting project, and a JDK 9 reviewer. He also represents SAP in the Executive Committee of the Java Community Process.