public void VisitNode(JSRetargetPackedArrayElementProxy rpaep) { var key = new RetargetKey( rpaep.ElementProxy, rpaep.Array, rpaep.Index ); var sris = SeenRetargetsInScope.Peek(); int cacheLastInitializedNodeIndex; if (!sris.TryGetValue(key, out cacheLastInitializedNodeIndex)) { sris.Add(key, NodeIndex); VisitChildren(rpaep); return; } var arrayIsConstant = IsCachedValueValidForGivenCacheKey(rpaep.Array, cacheLastInitializedNodeIndex); var indexIsConstant = IsCachedValueValidForGivenCacheKey(rpaep.Index, cacheLastInitializedNodeIndex); if (arrayIsConstant && indexIsConstant) { if (Trace) Console.WriteLine("Eliminating retarget for " + rpaep.ElementProxy + " because array and index are constant"); ParentNode.ReplaceChild(rpaep, rpaep.ElementProxy); VisitReplacement(rpaep.ElementProxy); return; } VisitChildren(rpaep); }
public void VisitNode(JSRetargetPackedArrayElementProxy rpaep) { var key = new RetargetKey( rpaep.ElementProxy, rpaep.Array, rpaep.Index ); var sris = SeenRetargetsInScope.Peek(); int cacheLastInitializedNodeIndex; if (!sris.TryGetValue(key, out cacheLastInitializedNodeIndex)) { sris.Add(key, NodeIndex); VisitChildren(rpaep); return; } var arrayIsConstant = IsCachedValueValidForGivenCacheKey(rpaep.Array, cacheLastInitializedNodeIndex); var indexIsConstant = IsCachedValueValidForGivenCacheKey(rpaep.Index, cacheLastInitializedNodeIndex); if (arrayIsConstant && indexIsConstant) { if (Trace) { Console.WriteLine("Eliminating retarget for " + rpaep.ElementProxy + " because array and index are constant"); } ParentNode.ReplaceChild(rpaep, rpaep.ElementProxy); VisitReplacement(rpaep.ElementProxy); return; } VisitChildren(rpaep); }