src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java
Index Unified diffs Context diffs Sdiffs Frames Patch New Old Previous File Next File
*** old/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java	Tue Aug 22 11:46:48 2017
--- new/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/DataBuilder.java	Tue Aug 22 11:46:48 2017

*** 1,7 **** --- 1,7 ---- /* ! * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 29,50 **** --- 29,50 ---- import java.util.Map.Entry; import jdk.tools.jaotc.binformat.BinaryContainer; import jdk.tools.jaotc.binformat.ByteContainer; import jdk.tools.jaotc.binformat.HeaderContainer; import jdk.tools.jaotc.utils.Timer; + import org.graalvm.compiler.code.CompilationResult; import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.hotspot.HotSpotHostBackend; import org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider; import org.graalvm.compiler.hotspot.stubs.Stub; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; import jdk.vm.ci.hotspot.HotSpotVMConfigStore; import jdk.vm.ci.hotspot.VMField; ! final class DataBuilder { private final Main main; private final HotSpotHostBackend backend;
*** 53,76 **** --- 53,76 ---- /** * Target-independent container in which text symbols and code bytes are created. */ private final BinaryContainer binaryContainer; ! private static final HashMap<Long, String> vmAddresses = new HashMap<>(); - public DataBuilder(Main main, HotSpotHostBackend backend, List<AOTCompiledClass> classes, BinaryContainer binaryContainer) { this.main = main; this.backend = backend; this.classes = classes; this.binaryContainer = binaryContainer; fillVMAddresses(HotSpotJVMCIRuntime.runtime().getConfigStore()); } /** * Returns a value-name map of all {@link VMField} fields. */ ! private static void fillVMAddresses(HotSpotVMConfigStore config) { for (VMField vmField : config.getFields().values()) { if (vmField.value != null && vmField.value instanceof Long) { final long address = (Long) vmField.value; String value = vmField.name; /*
*** 96,124 **** --- 96,124 ---- * Get the C/C++ function name associated with the foreign call target {@code address}. * * @param address native address * @return C/C++ functio name associated with the native address */ ! public String getVMFunctionNameForAddress(long address) { ! static String getVMFunctionNameForAddress(long address) { return vmAddresses.get(address); } /** * Returns the host backend used for this compilation. * * @return host backend */ - public HotSpotHostBackend getBackend() { return backend; } /** * Returns the binary container for this compilation. * * @return binary container */ - public BinaryContainer getBinaryContainer() { return binaryContainer; } /** * Prepare data with all compiled classes and stubs.
*** 126,136 **** --- 126,136 ---- * @param debug * * @throws Exception */ @SuppressWarnings("try") - public void prepareData(DebugContext debug) throws Exception { try (Timer t = new Timer(main, "Parsing compiled code")) { /* * Copy compiled code into code section container and calls stubs (PLT trampoline). */ CodeSectionProcessor codeSectionProcessor = new CodeSectionProcessor(this);
*** 145,155 **** --- 145,155 ---- AOTCompiledClass stubCompiledCode = retrieveStubCode(debug); // Free memory! try (Timer t = main.options.verbose ? new Timer(main, "Freeing memory") : null) { ! main.printer.printMemoryUsage(); System.gc(); } MetadataBuilder metadataBuilder = null; try (Timer t = new Timer(main, "Processing metadata")) {
*** 161,180 **** --- 161,180 ---- metadataBuilder.processMetadata(classes, stubCompiledCode); } // Free memory! try (Timer t = main.options.verbose ? new Timer(main, "Freeing memory") : null) { ! main.printer.printMemoryUsage(); System.gc(); } try (Timer t = new Timer(main, "Preparing stubs binary")) { prepareStubsBinary(stubCompiledCode); } try (Timer t = new Timer(main, "Preparing compiled binary")) { // Should be called after Stubs because they can set dependent klasses. - prepareCompiledBinary(metadataBuilder); } } /** * Get all stubs from Graal and add them to the code section.
*** 201,211 **** --- 201,211 ---- } /** * Prepare metaspace.offsets section. */ - private void prepareCompiledBinary(MetadataBuilder metadataBuilder) { for (AOTCompiledClass c : classes) { // Create records for compiled AOT methods. c.putMethodsData(binaryContainer); } // Create records for compiled AOT classes.
*** 214,225 **** --- 214,225 ---- // Fill in AOTHeader HeaderContainer header = binaryContainer.getHeaderContainer(); header.setClassesCount(AOTCompiledClass.getClassesCount()); header.setMethodsCount(CompiledMethodInfo.getMethodsCount()); // Record size of got sections ! ByteContainer bc = binaryContainer.getMetaspaceGotContainer(); ! header.setMetaspaceGotSize((bc.getByteStreamSize() / 8)); ! ByteContainer bc = binaryContainer.getKlassesGotContainer(); ! header.setKlassesGotSize((bc.getByteStreamSize() / 8)); bc = binaryContainer.getMetadataGotContainer(); header.setMetadataGotSize((bc.getByteStreamSize() / 8)); bc = binaryContainer.getOopGotContainer(); header.setOopGotSize((bc.getByteStreamSize() / 8)); }
*** 230,240 **** --- 230,240 ---- private void prepareStubsBinary(AOTCompiledClass compiledClass) { // For each of the compiled stubs, create records holding information about // them. ArrayList<CompiledMethodInfo> compiledStubs = compiledClass.getCompiledMethods(); int cntStubs = compiledStubs.size(); ! binaryContainer.addMethodsCount(cntStubs, binaryContainer.getStubsOffsetsContainer()); ! BinaryContainer.addMethodsCount(cntStubs, binaryContainer.getStubsOffsetsContainer()); for (CompiledMethodInfo methodInfo : compiledStubs) { // Note, stubs have different offsets container. methodInfo.addMethodOffsets(binaryContainer, binaryContainer.getStubsOffsetsContainer()); } }

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