Skip to content
Permalink
Browse files

8235634: Update Graal

Reviewed-by: kvn
  • Loading branch information
Igor Veresov
Igor Veresov committed Dec 13, 2019
1 parent 58cce5f commit 0e6db16232fe69fe78270ff5b23a8208a778199c
Showing with 2,967 additions and 797 deletions.
  1. +8 −3 src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
  2. +17 −1 .../org.graalvm.compiler.api.directives/src/org/graalvm/compiler/api/directives/GraalDirectives.java
  3. +5 −5 ...are/classes/org.graalvm.compiler.asm.amd64/src/org/graalvm/compiler/asm/amd64/AMD64Assembler.java
  4. +12 −1 ...iler/share/classes/org.graalvm.compiler.asm.amd64/src/org/graalvm/compiler/asm/amd64/AVXKind.java
  5. +9 −2 ...are/classes/org.graalvm.compiler.asm.sparc/src/org/graalvm/compiler/asm/sparc/SPARCAssembler.java
  6. +17 −2 ...classes/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64AddressNode.java
  7. +1 −1 ....graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64ArithmeticLIRGenerator.java
  8. +9 −8 ...lasses/org.graalvm.compiler.core.amd64/src/org/graalvm/compiler/core/amd64/AMD64LIRGenerator.java
  9. +16 −0 .../share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/LIRKind.java
  10. +6 −1 .../share/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/NumUtil.java
  11. +7 −0 ...are/classes/org.graalvm.compiler.core.common/src/org/graalvm/compiler/core/common/type/Stamp.java
  12. +16 −6 ...are/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/HashMapGetTest.java
  13. +57 −0 ...es/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ObjectSubstitutionsTest.java
  14. +27 −4 ...ompiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/DebugContext.java
  15. +6 −2 ...m.compiler/share/classes/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/ScopeImpl.java
  16. +1 −1 ...mpiler.hotspot.aarch64/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java
  17. +76 −0 ...r.hotspot.amd64.test/src/org/graalvm/compiler/hotspot/amd64/test/NumberOfTrailingZeroings003.java
  18. +2 −1 ...vm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotAddressLowering.java
  19. +1 −1 ...lvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotBackendFactory.java
  20. +1 −1 ...lvm.compiler.hotspot.sparc/src/org/graalvm/compiler/hotspot/sparc/SPARCHotSpotBackendFactory.java
  21. +1 −1 ...g.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CompilationWrapperTest.java
  22. +2 −1 ...sses/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CompileTheWorld.java
  23. +391 −0 ...lvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/MethodSubstitutionEffectTest.java
  24. +396 −0 ...ompiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/MethodSubstitutionForeignCallTest.java
  25. +204 −139 ...graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/WriteBarrierAdditionTest.java
  26. +1 −0 ...e/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java
  27. +3 −2 .../classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotBackendFactory.java
  28. +2 −1 ...re/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalRuntime.java
  29. +3 −1 ...es/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotGraalRuntimeProvider.java
  30. +1 −1 ...lasses/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/HotSpotReplacementsImpl.java
  31. +15 −6 ...classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/SymbolicSnippetEncoder.java
  32. +19 −24 ...raalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/DefaultHotSpotLoweringProvider.java
  33. +6 −4 ...classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotGCProvider.java
  34. +41 −5 ...rg.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotGraphBuilderPlugins.java
  35. +3 −26 ...rg.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/meta/HotSpotUnsafeSubstitutions.java
  36. +101 −0 ...es/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/FastNotifyNode.java
  37. +14 −1 ...compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/HotSpotG1WriteBarrierSnippets.java
  38. +6 −1 ...aalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/HotSpotReplacementsUtil.java
  39. +126 −0 ...es/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/ObjectSnippets.java
  40. +0 −64 ...g.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/ObjectSubstitutions.java
  41. +106 −0 ....graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/UnsafeCopyMemoryNode.java
  42. +104 −0 ...es/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/UnsafeSnippets.java
  43. +15 −2 ...mpiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BciBlockMapping.java
  44. +133 −20 ...ompiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java
  45. +19 −6 ...l.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/JsrScope.java
  46. +1 −1 ...are/classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/AMD64MathPowOp.java
  47. +72 −0 .../classes/org.graalvm.compiler.lir.amd64/src/org/graalvm/compiler/lir/amd64/vector/AVXBlendOp.java
  48. +4 −1 ...ler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGeneratorTool.java
  49. +58 −0 ...re/classes/org.graalvm.compiler.nodes.test/src/org/graalvm/compiler/nodes/test/StampToolTest.java
  50. +22 −25 ...ompiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/GraphDecoder.java
  51. +9 −2 ...ler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/GuardedValueNode.java
  52. +17 −11 ...share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/FloatEqualsNode.java
  53. +1 −1 ...iler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/IsNullNode.java
  54. +4 −4 ...are/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/PointerEqualsNode.java
  55. +75 −0 ...share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/debug/SideEffectNode.java
  56. +4 −0 ...mpiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/gc/BarrierSet.java
  57. +6 −0 ...are/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/gc/CardTableBarrierSet.java
  58. +54 −3 ...iler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/gc/G1BarrierSet.java
  59. +5 −5 ...sses/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/gc/G1ReferentFieldReadBarrier.java
  60. +12 −2 .../org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/IntrinsicContext.java
  61. +54 −6 ...g.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/graphbuilderconf/LoopExplosionPlugin.java
  62. +6 −1 ...er/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/memory/HeapAccess.java
  63. +5 −4 ...piler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/type/StampTool.java
  64. +34 −357 ...vm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ConditionalEliminationPhase.java
  65. +441 −0 ...lvm.compiler.phases.common/src/org/graalvm/compiler/phases/common/ConditionalEliminationUtil.java
  66. +8 −6 ...alvm.compiler.replacements/src/org/graalvm/compiler/replacements/DefaultJavaLoweringProvider.java
  67. +9 −1 ...rg.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/IntrinsicGraphBuilder.java
  68. +27 −7 ...alvm.compiler.replacements/src/org/graalvm/compiler/replacements/StandardGraphBuilderPlugins.java
  69. +21 −8 ...raalvm.compiler.replacements/src/org/graalvm/compiler/replacements/gc/G1WriteBarrierSnippets.java
  70. +5 −2 ...iler.replacements/src/org/graalvm/compiler/replacements/nodes/arithmetic/IntegerAddExactNode.java
  71. +7 −5 ...lacements/src/org/graalvm/compiler/replacements/nodes/arithmetic/IntegerAddExactOverflowNode.java
