mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-09 18:08:31 +00:00
8180267: Update Graal
Reviewed-by: iveresov
This commit is contained in:
parent
063286a618
commit
b2d6d6b622
@ -47,6 +47,7 @@ ifeq ($(INCLUDE_GRAAL), true)
|
||||
$(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_MATCH_PROCESSOR, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := \
|
||||
$(SRC_DIR)/org.graalvm.api.word/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.core/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.core.common/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.core.match.processor/src \
|
||||
@ -114,6 +115,7 @@ ifeq ($(INCLUDE_GRAAL), true)
|
||||
$(eval $(call SetupJavaCompilation, BUILD_VM_COMPILER_REPLACEMENTS_VERIFIER, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := \
|
||||
$(SRC_DIR)/org.graalvm.api.word/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.replacements.verifier/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.api.replacements/src \
|
||||
$(SRC_DIR)/org.graalvm.compiler.code/src \
|
||||
|
||||
@ -34,6 +34,7 @@ import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
|
||||
import org.graalvm.api.word.WordBase;
|
||||
import org.graalvm.compiler.api.directives.GraalDirectives;
|
||||
import org.graalvm.compiler.api.replacements.ClassSubstitution;
|
||||
import org.graalvm.compiler.api.replacements.MethodSubstitution;
|
||||
@ -43,7 +44,6 @@ import org.graalvm.compiler.graph.Node.NodeIntrinsic;
|
||||
import org.graalvm.compiler.hotspot.replacements.HotSpotClassSubstitutions;
|
||||
import org.graalvm.compiler.hotspot.word.MetaspacePointer;
|
||||
import org.graalvm.compiler.replacements.Snippets;
|
||||
import org.graalvm.compiler.word.WordBase;
|
||||
|
||||
public class GraalFilters {
|
||||
private List<ResolvedJavaType> specialClasses;
|
||||
|
||||
@ -42,6 +42,7 @@ module jdk.internal.vm.compiler {
|
||||
uses org.graalvm.compiler.options.OptionValuesAccess;
|
||||
uses org.graalvm.compiler.nodes.graphbuilderconf.NodeIntrinsicPluginFactory;
|
||||
|
||||
exports org.graalvm.api.word to jdk.aot;
|
||||
exports org.graalvm.compiler.api.directives to jdk.aot;
|
||||
exports org.graalvm.compiler.api.runtime to jdk.aot;
|
||||
exports org.graalvm.compiler.api.replacements to jdk.aot;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
/**
|
||||
* A {@link Unsigned} value that may be updated atomically. See the
|
||||
@ -36,7 +36,7 @@ public class AtomicUnsigned extends AtomicWord<Unsigned> {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final Unsigned getAndAdd(Unsigned delta) {
|
||||
return Word.unsigned(value.getAndAdd(delta.rawValue()));
|
||||
return WordFactory.unsigned(value.getAndAdd(delta.rawValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +46,7 @@ public class AtomicUnsigned extends AtomicWord<Unsigned> {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final Unsigned addAndGet(Unsigned delta) {
|
||||
return Word.unsigned(value.addAndGet(delta.rawValue()));
|
||||
return WordFactory.unsigned(value.addAndGet(delta.rawValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ public class AtomicUnsigned extends AtomicWord<Unsigned> {
|
||||
* @return the previous value
|
||||
*/
|
||||
public final Unsigned getAndSubtract(Unsigned delta) {
|
||||
return Word.unsigned(value.getAndAdd(-delta.rawValue()));
|
||||
return WordFactory.unsigned(value.getAndAdd(-delta.rawValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,6 +66,6 @@ public class AtomicUnsigned extends AtomicWord<Unsigned> {
|
||||
* @return the updated value
|
||||
*/
|
||||
public final Unsigned subtractAndGet(Unsigned delta) {
|
||||
return Word.unsigned(value.addAndGet(-delta.rawValue()));
|
||||
return WordFactory.unsigned(value.addAndGet(-delta.rawValue()));
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@ -42,7 +42,7 @@ public class AtomicWord<T extends WordBase> {
|
||||
protected final AtomicLong value;
|
||||
|
||||
/**
|
||||
* Creates a new AtomicLong with initial value {@link Word#zero}.
|
||||
* Creates a new AtomicWord with initial value {@link WordFactory#zero}.
|
||||
*/
|
||||
public AtomicWord() {
|
||||
value = new AtomicLong();
|
||||
@ -53,9 +53,8 @@ public class AtomicWord<T extends WordBase> {
|
||||
*
|
||||
* @return the current value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T get() {
|
||||
return (T) Word.unsigned(value.get());
|
||||
return WordFactory.unsigned(value.get());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,9 +72,8 @@ public class AtomicWord<T extends WordBase> {
|
||||
* @param newValue the new value
|
||||
* @return the previous value
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final T getAndSet(T newValue) {
|
||||
return (T) Word.unsigned(value.getAndSet(newValue.rawValue()));
|
||||
return WordFactory.unsigned(value.getAndSet(newValue.rawValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
public interface ComparableWord extends WordBase {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.common;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
// JaCoCo Exclude
|
||||
|
||||
@ -20,19 +20,14 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
|
||||
import org.graalvm.compiler.core.common.LocationIdentity;
|
||||
import org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
/**
|
||||
* Lowest-level memory access of native C memory. These methods access the raw memory without any
|
||||
* Lowest-level memory access of native C memory.
|
||||
* <p>
|
||||
* Do not use these methods to access Java objects. These methods access the raw memory without any
|
||||
* null checks, read- or write barriers. Even when the VM uses compressed pointers, then readObject
|
||||
* and writeObject methods access uncompressed pointers.
|
||||
* <p>
|
||||
* Do not use these methods to access Java objects, i.e., do not use
|
||||
* {@code Word.fromObject(obj).readXxx()}. Instead, use {@link ObjectAccess} or
|
||||
* {@link BarrieredAccess} to access Java objects.
|
||||
*/
|
||||
public interface Pointer extends Unsigned, PointerBase {
|
||||
|
||||
@ -164,7 +159,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
* @param locationIdentity the identity of the read
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Word readWord(WordBase offset, LocationIdentity locationIdentity);
|
||||
<T extends WordBase> T readWord(WordBase offset, LocationIdentity locationIdentity);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
@ -258,7 +253,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
* @param locationIdentity the identity of the read
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Word readWord(int offset, LocationIdentity locationIdentity);
|
||||
<T extends WordBase> T readWord(int offset, LocationIdentity locationIdentity);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
@ -612,7 +607,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
* @param offset the signed offset for the memory access
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Word readWord(WordBase offset);
|
||||
<T extends WordBase> T readWord(WordBase offset);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
@ -627,21 +622,6 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
*/
|
||||
Object readObject(WordBase offset);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. This access will decompress the oop if
|
||||
* the VM uses compressed oops, and it can be parameterized to allow read barriers (G1 referent
|
||||
* field).
|
||||
* <p>
|
||||
* The offset is always treated as a {@link Signed} value. However, the static type is
|
||||
* {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller
|
||||
* knows that the highest-order bit of the unsigned value is never used).
|
||||
*
|
||||
* @param offset the signed offset for the memory access
|
||||
* @param barrierType the type of the read barrier to be added
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Object readObject(WordBase offset, BarrierType barrierType);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
* bytes.
|
||||
@ -712,7 +692,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
* @param offset the signed offset for the memory access
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Word readWord(int offset);
|
||||
<T extends WordBase> T readWord(int offset);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
@ -723,17 +703,6 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
*/
|
||||
Object readObject(int offset);
|
||||
|
||||
/**
|
||||
* Reads the memory at address {@code (this + offset)}. This access will decompress the oop if
|
||||
* the VM uses compressed oops, and it can be parameterized to allow read barriers (G1 referent
|
||||
* field).
|
||||
*
|
||||
* @param offset the signed offset for the memory access
|
||||
* @param barrierType the type of the read barrier to be added
|
||||
* @return the result of the memory access
|
||||
*/
|
||||
Object readObject(int offset, BarrierType barrierType);
|
||||
|
||||
/**
|
||||
* Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
|
||||
* bytes.
|
||||
@ -855,7 +824,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
|
||||
long compareAndSwapLong(WordBase offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
|
||||
|
||||
Word compareAndSwapWord(WordBase offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
|
||||
<T extends WordBase> T compareAndSwapWord(WordBase offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
|
||||
|
||||
Object compareAndSwapObject(WordBase offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
|
||||
|
||||
@ -952,7 +921,7 @@ public interface Pointer extends Unsigned, PointerBase {
|
||||
|
||||
long compareAndSwapLong(int offset, long expectedValue, long newValue, LocationIdentity locationIdentity);
|
||||
|
||||
Word compareAndSwapWord(int offset, WordBase expectedValue, WordBase newValue, LocationIdentity locationIdentity);
|
||||
<T extends WordBase> T compareAndSwapWord(int offset, T expectedValue, T newValue, LocationIdentity locationIdentity);
|
||||
|
||||
Object compareAndSwapObject(int offset, Object expectedValue, Object newValue, LocationIdentity locationIdentity);
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
/**
|
||||
* Marker interface for all {@link WordBase word types} that have the semantic of a pointer (but not
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
/**
|
||||
* Utility methods on Pointers.
|
||||
@ -38,7 +38,7 @@ public final class PointerUtils {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends PointerBase> T nullPointer() {
|
||||
return (T) Word.zero();
|
||||
return (T) WordFactory.zero();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
public interface Signed extends ComparableWord {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
public interface Unsigned extends ComparableWord {
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
/**
|
||||
* Utility methods on Unsigned values.
|
||||
@ -20,9 +20,18 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.word;
|
||||
package org.graalvm.api.word;
|
||||
|
||||
public interface WordBase {
|
||||
|
||||
long rawValue();
|
||||
|
||||
/**
|
||||
* This is deprecated because of the easy to mistype name collision between {@link #equals} and
|
||||
* the other word based equality routines. In general you should never be statically calling
|
||||
* this method anyway.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
boolean equals(Object o);
|
||||
}
|
||||
@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2016, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.api.word;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public abstract class WordFactory {
|
||||
|
||||
/**
|
||||
* Links a method to a canonical operation represented by an {@link FactoryOpcode} val.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
protected @interface FactoryOperation {
|
||||
FactoryOpcode opcode();
|
||||
}
|
||||
|
||||
/**
|
||||
* The canonical {@link FactoryOperation} represented by a method in a word type.
|
||||
*/
|
||||
protected enum FactoryOpcode {
|
||||
ZERO,
|
||||
FROM_UNSIGNED,
|
||||
FROM_SIGNED,
|
||||
}
|
||||
|
||||
protected interface BoxFactory {
|
||||
<T extends WordBase> T box(long val);
|
||||
}
|
||||
|
||||
protected static final BoxFactory boxFactory;
|
||||
|
||||
static {
|
||||
try {
|
||||
/*
|
||||
* We know the implementation class, but cannot reference it statically because we need
|
||||
* to break the dependency between the interface and the implementation.
|
||||
*/
|
||||
boxFactory = (BoxFactory) Class.forName("org.graalvm.compiler.word.Word$BoxFactoryImpl").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
throw new ExceptionInInitializerError("Could not find and initialize the word type factory. The Graal compiler needs to be on the class path to use the word type.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We allow subclassing, because only subclasses can access the protected inner classes that we
|
||||
* use to mark the operations.
|
||||
*/
|
||||
protected WordFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The constant 0, i.e., the word with no bits set. There is no difference between a signed and
|
||||
* unsigned zero.
|
||||
*
|
||||
* @return the constant 0.
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.ZERO)
|
||||
public static <T extends WordBase> T zero() {
|
||||
return boxFactory.box(0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe conversion from a Java long value to a Word. The parameter is treated as an unsigned
|
||||
* 64-bit value (in contrast to the semantics of a Java long).
|
||||
*
|
||||
* @param val a 64 bit unsigned value
|
||||
* @return the value cast to Word
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.FROM_UNSIGNED)
|
||||
public static <T extends Unsigned> T unsigned(long val) {
|
||||
return boxFactory.box(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe conversion from a Java long value to a {@link PointerBase pointer}. The parameter is
|
||||
* treated as an unsigned 64-bit value (in contrast to the semantics of a Java long).
|
||||
*
|
||||
* @param val a 64 bit unsigned value
|
||||
* @return the value cast to PointerBase
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.FROM_UNSIGNED)
|
||||
public static <T extends PointerBase> T pointer(long val) {
|
||||
return boxFactory.box(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe conversion from a Java int value to a Word. The parameter is treated as an unsigned
|
||||
* 32-bit value (in contrast to the semantics of a Java int).
|
||||
*
|
||||
* @param val a 32 bit unsigned value
|
||||
* @return the value cast to Word
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.FROM_UNSIGNED)
|
||||
public static <T extends Unsigned> T unsigned(int val) {
|
||||
return boxFactory.box(val & 0xffffffffL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe conversion from a Java long value to a Word. The parameter is treated as a signed
|
||||
* 64-bit value (unchanged semantics of a Java long).
|
||||
*
|
||||
* @param val a 64 bit signed value
|
||||
* @return the value cast to Word
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.FROM_SIGNED)
|
||||
public static <T extends Signed> T signed(long val) {
|
||||
return boxFactory.box(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsafe conversion from a Java int value to a Word. The parameter is treated as a signed
|
||||
* 32-bit value (unchanged semantics of a Java int).
|
||||
*
|
||||
* @param val a 32 bit signed value
|
||||
* @return the value cast to Word
|
||||
*/
|
||||
@FactoryOperation(opcode = FactoryOpcode.FROM_SIGNED)
|
||||
public static <T extends Signed> T signed(int val) {
|
||||
return boxFactory.box(val);
|
||||
}
|
||||
}
|
||||
@ -24,13 +24,13 @@ package org.graalvm.compiler.api.test;
|
||||
|
||||
import java.util.Formatter;
|
||||
|
||||
import org.graalvm.compiler.api.runtime.GraalJVMCICompiler;
|
||||
import org.graalvm.compiler.api.runtime.GraalRuntime;
|
||||
|
||||
import jdk.vm.ci.runtime.JVMCI;
|
||||
import jdk.vm.ci.runtime.JVMCICompiler;
|
||||
import jdk.vm.ci.services.Services;
|
||||
|
||||
import org.graalvm.compiler.api.runtime.GraalJVMCICompiler;
|
||||
import org.graalvm.compiler.api.runtime.GraalRuntime;
|
||||
|
||||
/**
|
||||
* Access point for {@linkplain #getRuntime() retrieving} the {@link GraalRuntime} instance of the
|
||||
* system compiler from unit tests.
|
||||
@ -40,7 +40,7 @@ public class Graal {
|
||||
private static final GraalRuntime runtime = initializeRuntime();
|
||||
|
||||
private static GraalRuntime initializeRuntime() {
|
||||
Services.exportJVMCITo(Graal.class);
|
||||
Services.initializeJVMCI();
|
||||
JVMCICompiler compiler = JVMCI.getRuntime().getCompiler();
|
||||
if (compiler instanceof GraalJVMCICompiler) {
|
||||
GraalJVMCICompiler graal = (GraalJVMCICompiler) compiler;
|
||||
|
||||
@ -27,6 +27,16 @@ import static org.junit.Assume.assumeTrue;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.graalvm.compiler.asm.amd64.AMD64Assembler;
|
||||
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
|
||||
import org.graalvm.compiler.asm.test.AssemblerTest;
|
||||
import org.graalvm.compiler.code.CompilationResult;
|
||||
import org.graalvm.compiler.code.DataSection.Data;
|
||||
import org.graalvm.compiler.code.DataSection.RawData;
|
||||
import org.graalvm.compiler.code.DataSection.SerializableData;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.amd64.AMD64;
|
||||
import jdk.vm.ci.code.CallingConvention;
|
||||
import jdk.vm.ci.code.Register;
|
||||
@ -36,17 +46,6 @@ import jdk.vm.ci.code.site.DataSectionReference;
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.asm.amd64.AMD64Assembler;
|
||||
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
|
||||
import org.graalvm.compiler.asm.test.AssemblerTest;
|
||||
import org.graalvm.compiler.code.CompilationResult;
|
||||
import org.graalvm.compiler.code.DataSection.Data;
|
||||
import org.graalvm.compiler.code.DataSection.RawData;
|
||||
import org.graalvm.compiler.code.DataSection.SerializableData;
|
||||
|
||||
public class SimpleAssemblerTest extends AssemblerTest {
|
||||
|
||||
@Before
|
||||
|
||||
@ -37,7 +37,6 @@ import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.options.OptionValues;
|
||||
import org.graalvm.compiler.runtime.RuntimeProvider;
|
||||
import org.graalvm.compiler.serviceprovider.GraalServices;
|
||||
import org.graalvm.compiler.test.AddExports;
|
||||
import org.graalvm.compiler.test.GraalTest;
|
||||
import org.junit.Assert;
|
||||
|
||||
@ -52,7 +51,6 @@ import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
import jdk.vm.ci.runtime.JVMCI;
|
||||
import jdk.vm.ci.runtime.JVMCIBackend;
|
||||
|
||||
@AddExports("jdk.internal.vm.ci/jdk.vm.ci.runtime")
|
||||
public abstract class AssemblerTest extends GraalTest {
|
||||
|
||||
private final MetaAccessProvider metaAccess;
|
||||
|
||||
@ -63,6 +63,11 @@ public interface Bytecode {
|
||||
|
||||
ExceptionHandler[] getExceptionHandlers();
|
||||
|
||||
/**
|
||||
* Gets the {@link BytecodeProvider} from which this object was acquired.
|
||||
*/
|
||||
BytecodeProvider getOrigin();
|
||||
|
||||
static String toLocation(Bytecode bytecode, int bci) {
|
||||
return appendLocation(new StringBuilder(), bytecode, bci).toString();
|
||||
}
|
||||
|
||||
@ -36,9 +36,20 @@ import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
public class ResolvedJavaMethodBytecode implements Bytecode {
|
||||
|
||||
private final ResolvedJavaMethod method;
|
||||
private final BytecodeProvider origin;
|
||||
|
||||
public ResolvedJavaMethodBytecode(ResolvedJavaMethod method) {
|
||||
this(method, ResolvedJavaMethodBytecodeProvider.INSTANCE);
|
||||
}
|
||||
|
||||
public ResolvedJavaMethodBytecode(ResolvedJavaMethod method, BytecodeProvider origin) {
|
||||
this.method = method;
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BytecodeProvider getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -29,9 +29,14 @@ import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
*/
|
||||
public class ResolvedJavaMethodBytecodeProvider implements BytecodeProvider {
|
||||
|
||||
/**
|
||||
* A state-less, shared {@link ResolvedJavaMethodBytecodeProvider} instance.
|
||||
*/
|
||||
public static final ResolvedJavaMethodBytecodeProvider INSTANCE = new ResolvedJavaMethodBytecodeProvider();
|
||||
|
||||
@Override
|
||||
public Bytecode getBytecode(ResolvedJavaMethod method) {
|
||||
return new ResolvedJavaMethodBytecode(method);
|
||||
return new ResolvedJavaMethodBytecode(method, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -66,4 +66,13 @@ public class AArch64LIRKindTool implements LIRKindTool {
|
||||
return LIRKind.value(AArch64Kind.QWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AArch64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowPointerKind() {
|
||||
return LIRKind.value(AArch64Kind.DWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,4 +66,13 @@ public class AMD64LIRKindTool implements LIRKindTool {
|
||||
return LIRKind.value(AMD64Kind.QWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AMD64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowPointerKind() {
|
||||
return LIRKind.value(AMD64Kind.DWORD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig;
|
||||
|
||||
import jdk.vm.ci.code.Architecture;
|
||||
import jdk.vm.ci.meta.AllocatableValue;
|
||||
@ -169,23 +169,6 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
return inputs[0].getValueKind(LIRKind.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the types of the inputs. The result will have the {@link PlatformKind} of one of the
|
||||
* inputs. If all inputs are values (references), the result is a value (reference). Otherwise,
|
||||
* the result is an unknown reference.
|
||||
*
|
||||
* This method should be used to construct the result {@link LIRKind} of merge operation that
|
||||
* does not modify values (e.g. phis).
|
||||
*/
|
||||
public static LIRKind merge(Value... inputs) {
|
||||
assert inputs.length > 0;
|
||||
ArrayList<LIRKind> kinds = new ArrayList<>(inputs.length);
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
kinds.add(inputs[i].getValueKind(LIRKind.class));
|
||||
}
|
||||
return merge(kinds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to construct derived reference kinds. Returns the base value of a reference or
|
||||
* derived reference. For values it returns {@code null}, and for unknown references it returns
|
||||
@ -228,62 +211,62 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #merge(Value...)
|
||||
* Merges the reference information of the inputs. The result will have the {@link PlatformKind}
|
||||
* of {@code mergeKind}. If all inputs are values (references), the result is a value
|
||||
* (reference). Otherwise, the result is an unknown reference.
|
||||
*
|
||||
* The correctness of the {@link PlatformKind} is not verified.
|
||||
*/
|
||||
public static LIRKind merge(Iterable<LIRKind> kinds) {
|
||||
LIRKind mergeKind = null;
|
||||
public static LIRKind mergeReferenceInformation(LIRKind mergeKind, LIRKind inputKind) {
|
||||
assert mergeKind != null;
|
||||
assert inputKind != null;
|
||||
|
||||
for (LIRKind kind : kinds) {
|
||||
if (mergeKind.isUnknownReference()) {
|
||||
/**
|
||||
* {@code mergeKind} is an unknown reference, therefore the result can only be also an
|
||||
* unknown reference.
|
||||
*/
|
||||
return mergeKind;
|
||||
}
|
||||
|
||||
if (kind.isUnknownReference()) {
|
||||
/**
|
||||
* Kind is an unknown reference, therefore the result can only be also an unknown
|
||||
* reference.
|
||||
if (mergeKind.isValue()) {
|
||||
/* {@code mergeKind} is a value. */
|
||||
if (!inputKind.isValue()) {
|
||||
/*
|
||||
* Inputs consists of values and references. Make the result an unknown reference.
|
||||
*/
|
||||
mergeKind = kind;
|
||||
break;
|
||||
return mergeKind.makeUnknownReference();
|
||||
}
|
||||
if (mergeKind == null) {
|
||||
mergeKind = kind;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kind.isValue()) {
|
||||
/* Kind is a value. */
|
||||
if (mergeKind.referenceMask != 0) {
|
||||
/*
|
||||
* Inputs consists of values and references. Make the result an unknown
|
||||
* reference.
|
||||
*/
|
||||
mergeKind = mergeKind.makeUnknownReference();
|
||||
break;
|
||||
}
|
||||
/* Check that other inputs are also values. */
|
||||
} else {
|
||||
/* Kind is a reference. */
|
||||
if (mergeKind.referenceMask != kind.referenceMask) {
|
||||
/*
|
||||
* Reference maps do not match so the result can only be an unknown reference.
|
||||
*/
|
||||
mergeKind = mergeKind.makeUnknownReference();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return mergeKind;
|
||||
}
|
||||
/* {@code mergeKind} is a reference. */
|
||||
if (mergeKind.referenceMask != inputKind.referenceMask) {
|
||||
/*
|
||||
* Reference masks do not match so the result can only be an unknown reference.
|
||||
*/
|
||||
return mergeKind.makeUnknownReference();
|
||||
}
|
||||
assert mergeKind != null && verifyMerge(mergeKind, kinds);
|
||||
|
||||
// all inputs are values or references, just return one of them
|
||||
/* Both are references. */
|
||||
if (mergeKind.isDerivedReference()) {
|
||||
if (inputKind.isDerivedReference() && mergeKind.getDerivedReferenceBase().equals(inputKind.getDerivedReferenceBase())) {
|
||||
/* Same reference base so they must be equal. */
|
||||
return mergeKind;
|
||||
}
|
||||
/* Base pointers differ. Make the result an unknown reference. */
|
||||
return mergeKind.makeUnknownReference();
|
||||
}
|
||||
if (inputKind.isDerivedReference()) {
|
||||
/*
|
||||
* {@code mergeKind} is not derived but {@code inputKind} is. Make the result an unknown
|
||||
* reference.
|
||||
*/
|
||||
return mergeKind.makeUnknownReference();
|
||||
}
|
||||
/* Both are not derived references so they must be equal. */
|
||||
return mergeKind;
|
||||
}
|
||||
|
||||
private static boolean verifyMerge(LIRKind mergeKind, Iterable<LIRKind> kinds) {
|
||||
for (LIRKind kind : kinds) {
|
||||
assert mergeKind == null || verifyMoveKinds(mergeKind, kind) : String.format("Input kinds do not match %s vs. %s", mergeKind, kind);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link LIRKind} with the same reference information and a new
|
||||
* {@linkplain #getPlatformKind platform kind}. If the new kind is a longer vector than this,
|
||||
@ -447,6 +430,7 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getPlatformKind() == null) ? 0 : getPlatformKind().hashCode());
|
||||
result = prime * result + ((getDerivedReferenceBase() == null) ? 0 : getDerivedReferenceBase().hashCode());
|
||||
result = prime * result + referenceMask;
|
||||
return result;
|
||||
}
|
||||
@ -461,16 +445,37 @@ public final class LIRKind extends ValueKind<LIRKind> {
|
||||
}
|
||||
|
||||
LIRKind other = (LIRKind) obj;
|
||||
return getPlatformKind() == other.getPlatformKind() && referenceMask == other.referenceMask;
|
||||
if (getPlatformKind() != other.getPlatformKind() || referenceMask != other.referenceMask) {
|
||||
return false;
|
||||
}
|
||||
if (isDerivedReference()) {
|
||||
if (!other.isDerivedReference()) {
|
||||
return false;
|
||||
}
|
||||
return getDerivedReferenceBase().equals(other.getDerivedReferenceBase());
|
||||
}
|
||||
// `this` is not a derived reference
|
||||
if (other.isDerivedReference()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean verifyMoveKinds(ValueKind<?> dst, ValueKind<?> src) {
|
||||
public static boolean verifyMoveKinds(ValueKind<?> dst, ValueKind<?> src, RegisterAllocationConfig config) {
|
||||
if (src.equals(dst)) {
|
||||
return true;
|
||||
}
|
||||
if (src.getPlatformKind().equals(dst.getPlatformKind())) {
|
||||
return !isUnknownReference(src) || isUnknownReference(dst);
|
||||
if (isUnknownReference(dst) || isValue(dst) && isValue(src)) {
|
||||
PlatformKind srcPlatformKind = src.getPlatformKind();
|
||||
PlatformKind dstPlatformKind = dst.getPlatformKind();
|
||||
if (srcPlatformKind.equals(dstPlatformKind)) {
|
||||
return true;
|
||||
}
|
||||
// if the register category matches it should be fine, although the kind is different
|
||||
return config.getRegisterCategory(srcPlatformKind).equals(config.getRegisterCategory(dstPlatformKind));
|
||||
}
|
||||
// reference information mismatch
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import org.graalvm.util.EconomicMap;
|
||||
import org.graalvm.util.Equivalence;
|
||||
|
||||
import jdk.vm.ci.code.Register;
|
||||
import jdk.vm.ci.code.Register.RegisterCategory;
|
||||
import jdk.vm.ci.code.RegisterArray;
|
||||
import jdk.vm.ci.code.RegisterConfig;
|
||||
import jdk.vm.ci.meta.PlatformKind;
|
||||
@ -120,6 +121,13 @@ public class RegisterAllocationConfig {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link RegisterCategory} for the given {@link PlatformKind}.
|
||||
*/
|
||||
public RegisterCategory getRegisterCategory(PlatformKind kind) {
|
||||
return getAllocatableRegisters(kind).allocatableRegisters[0].getRegisterCategory();
|
||||
}
|
||||
|
||||
protected AllocatableRegisters createAllocatableRegisters(RegisterArray registers) {
|
||||
int min = Integer.MAX_VALUE;
|
||||
int max = Integer.MIN_VALUE;
|
||||
|
||||
@ -22,8 +22,8 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.common.spi;
|
||||
|
||||
import org.graalvm.api.word.LocationIdentity;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.core.common.LocationIdentity;
|
||||
|
||||
import jdk.vm.ci.code.ValueKindFactory;
|
||||
|
||||
|
||||
@ -48,4 +48,14 @@ public interface LIRKindTool {
|
||||
* Get the architecture specific kind pointer-sized integer kind.
|
||||
*/
|
||||
LIRKind getWordKind();
|
||||
|
||||
/**
|
||||
* Get the platform specific kind used to represent compressed oops.
|
||||
*/
|
||||
LIRKind getNarrowOopKind();
|
||||
|
||||
/**
|
||||
* Gets the platform specific kind used to represent compressed metaspace pointers.
|
||||
*/
|
||||
LIRKind getNarrowPointerKind();
|
||||
}
|
||||
|
||||
@ -80,6 +80,14 @@ public class ObjectStamp extends AbstractObjectStamp {
|
||||
|
||||
@Override
|
||||
public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
|
||||
return provider.readObjectConstant(base, displacement);
|
||||
try {
|
||||
return provider.readObjectConstant(base, displacement);
|
||||
} catch (IllegalArgumentException e) {
|
||||
/*
|
||||
* It's possible that the base and displacement aren't valid together so simply return
|
||||
* null.
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,15 @@ public abstract class PrimitiveStamp extends ArithmeticStamp {
|
||||
|
||||
@Override
|
||||
public Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement) {
|
||||
return provider.readPrimitiveConstant(getStackKind(), base, displacement, getBits());
|
||||
try {
|
||||
return provider.readPrimitiveConstant(getStackKind(), base, displacement, getBits());
|
||||
} catch (IllegalArgumentException e) {
|
||||
/*
|
||||
* It's possible that the base and displacement aren't valid together so simply return
|
||||
* null.
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -145,6 +145,8 @@ public abstract class Stamp {
|
||||
|
||||
/**
|
||||
* Read a value of this stamp from memory.
|
||||
*
|
||||
* @return the value read or null if the value can't be read for some reason.
|
||||
*/
|
||||
public abstract Constant readConstant(MemoryAccessProvider provider, Constant base, long displacement);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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
|
||||
@ -22,13 +22,14 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.common.util;
|
||||
|
||||
import static org.graalvm.compiler.core.common.util.Util.JAVA_SPECIFICATION_VERSION;
|
||||
import static org.graalvm.compiler.serviceprovider.JDK9Method.JAVA_SPECIFICATION_VERSION;
|
||||
|
||||
import java.lang.reflect.AccessibleObject;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.graalvm.compiler.debug.GraalError;
|
||||
|
||||
/**
|
||||
* Reflection based access to the Module API introduced by JDK 9. This allows the API to be used in
|
||||
* code that must be compiled on a JDK prior to 9. Use of this class must be guarded by a test for
|
||||
@ -42,47 +43,30 @@ import java.lang.reflect.Modifier;
|
||||
*/
|
||||
public final class ModuleAPI {
|
||||
|
||||
private ModuleAPI(Method method) {
|
||||
this.method = method;
|
||||
public ModuleAPI(Class<?> declaringClass, String name, Class<?>... parameterTypes) {
|
||||
try {
|
||||
this.method = declaringClass.getMethod(name, parameterTypes);
|
||||
} catch (Exception e) {
|
||||
throw new GraalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private final Method method;
|
||||
public final Method method;
|
||||
|
||||
public Class<?> getReturnType() {
|
||||
return method.getReturnType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code Class.getModule()}.
|
||||
*/
|
||||
public static final ModuleAPI getModule;
|
||||
|
||||
/**
|
||||
* {@code jdk.internal.module.Modules.addExports(Module, String, Module)}.
|
||||
*/
|
||||
public static final ModuleAPI addExports;
|
||||
|
||||
/**
|
||||
* {@code jdk.internal.module.Modules.addOpens(Module, String, Module)}.
|
||||
*/
|
||||
public static final ModuleAPI addOpens;
|
||||
|
||||
/**
|
||||
* {@code java.lang.Module.getResourceAsStream(String)}.
|
||||
*/
|
||||
public static final ModuleAPI getResourceAsStream;
|
||||
|
||||
/**
|
||||
* {@code java.lang.Module.getPackages()}.
|
||||
*/
|
||||
public static final ModuleAPI getPackages;
|
||||
|
||||
/**
|
||||
* {@code java.lang.Module.canRead(Module)}.
|
||||
*/
|
||||
public static final ModuleAPI canRead;
|
||||
|
||||
/**
|
||||
* {@code java.lang.Module.isExported(String)}.
|
||||
*/
|
||||
public static final ModuleAPI isExported;
|
||||
|
||||
/**
|
||||
* {@code java.lang.Module.isExported(String, Module)}.
|
||||
*/
|
||||
@ -98,7 +82,7 @@ public final class ModuleAPI {
|
||||
try {
|
||||
return (T) method.invoke(null, args);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
throw new InternalError(e);
|
||||
throw new GraalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,84 +96,31 @@ public final class ModuleAPI {
|
||||
try {
|
||||
return (T) method.invoke(receiver, args);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
throw new InternalError(e);
|
||||
throw new GraalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens all packages in {@code moduleMember}'s module for deep reflection (i.e., allow
|
||||
* {@link AccessibleObject#setAccessible(boolean)} to be called for any class/method/field) by
|
||||
* {@code requestor}'s module.
|
||||
*/
|
||||
public static void openAllPackagesForReflectionTo(Class<?> moduleMember, Class<?> requestor) {
|
||||
Object moduleToOpen = getModule.invoke(moduleMember);
|
||||
Object requestorModule = getModule.invoke(requestor);
|
||||
if (moduleToOpen != requestorModule) {
|
||||
String[] packages = getPackages.invoke(moduleToOpen);
|
||||
for (String pkg : packages) {
|
||||
addOpens.invokeStatic(moduleToOpen, pkg, requestorModule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens {@code declaringClass}'s package to allow a method declared in {@code accessor} to call
|
||||
* {@link AccessibleObject#setAccessible(boolean)} on an {@link AccessibleObject} representing a
|
||||
* field or method declared by {@code declaringClass}.
|
||||
*/
|
||||
public static void openForReflectionTo(Class<?> declaringClass, Class<?> accessor) {
|
||||
Object moduleToOpen = getModule.invoke(declaringClass);
|
||||
Object accessorModule = getModule.invoke(accessor);
|
||||
if (moduleToOpen != accessorModule) {
|
||||
addOpens.invokeStatic(moduleToOpen, declaringClass.getPackage().getName(), accessorModule);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the package named {@code packageName} declared in {@code moduleMember}'s module to
|
||||
* {@code requestor}'s module.
|
||||
*/
|
||||
public static void exportPackageTo(Class<?> moduleMember, String packageName, Class<?> requestor) {
|
||||
Object moduleToExport = getModule.invoke(moduleMember);
|
||||
Object requestorModule = getModule.invoke(requestor);
|
||||
if (moduleToExport != requestorModule) {
|
||||
addExports.invokeStatic(moduleToExport, packageName, requestorModule);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAvailability() throws InternalError {
|
||||
private void checkAvailability() throws GraalError {
|
||||
if (method == null) {
|
||||
throw new InternalError("Cannot use Module API on JDK " + JAVA_SPECIFICATION_VERSION);
|
||||
throw new GraalError("Cannot use Module API on JDK " + JAVA_SPECIFICATION_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
if (JAVA_SPECIFICATION_VERSION >= 9) {
|
||||
try {
|
||||
getModule = new ModuleAPI(Class.class.getMethod("getModule"));
|
||||
Class<?> moduleClass = getModule.method.getReturnType();
|
||||
Class<?> modulesClass = Class.forName("jdk.internal.module.Modules");
|
||||
getResourceAsStream = new ModuleAPI(moduleClass.getMethod("getResourceAsStream", String.class));
|
||||
getPackages = new ModuleAPI(moduleClass.getMethod("getPackages"));
|
||||
canRead = new ModuleAPI(moduleClass.getMethod("canRead", moduleClass));
|
||||
isExported = new ModuleAPI(moduleClass.getMethod("isExported", String.class));
|
||||
isExportedTo = new ModuleAPI(moduleClass.getMethod("isExported", String.class, moduleClass));
|
||||
addExports = new ModuleAPI(modulesClass.getDeclaredMethod("addExports", moduleClass, String.class, moduleClass));
|
||||
addOpens = new ModuleAPI(modulesClass.getDeclaredMethod("addOpens", moduleClass, String.class, moduleClass));
|
||||
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
getModule = new ModuleAPI(Class.class, "getModule");
|
||||
Class<?> moduleClass = getModule.getReturnType();
|
||||
getResourceAsStream = new ModuleAPI(moduleClass, "getResourceAsStream", String.class);
|
||||
isExportedTo = new ModuleAPI(moduleClass, "isExported", String.class, moduleClass);
|
||||
} else {
|
||||
ModuleAPI unavailable = new ModuleAPI(null);
|
||||
ModuleAPI unavailable = new ModuleAPI();
|
||||
getModule = unavailable;
|
||||
getResourceAsStream = unavailable;
|
||||
getPackages = unavailable;
|
||||
canRead = unavailable;
|
||||
isExported = unavailable;
|
||||
isExportedTo = unavailable;
|
||||
addExports = unavailable;
|
||||
addOpens = unavailable;
|
||||
}
|
||||
}
|
||||
|
||||
private ModuleAPI() {
|
||||
method = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,25 +39,6 @@ import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
private static int getJavaSpecificationVersion() {
|
||||
String value = System.getProperty("java.specification.version");
|
||||
if (value.startsWith("1.")) {
|
||||
value = value.substring(2);
|
||||
}
|
||||
return Integer.parseInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The integer value corresponding to the value of the {@code java.specification.version} system
|
||||
* property after any leading {@code "1."} has been stripped.
|
||||
*/
|
||||
public static final int JAVA_SPECIFICATION_VERSION = getJavaSpecificationVersion();
|
||||
|
||||
/**
|
||||
* Determines if the Java runtime is version 8 or earlier.
|
||||
*/
|
||||
public static final boolean Java8OrEarlier = JAVA_SPECIFICATION_VERSION <= 8;
|
||||
|
||||
/**
|
||||
* Statically cast an object to an arbitrary Object type. Dynamically checked.
|
||||
*/
|
||||
@ -193,9 +174,6 @@ public class Util {
|
||||
* {@code flag}.
|
||||
*/
|
||||
public static void setAccessible(Field field, boolean flag) {
|
||||
if (!Java8OrEarlier) {
|
||||
ModuleAPI.openForReflectionTo(field.getDeclaringClass(), Util.class);
|
||||
}
|
||||
field.setAccessible(flag);
|
||||
}
|
||||
|
||||
@ -204,9 +182,6 @@ public class Util {
|
||||
* {@code flag}.
|
||||
*/
|
||||
public static void setAccessible(Executable executable, boolean flag) {
|
||||
if (!Java8OrEarlier) {
|
||||
ModuleAPI.openForReflectionTo(executable.getDeclaringClass(), Util.class);
|
||||
}
|
||||
executable.setAccessible(flag);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,4 +65,14 @@ public class SPARCLIRKindTool implements LIRKindTool {
|
||||
public LIRKind getWordKind() {
|
||||
return LIRKind.value(SPARCKind.XWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(SPARCKind.WORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowPointerKind() {
|
||||
return LIRKind.value(SPARCKind.WORD);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.graalvm.api.word.LocationIdentity;
|
||||
import org.graalvm.compiler.api.replacements.Snippet;
|
||||
import org.graalvm.compiler.api.replacements.Snippet.ConstantParameter;
|
||||
import org.graalvm.compiler.api.replacements.Snippet.NonNullParameter;
|
||||
@ -50,7 +51,6 @@ import org.graalvm.compiler.bytecode.BridgeMethodUtils;
|
||||
import org.graalvm.compiler.core.CompilerThreadFactory;
|
||||
import org.graalvm.compiler.core.CompilerThreadFactory.DebugConfigAccess;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.core.common.LocationIdentity;
|
||||
import org.graalvm.compiler.core.common.type.ArithmeticOpTable;
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.DebugConfigScope;
|
||||
@ -79,6 +79,7 @@ import org.graalvm.compiler.phases.util.Providers;
|
||||
import org.graalvm.compiler.phases.verify.VerifyBailoutUsage;
|
||||
import org.graalvm.compiler.phases.verify.VerifyCallerSensitiveMethods;
|
||||
import org.graalvm.compiler.phases.verify.VerifyDebugUsage;
|
||||
import org.graalvm.compiler.phases.verify.VerifyInstanceOfUsage;
|
||||
import org.graalvm.compiler.phases.verify.VerifyUpdateUsages;
|
||||
import org.graalvm.compiler.phases.verify.VerifyUsageWithEquals;
|
||||
import org.graalvm.compiler.phases.verify.VerifyVirtualizableUsage;
|
||||
@ -167,7 +168,7 @@ public class CheckGraalInvariants extends GraalCompilerTest {
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
@ -365,6 +366,7 @@ public class CheckGraalInvariants extends GraalCompilerTest {
|
||||
new VerifyVirtualizableUsage().apply(graph, context);
|
||||
new VerifyUpdateUsages().apply(graph, context);
|
||||
new VerifyBailoutUsage().apply(graph, context);
|
||||
new VerifyInstanceOfUsage().apply(graph, context);
|
||||
if (graph.method().isBridge()) {
|
||||
BridgeMethodUtils.getBridgedMethod(graph.method());
|
||||
}
|
||||
|
||||
@ -28,14 +28,11 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
|
||||
import org.graalvm.compiler.core.common.calc.Condition;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.core.common.calc.Condition;
|
||||
import org.graalvm.compiler.test.AddExports;
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
|
||||
@AddExports("jdk.internal.vm.ci/jdk.vm.ci.meta")
|
||||
public class ConditionTest {
|
||||
|
||||
@Test
|
||||
|
||||
@ -25,7 +25,7 @@ package org.graalvm.compiler.core.test;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.tiers.HighTierContext;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -75,9 +75,11 @@ public class ConditionalEliminationMulTest extends GraalCompilerTest {
|
||||
private StructuredGraph prepareGraph(String snippet) {
|
||||
StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
|
||||
HighTierContext context = getDefaultHighTierContext();
|
||||
DominatorConditionalEliminationPhase.create(false).apply(graph, context);
|
||||
new ConditionalEliminationPhase(false).apply(graph, context);
|
||||
CanonicalizerPhase c = new CanonicalizerPhase();
|
||||
c.apply(graph, context);
|
||||
new ConditionalEliminationPhase(false).apply(graph, context);
|
||||
c.apply(graph, context);
|
||||
return graph;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,9 +26,8 @@ import org.graalvm.compiler.api.directives.GraalDirectives;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest1 extends ConditionalEliminationTestBase {
|
||||
protected static int sink3;
|
||||
|
||||
@ -22,22 +22,21 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.api.directives.GraalDirectives;
|
||||
import org.graalvm.compiler.nodes.GuardNode;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.nodes.spi.LoweringTool;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.LoweringPhase;
|
||||
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* This test checks the combined action of
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} and
|
||||
* {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase} and
|
||||
* {@link org.graalvm.compiler.phases.common.LoweringPhase}. The lowering phase needs to introduce
|
||||
* the null checks at the correct places for the dominator conditional elimination phase to pick
|
||||
* them up.
|
||||
@ -95,7 +94,7 @@ public class ConditionalEliminationTest10 extends ConditionalEliminationTestBase
|
||||
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
|
||||
PhaseContext context = new PhaseContext(getProviders());
|
||||
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
|
||||
DominatorConditionalEliminationPhase.create(true).apply(graph, context);
|
||||
new ConditionalEliminationPhase(true).apply(graph, context);
|
||||
Assert.assertEquals(guardCount, graph.getNodes().filter(GuardNode.class).count());
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,9 +27,8 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest11 extends ConditionalEliminationTestBase {
|
||||
@SuppressWarnings("all")
|
||||
|
||||
@ -22,22 +22,20 @@
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.nodes.GuardNode;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.nodes.spi.LoweringTool;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.FloatingReadPhase;
|
||||
import org.graalvm.compiler.phases.common.LoweringPhase;
|
||||
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest2 extends ConditionalEliminationTestBase {
|
||||
|
||||
@ -103,7 +101,7 @@ public class ConditionalEliminationTest2 extends ConditionalEliminationTestBase
|
||||
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
|
||||
canonicalizer.apply(graph, context);
|
||||
new FloatingReadPhase().apply(graph);
|
||||
DominatorConditionalEliminationPhase.create(true).apply(graph, context);
|
||||
new ConditionalEliminationPhase(true).apply(graph, context);
|
||||
canonicalizer.apply(graph, context);
|
||||
|
||||
assertDeepEquals(1, graph.getNodes().filter(GuardNode.class).count());
|
||||
@ -125,7 +123,7 @@ public class ConditionalEliminationTest2 extends ConditionalEliminationTestBase
|
||||
|
||||
new LoweringPhase(canonicalizer, LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
|
||||
canonicalizer.apply(graph, context);
|
||||
DominatorConditionalEliminationPhase.create(true).apply(graph, context);
|
||||
new ConditionalEliminationPhase(true).apply(graph, context);
|
||||
canonicalizer.apply(graph, context);
|
||||
|
||||
assertDeepEquals(0, graph.getNodes().filter(GuardNode.class).count());
|
||||
|
||||
@ -26,9 +26,8 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
@Ignore
|
||||
public class ConditionalEliminationTest3 extends ConditionalEliminationTestBase {
|
||||
|
||||
@ -25,9 +25,8 @@ package org.graalvm.compiler.core.test;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest4 extends ConditionalEliminationTestBase {
|
||||
|
||||
|
||||
@ -27,9 +27,8 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest5 extends ConditionalEliminationTestBase {
|
||||
|
||||
|
||||
@ -25,9 +25,8 @@ package org.graalvm.compiler.core.test;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest6 extends ConditionalEliminationTestBase {
|
||||
|
||||
|
||||
@ -26,9 +26,8 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
@Ignore
|
||||
public class ConditionalEliminationTest7 extends ConditionalEliminationTestBase {
|
||||
|
||||
@ -25,9 +25,8 @@ package org.graalvm.compiler.core.test;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest8 extends ConditionalEliminationTestBase {
|
||||
|
||||
|
||||
@ -27,9 +27,8 @@ import org.junit.Test;
|
||||
import org.graalvm.compiler.api.directives.GraalDirectives;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTest9 extends ConditionalEliminationTestBase {
|
||||
|
||||
|
||||
@ -29,17 +29,16 @@ import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.nodes.spi.LoweringTool;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase;
|
||||
import org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.LoweringPhase;
|
||||
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.schedule.SchedulePhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* Collection of tests for
|
||||
* {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
|
||||
* that triggered bugs in this phase.
|
||||
* Collection of tests for {@link org.graalvm.compiler.phases.common.ConditionalEliminationPhase}
|
||||
* including those that triggered bugs in this phase.
|
||||
*/
|
||||
public class ConditionalEliminationTestBase extends GraalCompilerTest {
|
||||
protected static int sink0;
|
||||
@ -70,7 +69,7 @@ public class ConditionalEliminationTestBase extends GraalCompilerTest {
|
||||
try (Debug.Scope scope = Debug.scope("ConditionalEliminationTest.ReferenceGraph", referenceGraph)) {
|
||||
prepareGraph(referenceGraph, canonicalizer, context, applyLowering);
|
||||
if (applyConditionalEliminationOnReference) {
|
||||
DominatorConditionalEliminationPhase.create(true).apply(referenceGraph, context);
|
||||
new ConditionalEliminationPhase(true).apply(referenceGraph, context);
|
||||
}
|
||||
canonicalizer.apply(referenceGraph, context);
|
||||
canonicalizer.apply(referenceGraph, context);
|
||||
@ -102,7 +101,7 @@ public class ConditionalEliminationTestBase extends GraalCompilerTest {
|
||||
canonicalizer.apply(graph, context);
|
||||
|
||||
int baseProxyCount = graph.getNodes().filter(ProxyNode.class).count();
|
||||
DominatorConditionalEliminationPhase.create(true).apply(graph, context);
|
||||
new ConditionalEliminationPhase(true).apply(graph, context);
|
||||
canonicalizer.apply(graph, context);
|
||||
new SchedulePhase(graph.getOptions()).apply(graph, context);
|
||||
int actualProxiesCreated = graph.getNodes().filter(ProxyNode.class).count() - baseProxyCount;
|
||||
|
||||
@ -35,9 +35,9 @@ import org.graalvm.compiler.nodeinfo.NodeInfo;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.calc.FloatingNode;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration;
|
||||
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
||||
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
|
||||
@ -242,10 +242,8 @@ public class CountedLoopTest extends GraalCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Plugins getDefaultGraphBuilderPlugins() {
|
||||
Plugins plugins = super.getDefaultGraphBuilderPlugins();
|
||||
Registration r = new Registration(plugins.getInvocationPlugins(), CountedLoopTest.class);
|
||||
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
Registration r = new Registration(invocationPlugins, CountedLoopTest.class);
|
||||
r.register2("get", IVProperty.class, int.class, new InvocationPlugin() {
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg1, ValueNode arg2) {
|
||||
@ -261,8 +259,7 @@ public class CountedLoopTest extends GraalCompilerTest {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return plugins;
|
||||
super.registerInvocationPlugins(invocationPlugins);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -52,7 +52,6 @@ import org.graalvm.compiler.core.GraalCompiler;
|
||||
import org.graalvm.compiler.core.GraalCompiler.Request;
|
||||
import org.graalvm.compiler.core.common.CompilationIdentifier;
|
||||
import org.graalvm.compiler.core.common.type.StampFactory;
|
||||
import org.graalvm.compiler.core.common.util.ModuleAPI;
|
||||
import org.graalvm.compiler.core.target.Backend;
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.Debug.Scope;
|
||||
@ -72,6 +71,7 @@ import org.graalvm.compiler.nodeinfo.NodeInfo;
|
||||
import org.graalvm.compiler.nodeinfo.NodeSize;
|
||||
import org.graalvm.compiler.nodeinfo.Verbosity;
|
||||
import org.graalvm.compiler.nodes.BreakpointNode;
|
||||
import org.graalvm.compiler.nodes.Cancellable;
|
||||
import org.graalvm.compiler.nodes.ConstantNode;
|
||||
import org.graalvm.compiler.nodes.FixedWithNextNode;
|
||||
import org.graalvm.compiler.nodes.FrameState;
|
||||
@ -112,6 +112,7 @@ import org.graalvm.compiler.phases.util.Providers;
|
||||
import org.graalvm.compiler.runtime.RuntimeProvider;
|
||||
import org.graalvm.compiler.test.AddExports;
|
||||
import org.graalvm.compiler.test.GraalTest;
|
||||
import org.graalvm.compiler.test.JLModule;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@ -133,7 +134,6 @@ import jdk.vm.ci.meta.ProfilingInfo;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
import jdk.vm.ci.meta.ResolvedJavaType;
|
||||
import jdk.vm.ci.meta.SpeculationLog;
|
||||
import jdk.vm.ci.services.Services;
|
||||
|
||||
/**
|
||||
* Base class for Graal compiler unit tests.
|
||||
@ -154,12 +154,7 @@ import jdk.vm.ci.services.Services;
|
||||
* <p>
|
||||
* These tests will be run by the {@code mx unittest} command.
|
||||
*/
|
||||
@AddExports({"jdk.internal.vm.ci/jdk.vm.ci.meta",
|
||||
"jdk.internal.vm.ci/jdk.vm.ci.services",
|
||||
"jdk.internal.vm.ci/jdk.vm.ci.code",
|
||||
"jdk.internal.vm.ci/jdk.vm.ci.services",
|
||||
"java.base/jdk.internal.org.objectweb.asm",
|
||||
"java.base/jdk.internal.org.objectweb.asm.tree"})
|
||||
@AddExports({"java.base/jdk.internal.org.objectweb.asm", "java.base/jdk.internal.org.objectweb.asm.tree"})
|
||||
public abstract class GraalCompilerTest extends GraalTest {
|
||||
|
||||
/**
|
||||
@ -179,11 +174,6 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
*/
|
||||
public static final Class<?> JAVA_BASE = Class.class;
|
||||
|
||||
/**
|
||||
* Representative class for the {@code jdk.vm.ci} module.
|
||||
*/
|
||||
public static final Class<?> JDK_VM_CI = Services.class;
|
||||
|
||||
/**
|
||||
* Exports the package named {@code packageName} declared in {@code moduleMember}'s module to
|
||||
* this object's module. This must be called before accessing packages that are no longer public
|
||||
@ -191,7 +181,7 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
*/
|
||||
protected final void exportPackage(Class<?> moduleMember, String packageName) {
|
||||
if (!Java8OrEarlier) {
|
||||
ModuleAPI.exportPackageTo(moduleMember, packageName, getClass());
|
||||
JLModule.exportPackageTo(moduleMember, packageName, getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,6 +372,15 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
if (invocationPluginExtensions != null) {
|
||||
synchronized (this) {
|
||||
if (invocationPluginExtensions != null) {
|
||||
extendedInvocationPlugins.removeTestPlugins(invocationPluginExtensions);
|
||||
extendedInvocationPlugins = null;
|
||||
invocationPluginExtensions = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (debugScope != null) {
|
||||
debugScope.close();
|
||||
}
|
||||
@ -1191,8 +1190,15 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
private StructuredGraph parse1(ResolvedJavaMethod javaMethod, PhaseSuite<HighTierContext> graphBuilderSuite, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId,
|
||||
OptionValues options) {
|
||||
assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod;
|
||||
StructuredGraph graph = new StructuredGraph.Builder(options, allowAssumptions).method(javaMethod).speculationLog(getSpeculationLog()).useProfilingInfo(true).compilationId(
|
||||
compilationId).build();
|
||||
// @formatter:off
|
||||
StructuredGraph graph = new StructuredGraph.Builder(options, allowAssumptions).
|
||||
method(javaMethod).
|
||||
speculationLog(getSpeculationLog()).
|
||||
useProfilingInfo(true).
|
||||
compilationId(compilationId).
|
||||
cancellable(getCancellable(javaMethod)).
|
||||
build();
|
||||
// @formatter:on
|
||||
try (Scope ds = Debug.scope("Parsing", javaMethod, graph)) {
|
||||
graphBuilderSuite.apply(graph, getDefaultHighTierContext());
|
||||
return graph;
|
||||
@ -1201,6 +1207,16 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cancellable that should be associated with a graph being created by any of the
|
||||
* {@code parse...()} methods.
|
||||
*
|
||||
* @param method the method being parsed into a graph
|
||||
*/
|
||||
protected Cancellable getCancellable(ResolvedJavaMethod method) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Plugins getDefaultGraphBuilderPlugins() {
|
||||
PhaseSuite<HighTierContext> suite = backend.getSuites().getDefaultGraphBuilderSuite();
|
||||
Plugins defaultPlugins = ((GraphBuilderPhase) suite.findPhase(GraphBuilderPhase.class).previous()).getGraphBuilderConfig().getPlugins();
|
||||
@ -1213,17 +1229,16 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
return backend.getSuites().getDefaultGraphBuilderSuite().copy();
|
||||
}
|
||||
|
||||
protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
|
||||
PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite();
|
||||
ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
|
||||
GraphBuilderConfiguration gbConfCopy = editGraphBuilderConfiguration(gbConf.copy());
|
||||
iterator.remove();
|
||||
iterator.add(new GraphBuilderPhase(gbConfCopy));
|
||||
return suite;
|
||||
}
|
||||
|
||||
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
|
||||
InvocationPlugins invocationPlugins = conf.getPlugins().getInvocationPlugins();
|
||||
/**
|
||||
* Registers extra invocation plugins for this test. The extra plugins are removed in the
|
||||
* {@link #afterTest()} method.
|
||||
*
|
||||
* Subclasses overriding this method should always call the same method on the super class in
|
||||
* case it wants to register plugins.
|
||||
*
|
||||
* @param invocationPlugins
|
||||
*/
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
invocationPlugins.register(new InvocationPlugin() {
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
|
||||
@ -1245,7 +1260,41 @@ public abstract class GraalCompilerTest extends GraalTest {
|
||||
return true;
|
||||
}
|
||||
}, GraalCompilerTest.class, "shouldBeOptimizedAway");
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link #testN(int, String, Object...)} method means multiple threads trying to initialize
|
||||
* this field.
|
||||
*/
|
||||
private volatile InvocationPlugins invocationPluginExtensions;
|
||||
|
||||
private InvocationPlugins extendedInvocationPlugins;
|
||||
|
||||
protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
|
||||
PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite();
|
||||
ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
|
||||
initializeInvocationPluginExtensions();
|
||||
GraphBuilderConfiguration gbConfCopy = editGraphBuilderConfiguration(gbConf.copy());
|
||||
iterator.remove();
|
||||
iterator.add(new GraphBuilderPhase(gbConfCopy));
|
||||
return suite;
|
||||
}
|
||||
|
||||
private void initializeInvocationPluginExtensions() {
|
||||
if (invocationPluginExtensions == null) {
|
||||
synchronized (this) {
|
||||
if (invocationPluginExtensions == null) {
|
||||
InvocationPlugins invocationPlugins = new InvocationPlugins();
|
||||
registerInvocationPlugins(invocationPlugins);
|
||||
extendedInvocationPlugins = getReplacements().getGraphBuilderPlugins().getInvocationPlugins();
|
||||
extendedInvocationPlugins.addTestPlugins(invocationPlugins, null);
|
||||
invocationPluginExtensions = invocationPlugins;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
|
||||
conf.getPlugins().prependInlineInvokePlugin(new InlineInvokePlugin() {
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,7 +35,6 @@ import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.debug.OpaqueNode;
|
||||
import org.graalvm.compiler.nodes.extended.LoadHubNode;
|
||||
import org.graalvm.compiler.nodes.extended.LoadMethodNode;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver;
|
||||
@ -118,8 +117,7 @@ public class GuardedIntrinsicTest extends GraalCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
|
||||
InvocationPlugins invocationPlugins = conf.getPlugins().getInvocationPlugins();
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
Registration r = new Registration(invocationPlugins, Super.class);
|
||||
|
||||
r.register1("getAge", Receiver.class, new InvocationPlugin() {
|
||||
@ -131,7 +129,7 @@ public class GuardedIntrinsicTest extends GraalCompilerTest {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return super.editGraphBuilderConfiguration(conf);
|
||||
super.registerInvocationPlugins(invocationPlugins);
|
||||
}
|
||||
|
||||
public static int referenceMakeSuperAge() {
|
||||
|
||||
@ -196,6 +196,33 @@ public class IfCanonicalizerTest extends GraalCompilerTest {
|
||||
return (n < 0) ? 1 : (n >= 1024) ? 1024 : n + 1;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10() {
|
||||
// Exercise NormalizeCompareNode with long values
|
||||
test("test10Snippet", 0, 1);
|
||||
}
|
||||
|
||||
public static long test10Snippet(int x, int y) {
|
||||
return (x < y) ? -1L : ((x == y) ? 0L : 1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test11() {
|
||||
test("test11Snippet", 0, 1);
|
||||
}
|
||||
|
||||
public static long test11Snippet(int x, int y) {
|
||||
long normalizeCompare = normalizeCompareLong(x, y);
|
||||
if (normalizeCompare == 0) {
|
||||
return 5;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static Long normalizeCompareLong(int x, int y) {
|
||||
return (x < y) ? -1L : ((x == y) ? 0L : 1L);
|
||||
}
|
||||
|
||||
private void testCombinedIf(String snippet, int count) {
|
||||
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
|
||||
PhaseContext context = new PhaseContext(getProviders());
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.Debug.Scope;
|
||||
import org.graalvm.compiler.debug.DebugDumpScope;
|
||||
import org.graalvm.compiler.loop.DefaultLoopPolicies;
|
||||
import org.graalvm.compiler.loop.phases.LoopFullUnrollPhase;
|
||||
import org.graalvm.compiler.nodes.LoopBeginNode;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LoopFullUnrollTest extends GraalCompilerTest {
|
||||
|
||||
public static int testMinToMax(int input) {
|
||||
int ret = 2;
|
||||
int current = input;
|
||||
for (long i = Long.MIN_VALUE; i < Long.MAX_VALUE; i++) {
|
||||
ret *= 2 + current;
|
||||
current /= 50;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runMinToMax() throws Throwable {
|
||||
test("testMinToMax", 1);
|
||||
}
|
||||
|
||||
public static int testMinTo0(int input) {
|
||||
int ret = 2;
|
||||
int current = input;
|
||||
for (long i = Long.MIN_VALUE; i <= 0; i++) {
|
||||
ret *= 2 + current;
|
||||
current /= 50;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runMinTo0() throws Throwable {
|
||||
test("testMinTo0", 1);
|
||||
}
|
||||
|
||||
public static int testNegativeTripCount(int input) {
|
||||
int ret = 2;
|
||||
int current = input;
|
||||
for (long i = 0; i <= -20; i++) {
|
||||
ret *= 2 + current;
|
||||
current /= 50;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runNegativeTripCount() throws Throwable {
|
||||
test("testNegativeTripCount", 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
private void test(String snippet, int loopCount) {
|
||||
try (Scope s = Debug.scope(getClass().getSimpleName(), new DebugDumpScope(snippet))) {
|
||||
final StructuredGraph graph = parseEager(snippet, AllowAssumptions.NO);
|
||||
|
||||
PhaseContext context = new PhaseContext(getProviders());
|
||||
new LoopFullUnrollPhase(new CanonicalizerPhase(), new DefaultLoopPolicies()).apply(graph, context);
|
||||
|
||||
assertTrue(graph.getNodes().filter(LoopBeginNode.class).count() == loopCount);
|
||||
} catch (Throwable e) {
|
||||
throw Debug.handle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -33,6 +33,7 @@ import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.test.AddExports;
|
||||
|
||||
// Export needed to open String.value field to reflection by this test
|
||||
@AddExports("java.base/java.lang")
|
||||
public final class MethodHandleEagerResolution extends GraalCompilerTest {
|
||||
private static final MethodHandle FIELD_HANDLE;
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Sometimes it's possible to emit a smaller read from a larger memory location instead reading the
|
||||
* whole thing and truncating it. Make sure it returns the right value.
|
||||
*/
|
||||
public class NarrowingReadTest extends GraalCompilerTest {
|
||||
|
||||
public byte testNarrowReadSnippetByte(Long l) {
|
||||
return (byte) l.longValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNarrowReadByte() {
|
||||
test("testNarrowReadSnippetByte", Long.valueOf(Byte.MAX_VALUE));
|
||||
}
|
||||
|
||||
public short testNarrowReadSnippetShort(Long l) {
|
||||
return (short) l.longValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNarrowReadShort() {
|
||||
test("testNarrowReadSnippetShort", Long.valueOf(Short.MAX_VALUE));
|
||||
}
|
||||
|
||||
public int testNarrowReadSnippetInt(Long l) {
|
||||
return (int) l.longValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNarrowReadInt() {
|
||||
test("testNarrowReadSnippetInt", Long.valueOf(Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
public long testNarrowReadSnippetIntToLong(Long l) {
|
||||
return (int) l.longValue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNarrowReadIntToLong() {
|
||||
test("testNarrowReadSnippetIntToLong", Long.valueOf(Integer.MAX_VALUE));
|
||||
}
|
||||
}
|
||||
@ -27,8 +27,7 @@ import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.core.common.LocationIdentity;
|
||||
import org.graalvm.api.word.LocationIdentity;
|
||||
import org.graalvm.compiler.graph.Node;
|
||||
import org.graalvm.compiler.loop.LoopEx;
|
||||
import org.graalvm.compiler.loop.LoopsData;
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import org.graalvm.compiler.core.common.type.Stamp;
|
||||
import org.graalvm.compiler.core.common.type.StampFactory;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.MemoryAccessProvider;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class StampMemoryAccessTest extends GraalCompilerTest {
|
||||
|
||||
@Ignore("not all JVMCI versions are safe yet")
|
||||
@Test
|
||||
public void testReadPrimitive() {
|
||||
MemoryAccessProvider memory = getConstantReflection().getMemoryAccessProvider();
|
||||
JavaConstant base = getSnippetReflection().forObject("");
|
||||
Stamp stamp = StampFactory.forKind(JavaKind.Long);
|
||||
assertTrue(stamp.readConstant(memory, base, 128) == null);
|
||||
}
|
||||
|
||||
@Ignore("not all JVMCI versions are safe yet")
|
||||
@Test
|
||||
public void testReadObject() {
|
||||
MemoryAccessProvider memory = getConstantReflection().getMemoryAccessProvider();
|
||||
JavaConstant base = getSnippetReflection().forObject("");
|
||||
Stamp stamp = StampFactory.forKind(JavaKind.Object);
|
||||
assertTrue(stamp.readConstant(memory, base, 128) == null);
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class StaticInterfaceFieldTest extends GraalTest {
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
|
||||
@ -28,10 +28,6 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.TTY;
|
||||
import org.graalvm.compiler.graph.Node;
|
||||
@ -44,9 +40,12 @@ import org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult;
|
||||
import org.graalvm.compiler.nodes.cfg.Block;
|
||||
import org.graalvm.compiler.nodes.java.InstanceOfNode;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.common.ConditionalEliminationPhase;
|
||||
import org.graalvm.compiler.phases.schedule.SchedulePhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* In the following tests, the scalar type system of the compiler should be complete enough to see
|
||||
@ -186,12 +185,12 @@ public class TypeSystemTest extends GraalCompilerTest {
|
||||
* tail-duplication gets activated thus resulting in a graph with more nodes than the
|
||||
* reference graph.
|
||||
*/
|
||||
DominatorConditionalEliminationPhase.create(false).apply(graph, new PhaseContext(getProviders()));
|
||||
new ConditionalEliminationPhase(false).apply(graph, new PhaseContext(getProviders()));
|
||||
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
|
||||
// a second canonicalizer is needed to process nested MaterializeNodes
|
||||
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
|
||||
StructuredGraph referenceGraph = parseEager(referenceSnippet, AllowAssumptions.NO);
|
||||
DominatorConditionalEliminationPhase.create(false).apply(referenceGraph, new PhaseContext(getProviders()));
|
||||
new ConditionalEliminationPhase(false).apply(referenceGraph, new PhaseContext(getProviders()));
|
||||
new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
|
||||
new CanonicalizerPhase().apply(referenceGraph, new PhaseContext(getProviders()));
|
||||
assertEquals(referenceGraph, graph);
|
||||
|
||||
@ -86,7 +86,7 @@ public class UnbalancedMonitorsTest extends GraalCompilerTest {
|
||||
ResolvedJavaMethod method = getResolvedJavaMethod(LOADER.findClass(INNER_CLASS_NAME), name);
|
||||
try {
|
||||
StructuredGraph graph = new StructuredGraph.Builder(getInitialOptions()).method(method).build();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(getMetaAccess()));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
|
||||
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2016, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.core.test;
|
||||
|
||||
import static org.graalvm.compiler.graph.test.matchers.NodeIterableIsEmpty.isEmpty;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.graalvm.compiler.graph.iterators.NodeIterable;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.java.NewArrayNode;
|
||||
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
|
||||
import org.graalvm.compiler.phases.tiers.PhaseContext;
|
||||
import org.junit.Test;
|
||||
|
||||
public class UnusedArray extends GraalCompilerTest {
|
||||
@SuppressWarnings("unused")
|
||||
public void smallArray() {
|
||||
byte[] array = new byte[3];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void largeArray() {
|
||||
byte[] array = new byte[10 * 1024 * 1024];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void unknownArray(int l) {
|
||||
byte[] array = new byte[l];
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmall() {
|
||||
test("smallArray");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLarge() {
|
||||
test("largeArray");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknown() {
|
||||
test("unknownArray");
|
||||
}
|
||||
|
||||
public void test(String method) {
|
||||
StructuredGraph graph = parseEager(method, StructuredGraph.AllowAssumptions.YES);
|
||||
new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
|
||||
NodeIterable<NewArrayNode> newArrayNodes = graph.getNodes().filter(NewArrayNode.class);
|
||||
assertThat(newArrayNodes, isEmpty());
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class VerifyBailoutUsageTest {
|
||||
Providers providers = rt.getHostBackend().getProviders();
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
|
||||
@ -328,7 +328,7 @@ public class VerifyDebugUsageTest {
|
||||
Providers providers = rt.getHostBackend().getProviders();
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
|
||||
@ -266,7 +266,7 @@ public class VerifyVirtualizableTest {
|
||||
Providers providers = rt.getHostBackend().getProviders();
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
|
||||
@ -91,8 +91,8 @@ public class AllocatorTest extends BackendTest {
|
||||
private void collectStats(final LIRInstruction instr) {
|
||||
instr.forEachOutput(collectStatsProc);
|
||||
|
||||
if (instr instanceof ValueMoveOp) {
|
||||
ValueMoveOp move = (ValueMoveOp) instr;
|
||||
if (ValueMoveOp.isValueMoveOp(instr)) {
|
||||
ValueMoveOp move = ValueMoveOp.asValueMoveOp(instr);
|
||||
Value def = move.getResult();
|
||||
Value use = move.getInput();
|
||||
if (ValueUtil.isRegister(def)) {
|
||||
|
||||
@ -247,7 +247,7 @@ public class VerifyMethodMetricsTest {
|
||||
Providers providers = rt.getHostBackend().getProviders();
|
||||
MetaAccessProvider metaAccess = providers.getMetaAccess();
|
||||
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
|
||||
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
|
||||
|
||||
@ -252,7 +252,7 @@ public class StaticAnalysis {
|
||||
* the code before static analysis, the classes would otherwise be not loaded
|
||||
* yet and the bytecode parser would only create a graph.
|
||||
*/
|
||||
Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
|
||||
Plugins plugins = new Plugins(new InvocationPlugins());
|
||||
GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
|
||||
/*
|
||||
* For simplicity, we ignore all exception handling during the static analysis.
|
||||
|
||||
@ -193,12 +193,11 @@ public class GraalCompiler {
|
||||
String methodPattern = GraalCompilerOptions.CrashAt.getValue(graph.getOptions());
|
||||
if (methodPattern != null) {
|
||||
String crashLabel = null;
|
||||
ResolvedJavaMethod method = graph.method();
|
||||
if (method == null) {
|
||||
if (graph.name.contains(methodPattern)) {
|
||||
crashLabel = graph.name;
|
||||
}
|
||||
} else {
|
||||
if (graph.name != null && graph.name.contains(methodPattern)) {
|
||||
crashLabel = graph.name;
|
||||
}
|
||||
if (crashLabel == null) {
|
||||
ResolvedJavaMethod method = graph.method();
|
||||
MethodFilter[] filters = MethodFilter.parse(methodPattern);
|
||||
for (MethodFilter filter : filters) {
|
||||
if (filter.matches(method)) {
|
||||
|
||||
@ -66,6 +66,10 @@ public class GraalDebugInitializationParticipant implements DebugInitializationP
|
||||
params.enableMethodFilter = true;
|
||||
}
|
||||
|
||||
if (!params.enable && GraalDebugConfig.Options.DumpOnPhaseChange.getValue(options) != null) {
|
||||
params.enable = true;
|
||||
}
|
||||
|
||||
if (!params.enableUnscopedMethodMetrics && GraalDebugConfig.Options.MethodMeter.getValue(options) != null) {
|
||||
// mm requires full debugging support
|
||||
params.enable = true;
|
||||
|
||||
@ -57,6 +57,7 @@ public class LIRGenerationPhase extends LIRPhase<LIRGenerationPhase.LIRGeneratio
|
||||
}
|
||||
|
||||
private static final DebugCounter instructionCounter = Debug.counter("GeneratedLIRInstructions");
|
||||
private static final DebugCounter nodeCount = Debug.counter("FinalNodeCount");
|
||||
|
||||
@Override
|
||||
protected final void run(TargetDescription target, LIRGenerationResult lirGenRes, LIRGenerationPhase.LIRGenerationContext context) {
|
||||
@ -68,6 +69,9 @@ public class LIRGenerationPhase extends LIRPhase<LIRGenerationPhase.LIRGeneratio
|
||||
}
|
||||
context.lirGen.beforeRegisterAllocation();
|
||||
assert SSAUtil.verifySSAForm(lirGenRes.getLIR());
|
||||
if (nodeCount.isEnabled()) {
|
||||
nodeCount.add(graph.getNodeCount());
|
||||
}
|
||||
}
|
||||
|
||||
private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
|
||||
|
||||
@ -243,32 +243,27 @@ public abstract class NodeLIRBuilder implements NodeLIRBuilderTool, LIRGeneratio
|
||||
}
|
||||
|
||||
protected LIRKind getExactPhiKind(PhiNode phi) {
|
||||
// TODO (je): maybe turn this into generator-style instead of allocating an ArrayList.
|
||||
ArrayList<LIRKind> values = new ArrayList<>(phi.valueCount());
|
||||
for (int i = 0; i < phi.valueCount(); i++) {
|
||||
LIRKind derivedKind = gen.toRegisterKind(gen.getLIRKind(phi.stamp()));
|
||||
/* Collect reference information. */
|
||||
for (int i = 0; i < phi.valueCount() && !derivedKind.isUnknownReference(); i++) {
|
||||
ValueNode node = phi.valueAt(i);
|
||||
Value value = getOperand(node);
|
||||
|
||||
// get ValueKind for input
|
||||
final LIRKind valueKind;
|
||||
if (value != null) {
|
||||
values.add(value.getValueKind(LIRKind.class));
|
||||
valueKind = value.getValueKind(LIRKind.class);
|
||||
} else {
|
||||
assert isPhiInputFromBackedge(phi, i) : String.format("Input %s to phi node %s is not yet available although it is not coming from a loop back edge", node, phi);
|
||||
// non-java constant -> get LIRKind from stamp.
|
||||
LIRKind kind = gen.getLIRKind(node.stamp());
|
||||
values.add(gen.toRegisterKind(kind));
|
||||
valueKind = gen.toRegisterKind(kind);
|
||||
}
|
||||
/* Merge the reference information of the derived kind and the input. */
|
||||
derivedKind = LIRKind.mergeReferenceInformation(derivedKind, valueKind);
|
||||
}
|
||||
LIRKind derivedKind = LIRKind.merge(values);
|
||||
assert verifyPHIKind(derivedKind, gen.getLIRKind(phi.stamp()));
|
||||
return derivedKind;
|
||||
}
|
||||
|
||||
private boolean verifyPHIKind(LIRKind derivedKind, LIRKind phiKind) {
|
||||
PlatformKind derivedPlatformKind = derivedKind.getPlatformKind();
|
||||
PlatformKind phiPlatformKind = gen.toRegisterKind(phiKind).getPlatformKind();
|
||||
assert derivedPlatformKind.equals(phiPlatformKind) : "kinds don't match: " + derivedPlatformKind + " vs " + phiPlatformKind;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isPhiInputFromBackedge(PhiNode phi, int index) {
|
||||
AbstractMergeNode merge = phi.merge();
|
||||
AbstractEndNode end = merge.phiPredecessorAt(index);
|
||||
|
||||
@ -122,6 +122,12 @@ public class Debug {
|
||||
return config.isDumpEnabledForMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* A special dump level that indicates the dumping machinery is enabled but no dumps will be
|
||||
* produced except through other options.
|
||||
*/
|
||||
public static final int ENABLED_LEVEL = 0;
|
||||
|
||||
/**
|
||||
* Basic debug level.
|
||||
*
|
||||
|
||||
@ -63,6 +63,9 @@ public class GraalDebugConfig implements DebugConfig {
|
||||
public static final OptionKey<String> MethodFilter = new OptionKey<>(null);
|
||||
@Option(help = "Only check MethodFilter against the root method in the context if true, otherwise check all methods", type = OptionType.Debug)
|
||||
public static final OptionKey<Boolean> MethodFilterRootOnly = new OptionKey<>(false);
|
||||
@Option(help = "Dump a before and after graph if the named phase changes the graph.%n" +
|
||||
"The argument is substring matched against the simple name of the phase class", type = OptionType.Debug)
|
||||
public static final OptionKey<String> DumpOnPhaseChange = new OptionKey<>(null);
|
||||
|
||||
@Option(help = "How to print counters and timing values:%n" +
|
||||
"Name - aggregate by unqualified name%n" +
|
||||
@ -320,8 +323,8 @@ public class GraalDebugConfig implements DebugConfig {
|
||||
} else {
|
||||
level = filter.matchLevel(Debug.currentScope());
|
||||
}
|
||||
if (level > 0 && !checkMethodFilter()) {
|
||||
level = 0;
|
||||
if (level >= 0 && !checkMethodFilter()) {
|
||||
level = -1;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ public final class DebugScope implements Debug.Scope {
|
||||
}
|
||||
|
||||
public boolean isDumpEnabled(int dumpLevel) {
|
||||
assert dumpLevel > 0;
|
||||
assert dumpLevel >= 0;
|
||||
return currentDumpLevel >= dumpLevel;
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ public final class DebugScope implements Debug.Scope {
|
||||
memUseTrackingEnabled = false;
|
||||
timeEnabled = false;
|
||||
verifyEnabled = false;
|
||||
currentDumpLevel = 0;
|
||||
currentDumpLevel = -1;
|
||||
methodMetricsEnabled = false;
|
||||
// Be pragmatic: provide a default log stream to prevent a crash if the stream is not
|
||||
// set while logging
|
||||
|
||||
@ -135,6 +135,30 @@
|
||||
<property name="format" value="new (Hashtable|Vector|Stack|StringBuffer)[^\w]"/>
|
||||
<property name="message" value="Don't use old synchronized collection classes"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="instanceof MoveOp"/>
|
||||
<property name="message" value="Do not use `op instanceof MoveOp`. Use `MoveOp.isMoveOp(op)` instead!"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="instanceof ValueMoveOp"/>
|
||||
<property name="message" value="Do not use `op instanceof ValueMoveOp`. Use `ValueMoveOp.isValueMoveOp(op)` instead!"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="instanceof LoadConstantOp"/>
|
||||
<property name="message" value="Do not use `op instanceof LoadConstantOp`. Use `LoadConstantOp.isLoadConstantOp(op)` instead!"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="\(MoveOp\)"/>
|
||||
<property name="message" value="Do not cast directly to `MoveOp`. Use `MoveOp.asMoveOp(op)` instead!"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="\(ValueMoveOp\)"/>
|
||||
<property name="message" value="Do not cast directly to `ValueMoveOp`. Use `ValueMoveOp.asValueMoveOp(op)` instead!"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="\(LoadConstantOp\)"/>
|
||||
<property name="message" value="Do not cast directly to `LoadConstantOp`. Use `LoadConstantOp.asLoadConstantOp(op)` instead!"/>
|
||||
</module>
|
||||
</module>
|
||||
<module name="RegexpHeader">
|
||||
<property name="header" value="/\*\n \* Copyright \(c\) (20[0-9][0-9], )?20[0-9][0-9], Oracle and/or its affiliates. All rights reserved.\n \* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n \*\n \* This code is free software; you can redistribute it and/or modify it\n \* under the terms of the GNU General Public License version 2 only, as\n \* published by the Free Software Foundation.\n \*\n \* This code is distributed in the hope that it will be useful, but WITHOUT\n \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n \* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n \* version 2 for more details \(a copy is included in the LICENSE file that\n \* accompanied this code\).\n \*\n \* You should have received a copy of the GNU General Public License version\n \* 2 along with this work; if not, write to the Free Software Foundation,\n \* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n \*\n \* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n \* or visit www.oracle.com if you need additional information or have any\n \* questions.\n \*/\n"/>
|
||||
|
||||
@ -135,7 +135,7 @@ public class AArch64HotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
replacements = createReplacements(graalRuntime.getOptions(), p, snippetReflection, bytecodeProvider);
|
||||
}
|
||||
try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
|
||||
plugins = createGraphBuilderPlugins(config, constantReflection, foreignCalls, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
|
||||
plugins = createGraphBuilderPlugins(compilerConfiguration, config, constantReflection, foreignCalls, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
|
||||
replacements.setGraphBuilderPlugins(plugins);
|
||||
}
|
||||
try (InitTimer rt = timer("create Suites provider")) {
|
||||
@ -150,11 +150,11 @@ public class AArch64HotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
}
|
||||
}
|
||||
|
||||
protected Plugins createGraphBuilderPlugins(GraalHotSpotVMConfig config, HotSpotConstantReflectionProvider constantReflection, HotSpotHostForeignCallsProvider foreignCalls,
|
||||
HotSpotMetaAccessProvider metaAccess, HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes,
|
||||
HotSpotStampProvider stampProvider) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
AArch64GraphBuilderPlugins.register(plugins, replacements.getReplacementBytecodeProvider());
|
||||
protected Plugins createGraphBuilderPlugins(CompilerConfiguration compilerConfiguration, GraalHotSpotVMConfig config, HotSpotConstantReflectionProvider constantReflection,
|
||||
HotSpotHostForeignCallsProvider foreignCalls, HotSpotMetaAccessProvider metaAccess, HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements,
|
||||
HotSpotWordTypes wordTypes, HotSpotStampProvider stampProvider) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(compilerConfiguration, config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
AArch64GraphBuilderPlugins.register(plugins, replacements.getDefaultReplacementBytecodeProvider());
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ import static jdk.vm.ci.aarch64.AArch64.r0;
|
||||
import static jdk.vm.ci.aarch64.AArch64.r3;
|
||||
import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall;
|
||||
import static jdk.vm.ci.meta.Value.ILLEGAL;
|
||||
import static org.graalvm.compiler.core.common.LocationIdentity.any;
|
||||
import static org.graalvm.api.word.LocationIdentity.any;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.JUMP_ADDRESS;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.RegisterEffect.PRESERVES_REGISTERS;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.Transition.LEAF;
|
||||
|
||||
@ -29,13 +29,14 @@ import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.graalvm.compiler.asm.Label;
|
||||
import org.graalvm.compiler.core.common.NumUtil;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Address.AddressingMode;
|
||||
import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64ArithmeticLIRGenerator;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64LIRGenerator;
|
||||
import org.graalvm.compiler.core.aarch64.AArch64LIRKindTool;
|
||||
import org.graalvm.compiler.core.common.CompressEncoding;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.core.common.NumUtil;
|
||||
import org.graalvm.compiler.core.common.calc.Condition;
|
||||
import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
|
||||
import org.graalvm.compiler.core.common.spi.LIRKindTool;
|
||||
@ -93,7 +94,7 @@ public class AArch64HotSpotLIRGenerator extends AArch64LIRGenerator implements H
|
||||
private HotSpotDebugInfoBuilder debugInfoBuilder;
|
||||
|
||||
protected AArch64HotSpotLIRGenerator(HotSpotProviders providers, GraalHotSpotVMConfig config, LIRGenerationResult lirGenRes) {
|
||||
this(new AArch64HotSpotLIRKindTool(), new AArch64ArithmeticLIRGenerator(), new AArch64HotSpotMoveFactory(), providers, config, lirGenRes);
|
||||
this(new AArch64LIRKindTool(), new AArch64ArithmeticLIRGenerator(), new AArch64HotSpotMoveFactory(), providers, config, lirGenRes);
|
||||
}
|
||||
|
||||
protected AArch64HotSpotLIRGenerator(LIRKindTool lirKindTool, AArch64ArithmeticLIRGenerator arithmeticLIRGen, MoveFactory moveFactory, HotSpotProviders providers, GraalHotSpotVMConfig config,
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.aarch64;
|
||||
|
||||
import org.graalvm.compiler.core.aarch64.AArch64LIRKindTool;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.HotSpotLIRKindTool;
|
||||
|
||||
import jdk.vm.ci.aarch64.AArch64Kind;
|
||||
|
||||
public class AArch64HotSpotLIRKindTool extends AArch64LIRKindTool implements HotSpotLIRKindTool {
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AArch64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowPointerKind() {
|
||||
return LIRKind.value(AArch64Kind.DWORD);
|
||||
}
|
||||
}
|
||||
@ -23,20 +23,15 @@
|
||||
|
||||
package org.graalvm.compiler.hotspot.amd64.test;
|
||||
|
||||
import static jdk.vm.ci.code.ValueUtil.asRegister;
|
||||
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
|
||||
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_2;
|
||||
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_1;
|
||||
import static jdk.vm.ci.code.ValueUtil.asRegister;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.asm.amd64.AMD64Address;
|
||||
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
|
||||
import org.graalvm.compiler.graph.NodeClass;
|
||||
import org.graalvm.compiler.hotspot.nodes.CompressionNode;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.NarrowOopStamp;
|
||||
import org.graalvm.compiler.hotspot.nodes.HotSpotCompressionNode;
|
||||
import org.graalvm.compiler.hotspot.test.HotSpotGraalCompilerTest;
|
||||
import org.graalvm.compiler.lir.LIRInstruction;
|
||||
import org.graalvm.compiler.lir.LIRInstructionClass;
|
||||
@ -46,12 +41,16 @@ import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
|
||||
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
||||
import org.graalvm.compiler.nodes.FixedWithNextNode;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration;
|
||||
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
||||
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
|
||||
import org.graalvm.compiler.nodes.type.NarrowOopStamp;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.amd64.AMD64;
|
||||
import jdk.vm.ci.meta.AllocatableValue;
|
||||
@ -141,9 +140,8 @@ public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Plugins getDefaultGraphBuilderPlugins() {
|
||||
Plugins plugins = super.getDefaultGraphBuilderPlugins();
|
||||
Registration r = new Registration(plugins.getInvocationPlugins(), DataPatchInConstantsTest.class);
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
Registration r = new Registration(invocationPlugins, DataPatchInConstantsTest.class);
|
||||
|
||||
r.register1("loadThroughPatch", Object.class, new InvocationPlugin() {
|
||||
@Override
|
||||
@ -156,14 +154,13 @@ public class DataPatchInConstantsTest extends HotSpotGraalCompilerTest {
|
||||
r.register1("loadThroughCompressedPatch", Object.class, new InvocationPlugin() {
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
|
||||
ValueNode compressed = b.add(CompressionNode.compress(arg, runtime().getVMConfig().getOopEncoding()));
|
||||
ValueNode compressed = b.add(HotSpotCompressionNode.compress(arg, runtime().getVMConfig().getOopEncoding()));
|
||||
ValueNode patch = b.add(new LoadThroughPatchNode(compressed));
|
||||
b.addPush(JavaKind.Object, CompressionNode.uncompress(patch, runtime().getVMConfig().getOopEncoding()));
|
||||
b.addPush(JavaKind.Object, HotSpotCompressionNode.uncompress(patch, runtime().getVMConfig().getOopEncoding()));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return plugins;
|
||||
super.registerInvocationPlugins(invocationPlugins);
|
||||
}
|
||||
|
||||
@NodeInfo(cycles = CYCLES_2, size = SIZE_1)
|
||||
|
||||
@ -39,11 +39,11 @@ import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.DebugCounter;
|
||||
import org.graalvm.compiler.graph.NodeClass;
|
||||
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
|
||||
import org.graalvm.compiler.hotspot.nodes.CompressionNode;
|
||||
import org.graalvm.compiler.hotspot.nodes.CompressionNode.CompressionOp;
|
||||
import org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp;
|
||||
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
||||
import org.graalvm.compiler.nodes.CompressionNode;
|
||||
import org.graalvm.compiler.nodes.CompressionNode.CompressionOp;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.calc.FloatingNode;
|
||||
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
||||
|
||||
@ -136,7 +136,8 @@ public class AMD64HotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
replacements = createReplacements(options, p, snippetReflection, bytecodeProvider);
|
||||
}
|
||||
try (InitTimer rt = timer("create GraphBuilderPhase plugins")) {
|
||||
plugins = createGraphBuilderPlugins(config, options, target, constantReflection, foreignCalls, metaAccess, snippetReflection, replacements, wordTypes, stampProvider);
|
||||
plugins = createGraphBuilderPlugins(compilerConfiguration, config, options, target, constantReflection, foreignCalls, metaAccess, snippetReflection, replacements, wordTypes,
|
||||
stampProvider);
|
||||
replacements.setGraphBuilderPlugins(plugins);
|
||||
}
|
||||
try (InitTimer rt = timer("create Suites provider")) {
|
||||
@ -151,12 +152,11 @@ public class AMD64HotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
}
|
||||
}
|
||||
|
||||
protected Plugins createGraphBuilderPlugins(GraalHotSpotVMConfig config, OptionValues options, TargetDescription target, HotSpotConstantReflectionProvider constantReflection,
|
||||
HotSpotHostForeignCallsProvider foreignCalls,
|
||||
HotSpotMetaAccessProvider metaAccess, HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes,
|
||||
HotSpotStampProvider stampProvider) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
AMD64GraphBuilderPlugins.register(plugins, replacements.getReplacementBytecodeProvider(), (AMD64) target.arch, GraalArithmeticStubs.getValue(options));
|
||||
protected Plugins createGraphBuilderPlugins(CompilerConfiguration compilerConfiguration, GraalHotSpotVMConfig config, OptionValues options, TargetDescription target,
|
||||
HotSpotConstantReflectionProvider constantReflection, HotSpotHostForeignCallsProvider foreignCalls, HotSpotMetaAccessProvider metaAccess,
|
||||
HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes, HotSpotStampProvider stampProvider) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(compilerConfiguration, config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
AMD64GraphBuilderPlugins.register(plugins, replacements.getDefaultReplacementBytecodeProvider(), (AMD64) target.arch, GraalArithmeticStubs.getValue(options));
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ import static jdk.vm.ci.amd64.AMD64.rax;
|
||||
import static jdk.vm.ci.amd64.AMD64.rdx;
|
||||
import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.NativeCall;
|
||||
import static jdk.vm.ci.meta.Value.ILLEGAL;
|
||||
import static org.graalvm.compiler.core.common.LocationIdentity.any;
|
||||
import static org.graalvm.api.word.LocationIdentity.any;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotBackend.EXCEPTION_HANDLER;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotBackend.EXCEPTION_HANDLER_IN_CALLER;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.JUMP_ADDRESS;
|
||||
|
||||
@ -35,6 +35,7 @@ import java.util.List;
|
||||
import org.graalvm.compiler.asm.amd64.AMD64Address.Scale;
|
||||
import org.graalvm.compiler.core.amd64.AMD64ArithmeticLIRGenerator;
|
||||
import org.graalvm.compiler.core.amd64.AMD64LIRGenerator;
|
||||
import org.graalvm.compiler.core.amd64.AMD64LIRKindTool;
|
||||
import org.graalvm.compiler.core.amd64.AMD64MoveFactoryBase.BackupSlotProvider;
|
||||
import org.graalvm.compiler.core.common.CompressEncoding;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
@ -52,7 +53,6 @@ import org.graalvm.compiler.hotspot.HotSpotLockStack;
|
||||
import org.graalvm.compiler.hotspot.debug.BenchmarkCounters;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotConstantLoadAction;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.HotSpotLIRKindTool;
|
||||
import org.graalvm.compiler.hotspot.stubs.Stub;
|
||||
import org.graalvm.compiler.lir.LIR;
|
||||
import org.graalvm.compiler.lir.LIRFrameState;
|
||||
@ -111,7 +111,7 @@ public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSp
|
||||
}
|
||||
|
||||
private AMD64HotSpotLIRGenerator(HotSpotProviders providers, GraalHotSpotVMConfig config, LIRGenerationResult lirGenRes, BackupSlotProvider backupSlotProvider) {
|
||||
this(new AMD64HotSpotLIRKindTool(), new AMD64HotSpotArithmeticLIRGenerator(), new AMD64HotSpotMoveFactory(backupSlotProvider), providers, config, lirGenRes);
|
||||
this(new AMD64LIRKindTool(), new AMD64HotSpotArithmeticLIRGenerator(), new AMD64HotSpotMoveFactory(backupSlotProvider), providers, config, lirGenRes);
|
||||
}
|
||||
|
||||
protected AMD64HotSpotLIRGenerator(LIRKindTool lirKindTool, AMD64ArithmeticLIRGenerator arithmeticLIRGen, MoveFactory moveFactory, HotSpotProviders providers, GraalHotSpotVMConfig config,
|
||||
@ -400,8 +400,7 @@ public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSp
|
||||
@Override
|
||||
public Value emitLoadObjectAddress(Constant constant) {
|
||||
HotSpotObjectConstant objectConstant = (HotSpotObjectConstant) constant;
|
||||
HotSpotLIRKindTool kindTool = (HotSpotLIRKindTool) getLIRKindTool();
|
||||
LIRKind kind = objectConstant.isCompressed() ? kindTool.getNarrowOopKind() : kindTool.getObjectKind();
|
||||
LIRKind kind = objectConstant.isCompressed() ? getLIRKindTool().getNarrowOopKind() : getLIRKindTool().getObjectKind();
|
||||
Variable result = newVariable(kind);
|
||||
append(new AMD64HotSpotLoadAddressOp(result, constant, HotSpotConstantLoadAction.RESOLVE));
|
||||
return result;
|
||||
@ -410,8 +409,7 @@ public class AMD64HotSpotLIRGenerator extends AMD64LIRGenerator implements HotSp
|
||||
@Override
|
||||
public Value emitLoadMetaspaceAddress(Constant constant, HotSpotConstantLoadAction action) {
|
||||
HotSpotMetaspaceConstant metaspaceConstant = (HotSpotMetaspaceConstant) constant;
|
||||
HotSpotLIRKindTool kindTool = (HotSpotLIRKindTool) getLIRKindTool();
|
||||
LIRKind kind = metaspaceConstant.isCompressed() ? kindTool.getNarrowPointerKind() : kindTool.getWordKind();
|
||||
LIRKind kind = metaspaceConstant.isCompressed() ? getLIRKindTool().getNarrowPointerKind() : getLIRKindTool().getWordKind();
|
||||
Variable result = newVariable(kind);
|
||||
append(new AMD64HotSpotLoadAddressOp(result, constant, action));
|
||||
return result;
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2015, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.amd64;
|
||||
|
||||
import org.graalvm.compiler.core.amd64.AMD64LIRKindTool;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.HotSpotLIRKindTool;
|
||||
|
||||
import jdk.vm.ci.amd64.AMD64Kind;
|
||||
|
||||
public class AMD64HotSpotLIRKindTool extends AMD64LIRKindTool implements HotSpotLIRKindTool {
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowOopKind() {
|
||||
return LIRKind.reference(AMD64Kind.DWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LIRKind getNarrowPointerKind() {
|
||||
return LIRKind.value(AMD64Kind.DWORD);
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class SPARCHotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime, constantReflection, wordTypes);
|
||||
BytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
|
||||
HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(runtime.getOptions(), p, snippetReflection, bytecodeProvider, target);
|
||||
Plugins plugins = createGraphBuilderPlugins(config, metaAccess, constantReflection, foreignCalls, stampProvider, snippetReflection, replacements, wordTypes);
|
||||
Plugins plugins = createGraphBuilderPlugins(compilerConfiguration, config, metaAccess, constantReflection, foreignCalls, stampProvider, snippetReflection, replacements, wordTypes);
|
||||
replacements.setGraphBuilderPlugins(plugins);
|
||||
HotSpotSuitesProvider suites = createSuites(config, runtime, compilerConfiguration, plugins, replacements);
|
||||
HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers,
|
||||
@ -110,11 +110,11 @@ public class SPARCHotSpotBackendFactory implements HotSpotBackendFactory {
|
||||
return createBackend(config, runtime, providers);
|
||||
}
|
||||
|
||||
protected Plugins createGraphBuilderPlugins(GraalHotSpotVMConfig config, HotSpotMetaAccessProvider metaAccess, HotSpotConstantReflectionProvider constantReflection,
|
||||
HotSpotForeignCallsProvider foreignCalls, HotSpotStampProvider stampProvider, HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements,
|
||||
HotSpotWordTypes wordTypes) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
SPARCGraphBuilderPlugins.register(plugins, replacements.getReplacementBytecodeProvider());
|
||||
protected Plugins createGraphBuilderPlugins(CompilerConfiguration compilerConfiguration, GraalHotSpotVMConfig config, HotSpotMetaAccessProvider metaAccess,
|
||||
HotSpotConstantReflectionProvider constantReflection, HotSpotForeignCallsProvider foreignCalls, HotSpotStampProvider stampProvider,
|
||||
HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes) {
|
||||
Plugins plugins = HotSpotGraphBuilderPlugins.create(compilerConfiguration, config, wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements);
|
||||
SPARCGraphBuilderPlugins.register(plugins, replacements.getDefaultReplacementBytecodeProvider());
|
||||
return plugins;
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ import static jdk.vm.ci.sparc.SPARC.i0;
|
||||
import static jdk.vm.ci.sparc.SPARC.i1;
|
||||
import static jdk.vm.ci.sparc.SPARC.o0;
|
||||
import static jdk.vm.ci.sparc.SPARC.o1;
|
||||
import static org.graalvm.compiler.core.common.LocationIdentity.any;
|
||||
import static org.graalvm.api.word.LocationIdentity.any;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotBackend.EXCEPTION_HANDLER;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotBackend.EXCEPTION_HANDLER_IN_CALLER;
|
||||
import static org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage.JUMP_ADDRESS;
|
||||
|
||||
@ -22,10 +22,10 @@
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.sparc;
|
||||
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.asConstant;
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
|
||||
import static jdk.vm.ci.sparc.SPARCKind.WORD;
|
||||
import static jdk.vm.ci.sparc.SPARCKind.XWORD;
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.asConstant;
|
||||
import static org.graalvm.compiler.lir.LIRValueUtil.isConstantValue;
|
||||
|
||||
import org.graalvm.compiler.core.common.CompressEncoding;
|
||||
import org.graalvm.compiler.core.common.LIRKind;
|
||||
@ -34,14 +34,15 @@ import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
|
||||
import org.graalvm.compiler.core.common.spi.LIRKindTool;
|
||||
import org.graalvm.compiler.core.sparc.SPARCArithmeticLIRGenerator;
|
||||
import org.graalvm.compiler.core.sparc.SPARCLIRGenerator;
|
||||
import org.graalvm.compiler.core.sparc.SPARCLIRKindTool;
|
||||
import org.graalvm.compiler.debug.GraalError;
|
||||
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
|
||||
import org.graalvm.compiler.hotspot.HotSpotBackend;
|
||||
import org.graalvm.compiler.hotspot.HotSpotDebugInfoBuilder;
|
||||
import org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage;
|
||||
import org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult;
|
||||
import org.graalvm.compiler.hotspot.HotSpotLIRGenerator;
|
||||
import org.graalvm.compiler.hotspot.HotSpotLockStack;
|
||||
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
|
||||
import org.graalvm.compiler.hotspot.debug.BenchmarkCounters;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider;
|
||||
@ -92,7 +93,7 @@ public class SPARCHotSpotLIRGenerator extends SPARCLIRGenerator implements HotSp
|
||||
}
|
||||
|
||||
private SPARCHotSpotLIRGenerator(HotSpotProviders providers, GraalHotSpotVMConfig config, LIRGenerationResult lirGenRes, ConstantTableBaseProvider constantTableBaseProvider) {
|
||||
this(new SPARCHotSpotLIRKindTool(), new SPARCArithmeticLIRGenerator(), new SPARCHotSpotMoveFactory(constantTableBaseProvider), providers, config, lirGenRes, constantTableBaseProvider);
|
||||
this(new SPARCLIRKindTool(), new SPARCArithmeticLIRGenerator(), new SPARCHotSpotMoveFactory(constantTableBaseProvider), providers, config, lirGenRes, constantTableBaseProvider);
|
||||
}
|
||||
|
||||
public SPARCHotSpotLIRGenerator(LIRKindTool lirKindTool, SPARCArithmeticLIRGenerator arithmeticLIRGen, MoveFactory moveFactory, HotSpotProviders providers, GraalHotSpotVMConfig config,
|
||||
|
||||
@ -22,22 +22,16 @@
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import static org.graalvm.compiler.core.common.util.Util.JAVA_SPECIFICATION_VERSION;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.api.test.Graal;
|
||||
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
|
||||
import org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider;
|
||||
@ -45,30 +39,33 @@ import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Binding;
|
||||
import org.graalvm.compiler.runtime.RuntimeProvider;
|
||||
import org.graalvm.compiler.serviceprovider.JDK9Method;
|
||||
import org.graalvm.compiler.test.GraalTest;
|
||||
import org.graalvm.util.EconomicSet;
|
||||
import org.graalvm.util.EconomicMap;
|
||||
import org.graalvm.util.MapCursor;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
|
||||
import jdk.vm.ci.hotspot.VMIntrinsicMethod;
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.meta.MetaUtil;
|
||||
import jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
|
||||
/**
|
||||
* Checks the set of intrinsics implemented by Graal against the set of intrinsics declared by
|
||||
* HotSpot. The purpose of this test is to detect when new intrinsics are added to HotSpot and
|
||||
* process them appropriately in Graal. This will be achieved by working through
|
||||
* {@link #TO_BE_INVESTIGATED} and either implementing the intrinsic or moving it to {@link #IGNORE}
|
||||
* .
|
||||
* Checks the intrinsics implemented by Graal against the set of intrinsics declared by HotSpot. The
|
||||
* purpose of this test is to detect when new intrinsics are added to HotSpot and process them
|
||||
* appropriately in Graal. This will be achieved by working through {@link #TO_BE_INVESTIGATED} and
|
||||
* either implementing the intrinsic or moving it to {@link #IGNORE} .
|
||||
*/
|
||||
public class CheckGraalIntrinsics extends GraalTest {
|
||||
|
||||
public static boolean match(ResolvedJavaMethod method, VMIntrinsicMethod intrinsic) {
|
||||
if (intrinsic.name.equals(method.getName())) {
|
||||
if (intrinsic.descriptor.equals(method.getSignature().toMethodDescriptor())) {
|
||||
String declaringClass = method.getDeclaringClass().toClassName().replace('.', '/');
|
||||
if (declaringClass.equals(intrinsic.declaringClass)) {
|
||||
public static boolean match(String type, Binding binding, VMIntrinsicMethod intrinsic) {
|
||||
if (intrinsic.name.equals(binding.name)) {
|
||||
if (intrinsic.descriptor.startsWith(binding.argumentsDescriptor)) {
|
||||
if (type.equals(intrinsic.declaringClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -76,16 +73,21 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ResolvedJavaMethod findMethod(EconomicSet<ResolvedJavaMethod> methods, VMIntrinsicMethod intrinsic) {
|
||||
for (ResolvedJavaMethod method : methods) {
|
||||
if (match(method, intrinsic)) {
|
||||
return method;
|
||||
public static InvocationPlugin findPlugin(EconomicMap<String, List<Binding>> bindings, VMIntrinsicMethod intrinsic) {
|
||||
MapCursor<String, List<Binding>> cursor = bindings.getEntries();
|
||||
while (cursor.advance()) {
|
||||
// Match format of VMIntrinsicMethod.declaringClass
|
||||
String type = MetaUtil.internalNameToJava(cursor.getKey(), true, false).replace('.', '/');
|
||||
for (Binding binding : cursor.getValue()) {
|
||||
if (match(type, binding, intrinsic)) {
|
||||
return binding.plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ResolvedJavaMethod resolveIntrinsic(MetaAccessProvider metaAccess, VMIntrinsicMethod intrinsic) throws ClassNotFoundException {
|
||||
public static ResolvedJavaMethod resolveIntrinsic(MetaAccessProvider metaAccess, VMIntrinsicMethod intrinsic) throws ClassNotFoundException {
|
||||
Class<?> c = Class.forName(intrinsic.declaringClass.replace('/', '.'), false, CheckGraalIntrinsics.class.getClassLoader());
|
||||
for (Method javaMethod : c.getDeclaredMethods()) {
|
||||
if (javaMethod.getName().equals(intrinsic.name)) {
|
||||
@ -366,7 +368,7 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
if (!config.useCRC32Intrinsics) {
|
||||
// Registration of the CRC32 plugins is guarded by UseCRC32Intrinsics
|
||||
add(IGNORE, "java/util/zip/CRC32.update(II)I");
|
||||
if (JAVA_SPECIFICATION_VERSION < 9) {
|
||||
if (JDK9Method.JAVA_SPECIFICATION_VERSION < 9) {
|
||||
add(IGNORE,
|
||||
"java/util/zip/CRC32.updateByteBuffer(IJII)I",
|
||||
"java/util/zip/CRC32.updateBytes(I[BII)I");
|
||||
@ -378,7 +380,7 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
"java/util/zip/CRC32C.updateDirectByteBuffer(IJII)I");
|
||||
}
|
||||
} else {
|
||||
if (JAVA_SPECIFICATION_VERSION >= 9) {
|
||||
if (JDK9Method.JAVA_SPECIFICATION_VERSION >= 9) {
|
||||
add(TO_BE_INVESTIGATED,
|
||||
"java/util/zip/CRC32C.updateBytes(I[BII)I",
|
||||
"java/util/zip/CRC32C.updateDirectByteBuffer(IJII)I");
|
||||
@ -387,7 +389,7 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
|
||||
if (!config.useAESIntrinsics) {
|
||||
// Registration of the AES plugins is guarded by UseAESIntrinsics
|
||||
if (JAVA_SPECIFICATION_VERSION < 9) {
|
||||
if (JDK9Method.JAVA_SPECIFICATION_VERSION < 9) {
|
||||
add(IGNORE,
|
||||
"com/sun/crypto/provider/AESCrypt.decryptBlock([BI[BI)V",
|
||||
"com/sun/crypto/provider/AESCrypt.encryptBlock([BI[BI)V",
|
||||
@ -403,7 +405,7 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
}
|
||||
if (!config.useMultiplyToLenIntrinsic()) {
|
||||
// Registration of the AES plugins is guarded by UseAESIntrinsics
|
||||
if (JAVA_SPECIFICATION_VERSION < 9) {
|
||||
if (JDK9Method.JAVA_SPECIFICATION_VERSION < 9) {
|
||||
add(IGNORE, "java/math/BigInteger.multiplyToLen([II[II[I)[I");
|
||||
} else {
|
||||
add(IGNORE, "java/math/BigInteger.implMultiplyToLen([II[II[I)[I");
|
||||
@ -426,28 +428,20 @@ public class CheckGraalIntrinsics extends GraalTest {
|
||||
public void test() throws ClassNotFoundException {
|
||||
HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
|
||||
HotSpotProviders providers = rt.getHostBackend().getProviders();
|
||||
Map<ResolvedJavaMethod, Object> impl = new HashMap<>();
|
||||
Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
|
||||
InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
|
||||
for (ResolvedJavaMethod method : invocationPlugins.getMethods()) {
|
||||
InvocationPlugin plugin = invocationPlugins.lookupInvocation(method);
|
||||
assert plugin != null;
|
||||
impl.put(method, plugin);
|
||||
}
|
||||
|
||||
EconomicSet<ResolvedJavaMethod> methods = invocationPlugins.getMethods();
|
||||
HotSpotVMConfigStore store = rt.getVMConfig().getStore();
|
||||
List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
|
||||
|
||||
List<String> missing = new ArrayList<>();
|
||||
EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
|
||||
for (VMIntrinsicMethod intrinsic : intrinsics) {
|
||||
ResolvedJavaMethod method = findMethod(methods, intrinsic);
|
||||
if (method == null) {
|
||||
method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
|
||||
|
||||
IntrinsicMethod intrinsicMethod = null;
|
||||
InvocationPlugin plugin = findPlugin(bindings, intrinsic);
|
||||
if (plugin == null) {
|
||||
ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
|
||||
if (method != null) {
|
||||
intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
|
||||
IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
|
||||
if (intrinsicMethod != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -26,9 +26,9 @@ import static java.util.Collections.singletonList;
|
||||
import static org.graalvm.compiler.core.GraalCompilerOptions.ExitVMOnException;
|
||||
import static org.graalvm.compiler.core.GraalCompilerOptions.PrintBailout;
|
||||
import static org.graalvm.compiler.core.GraalCompilerOptions.PrintStackTraceOnException;
|
||||
import static org.graalvm.compiler.core.common.util.Util.Java8OrEarlier;
|
||||
import static org.graalvm.compiler.core.test.ReflectionOptionDescriptors.extractEntries;
|
||||
import static org.graalvm.compiler.hotspot.test.CompileTheWorld.Options.DESCRIPTORS;
|
||||
import static org.graalvm.compiler.serviceprovider.JDK9Method.Java8OrEarlier;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
@ -69,7 +69,6 @@ import org.graalvm.compiler.api.replacements.Snippet;
|
||||
import org.graalvm.compiler.bytecode.Bytecodes;
|
||||
import org.graalvm.compiler.core.CompilerThreadFactory;
|
||||
import org.graalvm.compiler.core.CompilerThreadFactory.DebugConfigAccess;
|
||||
import org.graalvm.compiler.core.common.util.Util;
|
||||
import org.graalvm.compiler.core.test.ReflectionOptionDescriptors;
|
||||
import org.graalvm.compiler.debug.DebugEnvironment;
|
||||
import org.graalvm.compiler.debug.GraalDebugConfig;
|
||||
@ -85,7 +84,9 @@ import org.graalvm.compiler.options.OptionDescriptors;
|
||||
import org.graalvm.compiler.options.OptionKey;
|
||||
import org.graalvm.compiler.options.OptionValues;
|
||||
import org.graalvm.compiler.options.OptionsParser;
|
||||
import org.graalvm.compiler.serviceprovider.JDK9Method;
|
||||
import org.graalvm.util.EconomicMap;
|
||||
import org.graalvm.util.UnmodifiableEconomicMap;
|
||||
|
||||
import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider;
|
||||
import jdk.vm.ci.hotspot.HotSpotCompilationRequest;
|
||||
@ -98,7 +99,6 @@ import jdk.vm.ci.meta.ConstantPool;
|
||||
import jdk.vm.ci.meta.MetaAccessProvider;
|
||||
import jdk.vm.ci.runtime.JVMCI;
|
||||
import jdk.vm.ci.runtime.JVMCICompiler;
|
||||
import jdk.vm.ci.services.Services;
|
||||
|
||||
/**
|
||||
* This class implements compile-the-world functionality with JVMCI.
|
||||
@ -106,9 +106,9 @@ import jdk.vm.ci.services.Services;
|
||||
public final class CompileTheWorld {
|
||||
|
||||
/**
|
||||
* Magic token to denote that JDK classes are to be compiled. If {@link Util#Java8OrEarlier},
|
||||
* then the classes in {@code rt.jar} are compiled. Otherwise the classes in the Java runtime
|
||||
* image are compiled.
|
||||
* Magic token to denote that JDK classes are to be compiled. If
|
||||
* {@link JDK9Method#Java8OrEarlier}, then the classes in {@code rt.jar} are compiled. Otherwise
|
||||
* the classes in the Java runtime image are compiled.
|
||||
*/
|
||||
public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path";
|
||||
|
||||
@ -184,7 +184,7 @@ public final class CompileTheWorld {
|
||||
private ThreadPoolExecutor threadPool;
|
||||
|
||||
private OptionValues currentOptions;
|
||||
private final EconomicMap<OptionKey<?>, Object> compilationOptions;
|
||||
private final UnmodifiableEconomicMap<OptionKey<?>, Object> compilationOptions;
|
||||
|
||||
/**
|
||||
* Creates a compile-the-world instance.
|
||||
@ -205,21 +205,22 @@ public final class CompileTheWorld {
|
||||
this.methodFilters = methodFilters == null || methodFilters.isEmpty() ? null : MethodFilter.parse(methodFilters);
|
||||
this.excludeMethodFilters = excludeMethodFilters == null || excludeMethodFilters.isEmpty() ? null : MethodFilter.parse(excludeMethodFilters);
|
||||
this.verbose = verbose;
|
||||
EconomicMap<OptionKey<?>, Object> compilationOptionsCopy = EconomicMap.create(compilationOptions);
|
||||
this.currentOptions = initialOptions;
|
||||
|
||||
// Copy the initial options and add in any extra options
|
||||
EconomicMap<OptionKey<?>, Object> compilationOptionsCopy = EconomicMap.create(initialOptions.getMap());
|
||||
compilationOptionsCopy.putAll(compilationOptions);
|
||||
|
||||
// We don't want the VM to exit when a method fails to compile...
|
||||
ExitVMOnException.update(compilationOptionsCopy, false);
|
||||
ExitVMOnException.putIfAbsent(compilationOptionsCopy, false);
|
||||
|
||||
// ...but we want to see exceptions.
|
||||
PrintBailout.update(compilationOptionsCopy, true);
|
||||
PrintStackTraceOnException.update(compilationOptionsCopy, true);
|
||||
PrintBailout.putIfAbsent(compilationOptionsCopy, true);
|
||||
PrintStackTraceOnException.putIfAbsent(compilationOptionsCopy, true);
|
||||
|
||||
// By default only report statistics for the CTW threads themselves
|
||||
if (!GraalDebugConfig.Options.DebugValueThreadFilter.hasBeenSet(initialOptions)) {
|
||||
GraalDebugConfig.Options.DebugValueThreadFilter.update(compilationOptionsCopy, "^CompileTheWorld");
|
||||
}
|
||||
this.compilationOptions = EconomicMap.create(compilationOptionsCopy);
|
||||
GraalDebugConfig.Options.DebugValueThreadFilter.putIfAbsent(compilationOptionsCopy, "^CompileTheWorld");
|
||||
this.compilationOptions = compilationOptionsCopy;
|
||||
}
|
||||
|
||||
public CompileTheWorld(HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotGraalCompiler compiler, OptionValues options) {
|
||||
@ -509,7 +510,7 @@ public final class CompileTheWorld {
|
||||
}
|
||||
|
||||
OptionValues savedOptions = currentOptions;
|
||||
currentOptions = new OptionValues(savedOptions, compilationOptions);
|
||||
currentOptions = new OptionValues(compilationOptions);
|
||||
threadPool = new ThreadPoolExecutor(threadCount, threadCount, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(),
|
||||
new CompilerThreadFactory("CompileTheWorld", new DebugConfigAccess() {
|
||||
@Override
|
||||
@ -683,7 +684,7 @@ public final class CompileTheWorld {
|
||||
public void run() {
|
||||
waitToRun();
|
||||
OptionValues savedOptions = currentOptions;
|
||||
currentOptions = new OptionValues(savedOptions, compilationOptions);
|
||||
currentOptions = new OptionValues(compilationOptions);
|
||||
try {
|
||||
compileMethod(method, classFileCounter);
|
||||
} finally {
|
||||
@ -808,7 +809,6 @@ public final class CompileTheWorld {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Services.exportJVMCITo(CompileTheWorld.class);
|
||||
HotSpotJVMCIRuntime jvmciRuntime = HotSpotJVMCIRuntime.runtime();
|
||||
HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) jvmciRuntime.getCompiler();
|
||||
HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
|
||||
|
||||
@ -23,12 +23,10 @@
|
||||
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import static org.graalvm.compiler.core.common.util.ModuleAPI.addExports;
|
||||
import static org.graalvm.compiler.core.common.util.ModuleAPI.getModule;
|
||||
import static org.graalvm.compiler.test.JLModule.uncheckedAddExports;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.graalvm.compiler.core.common.util.Util;
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.Debug.Scope;
|
||||
@ -36,6 +34,7 @@ import org.graalvm.compiler.graph.Node;
|
||||
import org.graalvm.compiler.nodes.Invoke;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.test.JLModule;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
@ -109,11 +108,11 @@ public class ConstantPoolSubstitutionsTests extends GraalCompilerTest {
|
||||
* This test uses some API hidden by the JDK9 module system.
|
||||
*/
|
||||
private static void addExports(Class<?> c) {
|
||||
if (!Util.Java8OrEarlier) {
|
||||
Object javaBaseModule = getModule.invoke(String.class);
|
||||
Object cModule = getModule.invoke(c);
|
||||
addExports.invokeStatic(javaBaseModule, "jdk.internal.reflect", cModule);
|
||||
addExports.invokeStatic(javaBaseModule, "jdk.internal.misc", cModule);
|
||||
if (!Java8OrEarlier) {
|
||||
Object javaBaseModule = JLModule.fromClass(String.class);
|
||||
Object cModule = JLModule.fromClass(c);
|
||||
uncheckedAddExports(javaBaseModule, "jdk.internal.reflect", cModule);
|
||||
uncheckedAddExports(javaBaseModule, "jdk.internal.misc", cModule);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,17 +23,16 @@
|
||||
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.graalvm.compiler.core.common.CompressEncoding;
|
||||
import org.graalvm.compiler.hotspot.nodes.CompressionNode;
|
||||
import org.graalvm.compiler.hotspot.nodes.HotSpotCompressionNode;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.debug.OpaqueNode;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
@ -73,19 +72,18 @@ public class DataPatchTest extends HotSpotGraalCompilerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
|
||||
InvocationPlugins invocationPlugins = conf.getPlugins().getInvocationPlugins();
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
Registration r = new Registration(invocationPlugins, DataPatchTest.class);
|
||||
r.register1("compressUncompress", Object.class, new InvocationPlugin() {
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
|
||||
CompressEncoding encoding = runtime().getVMConfig().getOopEncoding();
|
||||
ValueNode compressed = b.add(CompressionNode.compress(arg, encoding));
|
||||
ValueNode compressed = b.add(HotSpotCompressionNode.compress(arg, encoding));
|
||||
ValueNode proxy = b.add(new OpaqueNode(compressed));
|
||||
b.addPush(JavaKind.Object, CompressionNode.uncompress(proxy, encoding));
|
||||
b.addPush(JavaKind.Object, HotSpotCompressionNode.uncompress(proxy, encoding));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return super.editGraphBuilderConfiguration(conf);
|
||||
super.registerInvocationPlugins(invocationPlugins);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotClassInitializationPlugin;
|
||||
import org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode;
|
||||
import org.graalvm.compiler.hotspot.phases.aot.EliminateRedundantInitializationPhase;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.phases.tiers.HighTierContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EliminateRedundantInitializationPhaseTest extends GraalCompilerTest {
|
||||
@Override
|
||||
protected Plugins getDefaultGraphBuilderPlugins() {
|
||||
Plugins plugins = super.getDefaultGraphBuilderPlugins();
|
||||
plugins.setClassInitializationPlugin(new HotSpotClassInitializationPlugin());
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public static class X {
|
||||
public static int x;
|
||||
public static int y;
|
||||
public static int z;
|
||||
}
|
||||
|
||||
public static class Y extends X {
|
||||
public static int a;
|
||||
public static int b;
|
||||
}
|
||||
|
||||
public static void assignFields() {
|
||||
X.x = 1;
|
||||
X.y = 2;
|
||||
X.z = 3;
|
||||
}
|
||||
|
||||
public static void assignFieldsConditionally(boolean choice) {
|
||||
X.x = 1;
|
||||
if (choice) {
|
||||
X.y = 2;
|
||||
} else {
|
||||
X.z = 3;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assignFieldsSubclassDominates() {
|
||||
Y.a = 1;
|
||||
X.x = 2;
|
||||
X.y = 3;
|
||||
X.z = 4;
|
||||
}
|
||||
|
||||
public static void assignFieldsConditionallySubclassDominates(boolean choice) {
|
||||
Y.a = 1;
|
||||
if (choice) {
|
||||
X.x = 2;
|
||||
} else {
|
||||
X.y = 3;
|
||||
}
|
||||
Y.z = 4;
|
||||
}
|
||||
|
||||
public static void assignFieldsSubclassPostdominates() {
|
||||
X.x = 1;
|
||||
Y.a = 2;
|
||||
}
|
||||
|
||||
public static void assignFieldsConditionallySubclassPostdominates(boolean choice) {
|
||||
X.x = 1;
|
||||
if (choice) {
|
||||
X.y = 2;
|
||||
} else {
|
||||
X.z = 3;
|
||||
}
|
||||
Y.a = 4;
|
||||
}
|
||||
|
||||
public static void assignFieldsConditionallyMixed(boolean choice) {
|
||||
X.x = 1;
|
||||
if (choice) {
|
||||
Y.a = 2;
|
||||
} else {
|
||||
X.z = 3;
|
||||
}
|
||||
Y.b = 4;
|
||||
}
|
||||
|
||||
public static void assignFieldsInLoop() {
|
||||
X.x = 1;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
X.y += X.z;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assignFieldsInBranches(boolean choice) {
|
||||
if (choice) {
|
||||
X.x = 1;
|
||||
} else {
|
||||
X.y = 2;
|
||||
}
|
||||
X.z = 3;
|
||||
}
|
||||
|
||||
public static void assignFieldsInBranchesMixed(boolean choice) {
|
||||
if (choice) {
|
||||
X.x = 1;
|
||||
} else {
|
||||
Y.a = 2;
|
||||
}
|
||||
X.z = 3;
|
||||
}
|
||||
|
||||
private void test(String name, int initNodesAfterParse, int initNodesAfterOpt) {
|
||||
StructuredGraph graph = parseEager(name, AllowAssumptions.NO);
|
||||
Assert.assertEquals(initNodesAfterParse, graph.getNodes().filter(InitializeKlassNode.class).count());
|
||||
HighTierContext highTierContext = getDefaultHighTierContext();
|
||||
new EliminateRedundantInitializationPhase().apply(graph, highTierContext);
|
||||
Assert.assertEquals(initNodesAfterOpt, graph.getNodes().filter(InitializeKlassNode.class).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
test("assignFields", 3, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
test("assignFieldsConditionally", 3, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3() {
|
||||
test("assignFieldsSubclassDominates", 4, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4() {
|
||||
test("assignFieldsConditionallySubclassDominates", 4, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test5() {
|
||||
test("assignFieldsSubclassPostdominates", 2, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test6() {
|
||||
test("assignFieldsConditionallySubclassPostdominates", 4, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test7() {
|
||||
test("assignFieldsConditionallyMixed", 4, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test8() {
|
||||
test("assignFieldsInLoop", 4, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test9() {
|
||||
test("assignFieldsInBranches", 3, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test10() {
|
||||
test("assignFieldsInBranchesMixed", 3, 2);
|
||||
}
|
||||
}
|
||||
@ -30,9 +30,9 @@ import org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProviderImpl;
|
||||
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
|
||||
import org.graalvm.compiler.nodes.ValueNode;
|
||||
import org.graalvm.compiler.nodes.extended.ForeignCallNode;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
@ -43,11 +43,9 @@ import jdk.vm.ci.meta.ResolvedJavaMethod;
|
||||
public class ForeignCallDeoptimizeTest extends GraalCompilerTest {
|
||||
|
||||
@Override
|
||||
protected Plugins getDefaultGraphBuilderPlugins() {
|
||||
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
|
||||
ForeignCallsProvider foreignCalls = ((HotSpotProviders) getProviders()).getForeignCalls();
|
||||
|
||||
Plugins ret = super.getDefaultGraphBuilderPlugins();
|
||||
ret.getInvocationPlugins().register(new InvocationPlugin() {
|
||||
invocationPlugins.register(new InvocationPlugin() {
|
||||
|
||||
@Override
|
||||
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
|
||||
@ -56,7 +54,7 @@ public class ForeignCallDeoptimizeTest extends GraalCompilerTest {
|
||||
return true;
|
||||
}
|
||||
}, ForeignCallDeoptimizeTest.class, "testCallInt", int.class);
|
||||
return ret;
|
||||
super.registerInvocationPlugins(invocationPlugins);
|
||||
}
|
||||
|
||||
public static int testCallInt(int value) {
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.reflect.Field;
|
||||
import javax.management.MBeanAttributeInfo;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectInstance;
|
||||
import javax.management.ObjectName;
|
||||
import org.graalvm.compiler.hotspot.HotSpotGraalMBean;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HotSpotGraalMBeanTest {
|
||||
@Test
|
||||
public void registration() throws Exception {
|
||||
ObjectName name;
|
||||
|
||||
Field field = null;
|
||||
try {
|
||||
field = stopMBeanServer();
|
||||
} catch (Exception ex) {
|
||||
if (ex.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
|
||||
// skip on JDK9
|
||||
return;
|
||||
}
|
||||
}
|
||||
assertNull("The platformMBeanServer isn't initialized now", field.get(null));
|
||||
|
||||
HotSpotGraalMBean bean = HotSpotGraalMBean.create();
|
||||
assertNotNull("Bean created", bean);
|
||||
|
||||
assertNull("It is not registered yet", bean.ensureRegistered(true));
|
||||
|
||||
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
|
||||
|
||||
assertNotNull("Now the bean thinks it is registered", name = bean.ensureRegistered(true));
|
||||
|
||||
assertNotNull("And the bean is found", server.getObjectInstance(name));
|
||||
}
|
||||
|
||||
private static Field stopMBeanServer() throws NoSuchFieldException, SecurityException, IllegalAccessException, IllegalArgumentException {
|
||||
final Field field = ManagementFactory.class.getDeclaredField("platformMBeanServer");
|
||||
field.setAccessible(true);
|
||||
field.set(null, null);
|
||||
return field;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readBeanInfo() throws Exception {
|
||||
ObjectName name;
|
||||
|
||||
assertNotNull("Server is started", ManagementFactory.getPlatformMBeanServer());
|
||||
|
||||
HotSpotGraalMBean realBean = HotSpotGraalMBean.create();
|
||||
assertNotNull("Bean is registered", name = realBean.ensureRegistered(false));
|
||||
|
||||
ObjectInstance bean = ManagementFactory.getPlatformMBeanServer().getObjectInstance(name);
|
||||
assertNotNull("Bean is registered", bean);
|
||||
MBeanInfo info = ManagementFactory.getPlatformMBeanServer().getMBeanInfo(name);
|
||||
assertNotNull("Info is found", info);
|
||||
for (MBeanAttributeInfo attr : info.getAttributes()) {
|
||||
if (attr.getName().equals("Dump")) {
|
||||
assertFalse("Read only now", attr.isWritable());
|
||||
assertTrue("Readable", attr.isReadable());
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("No Dump attribute found");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import org.graalvm.compiler.core.common.CompressEncoding;
|
||||
import org.graalvm.compiler.core.common.type.ObjectStamp;
|
||||
import org.graalvm.compiler.core.common.type.Stamp;
|
||||
import org.graalvm.compiler.core.common.type.StampFactory;
|
||||
import org.graalvm.compiler.hotspot.nodes.type.HotSpotNarrowOopStamp;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.meta.JavaConstant;
|
||||
import jdk.vm.ci.meta.JavaKind;
|
||||
import jdk.vm.ci.meta.MemoryAccessProvider;
|
||||
|
||||
public class HotSpotStampMemoryAccessTest extends HotSpotGraalCompilerTest {
|
||||
|
||||
@Ignore("not all versions are safe yet")
|
||||
@Test
|
||||
public void testReadNarrowObject() {
|
||||
CompressEncoding oopEncoding = runtime().getVMConfig().getOopEncoding();
|
||||
Assume.assumeTrue("Compressed oops must be enabled", runtime().getVMConfig().useCompressedOops);
|
||||
MemoryAccessProvider memory = getConstantReflection().getMemoryAccessProvider();
|
||||
JavaConstant base = getSnippetReflection().forObject("");
|
||||
ObjectStamp stamp = (ObjectStamp) StampFactory.forKind(JavaKind.Object);
|
||||
Stamp narrowStamp = HotSpotNarrowOopStamp.compressed(stamp, oopEncoding);
|
||||
assertTrue(narrowStamp.readConstant(memory, base, 128) == null);
|
||||
}
|
||||
}
|
||||
@ -25,20 +25,18 @@ package org.graalvm.compiler.hotspot.test;
|
||||
import static org.graalvm.compiler.debug.GraalDebugConfig.Options.Dump;
|
||||
import static org.graalvm.compiler.debug.GraalDebugConfig.Options.MethodFilter;
|
||||
import static org.graalvm.compiler.debug.GraalDebugConfig.Options.PrintGraph;
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.formatExecutedCommand;
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.getVMCommandLine;
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.withoutDebuggerArguments;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
import org.graalvm.compiler.test.SubprocessUtil;
|
||||
import org.graalvm.compiler.test.SubprocessUtil.Subprocess;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -47,9 +45,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class OptionsInFileTest extends GraalCompilerTest {
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
List<String> args = withoutDebuggerArguments(getVMCommandLine());
|
||||
|
||||
public void test() throws IOException, InterruptedException {
|
||||
String methodFilterValue = "a very unlikely method name";
|
||||
String debugFilterValue = "a very unlikely debug scope";
|
||||
File optionsFile = File.createTempFile("options", ".properties").getAbsoluteFile();
|
||||
@ -64,34 +60,25 @@ public class OptionsInFileTest extends GraalCompilerTest {
|
||||
out.println(PrintGraph.getName() + " = false");
|
||||
}
|
||||
|
||||
args.add("-Dgraal.options.file=" + optionsFile);
|
||||
args.add("-XX:+JVMCIPrintProperties");
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
|
||||
List<String> vmArgs = withoutDebuggerArguments(getVMCommandLine());
|
||||
vmArgs.add("-Dgraal.options.file=" + optionsFile);
|
||||
vmArgs.add("-XX:+JVMCIPrintProperties");
|
||||
Subprocess proc = SubprocessUtil.java(vmArgs);
|
||||
String[] expected = {
|
||||
"graal.MethodFilter := \"a very unlikely method name\"",
|
||||
"graal.Dump := \"a very unlikely debug scope\"",
|
||||
"graal.PrintGraph := false"};
|
||||
|
||||
List<String> outputLines = new ArrayList<>();
|
||||
|
||||
String line;
|
||||
while ((line = stdout.readLine()) != null) {
|
||||
outputLines.add(line);
|
||||
for (String line : proc.output) {
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
if (expected[i] != null && line.contains(expected[i])) {
|
||||
expected[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
String dashes = "-------------------------------------------------------";
|
||||
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
if (expected[i] != null) {
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", expected[i], formatExecutedCommand(args, outputLines, dashes, dashes)));
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", expected[i], proc));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
@ -22,43 +22,50 @@
|
||||
*/
|
||||
package org.graalvm.compiler.hotspot.test;
|
||||
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.formatExecutedCommand;
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.getVMCommandLine;
|
||||
import static org.graalvm.compiler.test.SubprocessUtil.withoutDebuggerArguments;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.graalvm.compiler.core.test.GraalCompilerTest;
|
||||
import org.graalvm.compiler.hotspot.CompilationTask;
|
||||
import org.graalvm.compiler.test.SubprocessUtil;
|
||||
import org.graalvm.compiler.test.SubprocessUtil.Subprocess;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests {@link CompilationTask} support for dumping graphs and other info useful for debugging a
|
||||
* compiler crash.
|
||||
* Tests support for dumping graphs and other info useful for debugging a compiler crash.
|
||||
*/
|
||||
public class RetryableCompilationTest extends GraalCompilerTest {
|
||||
|
||||
/**
|
||||
* Tests compilation requested by the VM.
|
||||
*/
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
List<String> args = withoutDebuggerArguments(getVMCommandLine());
|
||||
public void testVMCompilation() throws IOException, InterruptedException {
|
||||
testHelper(Arrays.asList("-XX:+BootstrapJVMCI", "-XX:+UseJVMCICompiler", "-Dgraal.CrashAt=Object.*,String.*", "-version"));
|
||||
}
|
||||
|
||||
args.add("-XX:+BootstrapJVMCI");
|
||||
args.add("-XX:+UseJVMCICompiler");
|
||||
args.add("-Dgraal.CrashAt=Object.*,String.*");
|
||||
args.add("-version");
|
||||
/**
|
||||
* Tests compilation requested by Truffle.
|
||||
*/
|
||||
@Test
|
||||
public void testTruffleCompilation() throws IOException, InterruptedException {
|
||||
testHelper(Arrays.asList("-Dgraal.CrashAt=root test1"), "org.graalvm.compiler.truffle.test.SLTruffleGraalTestSuite", "test");
|
||||
}
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(args);
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
private static void testHelper(List<String> extraVmArgs, String... mainClassAndArgs) throws IOException, InterruptedException {
|
||||
List<String> vmArgs = withoutDebuggerArguments(getVMCommandLine());
|
||||
vmArgs.addAll(extraVmArgs);
|
||||
|
||||
Subprocess proc = SubprocessUtil.java(vmArgs, mainClassAndArgs);
|
||||
|
||||
String forcedCrashString = "Forced crash after compiling";
|
||||
String diagnosticOutputFilePrefix = "Graal diagnostic output saved in ";
|
||||
@ -66,11 +73,7 @@ public class RetryableCompilationTest extends GraalCompilerTest {
|
||||
boolean seenForcedCrashString = false;
|
||||
String diagnosticOutputZip = null;
|
||||
|
||||
List<String> outputLines = new ArrayList<>();
|
||||
|
||||
String line;
|
||||
while ((line = stdout.readLine()) != null) {
|
||||
outputLines.add(line);
|
||||
for (String line : proc.output) {
|
||||
if (line.contains(forcedCrashString)) {
|
||||
seenForcedCrashString = true;
|
||||
} else if (diagnosticOutputZip == null) {
|
||||
@ -80,12 +83,11 @@ public class RetryableCompilationTest extends GraalCompilerTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
String dashes = "-------------------------------------------------------";
|
||||
if (!seenForcedCrashString) {
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", forcedCrashString, formatExecutedCommand(args, outputLines, dashes, dashes)));
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", forcedCrashString, proc));
|
||||
}
|
||||
if (diagnosticOutputZip == null) {
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", diagnosticOutputFilePrefix, formatExecutedCommand(args, outputLines, dashes, dashes)));
|
||||
Assert.fail(String.format("Did not find '%s' in output of command:%n%s", diagnosticOutputFilePrefix, proc));
|
||||
}
|
||||
|
||||
File zip = new File(diagnosticOutputZip).getAbsoluteFile();
|
||||
|
||||
@ -35,9 +35,10 @@ import org.graalvm.compiler.nodes.StructuredGraph;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Binding;
|
||||
import org.graalvm.compiler.nodes.graphbuilderconf.MethodSubstitutionPlugin;
|
||||
import org.graalvm.compiler.runtime.RuntimeProvider;
|
||||
import org.graalvm.util.EconomicSet;
|
||||
import org.graalvm.util.EconomicMap;
|
||||
import org.junit.Test;
|
||||
|
||||
import jdk.vm.ci.hotspot.HotSpotVMConfigStore;
|
||||
@ -50,46 +51,27 @@ import jdk.vm.ci.runtime.JVMCI;
|
||||
*/
|
||||
public class TestIntrinsicCompiles extends GraalCompilerTest {
|
||||
|
||||
private static boolean match(ResolvedJavaMethod method, VMIntrinsicMethod intrinsic) {
|
||||
if (intrinsic.name.equals(method.getName())) {
|
||||
if (intrinsic.descriptor.equals(method.getSignature().toMethodDescriptor())) {
|
||||
String declaringClass = method.getDeclaringClass().toClassName().replace('.', '/');
|
||||
if (declaringClass.equals(intrinsic.declaringClass)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static ResolvedJavaMethod findMethod(EconomicSet<ResolvedJavaMethod> methods, VMIntrinsicMethod intrinsic) {
|
||||
for (ResolvedJavaMethod method : methods) {
|
||||
if (match(method, intrinsic)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("try")
|
||||
public void test() {
|
||||
public void test() throws ClassNotFoundException {
|
||||
HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) JVMCI.getRuntime().getCompiler();
|
||||
HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
|
||||
HotSpotProviders providers = rt.getHostBackend().getProviders();
|
||||
Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
|
||||
InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
|
||||
|
||||
EconomicSet<ResolvedJavaMethod> pluginMethods = invocationPlugins.getMethods();
|
||||
EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
|
||||
HotSpotVMConfigStore store = rt.getVMConfig().getStore();
|
||||
List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
|
||||
for (VMIntrinsicMethod intrinsic : intrinsics) {
|
||||
ResolvedJavaMethod method = findMethod(pluginMethods, intrinsic);
|
||||
if (method != null) {
|
||||
InvocationPlugin plugin = invocationPlugins.lookupInvocation(method);
|
||||
if (plugin instanceof MethodSubstitutionPlugin && !method.isNative()) {
|
||||
StructuredGraph graph = compiler.getIntrinsicGraph(method, providers, INVALID_COMPILATION_ID, getInitialOptions());
|
||||
getCode(method, graph);
|
||||
InvocationPlugin plugin = CheckGraalIntrinsics.findPlugin(bindings, intrinsic);
|
||||
if (plugin != null) {
|
||||
if (plugin instanceof MethodSubstitutionPlugin) {
|
||||
ResolvedJavaMethod method = CheckGraalIntrinsics.resolveIntrinsic(getMetaAccess(), intrinsic);
|
||||
if (!method.isNative()) {
|
||||
StructuredGraph graph = compiler.getIntrinsicGraph(method, providers, INVALID_COMPILATION_ID, getInitialOptions());
|
||||
getCode(method, graph);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,8 +25,7 @@ package org.graalvm.compiler.hotspot.test;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.graalvm.compiler.core.common.LocationIdentity;
|
||||
import org.graalvm.api.word.LocationIdentity;
|
||||
import org.graalvm.compiler.debug.Debug;
|
||||
import org.graalvm.compiler.debug.Debug.Scope;
|
||||
import org.graalvm.compiler.debug.DebugConfig;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user