From b49f1569cd25b7f3055cbd640034b0136c6afc9f Mon Sep 17 00:00:00 2001 From: tiziw Date: Wed, 2 Sep 2020 21:27:55 +0200 Subject: [PATCH 1/4] - Make ArrayBoundsChecker a whole-program analysis to fix a concurrency bug --- .../testing/TestOptionsDialogHandler.java | 192 +++++------ .../sable/soot/ui/PhaseOptionsDialog.java | 76 ++--- src/main/generated/options/soot/AntTask.java | 134 ++++---- .../options/soot/options/Options.java | 107 +++--- src/main/java/soot/PackManager.java | 2 +- .../arraycheck/ArrayBoundsChecker.java | 24 +- src/main/xml/options/soot_options.xml | 318 +++++++++--------- tutorial/useannotation/useannotation.tex | 18 +- 8 files changed, 434 insertions(+), 437 deletions(-) diff --git a/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/testing/TestOptionsDialogHandler.java b/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/testing/TestOptionsDialogHandler.java index 885c90f2574..f5d29e052e2 100644 --- a/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/testing/TestOptionsDialogHandler.java +++ b/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/testing/TestOptionsDialogHandler.java @@ -1483,93 +1483,105 @@ public String getCmdLine() { cmd.append(COLON); cmd.append(path); cmd.append(SPACE); - } - - key = "p"+" "+"wjtp2"+" "+"disabled"; + } + + key = "p"+" "+"wjap.abc"+" "+"disabled"; value = settings.getBoolean(key.trim()); - + + boolDefault = true; + + + if (value != boolDefault ) { + cmd.append(DASH); + cmd.append(key.trim()); + cmd.append(SPACE); + } + + key = "p"+" "+"wjap.abc"+" "+"with-all"; + value = settings.getBoolean(key.trim()); + boolDefault = false; - - + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"wjtp2.ra"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"with-fieldref"; value = settings.getBoolean(key.trim()); - - boolDefault = true; - - + + boolDefault = false; + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"stp"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"with-arrayref"; value = settings.getBoolean(key.trim()); - + boolDefault = false; - - + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"sop"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"with-cse"; value = settings.getBoolean(key.trim()); - + boolDefault = false; - - + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"jtp"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"with-classfield"; value = settings.getBoolean(key.trim()); - + boolDefault = false; - - + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"jop"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"with-rectarray"; value = settings.getBoolean(key.trim()); - + boolDefault = false; - - + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"jop.cse"+" "+"disabled"; + + key = "p"+" "+"wjap.abc"+" "+"profiling"; value = settings.getBoolean(key.trim()); - - boolDefault = true; - - + + boolDefault = false; + + if (value != boolDefault ) { cmd.append(DASH); cmd.append(key.trim()); cmd.append(SPACE); } - key = "p"+" "+"jop.cse"+" "+"naive-side-effect"; + key = "p"+" "+"wjtp2"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1581,7 +1593,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.bcm"+" "+"disabled"; + key = "p"+" "+"wjtp2.ra"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = true; @@ -1593,7 +1605,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.bcm"+" "+"naive-side-effect"; + key = "p"+" "+"stp"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1605,10 +1617,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.lcm"+" "+"disabled"; + key = "p"+" "+"sop"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = true; + boolDefault = false; if (value != boolDefault ) { @@ -1617,10 +1629,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.lcm"+" "+"unroll"; + key = "p"+" "+"jtp"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = true; + boolDefault = false; if (value != boolDefault ) { @@ -1629,7 +1641,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.lcm"+" "+"naive-side-effect"; + key = "p"+" "+"jop"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1640,25 +1652,11 @@ public String getCmdLine() { cmd.append(key.trim()); cmd.append(SPACE); } - - key = "p"+" "+"jop.lcm"+" "+"safe"; - path = settings.get(key.trim()); - - defaultVal = "safe"; - - - if ((path != null) && (path.length() != 0) && (!path.equals(defaultVal))) { - cmd.append(DASH); - cmd.append(key.trim()); - cmd.append(COLON); - cmd.append(path); - cmd.append(SPACE); - } - key = "p"+" "+"jop.cp"+" "+"disabled"; + key = "p"+" "+"jop.cse"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = false; + boolDefault = true; if (value != boolDefault ) { @@ -1667,7 +1665,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.cp"+" "+"only-regular-locals"; + key = "p"+" "+"jop.cse"+" "+"naive-side-effect"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1679,10 +1677,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.cp"+" "+"only-stack-locals"; + key = "p"+" "+"jop.bcm"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = false; + boolDefault = true; if (value != boolDefault ) { @@ -1691,7 +1689,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.cpf"+" "+"disabled"; + key = "p"+" "+"jop.bcm"+" "+"naive-side-effect"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1703,10 +1701,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.cbf"+" "+"disabled"; + key = "p"+" "+"jop.lcm"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = false; + boolDefault = true; if (value != boolDefault ) { @@ -1715,10 +1713,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.dae"+" "+"disabled"; + key = "p"+" "+"jop.lcm"+" "+"unroll"; value = settings.getBoolean(key.trim()); - boolDefault = false; + boolDefault = true; if (value != boolDefault ) { @@ -1727,7 +1725,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.dae"+" "+"only-stack-locals"; + key = "p"+" "+"jop.lcm"+" "+"naive-side-effect"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1738,20 +1736,22 @@ public String getCmdLine() { cmd.append(key.trim()); cmd.append(SPACE); } + + key = "p"+" "+"jop.lcm"+" "+"safe"; + path = settings.get(key.trim()); - key = "p"+" "+"jop.uce1"+" "+"disabled"; - value = settings.getBoolean(key.trim()); - - boolDefault = false; + defaultVal = "safe"; - if (value != boolDefault ) { + if ((path != null) && (path.length() != 0) && (!path.equals(defaultVal))) { cmd.append(DASH); cmd.append(key.trim()); + cmd.append(COLON); + cmd.append(path); cmd.append(SPACE); - } + } - key = "p"+" "+"jop.uce2"+" "+"disabled"; + key = "p"+" "+"jop.cp"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1763,7 +1763,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.ubf1"+" "+"disabled"; + key = "p"+" "+"jop.cp"+" "+"only-regular-locals"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1775,7 +1775,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.ubf2"+" "+"disabled"; + key = "p"+" "+"jop.cp"+" "+"only-stack-locals"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1787,7 +1787,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jop.ule"+" "+"disabled"; + key = "p"+" "+"jop.cpf"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1799,7 +1799,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap"+" "+"disabled"; + key = "p"+" "+"jop.cbf"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1811,10 +1811,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.npc"+" "+"disabled"; + key = "p"+" "+"jop.dae"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = true; + boolDefault = false; if (value != boolDefault ) { @@ -1823,7 +1823,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.npc"+" "+"only-array-ref"; + key = "p"+" "+"jop.dae"+" "+"only-stack-locals"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1835,7 +1835,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.npc"+" "+"profiling"; + key = "p"+" "+"jop.uce1"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1847,10 +1847,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"disabled"; + key = "p"+" "+"jop.uce2"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = true; + boolDefault = false; if (value != boolDefault ) { @@ -1859,7 +1859,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-all"; + key = "p"+" "+"jop.ubf1"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1871,7 +1871,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-fieldref"; + key = "p"+" "+"jop.ubf2"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1883,7 +1883,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-arrayref"; + key = "p"+" "+"jop.ule"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1895,7 +1895,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-cse"; + key = "p"+" "+"jap"+" "+"disabled"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1907,10 +1907,10 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-classfield"; + key = "p"+" "+"jap.npc"+" "+"disabled"; value = settings.getBoolean(key.trim()); - boolDefault = false; + boolDefault = true; if (value != boolDefault ) { @@ -1919,7 +1919,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"with-rectarray"; + key = "p"+" "+"jap.npc"+" "+"only-array-ref"; value = settings.getBoolean(key.trim()); boolDefault = false; @@ -1931,7 +1931,7 @@ public String getCmdLine() { cmd.append(SPACE); } - key = "p"+" "+"jap.abc"+" "+"profiling"; + key = "p"+" "+"jap.npc"+" "+"profiling"; value = settings.getBoolean(key.trim()); boolDefault = false; diff --git a/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java b/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java index 3b7d69cc04a..7128a7022ad 100644 --- a/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java +++ b/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java @@ -627,6 +627,26 @@ private void initializeEnableGroups() { getwjapwjap_purityannotate_widget().getButton().addSelectionListener(this); getwjapwjap_purityverbose_widget().getButton().addSelectionListener(this); + makeNewEnableGroup("wjap", "wjap.abc"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcenabled_widget(), "enabled"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_all_widget(), "with-all"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_cse_widget(), "with-cse"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_arrayref_widget(), "with-arrayref"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_fieldref_widget(), "with-fieldref"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_classfield_widget(), "with-classfield"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcwith_rectarray_widget(), "with-rectarray"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcprofiling_widget(), "profiling"); + addToEnableGroup("wjap", "wjap.abc", getjapjap_abcadd_color_tags_widget(), "add-color-tags"); + getjapjap_abcenabled_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_all_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_cse_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_arrayref_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_fieldref_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_classfield_widget().getButton().addSelectionListener(this); + getjapjap_abcwith_rectarray_widget().getButton().addSelectionListener(this); + getjapjap_abcprofiling_widget().getButton().addSelectionListener(this); + getjapjap_abcadd_color_tags_widget().getButton().addSelectionListener(this); + makeNewEnableGroup("shimple"); addToEnableGroup("shimple", getshimpleenabled_widget(), "enabled"); addToEnableGroup("shimple", getshimplenode_elim_opt_widget(), "node-elim-opt"); @@ -750,26 +770,6 @@ private void initializeEnableGroups() { addToEnableGroup("jap", "jap.npcolorer", getjapjap_npcolorerenabled_widget(), "enabled"); getjapjap_npcolorerenabled_widget().getButton().addSelectionListener(this); - makeNewEnableGroup("jap", "jap.abc"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcenabled_widget(), "enabled"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_all_widget(), "with-all"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_cse_widget(), "with-cse"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_arrayref_widget(), "with-arrayref"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_fieldref_widget(), "with-fieldref"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_classfield_widget(), "with-classfield"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcwith_rectarray_widget(), "with-rectarray"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcprofiling_widget(), "profiling"); - addToEnableGroup("jap", "jap.abc", getjapjap_abcadd_color_tags_widget(), "add-color-tags"); - getjapjap_abcenabled_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_all_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_cse_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_arrayref_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_fieldref_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_classfield_widget().getButton().addSelectionListener(this); - getjapjap_abcwith_rectarray_widget().getButton().addSelectionListener(this); - getjapjap_abcprofiling_widget().getButton().addSelectionListener(this); - getjapjap_abcadd_color_tags_widget().getButton().addSelectionListener(this); - makeNewEnableGroup("jap", "jap.profiling"); addToEnableGroup("jap", "jap.profiling", getjapjap_profilingenabled_widget(), "enabled"); addToEnableGroup("jap", "jap.profiling", getjapjap_profilingnotmainentry_widget(), "notmainentry"); @@ -15163,7 +15163,7 @@ private Composite japjap_abcCreate(Composite parent) { - defKey = "p phase-option"+" "+"jap.abc"+" "+"enabled"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"enabled"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15172,9 +15172,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcenabled_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Enabled", "p phase-option", "jap.abc","enabled", "\n", defaultBool))); + setjapjap_abcenabled_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Enabled", "p phase-option", "wjap.abc","enabled", "\n", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-all"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-all"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15183,9 +15183,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_all_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With All", "p phase-option", "jap.abc","with-all", "\nSetting the With All option to true is equivalent to setting \neach of With CSE, With Array Ref, With Field Ref, With Class \nField, and With Rectangular Array to true.", defaultBool))); + setjapjap_abcwith_all_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With All", "p phase-option", "wjap.abc","with-all", "\nSetting the With All option to true is equivalent to setting \neach of With CSE, With Array Ref, With Field Ref, With Class \nField, and With Rectangular Array to true.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-cse"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-cse"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15194,9 +15194,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_cse_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Common Sub-expressions", "p phase-option", "jap.abc","with-cse", "\nThe analysis will consider common subexpressions. For example, \nconsider the situation where r1 is assigned a*b; later, r2 is \nassigned a*b, where neither a nor b have changed between the two \nstatements. The analysis can conclude that r2 has the same value \nas r1. Experiments show that this option can improve the result \nslightly.", defaultBool))); + setjapjap_abcwith_cse_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Common Sub-expressions", "p phase-option", "wjap.abc","with-cse", "\nThe analysis will consider common subexpressions. For example, \nconsider the situation where r1 is assigned a*b; later, r2 is \nassigned a*b, where neither a nor b have changed between the two \nstatements. The analysis can conclude that r2 has the same value \nas r1. Experiments show that this option can improve the result \nslightly.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-arrayref"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-arrayref"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15205,9 +15205,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_arrayref_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Array References", "p phase-option", "jap.abc","with-arrayref", "\nWith this option enabled, array references can be considered as \ncommon subexpressions; however, we are more conservative when \nwriting into an array, because array objects may be aliased. We \nalso assume that the application is single-threaded or that the \narray references occur in a synchronized block. That is, we \nassume that an array element may not be changed by other threads \nbetween two array references.", defaultBool))); + setjapjap_abcwith_arrayref_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Array References", "p phase-option", "wjap.abc","with-arrayref", "\nWith this option enabled, array references can be considered as \ncommon subexpressions; however, we are more conservative when \nwriting into an array, because array objects may be aliased. We \nalso assume that the application is single-threaded or that the \narray references occur in a synchronized block. That is, we \nassume that an array element may not be changed by other threads \nbetween two array references.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-fieldref"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-fieldref"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15216,9 +15216,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_fieldref_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Field References", "p phase-option", "jap.abc","with-fieldref", "\nThe analysis treats field references (static and instance) as \ncommon subexpressions; however, we are more conservative when \nwriting to a field, because the base of the field reference may \nbe aliased. We also assume that the application is \nsingle-threaded or that the field references occur in a \nsynchronized block. That is, we assume that a field may not be \nchanged by other threads between two field references.", defaultBool))); + setjapjap_abcwith_fieldref_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Field References", "p phase-option", "wjap.abc","with-fieldref", "\nThe analysis treats field references (static and instance) as \ncommon subexpressions; however, we are more conservative when \nwriting to a field, because the base of the field reference may \nbe aliased. We also assume that the application is \nsingle-threaded or that the field references occur in a \nsynchronized block. That is, we assume that a field may not be \nchanged by other threads between two field references.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-classfield"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-classfield"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15227,9 +15227,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_classfield_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Class Field", "p phase-option", "jap.abc","with-classfield", "\nThis option makes the analysis work on the class level. The \nalgorithm analyzes final or private class fields first. It can \nrecognize the fields that hold array objects of constant length. \nIn an application using lots of array fields, this option can \nimprove the analysis results dramatically.", defaultBool))); + setjapjap_abcwith_classfield_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Class Field", "p phase-option", "wjap.abc","with-classfield", "\nThis option makes the analysis work on the class level. The \nalgorithm analyzes final or private class fields first. It can \nrecognize the fields that hold array objects of constant length. \nIn an application using lots of array fields, this option can \nimprove the analysis results dramatically.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"with-rectarray"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"with-rectarray"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15238,9 +15238,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcwith_rectarray_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Rectangular Array", "p phase-option", "jap.abc","with-rectarray", "\nThis option is used together with wjap.ra to make Soot run the \nwhole-program analysis for rectangular array objects. This \nanalysis is based on the call graph, and it usually takes a long \ntime. If the application uses rectangular arrays, these options \ncan improve the analysis result.", defaultBool))); + setjapjap_abcwith_rectarray_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("With Rectangular Array", "p phase-option", "wjap.abc","with-rectarray", "\nThis option is used together with wjap.ra to make Soot run the \nwhole-program analysis for rectangular array objects. This \nanalysis is based on the call graph, and it usually takes a long \ntime. If the application uses rectangular arrays, these options \ncan improve the analysis result.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"profiling"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"profiling"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15249,9 +15249,9 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcprofiling_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Profiling", "p phase-option", "jap.abc","profiling", "\nProfile the results of array bounds check analysis. The inserted \nprofiling code assumes the existence of a MultiCounter class \nimplementing the methods invoked. For details, see the \nArrayBoundsChecker source code.", defaultBool))); + setjapjap_abcprofiling_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Profiling", "p phase-option", "wjap.abc","profiling", "\nProfile the results of array bounds check analysis. The inserted \nprofiling code assumes the existence of a MultiCounter class \nimplementing the methods invoked. For details, see the \nArrayBoundsChecker source code.", defaultBool))); - defKey = "p phase-option"+" "+"jap.abc"+" "+"add-color-tags"; + defKey = "p phase-option"+" "+"wjap.abc"+" "+"add-color-tags"; defKey = defKey.trim(); if (isInDefList(defKey)) { @@ -15260,7 +15260,7 @@ private Composite japjap_abcCreate(Composite parent) { defaultBool = false; } - setjapjap_abcadd_color_tags_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Add Color Tags", "p phase-option", "jap.abc","add-color-tags", "\nAdd color tags to the results of the array bounds check \nanalysis.", defaultBool))); + setjapjap_abcadd_color_tags_widget(new BooleanOptionWidget(editGroupjapjap_abc, SWT.NONE, new OptionData("Add Color Tags", "p phase-option", "wjap.abc","add-color-tags", "\nAdd color tags to the results of the array bounds check \nanalysis.", defaultBool))); return editGroupjapjap_abc; diff --git a/src/main/generated/options/soot/AntTask.java b/src/main/generated/options/soot/AntTask.java index 4475909e4b9..724a323b7da 100644 --- a/src/main/generated/options/soot/AntTask.java +++ b/src/main/generated/options/soot/AntTask.java @@ -628,14 +628,14 @@ public void setannot_purity(boolean arg) { if(arg) addArg("-annot-purity"); } - public void setannot_nullpointer(boolean arg) { - if(arg) addArg("-annot-nullpointer"); - } - public void setannot_arraybounds(boolean arg) { if(arg) addArg("-annot-arraybounds"); } + public void setannot_nullpointer(boolean arg) { + if(arg) addArg("-annot-nullpointer"); + } + public void setannot_side_effect(boolean arg) { if(arg) addArg("-annot-side-effect"); } @@ -2306,6 +2306,69 @@ public void setverbose(boolean arg) { } + public Object createp_wjap_abc() { + Object ret = new PhaseOptwjap_abc(); + phaseopts.add(ret); + return ret; + } + public class PhaseOptwjap_abc { + + public void setenabled(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("enabled:"+(arg?"true":"false")); + } + + public void setwith_all(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-all:"+(arg?"true":"false")); + } + + public void setwith_cse(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-cse:"+(arg?"true":"false")); + } + + public void setwith_arrayref(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-arrayref:"+(arg?"true":"false")); + } + + public void setwith_fieldref(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-fieldref:"+(arg?"true":"false")); + } + + public void setwith_classfield(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-classfield:"+(arg?"true":"false")); + } + + public void setwith_rectarray(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("with-rectarray:"+(arg?"true":"false")); + } + + public void setprofiling(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("profiling:"+(arg?"true":"false")); + } + + public void setadd_color_tags(boolean arg) { + addArg("-p"); + addArg("wjap.abc"); + addArg("add-color-tags:"+(arg?"true":"false")); + } + + } + public Object createp_shimple() { Object ret = new PhaseOptshimple(); phaseopts.add(ret); @@ -2744,69 +2807,6 @@ public void setenabled(boolean arg) { } - public Object createp_jap_abc() { - Object ret = new PhaseOptjap_abc(); - phaseopts.add(ret); - return ret; - } - public class PhaseOptjap_abc { - - public void setenabled(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("enabled:"+(arg?"true":"false")); - } - - public void setwith_all(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-all:"+(arg?"true":"false")); - } - - public void setwith_cse(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-cse:"+(arg?"true":"false")); - } - - public void setwith_arrayref(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-arrayref:"+(arg?"true":"false")); - } - - public void setwith_fieldref(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-fieldref:"+(arg?"true":"false")); - } - - public void setwith_classfield(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-classfield:"+(arg?"true":"false")); - } - - public void setwith_rectarray(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("with-rectarray:"+(arg?"true":"false")); - } - - public void setprofiling(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("profiling:"+(arg?"true":"false")); - } - - public void setadd_color_tags(boolean arg) { - addArg("-p"); - addArg("jap.abc"); - addArg("add-color-tags:"+(arg?"true":"false")); - } - - } - public Object createp_jap_profiling() { Object ret = new PhaseOptjap_profiling(); phaseopts.add(ret); diff --git a/src/main/generated/options/soot/options/Options.java b/src/main/generated/options/soot/options/Options.java index decdc944e25..c74e9c9777a 100644 --- a/src/main/generated/options/soot/options/Options.java +++ b/src/main/generated/options/soot/options/Options.java @@ -1276,32 +1276,33 @@ else if (false pushOption("enabled:true"); pushOption("wjap.purity"); pushOption("-p"); + } + else if (false + || option.equals("annot-nullpointer") + ) { pushOption("enabled:true"); pushOption("cg.spark"); pushOption("-p"); pushOption("-w"); } else if (false - || option.equals("annot-nullpointer") + || option.equals("annot-arraybounds") ) { + pushOption("-w"); pushOption("enabled:true"); - pushOption("tag.an"); + pushOption("wjap.ra"); pushOption("-p"); pushOption("enabled:true"); - pushOption("jap.npc"); + pushOption("wjap.abc"); pushOption("-p"); - } - else if (false - || option.equals("annot-arraybounds") - ) { pushOption("enabled:true"); pushOption("tag.an"); pushOption("-p"); pushOption("enabled:true"); - pushOption("jap.abc"); + pushOption("tag.an"); pushOption("-p"); pushOption("enabled:true"); - pushOption("wjap.ra"); + pushOption("jap.npc"); pushOption("-p"); } else if (false @@ -1845,8 +1846,8 @@ public String getUsage() { + padOpt("-write-local-annotations", "Write out debug annotations on local names") + "\nAnnotation Options:\n" + padOpt("-annot-purity", "Emit purity attributes") - + padOpt("-annot-nullpointer", "Emit null pointer attributes") + padOpt("-annot-arraybounds", "Emit array bounds check attributes") + + padOpt("-annot-nullpointer", "Emit null pointer attributes") + padOpt("-annot-side-effect", "Emit side-effect attributes") + padOpt("-annot-fieldrw", "Emit field read/write attributes") + "\nMiscellaneous Options:\n" @@ -1910,6 +1911,7 @@ public String getPhaseList() { + padVal("wjap.tqt", "Tags all qualifiers that could be tighter") + padVal("wjap.cgg", "Creates graphical call graph.") + padVal("wjap.purity", "Emit purity attributes") + + padVal("wjap.abc", "Array bound checker") + padOpt("shimple", "Sets parameters for Shimple SSA form") + padOpt("stp", "Shimple transformation pack") + padOpt("sop", "Shimple optimization pack") @@ -1932,7 +1934,6 @@ public String getPhaseList() { + padOpt("jap", "Jimple annotation pack: adds intraprocedural tags") + padVal("jap.npc", "Null pointer checker") + padVal("jap.npcolorer", "Null pointer colourer: tags references for eclipse") - + padVal("jap.abc", "Array bound checker") + padVal("jap.profiling", "Instruments null pointer and array checks") + padVal("jap.sea", "Side effect tagger") + padVal("jap.fieldrw", "Field read/write tagger") @@ -2521,6 +2522,20 @@ public String getPhaseHelp(String phaseName) { + padOpt("annotate (true)", "Marks pure methods with a purity bytecode attribute") + padOpt("verbose (false)", ""); + if (phaseName.equals("wjap.abc")) + return "Phase " + phaseName + ":\n" + + "\nThe Array Bound Checker performs a static analysis to determine \nwhich array bounds checks may safely be eliminated and then \nannotates statements with the results of the analysis. If Soot \nis in whole-program mode, the Array Bound Checker can use the \nresults provided by the Rectangular Array Finder." + + "\n\nRecognized options (with default values):\n" + + padOpt("enabled (false)", "") + + padOpt("with-all (false)", "") + + padOpt("with-cse (false)", "") + + padOpt("with-arrayref (false)", "") + + padOpt("with-fieldref (false)", "") + + padOpt("with-classfield (false)", "") + + padOpt("with-rectarray (false)", "") + + padOpt("profiling (false)", "Profile the results of array bounds check analysis.") + + padOpt("add-color-tags (false)", "Add color tags to results of array bound check analysis."); + if (phaseName.equals("shimple")) return "Phase " + phaseName + ":\n" + "\nShimple Control sets parameters which apply throughout the \ncreation and manipulation of Shimple bodies. Shimple is Soot's \nSSA representation." @@ -2674,20 +2689,6 @@ public String getPhaseHelp(String phaseName) { + "\n\nRecognized options (with default values):\n" + padOpt("enabled (false)", ""); - if (phaseName.equals("jap.abc")) - return "Phase " + phaseName + ":\n" - + "\nThe Array Bound Checker performs a static analysis to determine \nwhich array bounds checks may safely be eliminated and then \nannotates statements with the results of the analysis. If Soot \nis in whole-program mode, the Array Bound Checker can use the \nresults provided by the Rectangular Array Finder." - + "\n\nRecognized options (with default values):\n" - + padOpt("enabled (false)", "") - + padOpt("with-all (false)", "") - + padOpt("with-cse (false)", "") - + padOpt("with-arrayref (false)", "") - + padOpt("with-fieldref (false)", "") - + padOpt("with-classfield (false)", "") - + padOpt("with-rectarray (false)", "") - + padOpt("profiling (false)", "Profile the results of array bounds check analysis.") - + padOpt("add-color-tags (false)", "Add color tags to results of array bound check analysis."); - if (phaseName.equals("jap.profiling")) return "Phase " + phaseName + ":\n" + "\nThe Profiling Generator inserts the method invocations required \nto initialize and to report the results of any profiling \nperformed by the Null Pointer Checker and Array Bound Checker. \nUsers of the Profiling Generator must provide a MultiCounter \nclass implementing the methods invoked. For details, see the \nProfilingGenerator source code." @@ -3329,6 +3330,19 @@ public static String getDeclaredOptionsForPhase(String phaseName) { "verbose" ); + if (phaseName.equals("wjap.abc")) + return String.join(" ", + "enabled", + "with-all", + "with-cse", + "with-arrayref", + "with-fieldref", + "with-classfield", + "with-rectarray", + "profiling", + "add-color-tags" + ); + if (phaseName.equals("shimple")) return String.join(" ", "enabled", @@ -3457,19 +3471,6 @@ public static String getDeclaredOptionsForPhase(String phaseName) { "enabled" ); - if (phaseName.equals("jap.abc")) - return String.join(" ", - "enabled", - "with-all", - "with-cse", - "with-arrayref", - "with-fieldref", - "with-classfield", - "with-rectarray", - "profiling", - "add-color-tags" - ); - if (phaseName.equals("jap.profiling")) return String.join(" ", "enabled", @@ -4021,6 +4022,18 @@ public static String getDefaultOptionsForPhase(String phaseName) { + "annotate:true " + "verbose:false "; + if (phaseName.equals("wjap.abc")) + return "" + + "enabled:false " + + "with-all:false " + + "with-cse:false " + + "with-arrayref:false " + + "with-fieldref:false " + + "with-classfield:false " + + "with-rectarray:false " + + "profiling:false " + + "add-color-tags:false "; + if (phaseName.equals("shimple")) return "" + "enabled:true " @@ -4127,18 +4140,6 @@ public static String getDefaultOptionsForPhase(String phaseName) { return "" + "enabled:false "; - if (phaseName.equals("jap.abc")) - return "" - + "enabled:false " - + "with-all:false " - + "with-cse:false " - + "with-arrayref:false " - + "with-fieldref:false " - + "with-classfield:false " - + "with-rectarray:false " - + "profiling:false " - + "add-color-tags:false "; - if (phaseName.equals("jap.profiling")) return "" + "enabled:false " @@ -4355,6 +4356,7 @@ public void warnForeignPhase(String phaseName) { || phaseName.equals("wjap.tqt") || phaseName.equals("wjap.cgg") || phaseName.equals("wjap.purity") + || phaseName.equals("wjap.abc") || phaseName.equals("shimple") || phaseName.equals("stp") || phaseName.equals("sop") @@ -4377,7 +4379,6 @@ public void warnForeignPhase(String phaseName) { || phaseName.equals("jap") || phaseName.equals("jap.npc") || phaseName.equals("jap.npcolorer") - || phaseName.equals("jap.abc") || phaseName.equals("jap.profiling") || phaseName.equals("jap.sea") || phaseName.equals("jap.fieldrw") @@ -4524,6 +4525,8 @@ public void warnNonexistentPhase() { G.v().out.println("Warning: Options exist for non-existent phase wjap.cgg"); if (!PackManager.v().hasPhase("wjap.purity")) G.v().out.println("Warning: Options exist for non-existent phase wjap.purity"); + if (!PackManager.v().hasPhase("wjap.abc")) + G.v().out.println("Warning: Options exist for non-existent phase wjap.abc"); if (!PackManager.v().hasPhase("shimple")) G.v().out.println("Warning: Options exist for non-existent phase shimple"); if (!PackManager.v().hasPhase("stp")) @@ -4568,8 +4571,6 @@ public void warnNonexistentPhase() { G.v().out.println("Warning: Options exist for non-existent phase jap.npc"); if (!PackManager.v().hasPhase("jap.npcolorer")) G.v().out.println("Warning: Options exist for non-existent phase jap.npcolorer"); - if (!PackManager.v().hasPhase("jap.abc")) - G.v().out.println("Warning: Options exist for non-existent phase jap.abc"); if (!PackManager.v().hasPhase("jap.profiling")) G.v().out.println("Warning: Options exist for non-existent phase jap.profiling"); if (!PackManager.v().hasPhase("jap.sea")) diff --git a/src/main/java/soot/PackManager.java b/src/main/java/soot/PackManager.java index efa0e373415..0d782854550 100644 --- a/src/main/java/soot/PackManager.java +++ b/src/main/java/soot/PackManager.java @@ -259,6 +259,7 @@ private void init() { p.add(new Transform("wjap.tqt", TightestQualifiersTagger.v())); p.add(new Transform("wjap.cgg", CallGraphGrapher.v())); p.add(new Transform("wjap.purity", PurityAnalysis.v())); // [AM] + p.add(new Transform("wjap.abc", ArrayBoundsChecker.v())); } // Shimple pack @@ -299,7 +300,6 @@ private void init() { { p.add(new Transform("jap.npc", NullPointerChecker.v())); p.add(new Transform("jap.npcolorer", NullPointerColorer.v())); - p.add(new Transform("jap.abc", ArrayBoundsChecker.v())); p.add(new Transform("jap.profiling", ProfilingGenerator.v())); p.add(new Transform("jap.sea", SideEffectTagger.v())); p.add(new Transform("jap.fieldrw", FieldTagger.v())); diff --git a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java index f6a69caa6d2..8c21483545a 100644 --- a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java +++ b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java @@ -29,18 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import soot.ArrayType; -import soot.Body; -import soot.BodyTransformer; -import soot.G; -import soot.Local; -import soot.Scene; -import soot.Singletons; -import soot.SootClass; -import soot.SootMethod; -import soot.Type; -import soot.Value; -import soot.ValueBox; +import soot.*; import soot.jimple.ArrayRef; import soot.jimple.IntConstant; import soot.jimple.Jimple; @@ -53,12 +42,19 @@ import soot.tagkit.Tag; import soot.util.Chain; -public class ArrayBoundsChecker extends BodyTransformer { +public class ArrayBoundsChecker extends SceneTransformer { private static final Logger logger = LoggerFactory.getLogger(ArrayBoundsChecker.class); public ArrayBoundsChecker(Singletons.Global g) { } + @Override + protected void internalTransform(String phaseName, Map options) { + Scene.v().getReachableMethods().listener().forEachRemaining(method -> { + internalTransform(method.method().getActiveBody(), options); + }); + } + public static ArrayBoundsChecker v() { return G.v().soot_jimple_toolkits_annotation_arraycheck_ArrayBoundsChecker(); } @@ -70,7 +66,7 @@ public static ArrayBoundsChecker v() { protected boolean takeRectArray = false; protected boolean addColorTags = false; - protected void internalTransform(Body body, String phaseName, Map opts) { + protected void internalTransform(Body body, Map opts) { ABCOptions options = new ABCOptions(opts); if (options.with_all()) { takeClassField = true; diff --git a/src/main/xml/options/soot_options.xml b/src/main/xml/options/soot_options.xml index d8d3fd21f5e..be92edfb0e9 100644 --- a/src/main/xml/options/soot_options.xml +++ b/src/main/xml/options/soot_options.xml @@ -5071,6 +5071,146 @@ This locking scheme aims to achieve simple fine-grained locking. false + + Array Bound Checker + ABCOptions + wjap.abc + Array bound checker + +

+ The Array Bound Checker performs a static analysis to determine + which array bounds checks may safely be eliminated and then annotates + statements with the results of the analysis. +

+

+ If Soot is in whole-program mode, the Array Bound Checker can + use the results provided by the Rectangular Array Finder. +

+
+ + Enabled + enabled + false + + + + + With All + with-all + false + + +

+ Setting the With All option to true is equivalent to setting each + of With CSE, With Array Ref, With Field Ref, + With Class Field, and With Rectangular Array to true. +

+
+
+ + With Common Sub-expressions + with-cse + false + + +

+ The analysis will consider common subexpressions. For example, + consider the situation where r1 is assigned + a*b; later, r2 is assigned a*b, where + neither a nor b have changed between the two + statements. The analysis can conclude that r2 has the + same value as r1. Experiments show that this option can + improve the result slightly. +

+
+
+ + With Array References + with-arrayref + false + + +

+ With this option enabled, array references can be considered as + common subexpressions; however, we are more conservative when + writing into an array, because array objects may be aliased. We + also assume that the application is single-threaded or that the + array references occur in a synchronized block. That is, we + assume that an array element may not be changed by other threads + between two array references. +

+
+
+ + With Field References + with-fieldref + false + + +

+ The analysis treats field references (static and instance) as + common subexpressions; however, we are more conservative when + writing to a field, because the base of the field reference may + be aliased. We also assume that the application is + single-threaded or that the field references occur in a + synchronized block. That is, we assume that a field may + not be changed by other threads between two field references. +

+
+
+ + With Class Field + with-classfield + false + + +

+ This option makes the analysis work on the class level. The + algorithm analyzes final or private class + fields first. It can recognize the fields that hold array objects + of constant length. In an application using lots of array + fields, this option can improve the analysis results + dramatically. +

+
+
+ + With Rectangular Array + with-rectarray + false + + + This option is used together with wjap.ra to make Soot run the whole-program + analysis for rectangular array objects. This analysis is based on the + call graph, and it usually takes a long time. If the application uses + rectangular arrays, these options can improve the analysis + result. + + + + Profiling + profiling + false + Profile the results of array bounds check analysis. + +

+ Profile the results of array bounds check analysis. The inserted + profiling code assumes the existence of a + MultiCounter + class implementing the methods invoked. For details, see the + ArrayBoundsChecker + source code. +

+
+
+ + Add Color Tags + add-color-tags + false + Add color tags to results of array bound check analysis. + Add color tags to the results of the array bounds check analysis. + +
Shimple Control @@ -5794,146 +5934,6 @@ This locking scheme aims to achieve simple fine-grained locking. - - Array Bound Checker - ABCOptions - jap.abc - Array bound checker - -

- The Array Bound Checker performs a static analysis to determine - which array bounds checks may safely be eliminated and then annotates - statements with the results of the analysis. -

-

- If Soot is in whole-program mode, the Array Bound Checker can - use the results provided by the Rectangular Array Finder. -

-
- - Enabled - enabled - false - - - - - With All - with-all - false - - -

- Setting the With All option to true is equivalent to setting each - of With CSE, With Array Ref, With Field Ref, - With Class Field, and With Rectangular Array to true. -

-
-
- - With Common Sub-expressions - with-cse - false - - -

- The analysis will consider common subexpressions. For example, - consider the situation where r1 is assigned - a*b; later, r2 is assigned a*b, where - neither a nor b have changed between the two - statements. The analysis can conclude that r2 has the - same value as r1. Experiments show that this option can - improve the result slightly. -

-
-
- - With Array References - with-arrayref - false - - -

- With this option enabled, array references can be considered as - common subexpressions; however, we are more conservative when - writing into an array, because array objects may be aliased. We - also assume that the application is single-threaded or that the - array references occur in a synchronized block. That is, we - assume that an array element may not be changed by other threads - between two array references. -

-
-
- - With Field References - with-fieldref - false - - -

- The analysis treats field references (static and instance) as - common subexpressions; however, we are more conservative when - writing to a field, because the base of the field reference may - be aliased. We also assume that the application is - single-threaded or that the field references occur in a - synchronized block. That is, we assume that a field may - not be changed by other threads between two field references. -

-
-
- - With Class Field - with-classfield - false - - -

- This option makes the analysis work on the class level. The - algorithm analyzes final or private class - fields first. It can recognize the fields that hold array objects - of constant length. In an application using lots of array - fields, this option can improve the analysis results - dramatically. -

-
-
- - With Rectangular Array - with-rectarray - false - - - This option is used together with wjap.ra to make Soot run the whole-program - analysis for rectangular array objects. This analysis is based on the - call graph, and it usually takes a long time. If the application uses - rectangular arrays, these options can improve the analysis - result. - - - - Profiling - profiling - false - Profile the results of array bounds check analysis. - -

- Profile the results of array bounds check analysis. The inserted - profiling code assumes the existence of a - MultiCounter - class implementing the methods invoked. For details, see the - ArrayBoundsChecker - source code. -

-
-
- - Add Color Tags - add-color-tags - false - Add color tags to results of array bound check analysis. - Add color tags to the results of the array bounds check analysis. - -
Profiling Generator jap.profiling @@ -7310,24 +7310,6 @@ This locking scheme aims to achieve simple fine-grained locking. by Alexandru Salcianu and Martin Rinard. - - Null Pointer Annotation - annot-nullpointer - -p - jap.npc - enabled:true - -p - tag.an - enabled:true - Emit null pointer attributes - - Perform a static analysis of which dereferenced pointers may have - null values, and annotate class files with attributes - encoding the results of the analysis. For details, see the - documentation for Null Pointer Annotation and for the - Array Bounds and Null Pointer Check Tag Aggregator. - - Array Bounds Annotation annot-arraybounds @@ -7335,7 +7317,7 @@ This locking scheme aims to achieve simple fine-grained locking. wjap.ra enabled:true -p - jap.abc + wjap.abc enabled:true -p tag.an @@ -7349,6 +7331,24 @@ This locking scheme aims to achieve simple fine-grained locking. Bounds and Null Pointer Check Tag Aggregator. + + Null Pointer Annotation + annot-nullpointer + -p + jap.npc + enabled:true + -p + tag.an + enabled:true + Emit null pointer attributes + + Perform a static analysis of which dereferenced pointers may have + null values, and annotate class files with attributes + encoding the results of the analysis. For details, see the + documentation for Null Pointer Annotation and for the + Array Bounds and Null Pointer Check Tag Aggregator. + + Side effect annotation annot-side-effect diff --git a/tutorial/useannotation/useannotation.tex b/tutorial/useannotation/useannotation.tex index 128984a12d6..76c5af4f6c0 100644 --- a/tutorial/useannotation/useannotation.tex +++ b/tutorial/useannotation/useannotation.tex @@ -75,7 +75,7 @@ \subsection{Description of new options} Soot also has phase options for the array bounds check analysis. These options affect three levels of analyses: intraprocedural, class-level, and whole-program. The array bounds check analysis has -the phase name ``{\em jap.abc}''. If the whole-program analysis is +the phase name ``{\em wjap.abc}''. If the whole-program analysis is required, an extra phase ``{\em wjap.ra}'' for finding rectangular arrays is required. This phase can be also enabled with phase options. @@ -88,7 +88,7 @@ \subsection{Description of new options} \begin{description} -\item[-p jap.abc with-cse]\ \\ +\item[-p wjap.abc with-cse]\ \\ The analysis will consider common subexpressions. For example, consider the situation where {\tt r1} is assigned {\tt a*b}; later, {\tt r2} is assigned {\tt a*b}, where both {\tt a} and {\tt b} have @@ -96,7 +96,7 @@ \subsection{Description of new options} conclude that {\tt r2} has the same value as {\tt r1}. Experiments show that this option can improve the result slightly. -\item[-p jap.abc with-arrayref]\ \\ With this option enabled, array +\item[-p wjap.abc with-arrayref]\ \\ With this option enabled, array references can be considered as common subexpressions; however, we are more conservative when writing into an array, because array objects may be aliased. NOTE: We also assume that the application in a @@ -105,23 +105,23 @@ \subsection{Description of new options} references. % see my thesis for an example of what to do when you have contention! -plam -\item[-p jap.abc with-fieldref]\ \\ +\item[-p wjap.abc with-fieldref]\ \\ The analysis treats field references (static and instance) as common subexpressions. The restrictions from the `{\tt with-arrayref}' option also apply. -\item[-p jap.abc with-classfield]\ \\ +\item[-p wjap.abc with-classfield]\ \\ This option makes the analysis work on the class level. The algorithm analyzes `final' or `private' class fields first. It can recognize the fields that hold array objects with constant length. In an application using lots of array fields, this option can improve the analysis results dramatically. -\item[-p jap.abc with-all]\ \\ +\item[-p wjap.abc with-all]\ \\ A macro. Instead of typing a long string of phase options, this option -will turn on all options of the phase ``{\em jap.abc}''. +will turn on all options of the phase ``{\em wjap.abc}''. -\item[-p jap.abc with-rectarray, -p wjap.ra with-wholeapp]\ \\ These +\item[-p wjap.abc with-rectarray, -p wjap.ra with-wholeapp]\ \\ These two options are used together to make Soot run the whole-program analysis for rectangular array objects. This analysis is based on the call graph, and it usually takes a long time. If the application uses @@ -141,7 +141,7 @@ \subsection{Examples} mode. For example: \begin{verbatim} java soot.Main --app -annot-arraybounds -annot-arraybounds -p wjap.ra with-wholeapp - -p jap.abc with-all spec.benchmarks._222_mpegaudio.Main + -p wjap.abc with-all spec.benchmarks._222_mpegaudio.Main \end{verbatim} The following command only annotates the array reference bytecodes. From e35d8f08871b72095d195c82d6b144dbe20e015f Mon Sep 17 00:00:00 2001 From: tiziw <34965470+tiziw@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:40:58 +0200 Subject: [PATCH 2/4] Update ArrayBoundsChecker.java --- .../annotation/arraycheck/ArrayBoundsChecker.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java index 8c21483545a..ccc3cf0b27c 100644 --- a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java +++ b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java @@ -29,7 +29,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import soot.*; +import soot.ArrayType; +import soot.Body; +import soot.BodyTransformer; +import soot.G; +import soot.Local; +import soot.Scene; +import soot.Singletons; +import soot.SootClass; +import soot.SootMethod; +import soot.Type; +import soot.Value; +import soot.ValueBox; import soot.jimple.ArrayRef; import soot.jimple.IntConstant; import soot.jimple.Jimple; From 44059c00db594f7166d31cf1a6ef168c8ed44ddc Mon Sep 17 00:00:00 2001 From: tiziw <34965470+tiziw@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:44:31 +0200 Subject: [PATCH 3/4] Update ArrayBoundsChecker.java --- .../toolkits/annotation/arraycheck/ArrayBoundsChecker.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java index ccc3cf0b27c..43a01f5f84f 100644 --- a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java +++ b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java @@ -41,6 +41,7 @@ import soot.Type; import soot.Value; import soot.ValueBox; +import soot.SceneTransformer; import soot.jimple.ArrayRef; import soot.jimple.IntConstant; import soot.jimple.Jimple; From 396402b2b092a56245f91ce0ecd5acd4b2d318cd Mon Sep 17 00:00:00 2001 From: tiziw <34965470+tiziw@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:47:27 +0200 Subject: [PATCH 4/4] Update ArrayBoundsChecker.java --- .../toolkits/annotation/arraycheck/ArrayBoundsChecker.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java index 43a01f5f84f..eba261a57dd 100644 --- a/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java +++ b/src/main/java/soot/jimple/toolkits/annotation/arraycheck/ArrayBoundsChecker.java @@ -31,17 +31,16 @@ import soot.ArrayType; import soot.Body; -import soot.BodyTransformer; import soot.G; import soot.Local; import soot.Scene; +import soot.SceneTransformer; import soot.Singletons; import soot.SootClass; import soot.SootMethod; import soot.Type; import soot.Value; import soot.ValueBox; -import soot.SceneTransformer; import soot.jimple.ArrayRef; import soot.jimple.IntConstant; import soot.jimple.Jimple;