Skip to content

Commit

Permalink
Eliminate a source of non determinsim in ControlFlowAnalyzer.
Browse files Browse the repository at this point in the history
The results of ControlFlowAnalyzer are iterated in code splitter and
in some situations might cause non determinsm.

Change-Id: I8039abb08cbee12fba805c017a1797fda4401561
  • Loading branch information
rluble committed Sep 30, 2015
1 parent c9c3225 commit 380ee91
Showing 1 changed file with 9 additions and 9 deletions.
Expand Up @@ -374,7 +374,7 @@ public void endVisit(JsNameRef nameRef, JsContext ctx) {
@Override
public boolean visit(JMethodCall call, Context ctx) {
JMethod method = call.getTarget();
if (call.isVolatile() && method == runAsyncOnsuccess) {
if (call.isVolatile() && method == runAsyncOnSuccess) {
/*
* Note: In order to preserve code splitting, don't allow code flow from the
* AsyncFragmentLoader implementation back into the
Expand Down Expand Up @@ -891,10 +891,10 @@ private boolean isTypeInstantiatedOrJso(JDeclaredType type) {
private Set<JReferenceType> classLiteralsToBeRescuedIfGetClassIsLive = Sets.newHashSet();

private DependencyRecorder dependencyRecorder;
private Set<JField> fieldsWritten = Sets.newHashSet();
private Set<JReferenceType> instantiatedTypes = Sets.newHashSet();
private Set<JNode> liveFieldsAndMethods = Sets.newHashSet();
private Set<String> liveStrings = Sets.newHashSet();
private Set<JField> fieldsWritten = Sets.newLinkedHashSet();
private Set<JReferenceType> instantiatedTypes = Sets.newLinkedHashSet();
private Set<JNode> liveFieldsAndMethods = Sets.newLinkedHashSet();
private Set<String> liveStrings = Sets.newLinkedHashSet();

/**
* Schrodinger's members... aka "limbo". :) These are instance methods and
Expand All @@ -909,13 +909,13 @@ private boolean isTypeInstantiatedOrJso(JDeclaredType type) {
private final JProgram program;
private Set<JReferenceType> referencedTypes = Sets.newHashSet();
private final RescueVisitor rescuer;
private final JMethod runAsyncOnsuccess;
private final JMethod runAsyncOnSuccess;
private JMethod stringValueOfChar = null;

public ControlFlowAnalyzer(ControlFlowAnalyzer cfa) {
program = cfa.program;
asyncFragmentOnLoad = cfa.asyncFragmentOnLoad;
runAsyncOnsuccess = cfa.runAsyncOnsuccess;
runAsyncOnSuccess = cfa.runAsyncOnSuccess;
fieldsWritten = Sets.newHashSet(cfa.fieldsWritten);
instantiatedTypes = Sets.newHashSet(cfa.instantiatedTypes);
liveFieldsAndMethods = Sets.newHashSet(cfa.liveFieldsAndMethods);
Expand All @@ -936,7 +936,7 @@ public ControlFlowAnalyzer(ControlFlowAnalyzer cfa) {
public ControlFlowAnalyzer(JProgram program) {
this.program = program;
asyncFragmentOnLoad = program.getIndexedMethod("AsyncFragmentLoader.onLoad");
runAsyncOnsuccess = program.getIndexedMethod("RunAsyncCallback.onSuccess");
runAsyncOnSuccess = program.getIndexedMethod("RunAsyncCallback.onSuccess");
getClassField = program.getIndexedField("Object.___clazz");
getClassMethod = program.getIndexedMethod("Object.getClass");
rescuer = new RescueVisitor();
Expand Down Expand Up @@ -1049,7 +1049,7 @@ public void traverseEverything() {
* Keep callback.onSuccess() from being pruned since we explicitly avoid
* visiting it.
*/
liveFieldsAndMethods.add(runAsyncOnsuccess);
liveFieldsAndMethods.add(runAsyncOnSuccess);
}

/**
Expand Down

0 comments on commit 380ee91

Please sign in to comment.