src/third_party/mozjs/extract/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
// Return whether 'exp == value' holds only when execution is on the main thread.
Return whether 'exp == value' holds only when execution is on the main thread.
Return whether ' exp == value ' holds only when execution is on the main thread .
function testFailsOffMainThread(exp, value) {
    switch (exp.Kind) {
      case "Drf":
        var edge = expressionValueEdge(exp.Exp[0]);
        if (edge) {
            if (isDirectCall(edge, /NS_IsMainThread/) && value)
                return true;
            if (isDirectCall(edge, /IsInServoTraversal/) && !value)
                return true;
            if (isDirectCall(edge, /IsCurrentThreadInServoTraversal/) && !value)
                return true;
            if (isDirectCall(edge, /__builtin_expect/))
                return testFailsOffMainThread(edge.PEdgeCallArguments.Exp[0], value);
            if (edge.Kind == "Assign")
                return testFailsOffMainThread(edge.Exp[1], value);
        }
        break;
      case "Unop":
        if (exp.OpCode == "LogicalNot")
            return testFailsOffMainThread(exp.Exp[0], !value);
        break;
      case "Binop":
        if (exp.OpCode == "NotEqual" || exp.OpCode == "Equal") {
            var cmpExp = isZero(exp.Exp[0])
                ? exp.Exp[1]
                : (isZero(exp.Exp[1]) ? exp.Exp[0] : null);
            if (cmpExp)
                return testFailsOffMainThread(cmpExp, exp.OpCode == "NotEqual" ? value : !value);
        }
        break;
      case "Int":
        if (exp.String == "0" && value)
            return true;
        if (exp.String == "1" && !value)
            return true;
        break;
    }
    return false;
}
function testFailsOffMainThread ( exp , value ) { switch ( exp . Kind ) { case "Drf" : var edge = expressionValueEdge ( exp . Exp [ 0 ] ) ; if ( edge ) { if ( isDirectCall ( edge , / NS_IsMainThread / ) && value ) return true ; if ( isDirectCall ( edge , / IsInServoTraversal / ) && ! value ) return true ; if ( isDirectCall ( edge , / IsCurrentThreadInServoTraversal / ) && ! value ) return true ; if ( isDirectCall ( edge , / __builtin_expect / ) ) return testFailsOffMainThread ( edge . PEdgeCallArguments . Exp [ 0 ] , value ) ; if ( edge . Kind == "Assign" ) return testFailsOffMainThread ( edge . Exp [ 1 ] , value ) ; } break ; case "Unop" : if ( exp . OpCode == "LogicalNot" ) return testFailsOffMainThread ( exp . Exp [ 0 ] , ! value ) ; break ; case "Binop" : if ( exp . OpCode == "NotEqual" || exp . OpCode == "Equal" ) { var cmpExp = isZero ( exp . Exp [ 0 ] ) ? exp . Exp [ 1 ] : ( isZero ( exp . Exp [ 1 ] ) ? exp . Exp [ 0 ] : null ) ; if ( cmpExp ) return testFailsOffMainThread ( cmpExp , exp . OpCode == "NotEqual" ? value : ! value ) ; } break ; case "Int" : if ( exp . String == "0" && value ) return true ; if ( exp . String == "1" && ! value ) return true ; break ; } return false ; }
Return whether 'exp == value' holds only when execution is on the main thread.
Return whether ' exp == value ' holds only when execution is on the main thread .