rev 52889 : 8214023: Update Graal

   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.hotspot.amd64;
  26 
  27 import jdk.vm.ci.meta.JavaKind;
  28 import org.graalvm.compiler.api.replacements.Snippet;
  29 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
  30 import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
  31 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  32 import org.graalvm.compiler.hotspot.stubs.SnippetStub;
  33 import org.graalvm.compiler.options.OptionValues;
  34 import org.graalvm.compiler.replacements.amd64.AMD64ArrayIndexOfNode;
  35 import jdk.internal.vm.compiler.word.Pointer;
  36 
  37 public class AMD64ArrayIndexOfStub extends SnippetStub {
  38 
  39     public AMD64ArrayIndexOfStub(ForeignCallDescriptor foreignCallDescriptor, OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
  40         super(foreignCallDescriptor.getName(), options, providers, linkage);
  41     }
  42 
  43     @Snippet
  44     private static int indexOfTwoConsecutiveBytes(Pointer arrayPointer, int arrayLength, int searchValue) {
  45         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Byte, true, arrayPointer, arrayLength, searchValue);
  46     }
  47 
  48     @Snippet
  49     private static int indexOfTwoConsecutiveChars(Pointer arrayPointer, int arrayLength, int searchValue) {
  50         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Char, true, arrayPointer, arrayLength, searchValue);
  51     }
  52 
  53     @Snippet
  54     private static int indexOf1Byte(Pointer arrayPointer, int arrayLength, byte b) {
  55         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Byte, arrayPointer, arrayLength, b);
  56     }
  57 
  58     @Snippet
  59     private static int indexOf2Bytes(Pointer arrayPointer, int arrayLength, byte b1, byte b2) {
  60         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Byte, arrayPointer, arrayLength, b1, b2);
  61     }
  62 
  63     @Snippet
  64     private static int indexOf3Bytes(Pointer arrayPointer, int arrayLength, byte b1, byte b2, byte b3) {
  65         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Byte, arrayPointer, arrayLength, b1, b2, b3);
  66     }
  67 
  68     @Snippet
  69     private static int indexOf4Bytes(Pointer arrayPointer, int arrayLength, byte b1, byte b2, byte b3, byte b4) {
  70         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Byte, arrayPointer, arrayLength, b1, b2, b3, b4);
  71     }
  72 
  73     @Snippet
  74     private static int indexOf1Char(Pointer arrayPointer, int arrayLength, char c) {
  75         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Char, arrayPointer, arrayLength, c);
  76     }
  77 
  78     @Snippet
  79     private static int indexOf2Chars(Pointer arrayPointer, int arrayLength, char c1, char c2) {
  80         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Char, arrayPointer, arrayLength, c1, c2);
  81     }
  82 
  83     @Snippet
  84     private static int indexOf3Chars(Pointer arrayPointer, int arrayLength, char c1, char c2, char c3) {
  85         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Char, arrayPointer, arrayLength, c1, c2, c3);
  86     }
  87 
  88     @Snippet
  89     private static int indexOf4Chars(Pointer arrayPointer, int arrayLength, char c1, char c2, char c3, char c4) {
  90         return AMD64ArrayIndexOfNode.optimizedArrayIndexOf(JavaKind.Char, arrayPointer, arrayLength, c1, c2, c3, c4);
  91     }
  92 }
--- EOF ---