src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64/src/org/graalvm/compiler/core/aarch64/AArch64SuitesCreator.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58299 6df94ce3ab2f
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     1
/*
58299
6df94ce3ab2f 8229201: Update Graal
dlong
parents: 57537
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     4
 *
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     8
 *
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    13
 * accompanied this code).
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    14
 *
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    18
 *
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    21
 * questions.
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    22
 */
50858
2d3e99a72541 8205824: Update Graal
never
parents: 49873
diff changeset
    23
2d3e99a72541 8205824: Update Graal
never
parents: 49873
diff changeset
    24
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    25
package org.graalvm.compiler.core.aarch64;
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    26
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    27
import java.util.List;
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    28
import java.util.ListIterator;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    29
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    30
import org.graalvm.compiler.debug.GraalError;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    31
import org.graalvm.compiler.java.DefaultSuitesCreator;
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    32
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    33
import org.graalvm.compiler.options.OptionValues;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    34
import org.graalvm.compiler.phases.BasePhase;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    35
import org.graalvm.compiler.phases.Phase;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    36
import org.graalvm.compiler.phases.PhaseSuite;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    37
import org.graalvm.compiler.phases.tiers.CompilerConfiguration;
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    38
import org.graalvm.compiler.phases.tiers.LowTierContext;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    39
import org.graalvm.compiler.phases.tiers.Suites;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    40
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    41
public class AArch64SuitesCreator extends DefaultSuitesCreator {
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    42
    private final List<Class<? extends Phase>> insertReadReplacementBeforePositions;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    43
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    44
    public AArch64SuitesCreator(CompilerConfiguration compilerConfiguration, Plugins plugins, List<Class<? extends Phase>> insertReadReplacementBeforePositions) {
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    45
        super(compilerConfiguration, plugins);
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    46
        this.insertReadReplacementBeforePositions = insertReadReplacementBeforePositions;
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    47
    }
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    48
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    49
    @Override
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    50
    public Suites createSuites(OptionValues options) {
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    51
        Suites suites = super.createSuites(options);
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    52
        ListIterator<BasePhase<? super LowTierContext>> findPhase = null;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    53
        for (Class<? extends Phase> phase : insertReadReplacementBeforePositions) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    54
            findPhase = suites.getLowTier().findPhase(phase);
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    55
            if (findPhase != null) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    56
                // Put AArch64ReadReplacementPhase right before the requested phase
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    57
                while (PhaseSuite.findNextPhase(findPhase, phase)) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    58
                    // Search for last occurrence of SchedulePhase
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    59
                }
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    60
                findPhase.previous();
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    61
                break;
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    62
            }
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    63
        }
57537
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    64
        if (findPhase != null) {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    65
            findPhase.add(new AArch64ReadReplacementPhase());
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    66
        } else {
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    67
            throw GraalError.shouldNotReachHere("Cannot find phase to insert AArch64ReadReplacementPhase");
ecc6e394475f 8226771: Update Graal
dlong
parents: 52910
diff changeset
    68
        }
49873
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    69
        return suites;
26ebfe8ce852 8199755: Update Graal
dlong
parents: 47216
diff changeset
    70
    }
46536
79d8dffda212 8182018: Update Graal
iveresov
parents:
diff changeset
    71
}