src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java
author iveresov
Fri, 17 Aug 2018 13:20:53 -0700
changeset 51436 091c0d22e735
parent 50330 2cbc42a5764b
child 52578 7dd81e82d083
permissions -rw-r--r--
8206992: Update Graal Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     1
/*
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     4
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     8
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    13
 * accompanied this code).
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    14
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    18
 *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    21
 * questions.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    22
 */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    23
51436
091c0d22e735 8206992: Update Graal
iveresov
parents: 50330
diff changeset
    24
091c0d22e735 8206992: Update Graal
iveresov
parents: 50330
diff changeset
    25
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    26
package jdk.tools.jaotc;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    27
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    28
import java.util.ListIterator;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    29
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    30
import org.graalvm.compiler.code.CompilationResult;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    31
import org.graalvm.compiler.core.GraalCompiler;
47084
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
    32
import org.graalvm.compiler.core.common.CompilationIdentifier;
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
    33
import org.graalvm.compiler.debug.DebugContext;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    34
import org.graalvm.compiler.hotspot.HotSpotBackend;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    35
import org.graalvm.compiler.hotspot.HotSpotCompiledCodeBuilder;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    36
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    37
import org.graalvm.compiler.hotspot.meta.HotSpotInvokeDynamicPlugin;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    38
import org.graalvm.compiler.java.GraphBuilderPhase;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    39
import org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    40
import org.graalvm.compiler.lir.phases.LIRSuites;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    41
import org.graalvm.compiler.nodes.StructuredGraph;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    42
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    43
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
    44
import org.graalvm.compiler.options.OptionValues;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    45
import org.graalvm.compiler.phases.BasePhase;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    46
import org.graalvm.compiler.phases.OptimisticOptimizations;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    47
import org.graalvm.compiler.phases.PhaseSuite;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    48
import org.graalvm.compiler.phases.tiers.HighTierContext;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    49
import org.graalvm.compiler.phases.tiers.Suites;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    50
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    51
import jdk.vm.ci.code.InstalledCode;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    52
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    53
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    54
import jdk.vm.ci.meta.DefaultProfilingInfo;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    55
import jdk.vm.ci.meta.ProfilingInfo;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    56
import jdk.vm.ci.meta.ResolvedJavaMethod;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    57
import jdk.vm.ci.meta.TriState;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    58
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
    59
final class AOTBackend {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    60
    private final Main main;
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
    61
    private final OptionValues graalOptions;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    62
    private final HotSpotBackend backend;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    63
    private final HotSpotProviders providers;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    64
    private final HotSpotCodeCacheProvider codeCache;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    65
    private final PhaseSuite<HighTierContext> graphBuilderSuite;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    66
    private final HighTierContext highTierContext;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    67
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    68
    AOTBackend(Main main, OptionValues graalOptions, HotSpotBackend backend, HotSpotInvokeDynamicPlugin inokeDynamicPlugin) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    69
        this.main = main;
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
    70
        this.graalOptions = graalOptions;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    71
        this.backend = backend;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    72
        providers = backend.getProviders();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    73
        codeCache = providers.getCodeCache();
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
    74
        graphBuilderSuite = initGraphBuilderSuite(backend, main.options.compileWithAssertions, inokeDynamicPlugin);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    75
        highTierContext = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.ALL);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    76
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    77
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
    78
    PhaseSuite<HighTierContext> getGraphBuilderSuite() {
43405
1fab8e6866d7 8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents: 42650
diff changeset
    79
        return graphBuilderSuite;
1fab8e6866d7 8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents: 42650
diff changeset
    80
    }
1fab8e6866d7 8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents: 42650
diff changeset
    81
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
    82
    HotSpotBackend getBackend() {
46371
0337d0617e7b 8178088: Update Graal
iveresov
parents: 46344
diff changeset
    83
        return backend;
0337d0617e7b 8178088: Update Graal
iveresov
parents: 46344
diff changeset
    84
    }
