src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/NodeIntrinsificationProvider.java
changeset 58877 aec7bf35d6f5
parent 52956 4b0b796dd581
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    32 import org.graalvm.compiler.debug.GraalError;
    32 import org.graalvm.compiler.debug.GraalError;
    33 import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory.InjectionProvider;
    33 import org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory.InjectionProvider;
    34 import org.graalvm.compiler.replacements.arraycopy.ArrayCopyForeignCalls;
    34 import org.graalvm.compiler.replacements.arraycopy.ArrayCopyForeignCalls;
    35 import org.graalvm.compiler.word.WordTypes;
    35 import org.graalvm.compiler.word.WordTypes;
    36 
    36 
       
    37 import jdk.vm.ci.code.TargetDescription;
    37 import jdk.vm.ci.meta.JavaKind;
    38 import jdk.vm.ci.meta.JavaKind;
    38 import jdk.vm.ci.meta.MetaAccessProvider;
    39 import jdk.vm.ci.meta.MetaAccessProvider;
    39 import jdk.vm.ci.meta.ResolvedJavaType;
    40 import jdk.vm.ci.meta.ResolvedJavaType;
    40 
    41 
    41 public class NodeIntrinsificationProvider implements InjectionProvider {
    42 public class NodeIntrinsificationProvider implements InjectionProvider {
    42 
    43 
       
    44     public static final TargetDescription INJECTED_TARGET = null;
       
    45 
    43     private final MetaAccessProvider metaAccess;
    46     private final MetaAccessProvider metaAccess;
    44     private final SnippetReflectionProvider snippetReflection;
    47     private final SnippetReflectionProvider snippetReflection;
    45     private final ForeignCallsProvider foreignCalls;
    48     private final ForeignCallsProvider foreignCalls;
    46     private final WordTypes wordTypes;
    49     private final WordTypes wordTypes;
       
    50     private final TargetDescription target;
    47 
    51 
    48     public NodeIntrinsificationProvider(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, WordTypes wordTypes) {
    52     public NodeIntrinsificationProvider(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, WordTypes wordTypes, TargetDescription target) {
    49         this.metaAccess = metaAccess;
    53         this.metaAccess = metaAccess;
    50         this.snippetReflection = snippetReflection;
    54         this.snippetReflection = snippetReflection;
    51         this.foreignCalls = foreignCalls;
    55         this.foreignCalls = foreignCalls;
    52         this.wordTypes = wordTypes;
    56         this.wordTypes = wordTypes;
       
    57         this.target = target;
    53     }
    58     }
    54 
    59 
    55     @Override
    60     @Override
    56     public Stamp getInjectedStamp(Class<?> type, boolean nonNull) {
    61     public Stamp getInjectedStamp(Class<?> type, boolean nonNull) {
    57         JavaKind kind = JavaKind.fromJavaClass(type);
    62         JavaKind kind = JavaKind.fromJavaClass(type);
    76             return type.cast(foreignCalls);
    81             return type.cast(foreignCalls);
    77         } else if (type.equals(SnippetReflectionProvider.class)) {
    82         } else if (type.equals(SnippetReflectionProvider.class)) {
    78             return type.cast(snippetReflection);
    83             return type.cast(snippetReflection);
    79         } else if (type.equals(WordTypes.class)) {
    84         } else if (type.equals(WordTypes.class)) {
    80             return type.cast(wordTypes);
    85             return type.cast(wordTypes);
       
    86         } else if (type.equals(TargetDescription.class)) {
       
    87             return type.cast(target);
    81         } else {
    88         } else {
    82             throw new GraalError("Cannot handle injected argument of type %s.", type.getName());
    89             throw new GraalError("Cannot handle injected argument of type %s.", type.getName());
    83         }
    90         }
    84     }
    91     }
    85 }
    92 }