@@ -224,9 +224,14 @@ public boolean supportsDynamicInvoke(GraphBuilderContext builder, int index, int
System.gc();
}

HotSpotGC graal_gc = runtime.getGarbageCollector();
int def = graal_gc.ordinal() + 1;
String name = "CollectedHeap::" + graal_gc.name();
HotSpotGC graalGC = runtime.getGarbageCollector();
// Prior to JDK 14, the Graal HotSpotGC enum order matched the JDK CollectedHeap enum
// order, so using the ordinal value worked fine. In JDK 14, CMS was removed on the
// JDK side, so we need a symbolic lookup of the JDK value.
int def = graalGC.ordinal() + 1;
// The GC names are spelled the same in both enums, so no clever remapping is needed
// here.
String name = "CollectedHeap::" + graalGC.name();
int gc = graalHotSpotVMConfig.getConstant(name, Integer.class, def);

BinaryContainer binaryContainer = new BinaryContainer(graalOptions, graalHotSpotVMConfig, graphBuilderConfig, gc, JVM_VERSION);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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
@@ -71,6 +71,22 @@ public static boolean inCompiledCode() {
public static void controlFlowAnchor() {
}

/**
* A call to this method will force the compiler to assume this instruction has a visible memory
* effect killing all memory locations.
*/
public static void sideEffect() {

}

/**
* A call to this method will force the compiler to assume this instruction has a visible memory
* effect killing all memory locations.
*/
public static int sideEffect(@SuppressWarnings("unused") int a) {
return 0;
}

/**
* Injects a probability for the given condition into the profiling information of a branch
* instruction. The probability must be a value between 0.0 and 1.0 (inclusive).
@@ -1298,9 +1298,9 @@ public void emit(AMD64Assembler asm, AVXSize size, AMD64Address dst, Register sr
*/
public static class VexRVMROp extends VexOp {
// @formatter:off
public static final VexRVMROp VPBLENDVB = new VexRVMROp("VPBLENDVB", P_66, M_0F3A, W0, 0x4C, VEXOpAssertion.AVX1_2);
public static final VexRVMROp VPBLENDVPS = new VexRVMROp("VPBLENDVPS", P_66, M_0F3A, W0, 0x4A, VEXOpAssertion.AVX1);
public static final VexRVMROp VPBLENDVPD = new VexRVMROp("VPBLENDVPD", P_66, M_0F3A, W0, 0x4B, VEXOpAssertion.AVX1);
public static final VexRVMROp VPBLENDVB = new VexRVMROp("VPBLENDVB", P_66, M_0F3A, W0, 0x4C, VEXOpAssertion.AVX1_2);
public static final VexRVMROp VBLENDVPS = new VexRVMROp("VBLENDVPS", P_66, M_0F3A, W0, 0x4A, VEXOpAssertion.AVX1);
public static final VexRVMROp VBLENDVPD = new VexRVMROp("VBLENDVPD", P_66, M_0F3A, W0, 0x4B, VEXOpAssertion.AVX1);
// @formatter:on

protected VexRVMROp(String opcode, int pp, int mmmmm, int w, int op, VEXOpAssertion assertion) {
@@ -3139,14 +3139,14 @@ public final void xorps(Register dst, Register src) {
SSEOp.XOR.emit(this, PS, dst, src);
}

protected final void decl(Register dst) {
public final void decl(Register dst) {
// Use two-byte form (one-byte form is a REX prefix in 64-bit mode)
prefix(dst);
emitByte(0xFF);
emitModRM(1, dst);
}

protected final void incl(Register dst) {
public final void incl(Register dst) {
// Use two-byte form (one-byte from is a REX prefix in 64-bit mode)
prefix(dst);
emitByte(0xFF);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2019, 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
@@ -111,6 +111,17 @@ public static AMD64Kind changeSize(AMD64Kind kind, AVXSize newSize) {
return getAVXKind(kind.getScalar(), newSize);
}

public static AMD64Kind getMaskKind(AMD64Kind kind) {
switch (kind.getScalar()) {
case SINGLE:
return getAVXKind(AMD64Kind.DWORD, kind.getVectorLength());
case DOUBLE:
return getAVXKind(AMD64Kind.QWORD, kind.getVectorLength());
default:
return kind;
}
}

public static AMD64Kind getAVXKind(AMD64Kind base, AVXSize size) {
for (AMD64Kind ret : AMD64Kind.values()) {
if (ret.getScalar() == base && ret.getSizeInBytes() == size.getBytes()) {
@@ -628,6 +628,13 @@ public int getValue() {
return value;
}

public int getOpfCCValue() {
/*
* In the opf_cc encoding for FMOVcc, the third bit is set to indicate icc/xcc.
*/
return (isFloat ? value : (value | 0x4));
}

public String getOperator() {
return operator;
}
@@ -1613,7 +1620,7 @@ public void emit(SPARCMacroAssembler masm, ConditionFlag condition, CC cc, Regis
inst = BitSpec.rd.setBits(inst, rd.encoding());
inst = BitSpec.op3.setBits(inst, opfLow.op3.value);
inst = BitSpec.opfCond.setBits(inst, condition.value);
inst = BitSpec.opfCC.setBits(inst, cc.value);
inst = BitSpec.opfCC.setBits(inst, cc.getOpfCCValue());
inst = BitSpec.opfLow.setBits(inst, opfLow.value);
inst = BitSpec.rs2.setBits(inst, rs2.encoding());
masm.emitInt(inst);
@@ -2193,7 +2200,7 @@ public void fmovscc(ConditionFlag cond, CC cc, Register rs2, Register rd) {
}

private void fmovcc(ConditionFlag cond, CC cc, Register rs2, Register rd, int opfLow) {
int opfCC = cc.value;
int opfCC = cc.getOpfCCValue();
int a = opfCC << 11 | opfLow << 5 | rs2.encoding;
fmt10(rd.encoding, Fpop2.value, cond.value, a);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, 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
@@ -63,6 +63,14 @@

private int displacement;

/*
* If this address has been improved by folding an uncompress operation into it, this is set by
* the address lowering to the uncompression scale used by the encoding strategy. It is null
* otherwise. This might be different from scale if we lowered an uncompression followed by
* further improvements that modify the scale.
*/
private Scale uncompressionScale;

public AMD64AddressNode(ValueNode base) {
this(base, null);
}
@@ -72,6 +80,7 @@ public AMD64AddressNode(ValueNode base, ValueNode index) {
this.base = base;
this.index = index;
this.scale = Scale.Times1;
this.uncompressionScale = null;
}

public void canonicalizeIndex(SimplifierTool tool) {
@@ -103,12 +112,14 @@ public void generate(NodeLIRBuilderTool gen) {
AllocatableValue baseValue = base == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(base));
AllocatableValue indexValue = index == null ? Value.ILLEGAL : tool.asAllocatable(gen.operand(index));

AllocatableValue baseReference = LIRKind.derivedBaseFromValue(baseValue);
AllocatableValue baseReference = base == null ? null : LIRKind.derivedBaseFromValue(baseValue);
AllocatableValue indexReference;
if (index == null) {
indexReference = null;
} else if (scale.equals(Scale.Times1)) {
indexReference = LIRKind.derivedBaseFromValue(indexValue);
} else if (scale.equals(uncompressionScale) && LIRKind.isScalarCompressedReference(indexValue.getValueKind())) {
indexReference = LIRKind.derivedBaseFromValue(indexValue);
} else {
if (LIRKind.isValue(indexValue)) {
indexReference = null;
@@ -163,6 +174,10 @@ public void setDisplacement(int displacement) {
this.displacement = displacement;
}

public void setUncompressionScale(Scale scale) {
this.uncompressionScale = scale;
}

@Override
public long getMaxConstantDisplacement() {
return displacement;
@@ -1305,7 +1305,7 @@ public void emitCompareOp(AMD64Kind cmpKind, Variable left, Value right) {
return;
} else if (c instanceof VMConstant) {
VMConstant vc = (VMConstant) c;
if (size == DWORD && !GeneratePIC.getValue(getOptions())) {
if (size == DWORD && !GeneratePIC.getValue(getOptions()) && getLIRGen().target().inlineObjects) {
getLIRGen().append(new AMD64BinaryConsumer.VMConstOp(CMP.getMIOpcode(DWORD, false), left, vc));
} else {
getLIRGen().append(new AMD64BinaryConsumer.DataOp(CMP.getRMOpcode(size), size, left, vc));
@@ -409,7 +409,7 @@ public Variable emitIntegerTestMove(Value left, Value right, Value trueValue, Va
return result;
}

private static AVXSize getRegisterSize(Value a) {
protected static AVXSize getRegisterSize(Value a) {
AMD64Kind kind = (AMD64Kind) a.getPlatformKind();
if (kind.isXMM()) {
return AVXKind.getRegisterSize(kind);
@@ -479,18 +479,19 @@ protected boolean emitCompareMemoryConOp(OperandSize size, ConstantValue a, AMD6
if (JavaConstant.isNull(a.getConstant())) {
append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, 0, state));
return true;
} else if (a.getConstant() instanceof VMConstant && size == DWORD) {
} else if (a.getConstant() instanceof VMConstant && size == DWORD && target().inlineObjects) {
VMConstant vc = (VMConstant) a.getConstant();
append(new AMD64BinaryConsumer.MemoryVMConstOp(CMP.getMIOpcode(size, false), b, vc, state));
return true;
} else {
long value = a.getJavaConstant().asLong();
if (NumUtil.is32bit(value)) {
append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, (int) value, state));
return true;
} else {
return emitCompareRegMemoryOp(size, asAllocatable(a), b, state);
if (a.getConstant() instanceof JavaConstant && a.getJavaConstant().getJavaKind() != JavaKind.Object) {
long value = a.getJavaConstant().asLong();
if (NumUtil.is32bit(value)) {
append(new AMD64BinaryConsumer.MemoryConstOp(CMP, size, b, (int) value, state));
return true;
}
}
return emitCompareRegMemoryOp(size, asAllocatable(a), b, state);
}
}

@@ -421,6 +421,22 @@ public boolean isCompressedReference(int idx) {
return !isUnknownReference() && (referenceCompressionMask & (1 << idx)) != 0;
}

/**
* Check whether the given kind is a scalar (i.e., vector length 1) <b>compressed</b> reference.
*
* @param kind The kind to be checked.
* @return true if the given kind is a scalar compressed reference
*/
public static boolean isScalarCompressedReference(ValueKind<?> kind) {
if (kind instanceof LIRKind) {
LIRKind lirKind = (LIRKind) kind;
if (lirKind.getPlatformKind().getVectorLength() == 1 && lirKind.isCompressedReference(0)) {
return true;
}
}
return false;
}

/**
* Check whether this kind is a value type that doesn't need to be tracked at safepoints.
*/
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2019, 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
@@ -105,6 +105,11 @@ public static boolean is32bit(long x) {
return -0x80000000L <= x && x < 0x80000000L;
}

public static byte safeToByte(int v) {
assert isByte(v);
return (byte) v;
}

public static short safeToShort(int v) {
assert isShort(v);
return (short) v;
@@ -135,6 +135,13 @@ public boolean isUnrestricted() {
return this.equals(this.unrestricted());
}

/**
* Tests whether this stamp represents a pointer value.
*/
public boolean isPointerStamp() {
return this instanceof AbstractPointerStamp;
}

/**
* If this stamp represents a single value, the methods returns this single value. It returns
* null otherwise.
@@ -25,36 +25,46 @@
package org.graalvm.compiler.core.test;

import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.graalvm.compiler.nodes.FieldLocationIdentity;
import org.graalvm.compiler.nodes.IfNode;
import org.graalvm.compiler.nodes.LogicNode;
import org.graalvm.compiler.nodes.ReturnNode;
import org.graalvm.compiler.nodes.calc.ObjectEqualsNode;
import org.graalvm.compiler.nodes.memory.ReadNode;
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;

public class HashMapGetTest extends GraalCompilerTest {
public class HashMapGetTest extends SubprocessTest {

public static void mapGet(HashMap<Integer, Integer> map, Integer key) {
public static <K, V> void mapGet(HashMap<K, V> map, K key) {
map.get(key);
}

@Test
public void hashMapTest() {
HashMap<Integer, Integer> map = new HashMap<>();
ResolvedJavaMethod get = getResolvedJavaMethod(HashMapGetTest.class, "mapGet");
for (int i = 0; i < 5000; i++) {
for (int i = 0; i < 10000; i++) {
mapGet(map, i);
map.put(i, i);
mapGet(map, i);
}
test(get, null, map, 0);
for (IfNode ifNode : lastCompiledGraph.getNodes(IfNode.TYPE)) {
LogicNode condition = ifNode.condition();
if (ifNode.getTrueSuccessorProbability() < 0.4 && condition instanceof ObjectEqualsNode) {
assertTrue(ifNode.trueSuccessor().next() instanceof ReturnNode, "Expected return but got %s (trueSuccessor: %s)", ifNode.trueSuccessor().next(), ifNode.trueSuccessor());
if (ifNode.getTrueSuccessorProbability() < 0.4 && ifNode.predecessor() instanceof ReadNode && condition instanceof ObjectEqualsNode) {
ReadNode read = (ReadNode) ifNode.predecessor();
if (read.getLocationIdentity() instanceof FieldLocationIdentity && ((FieldLocationIdentity) read.getLocationIdentity()).getField().getName().contains("key")) {
assertTrue(ifNode.trueSuccessor().next() instanceof ReturnNode, "Expected return after %s, got %s", ifNode.trueSuccessor(), ifNode.trueSuccessor().next());
}
}
}
}

@Test
public void hashMapTestInSubprocess() throws IOException, InterruptedException {
launchSubprocess(this::hashMapTest);
}

}

0 comments on commit 0e6db16

Please sign in to comment.
You can’t perform that action at this time.