Code Review for hotspot-dvm

Prepared by:jrose on Sat Nov 8 23:41:17 PST 2008
Workspace:/Users/jrose/Projects/hotspot/hotspot-dvm
Compare against: http://hg.openjdk.java.net/jdk7/hotspot-comp-gate/hotspot
Compare against version:422
Summary of changes: 1900 lines changed: 1612 ins; 71 del; 217 mod; 75282 unchg
Patch of changes: hotspot-dvm.patch
Author comments:
For putback to http://hg.openjdk.java.net/jdk7/hotspot-comp-gate/hotspot
6655646: dynamic languages need dynamically linked call sites
Summary: first working invokedynamic instructions
Reviewed-by: ??
This group of changes implements the invokedynamic instruction, and is the last in a series of three changes to support the JSR 292 Reference Implementation.

An invokedynamic instruction is a new invoke opcode (0xBA) with a 5-byte format similar to invokeinterface. It allows an arbitrary name and signature. Unlike invokeinterface, there is no implciit receiver argument; every stacked argument is represented in the signature. Each distinct instance of an invokedynamic instruction gets its own constant pool cache entry, which holds a java.dyn.impl.DynCallSite object that reifies the call site.

In this putback, it is represented as a specially marked invokeinterface instruction. The marking consists of the empty receiver interface java.dyn.Dynamic. The method name and signature are arbitrary. The implicit receiver must be stacked as an Object reference. This is a transitional form which will go away in the next push.

Execution of this instruction follows the rules for bootstrapping and linkage defined by the JSR 292 EDR. At any point, the linkage state of the instruction may either be null (meaning that a bootstrapping process will be needed) or a method handle which matches the signature of the call site. This method handle is arbitrary, and is supplied not by the JVM but by application code. Any call site is linked only once, but an invokedynamic call site may be bootstrapped more than once, because the application is free to reset the linkage state to null at any time. The code reflects the fact that bootstrapping is a separate state transition from simple linkage.

