src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/BinaryContainer.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat

src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/BinaryContainer.java

Print this page




 170         {"StubRoutines::_jshort_disjoint_arraycopy", "_aot_stub_routines_jshort_disjoint_arraycopy"},
 171         {"StubRoutines::_jint_disjoint_arraycopy", "_aot_stub_routines_jint_disjoint_arraycopy"},
 172         {"StubRoutines::_jlong_disjoint_arraycopy", "_aot_stub_routines_jlong_disjoint_arraycopy"},
 173         {"StubRoutines::_oop_disjoint_arraycopy", "_aot_stub_routines_oop_disjoint_arraycopy"},
 174         {"StubRoutines::_oop_disjoint_arraycopy_uninit", "_aot_stub_routines_oop_disjoint_arraycopy_uninit"},
 175 
 176         {"StubRoutines::_arrayof_jbyte_arraycopy", "_aot_stub_routines_arrayof_jbyte_arraycopy"},
 177         {"StubRoutines::_arrayof_jshort_arraycopy", "_aot_stub_routines_arrayof_jshort_arraycopy"},
 178         {"StubRoutines::_arrayof_jint_arraycopy", "_aot_stub_routines_arrayof_jint_arraycopy"},
 179         {"StubRoutines::_arrayof_jlong_arraycopy", "_aot_stub_routines_arrayof_jlong_arraycopy"},
 180         {"StubRoutines::_arrayof_oop_arraycopy", "_aot_stub_routines_arrayof_oop_arraycopy"},
 181         {"StubRoutines::_arrayof_oop_arraycopy_uninit", "_aot_stub_routines_arrayof_oop_arraycopy_uninit"},
 182 
 183         {"StubRoutines::_arrayof_jbyte_disjoint_arraycopy", "_aot_stub_routines_arrayof_jbyte_disjoint_arraycopy"},
 184         {"StubRoutines::_arrayof_jshort_disjoint_arraycopy", "_aot_stub_routines_arrayof_jshort_disjoint_arraycopy"},
 185         {"StubRoutines::_arrayof_jint_disjoint_arraycopy", "_aot_stub_routines_arrayof_jint_disjoint_arraycopy"},
 186         {"StubRoutines::_arrayof_jlong_disjoint_arraycopy", "_aot_stub_routines_arrayof_jlong_disjoint_arraycopy"},
 187         {"StubRoutines::_arrayof_oop_disjoint_arraycopy", "_aot_stub_routines_arrayof_oop_disjoint_arraycopy"},
 188         {"StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", "_aot_stub_routines_arrayof_oop_disjoint_arraycopy_uninit"},
 189 
 190         {"StubRoutines::_checkcast_arraycopy", "_aot_stub_routines_checkcast_arraycopy"},
 191 
 192 
 193 

 194 
 195         {"StubRoutines::_aescrypt_encryptBlock", "_aot_stub_routines_aescrypt_encryptBlock"},
 196         {"StubRoutines::_aescrypt_decryptBlock", "_aot_stub_routines_aescrypt_decryptBlock"},
 197         {"StubRoutines::_cipherBlockChaining_encryptAESCrypt", "_aot_stub_routines_cipherBlockChaining_encryptAESCrypt"},
 198         {"StubRoutines::_cipherBlockChaining_decryptAESCrypt", "_aot_stub_routines_cipherBlockChaining_decryptAESCrypt"},
 199         {"StubRoutines::_updateBytesCRC32", "_aot_stub_routines_update_bytes_crc32"},
 200         {"StubRoutines::_crc_table_adr", "_aot_stub_routines_crc_table_adr"},
 201 
 202         {"StubRoutines::_sha1_implCompress", "_aot_stub_routines_sha1_implCompress" },
 203         {"StubRoutines::_sha1_implCompressMB", "_aot_stub_routines_sha1_implCompressMB" },
 204         {"StubRoutines::_sha256_implCompress", "_aot_stub_routines_sha256_implCompress" },
 205         {"StubRoutines::_sha256_implCompressMB", "_aot_stub_routines_sha256_implCompressMB" },
 206         {"StubRoutines::_sha512_implCompress", "_aot_stub_routines_sha512_implCompress" },
 207         {"StubRoutines::_sha512_implCompressMB", "_aot_stub_routines_sha512_implCompressMB" },
 208         {"StubRoutines::_multiplyToLen", "_aot_stub_routines_multiplyToLen" },
 209 
 210         {"StubRoutines::_counterMode_AESCrypt", "_aot_stub_routines_counterMode_AESCrypt" },
 211         {"StubRoutines::_ghash_processBlocks", "_aot_stub_routines_ghash_processBlocks" },
 212         {"StubRoutines::_crc32c_table_addr", "_aot_stub_routines_crc32c_table_addr" },
 213         {"StubRoutines::_updateBytesCRC32C", "_aot_stub_routines_updateBytesCRC32C" },


 461         createContainerSymbol(codeSegmentsContainer);
 462 
 463         createGotSymbol(getResolveStaticEntrySymbolName());
 464         createGotSymbol(getResolveVirtualEntrySymbolName());
 465         createGotSymbol(getResolveOptVirtualEntrySymbolName());
 466         createGotSymbol(getCardTableAddressSymbolName());
 467         createGotSymbol(getHeapTopAddressSymbolName());
 468         createGotSymbol(getHeapEndAddressSymbolName());
 469         createGotSymbol(getNarrowKlassBaseAddressSymbolName());
 470         createGotSymbol(getNarrowOopBaseAddressSymbolName());
 471         createGotSymbol(getPollingPageSymbolName());
 472         createGotSymbol(getLogOfHeapRegionGrainBytesSymbolName());
 473         createGotSymbol(getInlineContiguousAllocationSupportedSymbolName());
 474 
 475         for (HashMap.Entry<String, String> entry : functionNamesToAOTSymbols.entrySet()) {
 476             createGotSymbol(entry.getValue());
 477         }
 478     }
 479 
 480     /**
 481      * Creates a global symbol of the form {@code "A" + container name}.
 482      * Note, linker on Windows does not allow names which start with '.'
 483      *
 484      * @param container container to create a symbol for
 485      */
 486     private static void createContainerSymbol(ByteContainer container) {
 487         container.createSymbol(0, Kind.OBJECT, Binding.GLOBAL, 0, "A" + container.getContainerName());
 488     }
 489 
 490     /**
 491      * Creates a global GOT symbol of the form {@code "got." + name}.
 492      *
 493      * @param name name for the GOT symbol
 494      */
 495     private void createGotSymbol(String name) {
 496         String s = "got." + name;
 497         Symbol gotSymbol = extLinkageGOTContainer.createGotSymbol(s);
 498         extLinkageGOTContainer.createSymbol(gotSymbol.getOffset(), Kind.OBJECT, Binding.GLOBAL, 8, name);
 499     }
 500 
 501     /**
 502      * Create a platform-specific binary file representing the content of the


 668                     String methodName = name.substring(dotIndex + 1, parenthesesIndex);
 669                     out.writeUTF(methodName);
 670                     String signature = name.substring(parenthesesIndex, len);
 671                     out.writeUTF(signature);
 672                 } else {
 673                     out.writeUTF(name); // Klass
 674                 }
 675             }
 676             out.writeShort(0); // Terminate by 0.
 677             byte[] b = bout.toByteArray();
 678             metaspaceNamesContainer.appendBytes(b, 0, b.length);
 679 
 680             metaspaceNames.put(name, nameOffset);
 681             return nameOffset;
 682         } catch (IOException e) {
 683             throw new InternalError("Failed to append bytes to stubs sections", e);
 684         }
 685     }
 686 
 687     /**
 688      * Add oop symbol by as follows. Extend the oop.got section with another slot for the VM to patch.

 689      *
 690      * @param oopName name of the oop symbol
 691      */
 692     public Integer addOopSymbol(String oopName) {
 693         Integer oopGotOffset = getStringOffset(oopName);
 694         if (oopGotOffset != null) {
 695             return oopGotOffset;
 696         }
 697         return newOopSymbol(oopName);
 698     }
 699 
 700     private Integer newOopSymbol(String oopName) {
 701         // Reference to String resolution (ldc).
 702         int offset = oopGotContainer.getByteStreamSize();
 703         String gotName = "got.ldc." + offset;
 704         Symbol relocationSymbol = oopGotContainer.createGotSymbol(gotName);
 705 
 706         if (offset != relocationSymbol.getOffset()) {
 707             throw new InternalError("offset must equal! (" + offset + " vs " + relocationSymbol.getOffset());
 708         }


 711         return relocationSymbol.getOffset();
 712     }
 713 
 714     public int addCountersSymbol(String metaspaceName) {
 715         String gotName = "got." + metaspaceName;
 716         Symbol relocationSymbol = getGotSymbol(gotName);
 717         int metaspaceOffset = -1;
 718         if (relocationSymbol == null) {
 719             // Add slots when asked in the .metaspace.got section:
 720             countersGotContainer.createGotSymbol(gotName);
 721         }
 722         return metaspaceOffset;
 723     }
 724 
 725     public Symbol getGotSymbol(String name) {
 726         assert name.startsWith("got.");
 727         return symbolTable.get(name);
 728     }
 729 
 730     /**
 731      * Add klass symbol by as follows.
 732      *   - Adding the symbol name to the metaspace.names section
 733      *   - Add the offset of the name in metaspace.names to metaspace.offsets
 734      *   - Extend the klasses.got section with another slot for the VM to patch
 735      *
 736      * @param klassName name of the metaspace symbol
 737      * @return the got offset in the klasses.got of the metaspace symbol
 738      */
 739     public int addTwoSlotKlassSymbol(String klassName) {
 740         String gotName = "got." + klassName;
 741         Symbol previous = getGotSymbol(gotName);
 742         assert previous == null : "should be called only once for: " + klassName;
 743         // Add slots when asked in the .metaspace.got section:
 744         // First slot
 745         String gotInitName = "got.init." + klassName;
 746         GotSymbol slot1Symbol = klassesGotContainer.createGotSymbol(gotInitName);
 747         GotSymbol slot2Symbol = klassesGotContainer.createGotSymbol(gotName);
 748 
 749         slot1Symbol.getIndex(); // check alignment and ignore result
 750         // Get the index (offset/8) to the got in the .metaspace.got section
 751         return slot2Symbol.getIndex();
 752     }
 753 
 754     public static int addMethodsCount(int count, ReadOnlyDataContainer container) {




 170         {"StubRoutines::_jshort_disjoint_arraycopy", "_aot_stub_routines_jshort_disjoint_arraycopy"},
 171         {"StubRoutines::_jint_disjoint_arraycopy", "_aot_stub_routines_jint_disjoint_arraycopy"},
 172         {"StubRoutines::_jlong_disjoint_arraycopy", "_aot_stub_routines_jlong_disjoint_arraycopy"},
 173         {"StubRoutines::_oop_disjoint_arraycopy", "_aot_stub_routines_oop_disjoint_arraycopy"},
 174         {"StubRoutines::_oop_disjoint_arraycopy_uninit", "_aot_stub_routines_oop_disjoint_arraycopy_uninit"},
 175 
 176         {"StubRoutines::_arrayof_jbyte_arraycopy", "_aot_stub_routines_arrayof_jbyte_arraycopy"},
 177         {"StubRoutines::_arrayof_jshort_arraycopy", "_aot_stub_routines_arrayof_jshort_arraycopy"},
 178         {"StubRoutines::_arrayof_jint_arraycopy", "_aot_stub_routines_arrayof_jint_arraycopy"},
 179         {"StubRoutines::_arrayof_jlong_arraycopy", "_aot_stub_routines_arrayof_jlong_arraycopy"},
 180         {"StubRoutines::_arrayof_oop_arraycopy", "_aot_stub_routines_arrayof_oop_arraycopy"},
 181         {"StubRoutines::_arrayof_oop_arraycopy_uninit", "_aot_stub_routines_arrayof_oop_arraycopy_uninit"},
 182 
 183         {"StubRoutines::_arrayof_jbyte_disjoint_arraycopy", "_aot_stub_routines_arrayof_jbyte_disjoint_arraycopy"},
 184         {"StubRoutines::_arrayof_jshort_disjoint_arraycopy", "_aot_stub_routines_arrayof_jshort_disjoint_arraycopy"},
 185         {"StubRoutines::_arrayof_jint_disjoint_arraycopy", "_aot_stub_routines_arrayof_jint_disjoint_arraycopy"},
 186         {"StubRoutines::_arrayof_jlong_disjoint_arraycopy", "_aot_stub_routines_arrayof_jlong_disjoint_arraycopy"},
 187         {"StubRoutines::_arrayof_oop_disjoint_arraycopy", "_aot_stub_routines_arrayof_oop_disjoint_arraycopy"},
 188         {"StubRoutines::_arrayof_oop_disjoint_arraycopy_uninit", "_aot_stub_routines_arrayof_oop_disjoint_arraycopy_uninit"},
 189 
 190         {"StubRoutines::_unsafe_arraycopy", "_aot_stub_routines_unsafe_arraycopy"},


 191 
 192         {"StubRoutines::_checkcast_arraycopy", "_aot_stub_routines_checkcast_arraycopy"},
 193 
 194         {"StubRoutines::_aescrypt_encryptBlock", "_aot_stub_routines_aescrypt_encryptBlock"},
 195         {"StubRoutines::_aescrypt_decryptBlock", "_aot_stub_routines_aescrypt_decryptBlock"},
 196         {"StubRoutines::_cipherBlockChaining_encryptAESCrypt", "_aot_stub_routines_cipherBlockChaining_encryptAESCrypt"},
 197         {"StubRoutines::_cipherBlockChaining_decryptAESCrypt", "_aot_stub_routines_cipherBlockChaining_decryptAESCrypt"},
 198         {"StubRoutines::_updateBytesCRC32", "_aot_stub_routines_update_bytes_crc32"},
 199         {"StubRoutines::_crc_table_adr", "_aot_stub_routines_crc_table_adr"},
 200 
 201         {"StubRoutines::_sha1_implCompress", "_aot_stub_routines_sha1_implCompress" },
 202         {"StubRoutines::_sha1_implCompressMB", "_aot_stub_routines_sha1_implCompressMB" },
 203         {"StubRoutines::_sha256_implCompress", "_aot_stub_routines_sha256_implCompress" },
 204         {"StubRoutines::_sha256_implCompressMB", "_aot_stub_routines_sha256_implCompressMB" },
 205         {"StubRoutines::_sha512_implCompress", "_aot_stub_routines_sha512_implCompress" },
 206         {"StubRoutines::_sha512_implCompressMB", "_aot_stub_routines_sha512_implCompressMB" },
 207         {"StubRoutines::_multiplyToLen", "_aot_stub_routines_multiplyToLen" },
 208 
 209         {"StubRoutines::_counterMode_AESCrypt", "_aot_stub_routines_counterMode_AESCrypt" },
 210         {"StubRoutines::_ghash_processBlocks", "_aot_stub_routines_ghash_processBlocks" },
 211         {"StubRoutines::_crc32c_table_addr", "_aot_stub_routines_crc32c_table_addr" },
 212         {"StubRoutines::_updateBytesCRC32C", "_aot_stub_routines_updateBytesCRC32C" },


 460         createContainerSymbol(codeSegmentsContainer);
 461 
 462         createGotSymbol(getResolveStaticEntrySymbolName());
 463         createGotSymbol(getResolveVirtualEntrySymbolName());
 464         createGotSymbol(getResolveOptVirtualEntrySymbolName());
 465         createGotSymbol(getCardTableAddressSymbolName());
 466         createGotSymbol(getHeapTopAddressSymbolName());
 467         createGotSymbol(getHeapEndAddressSymbolName());
 468         createGotSymbol(getNarrowKlassBaseAddressSymbolName());
 469         createGotSymbol(getNarrowOopBaseAddressSymbolName());
 470         createGotSymbol(getPollingPageSymbolName());
 471         createGotSymbol(getLogOfHeapRegionGrainBytesSymbolName());
 472         createGotSymbol(getInlineContiguousAllocationSupportedSymbolName());
 473 
 474         for (HashMap.Entry<String, String> entry : functionNamesToAOTSymbols.entrySet()) {
 475             createGotSymbol(entry.getValue());
 476         }
 477     }
 478 
 479     /**
 480      * Creates a global symbol of the form {@code "A" + container name}. Note, linker on Windows
 481      * does not allow names which start with '.'
 482      *
 483      * @param container container to create a symbol for
 484      */
 485     private static void createContainerSymbol(ByteContainer container) {
 486         container.createSymbol(0, Kind.OBJECT, Binding.GLOBAL, 0, "A" + container.getContainerName());
 487     }
 488 
 489     /**
 490      * Creates a global GOT symbol of the form {@code "got." + name}.
 491      *
 492      * @param name name for the GOT symbol
 493      */
 494     private void createGotSymbol(String name) {
 495         String s = "got." + name;
 496         Symbol gotSymbol = extLinkageGOTContainer.createGotSymbol(s);
 497         extLinkageGOTContainer.createSymbol(gotSymbol.getOffset(), Kind.OBJECT, Binding.GLOBAL, 8, name);
 498     }
 499 
 500     /**
 501      * Create a platform-specific binary file representing the content of the


 667                     String methodName = name.substring(dotIndex + 1, parenthesesIndex);
 668                     out.writeUTF(methodName);
 669                     String signature = name.substring(parenthesesIndex, len);
 670                     out.writeUTF(signature);
 671                 } else {
 672                     out.writeUTF(name); // Klass
 673                 }
 674             }
 675             out.writeShort(0); // Terminate by 0.
 676             byte[] b = bout.toByteArray();
 677             metaspaceNamesContainer.appendBytes(b, 0, b.length);
 678 
 679             metaspaceNames.put(name, nameOffset);
 680             return nameOffset;
 681         } catch (IOException e) {
 682             throw new InternalError("Failed to append bytes to stubs sections", e);
 683         }
 684     }
 685 
 686     /**
 687      * Add oop symbol by as follows. Extend the oop.got section with another slot for the VM to
 688      * patch.
 689      *
 690      * @param oopName name of the oop symbol
 691      */
 692     public Integer addOopSymbol(String oopName) {
 693         Integer oopGotOffset = getStringOffset(oopName);
 694         if (oopGotOffset != null) {
 695             return oopGotOffset;
 696         }
 697         return newOopSymbol(oopName);
 698     }
 699 
 700     private Integer newOopSymbol(String oopName) {
 701         // Reference to String resolution (ldc).
 702         int offset = oopGotContainer.getByteStreamSize();
 703         String gotName = "got.ldc." + offset;
 704         Symbol relocationSymbol = oopGotContainer.createGotSymbol(gotName);
 705 
 706         if (offset != relocationSymbol.getOffset()) {
 707             throw new InternalError("offset must equal! (" + offset + " vs " + relocationSymbol.getOffset());
 708         }


 711         return relocationSymbol.getOffset();
 712     }
 713 
 714     public int addCountersSymbol(String metaspaceName) {
 715         String gotName = "got." + metaspaceName;
 716         Symbol relocationSymbol = getGotSymbol(gotName);
 717         int metaspaceOffset = -1;
 718         if (relocationSymbol == null) {
 719             // Add slots when asked in the .metaspace.got section:
 720             countersGotContainer.createGotSymbol(gotName);
 721         }
 722         return metaspaceOffset;
 723     }
 724 
 725     public Symbol getGotSymbol(String name) {
 726         assert name.startsWith("got.");
 727         return symbolTable.get(name);
 728     }
 729 
 730     /**
 731      * Add klass symbol by as follows. - Adding the symbol name to the metaspace.names section - Add
 732      * the offset of the name in metaspace.names to metaspace.offsets - Extend the klasses.got
 733      * section with another slot for the VM to patch

 734      *
 735      * @param klassName name of the metaspace symbol
 736      * @return the got offset in the klasses.got of the metaspace symbol
 737      */
 738     public int addTwoSlotKlassSymbol(String klassName) {
 739         String gotName = "got." + klassName;
 740         Symbol previous = getGotSymbol(gotName);
 741         assert previous == null : "should be called only once for: " + klassName;
 742         // Add slots when asked in the .metaspace.got section:
 743         // First slot
 744         String gotInitName = "got.init." + klassName;
 745         GotSymbol slot1Symbol = klassesGotContainer.createGotSymbol(gotInitName);
 746         GotSymbol slot2Symbol = klassesGotContainer.createGotSymbol(gotName);
 747 
 748         slot1Symbol.getIndex(); // check alignment and ignore result
 749         // Get the index (offset/8) to the got in the .metaspace.got section
 750         return slot2Symbol.getIndex();
 751     }
 752 
 753     public static int addMethodsCount(int count, ReadOnlyDataContainer container) {


src/jdk.aot/share/classes/jdk.tools.jaotc.binformat/src/jdk/tools/jaotc/binformat/BinaryContainer.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File