[loop-invariance] Add FPs for modified global and static invalidation

Reviewed By: mbouaziz, ngorogiannis

Differential Revision: D15451632

fbshipit-source-id: 67f5f4c89
master
Ezgi Çiçek 6 years ago committed by Facebook Github Bot
parent 673b11e2d9
commit 639c91c29f

@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Set;
class HoistGlobal {
@ -59,4 +61,61 @@ class HoistGlobal {
global_modification_dont_hoist(size);
}
}
private void processModulesDirectory_dont_hoist_FP(
Set<String> modulesToDelete, String[] existingFiles) {
final AppModuleFileInfo fInfo = new AppModuleFileInfo();
for (String existingFile : existingFiles) {
fInfo.setFileName(existingFile);
final boolean delete = modulesToDelete.contains(fInfo.mModuleName);
}
}
private void processModulesDirectory_param_dont_hoist_FP(
Set<String> modulesToDelete,
String[] existingFiles,
AppModuleFileInfo fInfo,
AppModuleFileInfo fInfo2) {
for (String existingFile : existingFiles) {
fInfo.setFileName(existingFile);
final boolean delete = modulesToDelete.contains(fInfo2.mModuleName);
}
}
private void processModulesDirectory_hoist(Set<Integer> modulesToDelete, String[] existingFiles) {
final AppModuleFileInfo fInfo = new AppModuleFileInfo();
for (String existingFile : existingFiles) {
fInfo.setFileName(existingFile);
final boolean delete = modulesToDelete.contains(fInfo.x);
}
}
void remove_first_dont_hoist_FP(LinkedList<String> list) {
while (list.size() >= 10) {
list.removeFirst();
}
}
String get_first_hoist(LinkedList<String> list, String s) {
for (int i = 0; i <= 10; i++) {
String first = list.getFirst();
if (list.contains(s)) { // hoist
return first;
}
}
return "";
}
}
class AppModuleFileInfo {
static String mModuleName;
static Integer x;
void setFileName(String fileName) {
mModuleName = fileName;
}
}

@ -29,8 +29,13 @@ codetoanalyze/java/hoisting/Hoist.java, Hoist.void_hoist(int):void, 2, INVARIANT
codetoanalyze/java/hoisting/Hoist.java, Hoist.x_not_invariant_dont_hoist(int,int,int):void, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function void Hoist.x_not_invariant_dont_hoist(int,int,int)]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal$Foo.read_global():int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistGlobal$Foo.read_global()]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal$Foo.return_zero():int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistGlobal$Foo.return_zero()]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.global_modification_hoist_FN(java.util.ArrayList):int, 3, INVARIANT_CALL, no_bucket, ERROR, [The call to int ArrayList.size() at line 49 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.get_first_hoist(java.util.LinkedList,java.lang.String):java.lang.String, 4, INVARIANT_CALL, no_bucket, ERROR, [The call to boolean LinkedList.contains(Object) at line 105 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.global_modification_hoist_FN(java.util.ArrayList):int, 3, INVARIANT_CALL, no_bucket, ERROR, [The call to int ArrayList.size() at line 51 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.processModulesDirectory_dont_hoist_FP(java.util.Set,java.lang.String[]):void, 5, INVARIANT_CALL, no_bucket, ERROR, [The call to boolean Set.contains(Object) at line 70 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.processModulesDirectory_hoist(java.util.Set,java.lang.String[]):void, 4, INVARIANT_CALL, no_bucket, ERROR, [The call to boolean Set.contains(Object) at line 90 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.processModulesDirectory_param_dont_hoist_FP(java.util.Set,java.lang.String[],AppModuleFileInfo,AppModuleFileInfo):void, 8, INVARIANT_CALL, no_bucket, ERROR, [The call to boolean Set.contains(Object) at line 82 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.read_global():int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistGlobal.read_global()]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.remove_first_dont_hoist_FP(java.util.LinkedList):void, 2, INVARIANT_CALL, no_bucket, ERROR, [The call to int LinkedList.size() at line 96 is loop-invariant]
codetoanalyze/java/hoisting/HoistGlobal.java, HoistGlobal.return_one():int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistGlobal.return_one()]
codetoanalyze/java/hoisting/HoistIndirect.java, HoistIndirect$Test.deep_modification_dont_hoist(int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistIndirect$Test.deep_modification_dont_hoist(int)]
codetoanalyze/java/hoisting/HoistIndirect.java, HoistIndirect$Test.foo(int):int, 0, PURE_FUNCTION, no_bucket, ERROR, [Side-effect free function int HoistIndirect$Test.foo(int)]

Loading…
Cancel
Save