(The "java.dyn.impl" package needs to be renamed outside of the "java.*" system of packages, for a cleaner spec. We'll probably use "com.sun.java.dyn.MH".)

The implementation is complete on x86_32 only, and only on the template interpreter. The other platforms have various missing parts stubbed out. Since the optional functionality is disabled by default, this is not a hazard for normal Java applications.

This change group builds on top of anonymous classes (project info) and method handles (project info).

module-by-module change summary

In order to address an unlimited number of constant pool cache entries, the index field of an invokedynamic instruction is widened to four bytes, a so-called "giant index". All bytecode parsers in the JVM are modified to recognize such indexes. These parser include the operand decoding assembly code in the interpreter, and various strings and bytecode parsers. The normalized "java_code" of invokedynamic is invokeinterface, and the parsers are taught to make an invokedynamic instruction look exactly like an invokeinterface, unless the client looks carefully at the raw invokedynamic bytecode.

For robustness, the four-byte index of an invokedynamic instruction is always a low-magnitude negative number, so that there is never any confusion with the small positive indexes carried by other instructions. The access logic in constantPoolOop recognizes these negative indexes and handles them properly. This is the same cut-point that handles byte swapping. One reason to make the four-byte indexes negative is to avoid undesirable byte swapping.

The bytecode rewriter (which lays out constant pool caches) rewrites invokedynamic instances to refer to their own private CP cache entries. These entries are called "secondary entries" and are unique to invokedynamic instructions. (The invokedynamic bytecode is internal to the JVM; the rewriter changes the bytecode at the same time it rewrites the indexes.) All invokedynamic instructions with a common name and signature also share a single primary entry in common; this is an ordinary invokeinterface CP cache entry, which is used to answer the usual link-time questions about the call site. The secondary entry, by contrast, contains only the dynamic part of the call site, a reference to a java.dyn.impl.DynCallSite instance.

The template interpreter is extended to support the new (internal) bytecode. Much of the existing setup code is reused, but there are new interpreter runtime functions to link the call site to the correct method handle type, to create the DynCallSite, and the invoke the bootstrap method when necessary.

The template interpreter's return entry code is extended to deal with the mismatch between a reference returning from a bootstrap method and the actual return type of the call site's signature. This extension is called the "unboxing" variation of the return; it is capable of check-casting a reference return and then optionally unwrapping a primitive value.

The set of built-in, well-known symbols, classes, and class layouts is extended as need (in the classfile subdirectory, files vmSymbols, systemDictionary, and javaClasses).

The link resolver's "implicit method" mechanism (used for method handle invokers) is extended to provide augmented invokers for invokedynamic sites. The augmented invoke methods receive an extra reference argument, which is the untyped receiver of the invokedynamic instruction. The linkage processing of the bytecode also requires new calls to the system dictionary, to construct DynCallSite objects and look up bootstrap methods. Both of these requests are forwarded up to Java code.

In order to support the varargs-style argument lists of the bootstrapping API, a new C function get_jvalue_in_slot makes it easy to traverse interpreter argument lists.

There are occasional minor cleanups, such as the rewriting of old comments, deletion of dead code, or the improvement of debugging code. The printing code for bytecodes and instances was dusted off thoroughly.

Currently, compiler changes are minimal. Dynamic invocation call sites always deoptimize, but without triggering recompilation. This is a bug to fix later.

Legend: Modified file
Deleted file
New file

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/sparc/vm/interp_masm_sparc.cpp

rev 423 : imported patch indy.patch
22 lines changed: 19 ins; 0 del; 3 mod; 2603 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/sparc/vm/interp_masm_sparc.hpp

rev 423 : imported patch indy.patch
4 lines changed: 1 ins; 0 del; 3 mod; 329 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/sparc/vm/templateInterpreter_sparc.cpp

rev 423 : imported patch indy.patch
37 lines changed: 35 ins; 0 del; 2 mod; 1997 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/sparc/vm/templateTable_sparc.cpp

rev 423 : imported patch indy.patch
14 lines changed: 14 ins; 0 del; 0 mod; 3649 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/interp_masm_x86_32.cpp

rev 423 : imported patch indy.patch
28 lines changed: 22 ins; 0 del; 6 mod; 1551 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/interp_masm_x86_32.hpp

rev 423 : imported patch indy.patch
5 lines changed: 2 ins; 0 del; 3 mod; 242 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/interp_masm_x86_64.cpp

rev 423 : imported patch indy.patch
30 lines changed: 23 ins; 0 del; 7 mod; 1629 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/interp_masm_x86_64.hpp

rev 423 : imported patch indy.patch
5 lines changed: 2 ins; 0 del; 3 mod; 258 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateInterpreter_x86_32.cpp

rev 423 : imported patch indy.patch
118 lines changed: 112 ins; 0 del; 6 mod; 1812 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateInterpreter_x86_64.cpp

rev 423 : imported patch indy.patch
25 lines changed: 23 ins; 0 del; 2 mod; 1856 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateTable_x86_32.cpp

rev 423 : imported patch indy.patch
122 lines changed: 100 ins; 2 del; 20 mod; 3648 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateTable_x86_32.hpp

rev 423 : imported patch indy.patch
2 lines changed: 0 ins; 1 del; 1 mod; 31 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateTable_x86_64.cpp

rev 423 : imported patch indy.patch
130 lines changed: 105 ins; 2 del; 23 mod; 3649 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/cpu/x86/vm/templateTable_x86_64.hpp

rev 423 : imported patch indy.patch
2 lines changed: 0 ins; 1 del; 1 mod; 31 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/c1/c1_GraphBuilder.cpp

rev 423 : imported patch indy.patch
9 lines changed: 8 ins; 1 del; 0 mod; 3834 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/ci/bcEscapeAnalyzer.cpp

rev 423 : imported patch indy.patch
3 lines changed: 0 ins; 3 del; 0 mod; 1417 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/ci/ciMethod.cpp

rev 423 : imported patch indy.patch
7 lines changed: 7 ins; 0 del; 0 mod; 1066 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/ci/ciMethod.hpp

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 248 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/ci/ciStreams.cpp

rev 423 : imported patch indy.patch
1 line changed: 0 ins; 0 del; 1 mod; 366 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/ci/ciStreams.hpp

rev 423 : imported patch indy.patch
43 lines changed: 29 ins; 6 del; 8 mod; 355 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/classfile/javaClasses.cpp

rev 423 : imported patch indy.patch
49 lines changed: 49 ins; 0 del; 0 mod; 2760 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/classfile/javaClasses.hpp

rev 423 : imported patch indy.patch
34 lines changed: 34 ins; 0 del; 0 mod; 1042 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/classfile/systemDictionary.cpp

rev 423 : imported patch indy.patch
142 lines changed: 142 ins; 0 del; 0 mod; 2589 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/classfile/systemDictionary.hpp

rev 423 : imported patch indy.patch
25 lines changed: 25 ins; 0 del; 0 mod; 641 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/classfile/vmSymbols.hpp

rev 423 : imported patch indy.patch
9 lines changed: 9 ins; 0 del; 0 mod; 937 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/includeDB_core

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 4681 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/includeDB_gc_parallel

rev 423 : imported patch indy.patch
6 lines changed: 6 ins; 0 del; 0 mod; 172 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/includeDB_jvmti

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 258 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/abstractInterpreter.hpp

rev 423 : imported patch indy.patch
71 lines changed: 71 ins; 0 del; 0 mod; 244 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecode.cpp

rev 423 : imported patch indy.patch
10 lines changed: 3 ins; 6 del; 1 mod; 198 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecode.hpp

rev 423 : imported patch indy.patch
33 lines changed: 21 ins; 10 del; 2 mod; 364 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecodeStream.hpp

rev 423 : imported patch indy.patch
25 lines changed: 23 ins; 0 del; 2 mod; 170 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecodeTracer.cpp

rev 423 : imported patch indy.patch
116 lines changed: 95 ins; 12 del; 9 mod; 398 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecodes.cpp

rev 423 : imported patch indy.patch
4 lines changed: 3 ins; 0 del; 1 mod; 446 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/bytecodes.hpp

rev 423 : imported patch indy.patch
6 lines changed: 4 ins; 0 del; 2 mod; 358 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/interpreterRuntime.cpp

rev 423 : imported patch indy.patch
125 lines changed: 125 ins; 0 del; 0 mod; 1174 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/interpreterRuntime.hpp

rev 423 : imported patch indy.patch
7 lines changed: 5 ins; 0 del; 2 mod; 150 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/linkResolver.cpp

rev 423 : imported patch indy.patch
35 lines changed: 35 ins; 0 del; 0 mod; 1019 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/linkResolver.hpp

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 172 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/rewriter.cpp

rev 423 : imported patch indy.patch
168 lines changed: 103 ins; 22 del; 43 mod; 181 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/rewriter.hpp

rev 423 : imported patch indy.patch
36 lines changed: 31 ins; 0 del; 5 mod; 32 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/templateInterpreter.cpp

rev 423 : imported patch indy.patch
35 lines changed: 33 ins; 0 del; 2 mod; 598 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/templateInterpreter.hpp

rev 423 : imported patch indy.patch
7 lines changed: 4 ins; 0 del; 3 mod; 176 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/templateInterpreterGenerator.hpp

rev 423 : imported patch indy.patch
4 lines changed: 3 ins; 0 del; 1 mod; 90 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/templateTable.cpp

rev 423 : imported patch indy.patch
2 lines changed: 2 ins; 0 del; 0 mod; 541 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/interpreter/templateTable.hpp

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 330 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/constantPoolKlass.cpp

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 472 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/constantPoolOop.cpp

rev 423 : imported patch indy.patch
12 lines changed: 12 ins; 0 del; 0 mod; 1296 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/constantPoolOop.hpp

rev 423 : imported patch indy.patch
10 lines changed: 5 ins; 2 del; 3 mod; 564 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/cpCacheKlass.cpp

rev 423 : imported patch indy.patch
36 lines changed: 36 ins; 0 del; 0 mod; 206 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/cpCacheOop.cpp

rev 423 : imported patch indy.patch
34 lines changed: 32 ins; 0 del; 2 mod; 448 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/cpCacheOop.hpp

rev 423 : imported patch indy.patch
34 lines changed: 33 ins; 0 del; 1 mod; 329 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/generateOopMap.cpp

rev 423 : imported patch indy.patch
3 lines changed: 0 ins; 0 del; 3 mod; 2521 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/instanceKlass.cpp

rev 423 : imported patch indy.patch
34 lines changed: 26 ins; 2 del; 6 mod; 2631 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/instanceKlass.hpp

rev 423 : imported patch indy.patch
7 lines changed: 7 ins; 0 del; 0 mod; 959 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/instanceKlassKlass.cpp

rev 423 : imported patch indy.patch
52 lines changed: 19 ins; 1 del; 32 mod; 799 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/methodOop.cpp

rev 423 : imported patch indy.patch
41 lines changed: 40 ins; 0 del; 1 mod; 1355 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/oops/methodOop.hpp

rev 423 : imported patch indy.patch
11 lines changed: 10 ins; 0 del; 1 mod; 751 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/opto/bytecodeInfo.cpp

rev 423 : imported patch indy.patch
1 line changed: 0 ins; 0 del; 1 mod; 505 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/opto/doCall.cpp

rev 423 : imported patch indy.patch
8 lines changed: 8 ins; 0 del; 0 mod; 864 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/prims/jvmtiClassFileReconstituter.cpp

rev 423 : imported patch indy.patch
10 lines changed: 9 ins; 0 del; 1 mod; 676 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/prims/methodComparator.cpp

rev 423 : imported patch indy.patch
2 lines changed: 0 ins; 0 del; 2 mod; 381 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/prims/methodHandles.cpp

rev 423 : imported patch indy.patch
13 lines changed: 12 ins; 0 del; 1 mod; 661 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/arguments.cpp

rev 423 : imported patch indy.patch
6 lines changed: 6 ins; 0 del; 0 mod; 2826 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/globals.hpp

rev 423 : imported patch indy.patch
6 lines changed: 6 ins; 0 del; 0 mod; 3327 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/runtime/sharedRuntime.cpp

rev 423 : imported patch indy.patch
1 line changed: 1 ins; 0 del; 0 mod; 2297 unchg

Cdiffs Udiffs Sdiffs Frames Old New Patch Raw src/share/vm/utilities/globalDefinitions.hpp

rev 423 : imported patch indy.patch
17 lines changed: 16 ins; 0 del; 1 mod; 1122 unchg

This code review page was prepared using /Users/jrose/bin/hgwebrev (vers 23.12-hg-never).