Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
1fae644
update to jvmci-23.0-b05
marwan-hallaoui Dec 12, 2022
eb9940c
remove labsjdk-ce-17
marwan-hallaoui Dec 15, 2022
fc01571
remove unused code in compiler.graph
wirthi Dec 16, 2022
3a35f13
remove unused code in compiler.phases
wirthi Dec 16, 2022
d45b2e0
remove unused code in compiler.phases.common
wirthi Dec 16, 2022
44199ef
remove unused code in compiler.nodes and others
wirthi Dec 16, 2022
5a9b8bd
move methods from core.common.util.Util to more specific places
wirthi Dec 16, 2022
0e81c54
* Make sure we don't use the Truffle logger before we have the Truffl…
javeleon Dec 19, 2022
1b9c7ef
Implement unsigned normalize compare optimization cases
gergo- Dec 19, 2022
3898afd
make logging methods static
javeleon Dec 19, 2022
e599a9a
fix JavaDoc
wirthi Dec 16, 2022
2c16de5
remove unnecessary utility method
wirthi Dec 19, 2022
9a8ceb3
remove unused enum
javeleon Dec 20, 2022
8e5d2cc
remove unused imports
javeleon Dec 20, 2022
3389c1d
add new Intrinsic
marwan-hallaoui Dec 16, 2022
fada1f9
remove jdk17 ce atifacts
marwan-hallaoui Dec 20, 2022
5bee769
[GR-43147] NIOFileSystemTest#testCreateDirectory fails on JDK-11.
tzezula Dec 20, 2022
4c2da20
revert 3898afda7da
javeleon Dec 21, 2022
9d3c8c2
make the bootstrapping thread local context-specific
javeleon Dec 21, 2022
543bc92
fix missing imports from revert
javeleon Dec 21, 2022
06f506d
mem improvements
davleopo Nov 18, 2022
45143d0
address review comments
davleopo Nov 21, 2022
bb33149
Basic Blocks: remove pred and succ arrays and use one of first element
davleopo Nov 21, 2022
3a050ab
measure cfg and compiler memory
davleopo Nov 21, 2022
0285d02
basic blocks: use rpo references instead of actual block pointers
davleopo Nov 22, 2022
9ffd60a
svm: report metrics after compilation
davleopo Nov 22, 2022
1086ad9
control flow graph: make default basic blocks use the graph to answer
davleopo Nov 24, 2022
658ab63
renaming and restructuring around AbstractBlockBase
dougxc Nov 28, 2022
8044323
basic blocks: use char index instead of int
davleopo Nov 30, 2022
fff6b2e
drop block arrays in the backend, use indices into the cfg reverse post
davleopo Nov 30, 2022
febd9f4
basic blocks: refactorings
davleopo Dec 1, 2022
83a4397
address review comments
davleopo Dec 5, 2022
d733cb4
address review comments
davleopo Dec 19, 2022
34834ea
Rename AbstractBlockBase to BasicBlock and Block to HIRBlock.
davleopo Dec 19, 2022
2dccbbd
checkstyle fixes
davleopo Dec 19, 2022
b76380b
unused import
javeleon Dec 21, 2022
5b0d153
avoid hiding a field
javeleon Dec 21, 2022
54f64bd
Corrections after changes in breakpoints resolution. (GR-43152)
entlicher Dec 20, 2022
019ee63
Update LLVM toolchain version to 15.0.6.
rschatz Nov 25, 2022
7b314e3
Update LLVM patches.
rschatz Nov 25, 2022
ac2fb4d
Fix new compiler error from LLVM 15.
rschatz Nov 25, 2022
47f7e9d
Update bitcode test for LLVM 15.
rschatz Nov 25, 2022
1fe33fa
Switch generated LLIR tests to opaque pointers.
rschatz Nov 25, 2022
42ecef4
Keep track of base type in getelementptr instruction and use it inste…
rschatz Nov 28, 2022
6097c41
Parser support for new opaque pointer type.
rschatz Nov 28, 2022
90f5cbf
Add intrinsic name variants for opaque pointer arguments.
rschatz Nov 28, 2022
3af77ed
Simplify constructor/destructor handling in LLVM InitializeModuleNode.
rschatz Nov 29, 2022
fed8fe3
Support opaque pointers in atomic instructions (cmpxchg, rmw).
rschatz Nov 29, 2022
ede8af9
Use type from byval attribute instead of relying on non-opaque pointers.
rschatz Nov 29, 2022
b5c66d0
Fix usage of getPointeeType on opaque pointer.
rschatz Nov 30, 2022
b5a0c92
Reformat with updated clang-format.
rschatz Nov 30, 2022
4dd559d
[GR-41540] Revert "[GR-41537] Workaround for dsymutil bug on Darwin"
rschatz Nov 30, 2022
a24b5f2
Use ar/libtool from llvm for static linking of libc++experimental.
rschatz Dec 1, 2022
e09ce9b
Treat function types as pointer types in inline assembly.
rschatz Dec 12, 2022
4a95516
Fix "invalid receiver" in LLVMManagedWriteLibrary.
rschatz Dec 14, 2022
f6e7f4a
Update LLVM fuzzer patches.
rschatz Dec 14, 2022
356a1f2
Prefer function type encoded in call/invoke bitcode instruction over …
rschatz Dec 16, 2022
1d78185
Update fastr and truffleruby import to include LLVM 15 fixes.
rschatz Dec 16, 2022
702f0cd
use deployed artifacts
marwan-hallaoui Dec 21, 2022
52f5928
minor formatting fix
javeleon Dec 21, 2022
55994ef
extra diagnostics to debug transiently failing gate
dougxc Dec 21, 2022
c721822
Broken links check
olyagpl Dec 21, 2022
d73df9f
[GR-41580] Update to jvmci-23.0-b05.
marwan-hallaoui Dec 21, 2022
59c6485
[GR-42230] Memory improvements.
davleopo Dec 21, 2022
e0983e6
[GR-40487] Implement unsigned normalize compare optimization cases
gergo- Dec 21, 2022
e79c746
[GR-43147] NIOFileSystemTest#testCreateDirectory fails on JDK-11.
tzezula Dec 22, 2022
15ed98e
[GR-21590] Update Python imports.
fangerer Dec 22, 2022
cd88917
[GR-43128] Broken links check.
olyagpl Dec 22, 2022
4d9b03e
[GR-43161] Extra diagnostics to debug transiently failing gate.
dougxc Dec 22, 2022
cb3cd26
[GR-43111] [GR-43026] Remove unused code from several compiler packages.
wirthi Dec 22, 2022
a1ce8a9
[GR-43117] Fix Espresso jdwp deadlock in embedding use case.
javeleon Dec 22, 2022
617b535
[GR-43152] Corrections after changes in breakpoints resolution.
entlicher Dec 22, 2022
3c3f12b
disable failing test
dougxc Dec 22, 2022
809e02f
[GR-41539] Update to LLVM 15.0.6.
rschatz Dec 22, 2022
d614c1d
[GR-43161] Disable failing test.
dougxc Dec 22, 2022
890c1a2
Consolidate platform exclusions across variants
pejovica Dec 12, 2022
37a1b93
Switch SVM style gate to JDK 20
pejovica Dec 21, 2022
49c52cc
Fix lossy conversion warnings
pejovica Dec 22, 2022
01cfe78
Move validation of JSON build info out of style gate
pejovica Dec 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ci/ci_common/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ local add_jdk_version(name) =
for name in std.objectFieldsAll(jdks)
} + {
# Aliases to edition specific labsjdks
labsjdk17:: self["labsjdk-" + repo_config.graalvm_edition + "-17"],
labsjdk17:: self["labsjdk-ee-17"],
labsjdk19:: self["labsjdk-" + repo_config.graalvm_edition + "-19"],
labsjdk17Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-17Debug"],
labsjdk17Debug:: self["labsjdk-ee-17Debug"],
labsjdk19Debug:: self["labsjdk-" + repo_config.graalvm_edition + "-19Debug"],
labsjdk17LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-17-llvm"],
labsjdk17LLVM:: self["labsjdk-ee-17-llvm"],
labsjdk19LLVM:: self["labsjdk-" + repo_config.graalvm_edition + "-19-llvm"],

# Only CE exists for JDK 20 until JDK 20 GA.
Expand Down
21 changes: 9 additions & 12 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@

"jdks": {
"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.1", "build_id": "12", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.6+2-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ce-17Debug": {"name": "labsjdk", "version": "ce-17.0.6+2-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ce-17-llvm": {"name": "labsjdk", "version": "ce-17.0.6+2-jvmci-23.0-b04-sulong", "platformspecific": true },
"labsjdk-ee-17": {"name": "labsjdk", "version": "ee-17.0.6+7-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ee-17Debug": {"name": "labsjdk", "version": "ee-17.0.6+7-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ee-17-llvm": {"name": "labsjdk", "version": "ee-17.0.6+7-jvmci-23.0-b04-sulong", "platformspecific": true },
"labsjdk-ee-17": {"name": "labsjdk", "version": "ee-17.0.6+9-jvmci-22.3-b11", "platformspecific": true },
"labsjdk-ee-17Debug": {"name": "labsjdk", "version": "ee-17.0.6+9-jvmci-22.3-b11-debug", "platformspecific": true },
"labsjdk-ee-17-llvm": {"name": "labsjdk", "version": "ee-17.0.6+9-jvmci-22.3-b11-sulong", "platformspecific": true },

"oraclejdk19": {"name": "jpg-jdk", "version": "19", "build_id": "26", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-19": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ce-19Debug": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ce-19-llvm": {"name": "labsjdk", "version": "ce-19.0.1+10-jvmci-23.0-b04-sulong", "platformspecific": true },
"labsjdk-ee-19": {"name": "labsjdk", "version": "ee-19.0.2+6-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ee-19Debug": {"name": "labsjdk", "version": "ee-19.0.2+6-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ee-19-llvm": {"name": "labsjdk", "version": "ee-19.0.2+6-jvmci-23.0-b04-sulong", "platformspecific": true },
"labsjdk-ee-19": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05", "platformspecific": true },
"labsjdk-ee-19Debug": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05-debug", "platformspecific": true },
"labsjdk-ee-19-llvm": {"name": "labsjdk", "version": "ee-19.0.2+7-jvmci-23.0-b05-sulong", "platformspecific": true },

"oraclejdk20": {"name": "jpg-jdk", "version": "20", "build_id": "24", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-20": {"name": "labsjdk", "version": "ce-20+25-jvmci-23.0-b04", "platformspecific": true },
"labsjdk-ce-20Debug": {"name": "labsjdk", "version": "ce-20+25-jvmci-23.0-b04-debug", "platformspecific": true },
"labsjdk-ce-20-llvm": {"name": "labsjdk", "version": "ce-20+25-jvmci-23.0-b04-sulong", "platformspecific": true }
"labsjdk-ce-20": {"name": "labsjdk", "version": "ce-20+26-jvmci-23.0-b05", "platformspecific": true },
"labsjdk-ce-20Debug": {"name": "labsjdk", "version": "ce-20+26-jvmci-23.0-b05-debug", "platformspecific": true },
"labsjdk-ce-20-llvm": {"name": "labsjdk", "version": "ce-20+26-jvmci-23.0-b05-sulong", "platformspecific": true }
},

"COMMENT.devkits" : "The devkits versions reflect those used to build the JVMCI JDKs (e.g., see devkit_platform_revisions in <jdk>/make/conf/jib-profiles.js)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected void run(
protected void checkLIR(String methodName, Predicate<LIRInstruction> predicate, int expected) {
compile(getResolvedJavaMethod(methodName), null);
int actualOpNum = 0;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (predicate.test(ins)) {
actualOpNum++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import static org.junit.Assume.assumeTrue;

import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
import org.graalvm.compiler.core.common.cfg.BasicBlock;
import org.graalvm.compiler.core.test.MatchRuleTest;
import org.graalvm.compiler.lir.LIR;
import org.graalvm.compiler.lir.LIRInstruction;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void test1() {
compile(getResolvedJavaMethod("test1Snippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof MemoryConstOp && ((MemoryConstOp) ins).getOpcode().toString().equals("CMP")) {
assertFalse("MemoryConstOp expected only once in first block", found);
found = true;
Expand Down Expand Up @@ -101,7 +101,7 @@ public void testVolatileExtension() {
compile(getResolvedJavaMethod("testVolatileExtensionSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Unary.MemoryOp) {
ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
assertFalse("MemoryOp expected only once in first block", found);
Expand Down Expand Up @@ -131,7 +131,7 @@ public void testLoadTestNoMatch() {
compile(getResolvedJavaMethod("testLoadTestNoMatchSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof ConstOp && ((ConstOp) ins).getOpcode().toString().equals("CMP")) {
assertFalse("CMP expected only once in first block", found);
found = true;
Expand All @@ -158,7 +158,7 @@ public void testAddLoad() {
compile(getResolvedJavaMethod("testAddLoadSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Binary.MemoryTwoOp && ((AMD64Binary.MemoryTwoOp) ins).getOpcode().toString().equals("ADD")) {
assertFalse("MemoryTwoOp expected only once in first block", found);
found = true;
Expand All @@ -181,7 +181,7 @@ public void testAddLoadNoMatch() {
compile(getResolvedJavaMethod("testAddLoadNoMatchSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Binary.CommutativeTwoOp && ((AMD64Binary.CommutativeTwoOp) ins).getOpcode().toString().equals("ADD")) {
assertFalse("CommutativeTwoOp expected only once in first block", found);
found = true;
Expand All @@ -207,7 +207,7 @@ public void testVolatileExtensionDifferentBlocks() {
compile(getResolvedJavaMethod("testVolatileExtensionDifferentBlocksSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Unary.MemoryOp) {
ins.visitEachOutput((value, mode, flags) -> assertTrue(value.getPlatformKind().toString(), value.getPlatformKind().equals(AMD64Kind.QWORD)));
assertFalse("MemoryOp expected only once in first block", found);
Expand All @@ -234,7 +234,8 @@ public void testAddLoadDifferentBlocksNoMatch() {
compile(getResolvedJavaMethod("testAddLoadDifferentBlocksNoMatchSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (AbstractBlockBase<?> b : lir.codeEmittingOrder()) {
for (int blockId : lir.codeEmittingOrder()) {
BasicBlock<?> b = lir.getBlockById(blockId);
for (LIRInstruction ins : lir.getLIRforBlock(b)) {
if (ins instanceof AMD64Binary.CommutativeTwoOp && ((AMD64Binary.CommutativeTwoOp) ins).getOpcode().toString().equals("ADD")) {
assertFalse("CommutativeTwoOp expected only once in first block", found);
Expand Down Expand Up @@ -262,7 +263,7 @@ public void testAddLoadDifferentBlocks() {
compile(getResolvedJavaMethod("testAddLoadDifferentBlocksSnippet"), null);
LIR lir = getLIR();
boolean found = false;
for (LIRInstruction ins : lir.getLIRforBlock(lir.codeEmittingOrder()[0])) {
for (LIRInstruction ins : lir.getLIRforBlock(lir.getControlFlowGraph().getBlocks()[lir.codeEmittingOrder()[0]])) {
if (ins instanceof AMD64Binary.MemoryTwoOp && ((AMD64Binary.MemoryTwoOp) ins).getOpcode().toString().equals("ADD")) {
assertFalse("MemoryTwoOp expected only once in first block", found);
found = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.graalvm.compiler.nodes.calc.IntegerEqualsNode;
import org.graalvm.compiler.nodes.calc.SignedDivNode;
import org.graalvm.compiler.nodes.calc.SignedRemNode;
import org.graalvm.compiler.nodes.cfg.Block;
import org.graalvm.compiler.nodes.cfg.HIRBlock;
import org.graalvm.compiler.nodes.extended.MultiGuardNode;
import org.graalvm.compiler.nodes.memory.address.AddressNode;
import org.graalvm.compiler.nodes.util.GraphUtil;
Expand Down Expand Up @@ -86,6 +86,7 @@ public Optional<NotApplicable> notApplicableTo(GraphState graphState) {

@Override
protected void run(StructuredGraph graph, LowTierContext context) {
graph.clearLastSchedule();
if (!GraalOptions.FloatingDivNodes.getValue(graph.getOptions())) {
return;
}
Expand Down Expand Up @@ -118,8 +119,8 @@ protected void run(StructuredGraph graph, LowTierContext context) {
// condition ensures that divisor is dominated by condition, now do
// the
// same for the dividend
Block ifBlock = sched.getNodeToBlockMap().get(ifNode);
Block dividendBlock = sched.getNodeToBlockMap().get(dividend);
HIRBlock ifBlock = sched.getNodeToBlockMap().get(ifNode);
HIRBlock dividendBlock = sched.getNodeToBlockMap().get(dividend);
if (dividendBlock == null) {
assert dividend instanceof PhiNode;
dividendBlock = sched.getNodeToBlockMap().get(((PhiNode) dividend).merge());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,24 @@ public static long minUnsigned(long a, long b) {
public static boolean sameSign(long a, long b) {
return a < 0 == b < 0;
}

/**
* Converts a hex string to a byte array. Two characters are converted to a byte at a time.
*
* @param hex the hex string
* @return byte array
*/
public static byte[] hexStringToBytes(String hex) {
int len = hex.length() / 2;
byte[] bytes = new byte[len];
for (int i = 0; i < len; i++) {
// need to parse as int, because parseByte will throw on values > 127
int val = Integer.parseInt(hex.substring(i << 1, (i << 1) + 2), 16);
if (val < 0 || val > 255) {
throw new NumberFormatException("Value out of range: " + val);
}
bytes[i] = (byte) val;
}
return bytes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import java.util.Comparator;
import java.util.PriorityQueue;

import org.graalvm.compiler.core.common.cfg.AbstractBlockBase;
import org.graalvm.compiler.core.common.cfg.BasicBlock;
import org.graalvm.compiler.core.common.cfg.CodeEmissionOrder.ComputationTime;
import org.graalvm.compiler.debug.GraalError;

Expand All @@ -50,7 +50,7 @@ public final class BasicBlockOrderUtils {
/**
* Initializes the priority queue used for the work list of blocks and adds the start block.
*/
protected static <T extends AbstractBlockBase<T>> PriorityQueue<T> initializeWorklist(T startBlock, BitSet visitedBlocks) {
protected static <T extends BasicBlock<T>> PriorityQueue<T> initializeWorklist(T startBlock, BitSet visitedBlocks) {
PriorityQueue<T> result = new PriorityQueue<>(INITIAL_WORKLIST_CAPACITY, new BlockOrderComparator<>());
result.add(startBlock);
visitedBlocks.set(startBlock.getId());
Expand All @@ -60,36 +60,36 @@ protected static <T extends AbstractBlockBase<T>> PriorityQueue<T> initializeWor
/**
* Checks that the ordering contains the expected number of blocks.
*/
protected static boolean checkOrder(BlockList<? extends AbstractBlockBase<?>> order, int expectedBlockCount) {
protected static boolean checkOrder(BlockList<? extends BasicBlock<?>> order, int expectedBlockCount) {
GraalError.guarantee(order.size() == expectedBlockCount, "Number of blocks in ordering (%d) does not match expected block count (%d)", order.size(), expectedBlockCount);
return true;
}

/**
* Checks that the ordering starts with the expected start block.
*/
protected static <T extends AbstractBlockBase<T>> boolean checkStartBlock(BlockList<T> order, T startBlock) {
protected static <T extends BasicBlock<T>> boolean checkStartBlock(BlockList<T> order, T startBlock) {
GraalError.guarantee(order.first() == startBlock, "First block of ordering (%s) does not match expected start block %s", order.first(), startBlock);
return true;
}

/**
* Find the highest likely unvisited successor block of a given block.
*/
protected static <T extends AbstractBlockBase<T>> T findAndMarkMostLikelySuccessor(T block, BlockList<T> order, BitSet visitedBlocks) {
protected static <T extends BasicBlock<T>> T findAndMarkMostLikelySuccessor(T block, BlockList<T> order, BitSet visitedBlocks) {
return findAndMarkMostLikelySuccessor(block, order, visitedBlocks, ComputationTime.BEFORE_CONTROL_FLOW_OPTIMIZATIONS, null);
}

protected static <T extends AbstractBlockBase<T>> T findAndMarkMostLikelySuccessor(T block, BlockList<T> order, BitSet visitedBlocks, ComputationTime computationTime,
protected static <T extends BasicBlock<T>> T findAndMarkMostLikelySuccessor(T block, BlockList<T> order, BitSet visitedBlocks, ComputationTime computationTime,
PriorityQueue<T> worklist) {
T result = null;
double maxSuccFrequency = -1.0;
double maxScheduledSuccProbability = -1.0;
boolean isTriangle = false;
if (block.getSuccessorCount() == 2 && computationTime == ComputationTime.AFTER_CONTROL_FLOW_OPTIMIZATIONS) {
double thisFrequency = block.getRelativeFrequency();
T left = block.getSuccessors()[0];
T right = block.getSuccessors()[1];
T left = block.getSuccessorAt(0);
T right = block.getSuccessorAt(1);
// Check if we have a control flow triangle merging up at one of these successors. See
// usage of isTriangle below for explanation.
if (Math.abs(left.getRelativeFrequency() - thisFrequency) < 0.0001 && right.getPredecessorCount() == 1) {
Expand All @@ -99,8 +99,8 @@ protected static <T extends AbstractBlockBase<T>> T findAndMarkMostLikelySuccess
}
}
for (int i = 0; i < block.getSuccessorCount(); i++) {
T successor = block.getSuccessors()[i];
double succProbability = block.getSuccessorProbabilities()[i];
T successor = block.getSuccessorAt(i);
double succProbability = block.getSuccessorProbabilityAt(i);
double succFrequency = successor.getRelativeFrequency();
assert succFrequency >= 0.0 : "Relative frequencies must be positive";
if (computationTime == ComputationTime.AFTER_CONTROL_FLOW_OPTIMIZATIONS) {
Expand Down Expand Up @@ -252,8 +252,9 @@ protected static <T extends AbstractBlockBase<T>> T findAndMarkMostLikelySuccess
/**
* Add successor blocks into the given work list if they are not already marked as visited.
*/
protected static <T extends AbstractBlockBase<T>> void enqueueSuccessors(T block, PriorityQueue<T> worklist, BitSet visitedBlocks) {
for (T successor : block.getSuccessors()) {
protected static <T extends BasicBlock<T>> void enqueueSuccessors(T block, PriorityQueue<T> worklist, BitSet visitedBlocks) {
for (int i = 0; i < block.getSuccessorCount(); i++) {
T successor = block.getSuccessorAt(i);
if (!visitedBlocks.get(successor.getId())) {
visitedBlocks.set(successor.getId());
worklist.add(successor);
Expand All @@ -264,7 +265,7 @@ protected static <T extends AbstractBlockBase<T>> void enqueueSuccessors(T block
/**
* Comparator for sorting blocks based on loop depth and probability.
*/
public static class BlockOrderComparator<T extends AbstractBlockBase<T>> implements Comparator<T> {
public static class BlockOrderComparator<T extends BasicBlock<T>> implements Comparator<T> {
private static final double EPSILON = 1E-6;

@Override
Expand All @@ -291,7 +292,7 @@ public int compare(T a, T b) {
* A data structure combining an append-only list of blocks and a bit set for efficiently
* checking which blocks have been added.
*/
protected static class BlockList<T extends AbstractBlockBase<T>> {
protected static class BlockList<T extends BasicBlock<T>> {
private final ArrayList<T> order;
private final BitSet scheduledBlocks;

Expand All @@ -318,8 +319,20 @@ public boolean isScheduled(T block) {
return scheduledBlocks.get(block.getId());
}

public AbstractBlockBase<?>[] toArray() {
return order.toArray(new AbstractBlockBase<?>[0]);
public BasicBlock<?>[] toArray() {
return order.toArray(new BasicBlock<?>[0]);
}

public char[] toIdArray() {
char[] orderIndices = new char[order.size()];
for (int i = 0; i < order.size(); i++) {
orderIndices[i] = order.get(i).getId();
}
return orderIndices;
}

public ArrayList<T> getOrder() {
return order;
}
}
}
Loading