0337d0617e7b 8178088: Update Graal
iveresov
parents: 46344
diff changeset
    85
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
    86
    HotSpotProviders getProviders() {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
    87
        return providers;
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
    88
    }
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
    89
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    90
    private Suites getSuites() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    91
        // create suites every time, as we modify options for the compiler
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
    92
        return backend.getSuites().getDefaultSuites(graalOptions);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    93
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    94
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    95
    private LIRSuites getLirSuites() {
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    96
        // create suites every time, as we modify options for the compiler
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
    97
        return backend.getSuites().getDefaultLIRSuites(graalOptions);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    98
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
    99
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   100
    @SuppressWarnings("try")
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
   101
    CompilationResult compileMethod(ResolvedJavaMethod resolvedMethod, DebugContext debug) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   102
        StructuredGraph graph = buildStructuredGraph(resolvedMethod, debug);
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
   103
        if (graph != null) {
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   104
            return compileGraph(resolvedMethod, graph, debug);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   105
        }
46344
694c102fd8ed 8177046: Update Graal
iveresov
parents: 43405
diff changeset
   106
        return null;
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   107
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   108
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   109
    /**
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   110
     * Build a structured graph for the member.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   111
     *
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   112
     * @param javaMethod method for whose code the graph is to be created
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   113
     * @param debug
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   114
     * @return structured graph
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   115
     */
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   116
    @SuppressWarnings("try")
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   117
    private StructuredGraph buildStructuredGraph(ResolvedJavaMethod javaMethod, DebugContext debug) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   118
        try (DebugContext.Scope s = debug.scope("AOTParseMethod")) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   119
            StructuredGraph graph = new StructuredGraph.Builder(graalOptions, debug).method(javaMethod).useProfilingInfo(false).build();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   120
            graphBuilderSuite.apply(graph, highTierContext);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   121
            return graph;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   122
        } catch (Throwable e) {
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
   123
            main.handleError(javaMethod, e, " (building graph)");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   124
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   125
        return null;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   126
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   127
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   128
    @SuppressWarnings("try")
46640
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   129
    private CompilationResult compileGraph(ResolvedJavaMethod resolvedMethod, StructuredGraph graph, DebugContext debug) {
70bdce04c59b 8183991: Update Graal
iveresov
parents: 46371
diff changeset
   130
        try (DebugContext.Scope s = debug.scope("AOTCompileMethod")) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   131
            ProfilingInfo profilingInfo = DefaultProfilingInfo.get(TriState.FALSE);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   132
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   133
            final boolean isImmutablePIC = true;
47084
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   134
            CompilationIdentifier id = new CompilationIdentifier() {
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   135
                @Override
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   136
                public String toString(Verbosity verbosity) {
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   137
                    return resolvedMethod.getName();
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   138
                }
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   139
            };
630d326a3d15 8186850: Update Graal
iveresov
parents: 46949
diff changeset
   140
            CompilationResult compilationResult = new CompilationResult(id, isImmutablePIC);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   141
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   142
            return GraalCompiler.compileGraph(graph, resolvedMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, profilingInfo, getSuites(), getLirSuites(),
50330
2cbc42a5764b 8202670: Update Graal
dlong
parents: 48443
diff changeset
   143
                            compilationResult, CompilationResultBuilderFactory.Default, true);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   144
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   145
        } catch (Throwable e) {
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
   146
            main.handleError(resolvedMethod, e, " (compiling graph)");
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   147
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   148
        return null;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   149
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   150
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   151
    private static PhaseSuite<HighTierContext> initGraphBuilderSuite(HotSpotBackend backend, boolean compileWithAssertions, HotSpotInvokeDynamicPlugin inokeDynamicPlugin) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   152
        PhaseSuite<HighTierContext> graphBuilderSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   153
        ListIterator<BasePhase<? super HighTierContext>> iterator = graphBuilderSuite.findPhase(GraphBuilderPhase.class);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   154
        GraphBuilderConfiguration baseConfig = ((GraphBuilderPhase) iterator.previous()).getGraphBuilderConfig();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   155
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   156
        // Use all default plugins.
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   157
        Plugins plugins = baseConfig.getPlugins();
47668
fc4cfca10556 8132547: [AOT] support invokedynamic instructions
dlong
parents: 47216
diff changeset
   158
        plugins.setInvokeDynamicPlugin(inokeDynamicPlugin);
43405
1fab8e6866d7 8168792: [AOT] problems in MethodHandle with aot-compiled java.base
iveresov
parents: 42650
diff changeset
   159
        GraphBuilderConfiguration aotConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withOmitAssertions(!compileWithAssertions);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   160
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   161
        iterator.next();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   162
        iterator.remove();
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   163
        iterator.add(new GraphBuilderPhase(aotConfig));
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   164
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   165
        return graphBuilderSuite;
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   166
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   167
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
   168
    void printCompiledMethod(HotSpotResolvedJavaMethod resolvedMethod, CompilationResult compResult) {
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   169
        // This is really not installing the method.
48443
8935285e8759 8194271: jaotc crashes with --debug flag
iveresov
parents: 47668
diff changeset
   170
        InstalledCode installedCode = codeCache.addCode(resolvedMethod, HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, resolvedMethod, null, compResult), null, null);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   171
        String disassembly = codeCache.disassemble(installedCode);
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   172
        if (disassembly != null) {
46949
44ccdba2d72e 8186453: [AOT] refactor AOT tool code
kvn
parents: 46640
diff changeset
   173
            main.printer.printlnDebug(disassembly);
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   174
        }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   175
    }
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents:
diff changeset
   176
}