improve performance of logical conjunction (IDEA-182226)

master
stsypanov 6 years ago committed by Anna.Kozlova
parent 43fec2e7bb
commit 8824c20cbb
  1. 4
      src/org/jetbrains/java/decompiler/modules/code/DeadCodeHelper.java
  2. 7
      src/org/jetbrains/java/decompiler/modules/decompiler/DecHelper.java
  3. 7
      src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java
  4. 9
      src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java

@ -216,14 +216,14 @@ public class DeadCodeHelper {
for (int i = 0; i < node.getPreds().size(); i++) {
BasicBlock pred = node.getPreds().get(i);
if (!marked.contains(pred) && pred != dom) {
if (pred != dom && !marked.contains(pred)) {
lstNodes.add(pred);
}
}
for (int i = 0; i < node.getPredExceptions().size(); i++) {
BasicBlock pred = node.getPredExceptions().get(i);
if (!marked.contains(pred) && pred != dom) {
if (pred != dom && !marked.contains(pred)) {
lstNodes.add(pred);
}
}

@ -4,7 +4,10 @@ package org.jetbrains.java.decompiler.modules.decompiler;
import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent;
import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class DecHelper {
@ -145,7 +148,7 @@ public class DecHelper {
if (head == statd) {
return false;
}
if (!setDest.contains(statd) && post != statd) {
if (post != statd && !setDest.contains(statd)) {
if (post != null) {
return false;
}

@ -1,7 +1,10 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.modules.decompiler;
import org.jetbrains.java.decompiler.code.*;
import org.jetbrains.java.decompiler.code.CodeConstants;
import org.jetbrains.java.decompiler.code.Instruction;
import org.jetbrains.java.decompiler.code.InstructionSequence;
import org.jetbrains.java.decompiler.code.SimpleInstructionSequence;
import org.jetbrains.java.decompiler.code.cfg.BasicBlock;
import org.jetbrains.java.decompiler.code.cfg.ControlFlowGraph;
import org.jetbrains.java.decompiler.code.cfg.ExceptionRangeCFG;
@ -321,7 +324,7 @@ public class FinallyProcessor {
for (BasicBlock dest : lstSucc) {
// break out
if (!setCopy.contains(dest) && dest != graph.getLast()) {
if (dest != graph.getLast() && !setCopy.contains(dest)) {
// disable semaphore
SimpleInstructionSequence seq = new SimpleInstructionSequence();
seq.addInstruction(Instruction.create(CodeConstants.opc_bipush, false, CodeConstants.GROUP_GENERAL, bytecode_version, new int[]{0}), -1);

@ -5,7 +5,6 @@ package org.jetbrains.java.decompiler.modules.decompiler.stats;
import org.jetbrains.java.decompiler.code.CodeConstants;
import org.jetbrains.java.decompiler.main.DecompilerContext;
import org.jetbrains.java.decompiler.util.TextBuffer;
import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer;
import org.jetbrains.java.decompiler.main.collectors.CounterContainer;
import org.jetbrains.java.decompiler.modules.decompiler.DecHelper;
@ -13,8 +12,12 @@ import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor;
import org.jetbrains.java.decompiler.modules.decompiler.StatEdge;
import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent;
import org.jetbrains.java.decompiler.struct.gen.VarType;
import org.jetbrains.java.decompiler.util.TextBuffer;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class CatchAllStatement extends Statement {
@ -75,7 +78,7 @@ public class CatchAllStatement extends Statement {
for (StatEdge edge : head.getSuccessorEdges(StatEdge.TYPE_EXCEPTION)) {
Statement exc = edge.getDestination();
if (edge.getExceptions() == null && setHandlers.contains(exc) && exc.getLastBasicType() == LASTBASICTYPE_GENERAL) {
if (edge.getExceptions() == null && exc.getLastBasicType() == LASTBASICTYPE_GENERAL && setHandlers.contains(exc)) {
List<StatEdge> lstSuccs = exc.getSuccessorEdges(STATEDGE_DIRECT_ALL);
if (lstSuccs.isEmpty() || lstSuccs.get(0).getType() != StatEdge.TYPE_REGULAR) {

Loading…
Cancel
Save