public static void AddRule <T>(CallSite <T> site, CallSiteRule <T> rule) where T : class { lock (site) { if (site.Rules == null) { site.Rules = rule.RuleSet; } else { site.Rules = site.Rules.AddRule(rule); } } }
public static CallSiteRule <T> CreateNewRule <T>(CallSite <T> site, CallSiteRule <T> oldRule, CallSiteRule <T> originalRule, object[] args) where T : class { if (oldRule != null) { // // The rule didn't work and since we optimistically added it into the // level 2 cache. Remove it now since the rule is no good. // site.RuleCache.RemoveRule(args, oldRule); } Expression binding = site.Binder.Bind(args, CallSiteRule <T> .Parameters, CallSiteRule <T> .ReturnLabel); // // Check the produced rule // if (binding == null) { throw Error.NoOrInvalidRuleProduced(); } var rule = new CallSiteRule <T>(binding); if (originalRule != null) { // compare our new rule and our original monomorphic rule. If they only differ from constants // then we'll want to re-use the code gen if possible. rule = AutoRuleTemplate.CopyOrCreateTemplatedRule(originalRule, rule); } // // Add the rule to the level 2 cache. This is an optimistic add so that cache miss // on another site can find this existing rule rather than building a new one. We // add the originally added rule, not the templated one, to the global cache. That // allows sites to template on their own. // site.RuleCache.AddRule(args, rule); return(rule); }
public static void MoveRule <T>(CallSite <T> site, CallSiteRule <T> rule, object [] args) where T : class { site.RuleCache.MoveRule(rule, args); }
public static T SetTarget <T>(CallSite <T> site, CallSiteRule <T> rule) where T : class { return(site.Target = rule.RuleSet.GetTarget()); }