< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/gen/LIRGenerator.java
Print this page
*** 44,53 ****
--- 44,54 ----
import org.graalvm.compiler.core.common.spi.CodeGenProviders;
import org.graalvm.compiler.core.common.spi.ForeignCallLinkage;
import org.graalvm.compiler.core.common.spi.ForeignCallsProvider;
import org.graalvm.compiler.core.common.spi.LIRKindTool;
import org.graalvm.compiler.core.common.type.Stamp;
+ import org.graalvm.compiler.debug.DebugCloseable;
import org.graalvm.compiler.debug.GraalError;
import org.graalvm.compiler.debug.TTY;
import org.graalvm.compiler.graph.NodeSourcePosition;
import org.graalvm.compiler.lir.ConstantValue;
import org.graalvm.compiler.lir.LIR;
*** 384,393 ****
--- 385,412 ----
BlockScopeImpl blockScope = new BlockScopeImpl(block);
blockScope.doBlockStart();
return blockScope;
}
+ private final class MatchScope implements DebugCloseable {
+
+ private MatchScope(AbstractBlockBase<?> block) {
+ currentBlock = block;
+ }
+
+ @Override
+ public void close() {
+ currentBlock = null;
+ }
+
+ }
+
+ public final DebugCloseable getMatchScope(AbstractBlockBase<?> block) {
+ MatchScope matchScope = new MatchScope(block);
+ return matchScope;
+ }
+
@Override
public void emitIncomingValues(Value[] params) {
((LabelOp) res.getLIR().getLIRforBlock(getCurrentBlock()).get(0)).setIncomingValues(params);
}
*** 455,465 ****
int keyCount = keyConstants.length;
double minDensity = 1 / Math.sqrt(strategy.getAverageEffort());
Optional<Hasher> hasher = hasherFor(keyConstants, minDensity);
double hashTableSwitchDensity = hasher.map(h -> keyCount / (double) h.cardinality()).orElse(0d);
! long valueRange = keyConstants[keyCount - 1].asLong() - keyConstants[0].asLong() + 1;
double tableSwitchDensity = keyCount / (double) valueRange;
/*
* This heuristic tries to find a compromise between the effort for the best switch strategy
* and the density of a tableswitch. If the effort for the strategy is at least 4, then a
--- 474,485 ----
int keyCount = keyConstants.length;
double minDensity = 1 / Math.sqrt(strategy.getAverageEffort());
Optional<Hasher> hasher = hasherFor(keyConstants, minDensity);
double hashTableSwitchDensity = hasher.map(h -> keyCount / (double) h.cardinality()).orElse(0d);
! // The value range computation below may overflow, so compute it as a long.
! long valueRange = (long) keyConstants[keyCount - 1].asInt() - (long) keyConstants[0].asInt() + 1;
double tableSwitchDensity = keyCount / (double) valueRange;
/*
* This heuristic tries to find a compromise between the effort for the best switch strategy
* and the density of a tableswitch. If the effort for the strategy is at least 4, then a
*** 477,487 ****
for (int i = 0; i < cardinality; i++) {
keys[i] = JavaConstant.INT_0;
targets[i] = defaultTarget;
}
for (int i = 0; i < keyCount; i++) {
! int idx = h.hash(keyConstants[i].asLong());
keys[idx] = keyConstants[i];
targets[idx] = keyTargets[i];
}
emitHashTableSwitch(h, keys, defaultTarget, targets, value);
} else {
--- 497,507 ----
for (int i = 0; i < cardinality; i++) {
keys[i] = JavaConstant.INT_0;
targets[i] = defaultTarget;
}
for (int i = 0; i < keyCount; i++) {
! int idx = h.hash(keyConstants[i].asInt());
keys[idx] = keyConstants[i];
targets[idx] = keyTargets[i];
}
emitHashTableSwitch(h, keys, defaultTarget, targets, value);
} else {
< prev index next >