Skip to content
Permalink
Browse files

8247251: Assert (_pcs_length == 0 || last_pc()->pc_offset() < pc_offs…

Co-authored-by: Tom Rodriguez <never@openjdk.org>
Reviewed-by: never
  • Loading branch information
Vladimir Kozlov Tom Rodriguez
Vladimir Kozlov and Tom Rodriguez committed Sep 22, 2020
1 parent 3d5fea1 commit 24e12b3811cb9e3e593f75f9daeff8bfd39dc632
@@ -79,7 +79,7 @@
public static <T extends CompilationResult> void emitBackEnd(StructuredGraph graph, Object stub, ResolvedJavaMethod installedCodeOwner, Backend backend, T compilationResult,
CompilationResultBuilderFactory factory, RegisterConfig registerConfig, LIRSuites lirSuites) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope s = debug.scope("BackEnd", graph.getLastSchedule()); DebugCloseable a = BackEnd.start(debug)) {
try (DebugContext.Scope s = debug.scope("BackEnd", graph, graph.getLastSchedule()); DebugCloseable a = BackEnd.start(debug)) {
LIRGenerationResult lirGen = null;
lirGen = emitLIR(backend, graph, stub, registerConfig, lirSuites);
try (DebugContext.Scope s2 = debug.scope("CodeGen", lirGen, lirGen.getLIR())) {
@@ -28,14 +28,15 @@
import java.util.ArrayList;
import java.util.HashMap;

import org.graalvm.compiler.api.directives.GraalDirectives;
import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.graalvm.compiler.graph.Node;
import org.graalvm.compiler.replacements.arraycopy.ArrayCopySnippets;
import org.graalvm.compiler.nodes.DirectCallTargetNode;
import org.graalvm.compiler.nodes.Invoke;
import org.graalvm.compiler.nodes.LoweredCallTargetNode;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.replacements.arraycopy.ArrayCopySnippets;
import org.junit.Assert;
import org.junit.Test;

@@ -370,4 +371,22 @@ public void testObjectArrayExceptions() {
test("objectArraycopyCatchArrayStoreException", longSource, 4, integerDest, 2, 3);
test("objectArraycopyCatchArrayIndexException", new Integer[128], 0, new Integer[128], Integer.MAX_VALUE, 1);
}

@Test
public void testArraycopyDeoptWithSideEffect() {
ArgSupplier s = () -> new int[4];
int[] b = new int[]{1, 1, 1, 1};
int[] c = new int[]{2, 2, 2, 2};
test("arraycopyAndDeopt", s, b, c);
}

public static int[] arraycopyAndDeopt(int[] a, int[] b, int[] c) {
if (a[0] == 0) {
System.arraycopy(b, 0, a, 0, b.length);
GraalDirectives.deoptimize();
} else {
System.arraycopy(c, 0, a, 0, b.length);
}
return a;
}
}
@@ -47,6 +47,7 @@
import org.graalvm.compiler.debug.DebugDumpScope;
import org.graalvm.compiler.debug.DebugHandlersFactory;
import org.graalvm.compiler.debug.TimerKey;
import org.graalvm.compiler.nodes.StructuredGraph;
import org.graalvm.compiler.options.OptionKey;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.printer.GraalDebugHandlersFactory;
@@ -165,15 +166,17 @@ protected HotSpotCompilationRequestResult performCompilation(DebugContext debug)

final CompilationPrinter printer = CompilationPrinter.begin(debug.getOptions(), compilationId, method, entryBCI);

StructuredGraph graph;
try (DebugContext.Scope s = debug.scope("Compiling", new DebugDumpScope(getIdString(), true))) {
result = compiler.compile(method, entryBCI, useProfilingInfo, shouldRetainLocalVariables, compilationId, debug);
graph = compiler.createGraph(method, entryBCI, useProfilingInfo, compilationId, debug.getOptions(), debug);
result = compiler.compile(graph, method, entryBCI, useProfilingInfo, shouldRetainLocalVariables, compilationId, debug);
} catch (Throwable e) {
throw debug.handle(e);
}

if (result != null) {
try (DebugCloseable b = CodeInstallationTime.start(debug)) {
installMethod(debug, result);
installMethod(debug, graph, result);
}
// Installation is included in compilation time and memory usage reported by printer
printer.finish(result);
@@ -352,12 +355,12 @@ public HotSpotCompilationRequestResult runCompilation(DebugContext debug) {
}

@SuppressWarnings("try")
private void installMethod(DebugContext debug, final CompilationResult compResult) {
private void installMethod(DebugContext debug, StructuredGraph graph, final CompilationResult compResult) {
final CodeCacheProvider codeCache = jvmciRuntime.getHostJVMCIBackend().getCodeCache();
HotSpotBackend backend = compiler.getGraalRuntime().getHostBackend();
installedCode = null;
Object[] context = {new DebugDumpScope(getIdString(), true), codeCache, getMethod(), compResult};
try (DebugContext.Scope s = debug.scope("CodeInstall", context)) {
try (DebugContext.Scope s = debug.scope("CodeInstall", context, graph)) {
HotSpotCompilationRequest request = getRequest();
installedCode = (HotSpotInstalledCode) backend.createInstalledCode(debug,
request.getMethod(),
@@ -235,13 +235,13 @@ public CompilationResult compileHelper(CompilationResultBuilderFactory crbf, Com
return result;
}

public CompilationResult compile(ResolvedJavaMethod method,
public CompilationResult compile(StructuredGraph graph,
ResolvedJavaMethod method,
int entryBCI,
boolean useProfilingInfo,
boolean shouldRetainLocalVariables,
CompilationIdentifier compilationId,
DebugContext debug) {
StructuredGraph graph = createGraph(method, entryBCI, useProfilingInfo, compilationId, debug.getOptions(), debug);
CompilationResult result = new CompilationResult(compilationId);
return compileHelper(CompilationResultBuilderFactory.Default, result, graph, method, entryBCI, useProfilingInfo, shouldRetainLocalVariables, debug.getOptions());
}
@@ -216,13 +216,20 @@ protected NodeStateAssignment afterSplit(AbstractBeginNode node, NodeStateAssign
afterCount++;
}
}
NodeStateAssignment selected = null;
if (invalidCount > 0) {
stateMapping.put(loop, NodeStateAssignment.INVALID);
selected = NodeStateAssignment.INVALID;
} else {
if (afterCount > 0) {
stateMapping.put(loop, NodeStateAssignment.AFTER_BCI);
selected = NodeStateAssignment.AFTER_BCI;
} else {
stateMapping.put(loop, NodeStateAssignment.BEFORE_BCI);
selected = NodeStateAssignment.BEFORE_BCI;
}
}
stateMapping.put(loop, selected);
if (selected != initialState) {
for (LoopExitNode exit : loop.loopExits()) {
loopInfo.exitStates.put(exit, selected);
}
}
return loopInfo.exitStates;
@@ -51,6 +51,7 @@
import org.graalvm.compiler.nodes.calc.IntegerConvertNode;
import org.graalvm.compiler.nodes.calc.LeftShiftNode;
import org.graalvm.compiler.nodes.extended.ForeignCallNode;
import org.graalvm.compiler.nodes.memory.AbstractMemoryCheckpoint;
import org.graalvm.compiler.nodes.memory.MemoryAccess;
import org.graalvm.compiler.nodes.memory.MemoryKill;
import org.graalvm.compiler.nodes.memory.SingleMemoryKill;
@@ -67,7 +68,7 @@
import jdk.vm.ci.meta.PrimitiveConstant;

@NodeInfo(allowedUsageTypes = {Memory}, cycles = CYCLES_UNKNOWN, size = SIZE_UNKNOWN)
public final class ArrayCopyCallNode extends FixedWithNextNode implements Lowerable, SingleMemoryKill, MemoryAccess, Canonicalizable {
public final class ArrayCopyCallNode extends AbstractMemoryCheckpoint implements Lowerable, SingleMemoryKill, MemoryAccess, Canonicalizable {

public static final NodeClass<ArrayCopyCallNode> TYPE = NodeClass.create(ArrayCopyCallNode.class);
@Input protected ValueNode src;
@@ -214,6 +215,11 @@ public LocationIdentity getKilledLocationIdentity() {
return killedLocationIdentity;
}

@Override
public boolean hasSideEffect() {
return !killedLocationIdentity.isInit();
}

@NodeIntrinsic(hasSideEffect = true)
private static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length, @ConstantNodeParameter JavaKind elementKind, @ConstantNodeParameter boolean aligned,
@ConstantNodeParameter boolean disjoint, @ConstantNodeParameter boolean uninitialized, @ConstantNodeParameter int heapWordSize);

1 comment on commit 24e12b3

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on 24e12b3 Sep 22, 2020

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