<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -358,7 +358,7 @@ namespace IronRuby.StandardLibrary.Yaml {
             );
             
             module.DefineLibraryMethod(&quot;add&quot;, 0x11, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream, System.Object, IronRuby.Builtins.RubyArray&gt;(IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream.Add)
+                new System.Func&lt;IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream, System.Object, IronRuby.Builtins.RubyArray&gt;(IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream.Add)
             );
             
             module.DefineLibraryMethod(&quot;documents&quot;, 0x11, 
@@ -370,7 +370,7 @@ namespace IronRuby.StandardLibrary.Yaml {
             );
             
             module.DefineLibraryMethod(&quot;edit&quot;, 0x11, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream, System.Int32, System.Object, System.Object&gt;(IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream.EditDocument)
+                new System.Func&lt;IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream, System.Int32, System.Object, System.Object&gt;(IronRuby.StandardLibrary.Yaml.RubyYaml.YamlStream.EditDocument)
             );
             
             module.DefineLibraryMethod(&quot;emit&quot;, 0x11, </diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/Initializer.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -60,8 +60,8 @@ namespace IronRuby.StandardLibrary.Yaml {
             }
 
             [RubyMethod(&quot;add&quot;)]
-            public static RubyArray Add(RubyContext/*!*/ context, YamlStream/*!*/ self, object document) {
-                IListOps.Append(context, self._documents, document);
+            public static RubyArray Add(YamlStream/*!*/ self, object document) {
+                IListOps.Append(self._documents, document);
                 return self._documents;
             }
 
@@ -71,8 +71,8 @@ namespace IronRuby.StandardLibrary.Yaml {
             }
 
             [RubyMethod(&quot;edit&quot;)]
-            public static object EditDocument(RubyContext/*!*/ context, YamlStream/*!*/ self, [DefaultProtocol]int index, object document) {
-                return IListOps.SetElement(context, self._documents, index, document);
+            public static object EditDocument(YamlStream/*!*/ self, [DefaultProtocol]int index, object document) {
+                return IListOps.SetElement(self._documents, index, document);
             }
 
             [RubyMethod(&quot;documents&quot;)]</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/IronRuby.Libraries.Yaml/YamlStream.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,6 @@
+orig_dir = Dir.pwd
+at_exit { Dir.chdir(orig_dir)}
+Dir.chdir(File.dirname(__FILE__))
 require 'test/unit'
 require 'load_tests'
 require 'load_file_tests'
@@ -6,4 +9,31 @@ require 'load_stream_tests'
 require 'collections_tests'
 require 'dump_tests'
 require 'tags_tests'
+
+class Load_tests &lt; Test::Unit::TestCase
+  def test_to_yaml
+  end
+end
 require 'test_yaml'
+
+class YAML_Unit_Tests &lt; Test::Unit::TestCase
+  def test_spec_builtin_time
+  end
+
+  def test_spec_private_types
+  end
+
+  def test_spec_url_escaping
+  end
+
+  def test_symbol_cycle
+  end
+
+  def test_time_now_cycle
+  end
+
+  def test_ypath_parsing
+  end
+end
+
+</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Yaml/YamlTest/yaml_test_suite.rb</filename>
    </modified>
    <modified>
      <diff>@@ -77,4 +77,10 @@ describe &quot;Array#-&quot; do
     a - [:a, :b, :c]
     a.should == [1, 2, 3]
   end
+  
+  it &quot;handles nil correctly&quot; do
+    a = [nil, 1, nil]
+    (a - [nil]).should == [1]
+    (a - [1]).should == [nil, nil]
+  end
 end</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/array/minus_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,9 @@ describe :kernel_object_id, :shared =&gt; true do
   it &quot;returns an integer&quot; do
     mock('fixnum').send(@method).class.should == Fixnum
     nil.send(@method).class.should == Fixnum
+    
+    # this can return Finxum or Bignum depending on the platform
+    900_000_000.send(@method).kind_of?(Integer).should be_true
   end
 
   it &quot;returns the same value on all calls to id for a given object&quot; do</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/kernel/shared/object_id.rb</filename>
    </modified>
    <modified>
      <diff>@@ -93,7 +93,7 @@ module REXML
 
 		# Creates (and returns) a hash from both the name and value
 		def hash
-			name.hash + value.hash
+			name.hash ^ value.hash
 		end
 
 		# Returns this attribute out as XML source, expanding the name</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/1.8/rexml/attribute.rb</filename>
    </modified>
    <modified>
      <diff>@@ -112,7 +112,7 @@ class Gem::Dependency
   end
 
   def hash # :nodoc:
-    name.hash + type.hash + version_requirements.hash
+    name.hash ^ type.hash ^ version_requirements.hash
   end
 
 end</diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/rubygems/dependency.rb</filename>
    </modified>
    <modified>
      <diff>@@ -661,9 +661,8 @@ module Gem
     private :same_attributes?
 
     def hash # :nodoc:
-      @@attributes.inject(0) { |hash_code, (name, default_value)|
-        n = self.send(name).hash
-        hash_code + n
+      @@attributes.inject(612553) { |hash_code, (name, default_value)|
+        hash_code ^ self.send(name).hash
       }
     end
 </diff>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/redist-libs/ruby/site_ruby/1.8/rubygems/specification.rb</filename>
    </modified>
    <modified>
      <diff>@@ -479,7 +479,7 @@ namespace IronRuby.Builtins {
             BlockParam block, RubyArray/*!*/ self) {
 
             RubyArray result = self.CreateInstance();
-            IListOps.Replace(comparisonStorage.Context, result, self);
+            IListOps.Replace(result, self);
             return SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, block, result);
         }
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/ArrayOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,7 @@ using IronRuby.Runtime.Calls;
 using Microsoft.Scripting.Math;
 using Microsoft.Scripting.Runtime;
 using Ast = System.Linq.Expressions.Expression;
+using System.Collections;
 
 namespace IronRuby.Builtins {
 
@@ -617,10 +618,10 @@ namespace IronRuby.Builtins {
 
         public static MutableString/*!*/ ToPrintedString(ConversionStorage&lt;MutableString&gt;/*!*/ tosConversion, object obj) {
             IDictionary&lt;object, object&gt; hash;
-            List&lt;object&gt; list;
+            IList list;
             MutableString str;
 
-            if ((list = obj as List&lt;object&gt;) != null) {
+            if ((list = obj as IList) != null) {
                 return IListOps.Join(tosConversion, list, NewLine);
             } else if ((hash = obj as IDictionary&lt;object, object&gt;) != null) {
                 return IDictionaryOps.ToMutableString(tosConversion, hash);</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/IoOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1049,15 +1049,15 @@ namespace IronRuby.Builtins {
         #region __id__, id, object_id, class
 
         [RubyMethod(&quot;id&quot;)]
-        public static int GetId(RubyContext/*!*/ context, object self) {
+        public static object GetId(RubyContext/*!*/ context, object self) {
             context.ReportWarning(&quot;Object#id will be deprecated; use Object#object_id&quot;);
             return GetObjectId(context, self);
         }
 
         [RubyMethod(&quot;__id__&quot;)]
         [RubyMethod(&quot;object_id&quot;)]
-        public static int GetObjectId(RubyContext/*!*/ context, object self) {
-            return RubyUtils.GetObjectId(context, self);
+        public static object GetObjectId(RubyContext/*!*/ context, object self) {
+            return ClrInteger.Narrow(RubyUtils.GetObjectId(context, self));
         }
 
         [RubyMethod(&quot;type&quot;)]</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/KernelOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -76,7 +76,8 @@ namespace IronRuby.Builtins {
 
         #endregion
 
-        #region begin, first
+        #region begin, first, end, last, exclude_end?
+
         /// &lt;summary&gt;
         /// Returns the first object in self
         /// &lt;/summary&gt;
@@ -84,9 +85,7 @@ namespace IronRuby.Builtins {
         public static object Begin([NotNull]Range/*!*/ self) {
             return self.Begin;
         }
-        #endregion
 
-        #region end, last
         /// &lt;summary&gt;
         /// Returns the object that defines the end of self
         /// &lt;/summary&gt;
@@ -94,9 +93,7 @@ namespace IronRuby.Builtins {
         public static object End([NotNull]Range/*!*/ self) {
             return self.End;
         }
-        #endregion
 
-        #region exclude_end?
         /// &lt;summary&gt;
         /// Returns true if self excludes its end value. 
         /// &lt;/summary&gt;
@@ -104,6 +101,7 @@ namespace IronRuby.Builtins {
         public static bool ExcludeEnd([NotNull]Range/*!*/ self) {
             return self.ExcludeEnd;
         }
+
         #endregion
 
         #region inspect, to_s
@@ -168,7 +166,6 @@ namespace IronRuby.Builtins {
         /// &lt;/example&gt;
         [RubyMethod(&quot;eql?&quot;)]
         public static bool Eql(BinaryOpStorage/*!*/ equalsStorage, Range/*!*/ self, [NotNull]Range/*!*/ other) {
-
             if (self == other) {
                 return true;
             }
@@ -221,17 +218,23 @@ namespace IronRuby.Builtins {
         #endregion
 
         #region hash
+
         /// &lt;summary&gt;
         /// Generate a hash value such that two ranges with the same start and end points,
         /// and the same value for the &quot;exclude end&quot; flag, generate the same hash value. 
         /// &lt;/summary&gt;
         [RubyMethod(&quot;hash&quot;)]
-        public static int GetHashCode(Range/*!*/ self) {
-            int hash = RubyUtils.GetHashCode(self.Begin);
-            hash ^= RubyUtils.GetHashCode(self.End);
-            hash ^= RubyUtils.GetHashCode(self.ExcludeEnd);
-            return hash;
+        public static int GetHashCode(UnaryOpStorage/*!*/ hashStorage, Range/*!*/ self) {
+            // MRI: Ruby treatment of hash return value is inconsistent. 
+            // No conversions happen here (unlike e.g. Array.hash).
+            var hashSite = hashStorage.GetCallSite(&quot;hash&quot;);
+            return unchecked(
+                Protocols.ToHashCode(hashSite.Target(hashSite, self.Begin)) ^
+                Protocols.ToHashCode(hashSite.Target(hashSite, self.End)) ^ 
+                (self.ExcludeEnd ? 179425693 : 1794210891)
+            );
         }
+
         #endregion
 
         #region each
@@ -252,7 +255,7 @@ namespace IronRuby.Builtins {
             UnaryOpStorage/*!*/ succStorage,
             BlockParam block, Range/*!*/ self) {
 
-            // We check that self.begin responds to &quot;succ&quot; even though some of the implementations don't use it.
+            // MRI: Checks that self.begin responds to &quot;succ&quot; even though it might not be used.
             CheckBegin(respondToStorage, self.Begin);
 
             if (self.Begin is int &amp;&amp; self.End is int) {
@@ -301,7 +304,7 @@ namespace IronRuby.Builtins {
                 // self.begin is Fixnum; directly call item = item + 1 instead of succ
                 int intStep = Protocols.CastToFixnum(fixnumCast, step);
                 return StepFixnum(block, self, (int)self.Begin, (int)self.End, intStep);
-            } else if (self.Begin is MutableString ) {
+            } else if (self.Begin is MutableString) {
                 // self.begin is String; use item.succ and item &lt;=&gt; self.end but make sure you check the length of the strings
                 int intStep = Protocols.CastToFixnum(fixnumCast, step);
                 return StepString(stringCast, comparisonStorage, lessThanStorage, greaterThanStorage, succStorage, </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/RangeOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -200,13 +200,13 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;hash&quot;)]
-        public static int Hash(RubyStruct/*!*/ self) {
-            return self.GetHashCode();
+        public static int Hash(UnaryOpStorage/*!*/ hashStorage, ConversionStorage&lt;int&gt;/*!*/ fixnumCast, RubyStruct/*!*/ self) {
+            return self.GetHashCode(hashStorage, fixnumCast);
         }
 
         [RubyMethod(&quot;eql?&quot;)]
-        public static bool Equal(RubyStruct/*!*/ self, object other) {
-            return self.Equals(other);
+        public static bool Equal(BinaryOpStorage/*!*/ eqlStorage, RubyStruct/*!*/ self, object other) {
+            return self.Equals(eqlStorage, other);
         }
 
         // same pattern as RubyStruct.Equals, but we need to call == instead of eql?</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/StructOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -35,6 +35,14 @@ namespace IronRuby.Builtins {
         
         #region Helpers
 
+        // MRI: Some operations check frozen flag even if they don't change the array content.
+        private static void RequireNotFrozen(IList/*!*/ self) {
+            RubyArray array = self as RubyArray;
+            if (array != null &amp;&amp; array.IsFrozen) {
+                throw RubyExceptions.CreateTypeError(&quot;can't modify frozen object&quot;);
+            }
+        }
+
         internal static int NormalizeIndex(IList/*!*/ list, int index) {
             return NormalizeIndex(list.Count, index);
         }
@@ -99,8 +107,11 @@ namespace IronRuby.Builtins {
         }
 
         private static void InsertRange(IList/*!*/ collection, int index, IEnumerable&lt;object&gt;/*!*/ items) {
-            List&lt;object&gt; list = collection as List&lt;object&gt;;
-            if (list != null) {
+            List&lt;object&gt; list;
+            RubyArray array;
+            if ((array = collection as RubyArray) != null) {
+                array.InsertRange(index, items);
+            } else if ((list = collection as List&lt;object&gt;) != null) {
                 list.InsertRange(index, items);
             } else {
                 int i = index;
@@ -110,9 +121,19 @@ namespace IronRuby.Builtins {
             }
         }
 
-        private static void RemoveRange(IList/*!*/ collection, int index, int count) {
-            List&lt;object&gt; list = collection as List&lt;object&gt;;
-            if (list != null) {
+        internal static void RemoveRange(IList/*!*/ collection, int index, int count) {
+            if (count &lt;= 1) {
+                if (count &gt; 0) {
+                    collection.RemoveAt(index);
+                }
+                return;
+            }
+
+            List&lt;object&gt; list;
+            RubyArray array;
+            if ((array = collection as RubyArray) != null) {
+                array.RemoveRange(index, count);
+            } else if ((list = collection as List&lt;object&gt;) != null) {
                 list.RemoveRange(index, count);
             } else {
                 for (int i = index + count - 1; i &gt;= index; i--) {
@@ -122,14 +143,21 @@ namespace IronRuby.Builtins {
         }
 
         internal static void AddRange(IList/*!*/ collection, IList/*!*/ items) {
-            List&lt;object&gt; list = collection as List&lt;object&gt;;
-            if (list != null) {
-                list.Capacity += items.Count;
-            }
-            // note: &quot;collection&quot; could be the same as &quot;items&quot; so we can't use an enumerator
             int count = items.Count;
-            for (int i = 0; i &lt; count; i++) {
-                collection.Add(items[i]);
+            if (count &lt;= 1) {
+                if (count &gt; 0) {
+                    collection.Add(items[0]);
+                }
+                return;
+            }
+
+            RubyArray array = collection as RubyArray;
+            if (array != null) {
+                array.AddRange(items);
+            } else {
+                for (int i = 0; i &lt; count; i++) {
+                    collection.Add(items[i]);
+                }
             }
         }
 
@@ -157,17 +185,14 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;replace&quot;)]
         [RubyMethod(&quot;initialize_copy&quot;, RubyMethodAttributes.PrivateInstance)]
-        public static IList/*!*/ Replace(RubyContext/*!*/ context, IList/*!*/ self, [NotNull, DefaultProtocol]IList/*!*/ other) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static IList/*!*/ Replace(IList/*!*/ self, [NotNull, DefaultProtocol]IList/*!*/ other) {
             self.Clear();
             AddRange(self, other);
             return self;
         }
 
         [RubyMethod(&quot;clear&quot;)]
-        public static IList Clear(RubyContext/*!*/ context, IList/*!*/ self) {
-            RubyUtils.RequiresNotFrozen(context, self);
+        public static IList Clear(IList/*!*/ self) {
             self.Clear();
             return self;
         }
@@ -228,28 +253,30 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;concat&quot;)]
-        public static IList/*!*/ Concat(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol, NotNull]IList/*!*/ other) {
-            if (other.Count &gt; 0) {
-                RubyUtils.RequiresNotFrozen(context, self);
-            }
+        public static IList/*!*/ Concat(IList/*!*/ self, [DefaultProtocol, NotNull]IList/*!*/ other) {
             AddRange(self, other);
             return self;
         }
 
         [RubyMethod(&quot;-&quot;)]
         public static RubyArray/*!*/ Difference(UnaryOpStorage/*!*/ hashStorage, BinaryOpStorage/*!*/ eqlStorage, 
-            RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol, NotNull]IList/*!*/ other) {
+            IList/*!*/ self, [DefaultProtocol, NotNull]IList/*!*/ other) {
 
             RubyArray result = new RubyArray();
             
             // cost: (|self| + |other|) * (hash + eql) + dict
             var remove = new Dictionary&lt;object, bool&gt;(new EqualityComparer(hashStorage, eqlStorage));
+            bool removeNull = false;
             foreach (var item in other) {
-                remove[item] = true;
+                if (item != null) {
+                    remove[item] = true;
+                } else {
+                    removeNull = true;
+                }
             }
 
             foreach (var item in self) {
-                if (!remove.ContainsKey(item)) {
+                if (!(item != null ? remove.ContainsKey(item) : removeNull)) {
                     result.Add(item);
                 }
             }
@@ -408,14 +435,17 @@ namespace IronRuby.Builtins {
                 if (index + length &gt; list.Count) {
                     length = list.Count - index;
                 }
-                RemoveRange(list, index, length);
+
+                if (length == 0) {
+                    RequireNotFrozen(list);
+                } else {
+                    RemoveRange(list, index, length);
+                }
             }
         }
 
         [RubyMethod(&quot;[]=&quot;)]
-        public static object SetElement(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol]int index, object value) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static object SetElement(IList/*!*/ self, [DefaultProtocol]int index, object value) {
             index = NormalizeIndex(self, index);
 
             if (index &lt; 0) {
@@ -435,8 +465,6 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;[]=&quot;)]
         public static object SetElement(ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, IList/*!*/ self, 
             [DefaultProtocol]int index, [DefaultProtocol]int length, object value) {
-            RubyUtils.RequiresNotFrozen(arrayTryCast.Context, self);
-
             if (length &lt; 0) {
                 throw RubyExceptions.CreateIndexError(String.Format(&quot;negative length ({0})&quot;, length));
             }
@@ -446,16 +474,21 @@ namespace IronRuby.Builtins {
                 throw RubyExceptions.CreateIndexError(String.Format(&quot;index {0} out of array&quot;, index));
             }
 
+            if (value == null) {
+                DeleteItems(self, index, length);
+                return null;
+            }
+
             IList valueAsList = value as IList;
             if (valueAsList == null) {
                 valueAsList = Protocols.TryCastToArray(arrayTryCast, value);
             }
 
-            if (value == null || (valueAsList != null &amp;&amp; valueAsList.Count == 0)) {
+            if (valueAsList != null &amp;&amp; valueAsList.Count == 0) {
                 DeleteItems(self, index, length);
             } else {
                 if (valueAsList == null) {
-                    Insert(arrayTryCast.Context, self, index, value);
+                    Insert(self, index, value);
                     
                     if (length &gt; 0) {
                         RemoveRange(self, index + 1, Math.Min(length, self.Count - index - 1));
@@ -489,8 +522,7 @@ namespace IronRuby.Builtins {
         [RubyMethod(&quot;[]=&quot;)]
         public static object SetElement(ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, ConversionStorage&lt;int&gt;/*!*/ fixnumCast, 
             IList/*!*/ self, [NotNull]Range/*!*/ range, object value) {
-            RubyUtils.RequiresNotFrozen(fixnumCast.Context, self);
-            
+
             int begin = Protocols.CastToFixnum(fixnumCast, range.Begin);
             int end = Protocols.CastToFixnum(fixnumCast, range.End);
 
@@ -510,8 +542,9 @@ namespace IronRuby.Builtins {
         #region &amp;, |
 
         [RubyMethod(&quot;&amp;&quot;)]
-        public static RubyArray/*!*/ Intersection(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol]IList/*!*/ other) {
-            Dictionary&lt;object, bool&gt; items = new Dictionary&lt;object, bool&gt;(context.EqualityComparer);
+        public static RubyArray/*!*/ Intersection(UnaryOpStorage/*!*/ hashStorage, BinaryOpStorage/*!*/ eqlStorage, 
+            IList/*!*/ self, [DefaultProtocol]IList/*!*/ other) {
+            Dictionary&lt;object, bool&gt; items = new Dictionary&lt;object, bool&gt;(new EqualityComparer(hashStorage, eqlStorage));
             RubyArray result = new RubyArray();
 
             // first get the items in the RHS
@@ -551,8 +584,9 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;|&quot;)]
-        public static RubyArray/*!*/ Union(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol]IList other) {
-            var seen = new Dictionary&lt;object, bool&gt;(context.EqualityComparer);
+        public static RubyArray/*!*/ Union(UnaryOpStorage/*!*/ hashStorage, BinaryOpStorage/*!*/ eqlStorage, 
+            IList/*!*/ self, [DefaultProtocol]IList other) {
+            var seen = new Dictionary&lt;object, bool&gt;(new EqualityComparer(hashStorage, eqlStorage));
             bool nilSeen = false;
             var result = new RubyArray();
 
@@ -596,15 +630,13 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;collect!&quot;)]
         [RubyMethod(&quot;map!&quot;)]
-        public static object CollectInPlace(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self) {
-            Assert.NotNull(context, self);
+        public static object CollectInPlace(BlockParam block, IList/*!*/ self) {
+            Assert.NotNull(self);
 
             if (self.Count &gt; 0 &amp;&amp; block == null) {
                 throw RubyExceptions.NoBlockGiven();
             }
 
-            RubyUtils.RequiresNotFrozen(context, self);
-
             int i = 0;
             while (i &lt; self.Count) {
                 object result;
@@ -634,8 +666,8 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;compact!&quot;)]
-        public static IList CompactInPlace(RubyContext/*!*/ context, IList/*!*/ self) {
-            RubyUtils.RequiresNotFrozen(context, self);
+        public static IList CompactInPlace(IList/*!*/ self) {
+            RequireNotFrozen(self);
 
             bool changed = false;
             int i = 0;
@@ -659,11 +691,10 @@ namespace IronRuby.Builtins {
             bool removed = false;
             while (i &lt; self.Count) {
                 if (Protocols.IsEqual(equals, self[i], item)) {
-                    RubyUtils.RequiresNotFrozen(equals.Context, self);
                     self.RemoveAt(i);
                     removed = true;
                 } else {
-                    ++i;
+                    i++;
                 }
             }
             return removed;
@@ -687,9 +718,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;delete_at&quot;)]
-        public static object DeleteAt(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol]int index) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static object DeleteAt(IList/*!*/ self, [DefaultProtocol]int index) {
             index = index &lt; 0 ? index + self.Count : index;
             if (index &lt; 0 || index &gt; self.Count) {
                 return null;
@@ -701,22 +730,30 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;delete_if&quot;)]
-        public static object DeleteIf(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self) {
+        public static object DeleteIf(BlockParam block, IList/*!*/ self) {
             bool changed, jumped;
-            DeleteIf(context, block, self, out changed, out jumped);
+            DeleteIf(block, self, out changed, out jumped);
             return self;
         }
 
-        private static object DeleteIf(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self, out bool changed, out bool jumped) {
-            RubyUtils.RequiresNotFrozen(context, self);
+        [RubyMethod(&quot;reject!&quot;)]
+        public static object RejectInPlace(BlockParam block, IList/*!*/ self) {
+            bool changed, jumped;
+            object result = DeleteIf(block, self, out changed, out jumped);
+            return jumped ? result : changed ? self : null;
+        }
+
+        private static object DeleteIf(BlockParam block, IList/*!*/ self, out bool changed, out bool jumped) {
             changed = false;
             jumped = false;
 
             if (block == null &amp;&amp; self.Count &gt; 0) {
                 throw RubyExceptions.NoBlockGiven();
             }
+
+            RequireNotFrozen(self);
             
-            // TODO: if block jumpes the array is not modified:
+            // TODO: if block jumps the array is not modified:
             int i = 0;
             while (i &lt; self.Count) {
                 object result;
@@ -735,23 +772,12 @@ namespace IronRuby.Builtins {
             return null;
         }
 
-        [RubyMethod(&quot;reject!&quot;)]
-        public static object RejectInPlace(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self) {
-            bool changed, jumped;
-            object result = DeleteIf(context, block, self, out changed, out jumped);
-            if (jumped) return result;
-            if (changed) return self;
-            return null;
-        }
-
         #endregion
 
         #region each, each_index
 
         [RubyMethod(&quot;each&quot;)]
-        public static object Each(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self) {
-            Assert.NotNull(context, self);
-
+        public static object Each(BlockParam block, IList/*!*/ self) {
             if (self.Count &gt; 0 &amp;&amp; block == null) {
                 throw RubyExceptions.NoBlockGiven();
             }
@@ -766,9 +792,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;each_index&quot;)]
-        public static object EachIndex(RubyContext/*!*/ context, BlockParam block, IList/*!*/ self) {
-            Assert.NotNull(context, self);
-
+        public static object EachIndex(BlockParam block, IList/*!*/ self) {
             if (self.Count &gt; 0 &amp;&amp; block == null) {
                 throw RubyExceptions.NoBlockGiven();
             }
@@ -824,9 +848,7 @@ namespace IronRuby.Builtins {
         #region fill
 
         [RubyMethod(&quot;fill&quot;)]
-        public static IList/*!*/ Fill(RubyContext/*!*/ context, IList/*!*/ self, object obj, [DefaultParameterValue(0)]int start) {
-            RubyUtils.RequiresNotFrozen(context, self);
-            
+        public static IList/*!*/ Fill(IList/*!*/ self, object obj, [DefaultParameterValue(0)]int start) {
             // Note: Array#fill(obj, start) is not equivalent to Array#fill(obj, start, 0)
             // (as per MRI behavior, the latter can expand the array if start &gt; length, but the former doesn't)
             start = Math.Max(0, NormalizeIndex(self, start));
@@ -838,9 +860,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;fill&quot;)]
-        public static IList/*!*/ Fill(RubyContext/*!*/ context, IList/*!*/ self, object obj, int start, int length) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static IList/*!*/ Fill(IList/*!*/ self, object obj, int start, int length) {
             // Note: Array#fill(obj, start) is not equivalent to Array#fill(obj, start, 0)
             // (as per MRI behavior, the latter can expand the array if start &gt; length, but the former doesn't)
             start = Math.Max(0, NormalizeIndex(self, start));
@@ -858,9 +878,9 @@ namespace IronRuby.Builtins {
         public static IList/*!*/ Fill(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, IList/*!*/ self, object obj, object start, [DefaultParameterValue(null)]object length) {
             int startFixnum = (start == null) ? 0 : Protocols.CastToFixnum(fixnumCast, start);
             if (length == null) {
-                return Fill(fixnumCast.Context, self, obj, startFixnum);
+                return Fill(self, obj, startFixnum);
             } else {
-                return Fill(fixnumCast.Context, self, obj, startFixnum, Protocols.CastToFixnum(fixnumCast, length));
+                return Fill(self, obj, startFixnum, Protocols.CastToFixnum(fixnumCast, length));
             }
         }
 
@@ -870,13 +890,11 @@ namespace IronRuby.Builtins {
             int end = NormalizeIndex(self, Protocols.CastToFixnum(fixnumCast, range.End));
             int length = Math.Max(0, end - begin + (range.ExcludeEnd ? 0 : 1));
 
-            return Fill(fixnumCast.Context, self, obj, begin, length);
+            return Fill(self, obj, begin, length);
         }
 
         [RubyMethod(&quot;fill&quot;)]
-        public static object Fill(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, IList/*!*/ self, [DefaultParameterValue(0)]int start) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static object Fill([NotNull]BlockParam/*!*/ block, IList/*!*/ self, [DefaultParameterValue(0)]int start) {
             start = Math.Max(0, NormalizeIndex(self, start));
 
             for (int i = start; i &lt; self.Count; i++) {
@@ -890,9 +908,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;fill&quot;)]
-        public static object Fill(RubyContext/*!*/ context, [NotNull]BlockParam/*!*/ block, IList/*!*/ self, int start, int length) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static object Fill([NotNull]BlockParam/*!*/ block, IList/*!*/ self, int start, int length) {
             start = Math.Max(0, NormalizeIndex(self, start));
 
             ExpandList(self, Math.Min(start, start + length));
@@ -912,9 +928,9 @@ namespace IronRuby.Builtins {
         public static object Fill(ConversionStorage&lt;int&gt;/*!*/ fixnumCast, [NotNull]BlockParam/*!*/ block, IList/*!*/ self, object start, [DefaultParameterValue(null)]object length) {
             int startFixnum = (start == null) ? 0 : Protocols.CastToFixnum(fixnumCast, start);
             if (length == null) {
-                return Fill(fixnumCast.Context, block, self, startFixnum);
+                return Fill(block, self, startFixnum);
             } else {
-                return Fill(fixnumCast.Context, block, self, startFixnum, Protocols.CastToFixnum(fixnumCast, length));
+                return Fill(block, self, startFixnum, Protocols.CastToFixnum(fixnumCast, length));
             }
         }
 
@@ -924,7 +940,7 @@ namespace IronRuby.Builtins {
             int end = NormalizeIndex(self, Protocols.CastToFixnum(fixnumCast, range.End));
             int length = Math.Max(0, end - begin + (range.ExcludeEnd ? 0 : 1));
 
-            return Fill(fixnumCast.Context, block, self, begin, length);
+            return Fill(block, self, begin, length);
         }
 
         #endregion
@@ -943,7 +959,7 @@ namespace IronRuby.Builtins {
             }
 
             count = count &gt; self.Count ? self.Count : count;
-            return RubyArray.Create(self as IList&lt;object&gt;, 0, count);
+            return new RubyArray(self, 0, count);
         }
 
         [RubyMethod(&quot;last&quot;)]
@@ -958,7 +974,7 @@ namespace IronRuby.Builtins {
             }
 
             count = count &gt; self.Count ? self.Count : count;
-            return RubyArray.Create(self as IList&lt;object&gt;, self.Count - count, count);
+            return new RubyArray(self, self.Count - count, count);
         }
 
         #endregion
@@ -1004,7 +1020,8 @@ namespace IronRuby.Builtins {
         public static IList/*!*/ Flatten(
             CallSiteStorage&lt;Func&lt;CallSite, RubyClass, object&gt;&gt;/*!*/ allocateStorage, 
             ConversionStorage&lt;IList&gt;/*!*/ tryToAry, 
-            RubyContext/*!*/ context, IList/*!*/ self) {
+            IList/*!*/ self) {
+
             IList result;
             TryFlattenArray(allocateStorage, tryToAry, self, out result);
             return result;
@@ -1014,13 +1031,13 @@ namespace IronRuby.Builtins {
         public static IList FlattenInPlace(
             CallSiteStorage&lt;Func&lt;CallSite, RubyClass, object&gt;&gt;/*!*/ allocateStorage, 
             ConversionStorage&lt;IList&gt;/*!*/ tryToAry, 
-            RubyContext/*!*/ context, IList/*!*/ self) {
+            IList/*!*/ self) {
+
             IList result;
             if (!TryFlattenArray(allocateStorage, tryToAry, self, out result)) {
                 return null;
             }
 
-            RubyUtils.RequiresNotFrozen(context, self);
             self.Clear();
             AddRange(self, result);
             return self;
@@ -1124,6 +1141,7 @@ namespace IronRuby.Builtins {
 
             Assert.NotNull(list, separator, result, seen);
             RubyContext context = tosConversion.Context;
+
             // TODO: can we get by only tracking List&lt;&gt; ?
             // (inspect needs to track everything)
             bool found;
@@ -1240,10 +1258,7 @@ namespace IronRuby.Builtins {
         #region insert, push, pop, shift, unshift, &lt;&lt;
 
         [RubyMethod(&quot;insert&quot;)]
-        public static IList/*!*/ Insert(RubyContext/*!*/ context, IList/*!*/ self, [DefaultProtocol]int index, [NotNull]params object[]/*!*/ args) {
-            if (args.Length &gt; 0)
-                RubyUtils.RequiresNotFrozen(context, self);
-
+        public static IList/*!*/ Insert(IList/*!*/ self, [DefaultProtocol]int index, [NotNull]params object[]/*!*/ args) {
             if (args.Length == 0) {
                 return self;
             }
@@ -1269,30 +1284,24 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;push&quot;)]
-        public static IList/*!*/ Push(RubyContext/*!*/ context, IList/*!*/ self, [NotNull]params object[]/*!*/ values) {
-            if (values.Length &gt; 0) {
-                RubyUtils.RequiresNotFrozen(context, self);
-            }
+        public static IList/*!*/ Push(IList/*!*/ self, [NotNull]params object[]/*!*/ values) {
             AddRange(self, values);
             return self;
         }
 
         [RubyMethod(&quot;pop&quot;)]
-        public static object Pop(RubyContext/*!*/ context, IList/*!*/ self) {
+        public static object Pop(IList/*!*/ self) {
             if (self.Count == 0) {
                 return null;
             }
 
-            RubyUtils.RequiresNotFrozen(context, self);
             object result = self[self.Count - 1];
             self.RemoveAt(self.Count - 1);
             return result;
         }
 
         [RubyMethod(&quot;shift&quot;)]
-        public static object Shift(RubyContext/*!*/ context, IList/*!*/ self) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static object Shift(IList/*!*/ self) {
             if (self.Count == 0) {
                 return null;
             }
@@ -1303,18 +1312,21 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;unshift&quot;)]
-        public static IList/*!*/ Unshift(RubyContext/*!*/ context, IList/*!*/ self, [NotNull]params object[]/*!*/ args) {
+        public static IList/*!*/ Unshift(IList/*!*/ self, object/*!*/ arg) {
+            self.Insert(0, arg);
+            return self;
+        }
+
+        [RubyMethod(&quot;unshift&quot;)]
+        public static IList/*!*/ Unshift(IList/*!*/ self, [NotNull]params object[]/*!*/ args) {
             if (args.Length &gt; 0) {
-                RubyUtils.RequiresNotFrozen(context, self);
+                InsertRange(self, 0, args);
             }
-
-            InsertRange(self, 0, args);
             return self;
         }
 
         [RubyMethod(&quot;&lt;&lt;&quot;)]
-        public static IList/*!*/ Append(RubyContext/*!*/ context, IList/*!*/ self, object value) {
-            RubyUtils.RequiresNotFrozen(context, self);
+        public static IList/*!*/ Append(IList/*!*/ self, object value) {
             self.Add(value);
             return self;
         }
@@ -1325,7 +1337,6 @@ namespace IronRuby.Builtins {
 
         [RubyMethod(&quot;slice!&quot;)]
         public static object SliceInPlace(ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, IList/*!*/ self, [DefaultProtocol]int index) {
-            RubyUtils.RequiresNotFrozen(arrayTryCast.Context, self);
             index = index &lt; 0 ? index + self.Count : index;
             if (index &gt;= 0 &amp;&amp; index &lt; self.Count) {
                 object result = self[index];
@@ -1337,21 +1348,23 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;slice!&quot;)]
-        public static object SliceInPlace(ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, 
+        public static object SliceInPlace(
+            ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, 
             ConversionStorage&lt;int&gt;/*!*/ fixnumCast, 
             CallSiteStorage&lt;Func&lt;CallSite, RubyClass, object&gt;&gt;/*!*/ allocateStorage, 
             IList/*!*/ self, [NotNull]Range/*!*/ range) {
-            RubyUtils.RequiresNotFrozen(fixnumCast.Context, self);
+
             object result = GetElement(fixnumCast, allocateStorage, self, range);
             SetElement(arrayTryCast, fixnumCast, self, range, null);
             return result;
         }
 
         [RubyMethod(&quot;slice!&quot;)]
-        public static IList/*!*/ SliceInPlace(ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, 
+        public static IList/*!*/ SliceInPlace(
+            ConversionStorage&lt;IList&gt;/*!*/ arrayTryCast, 
             CallSiteStorage&lt;Func&lt;CallSite, RubyClass, object&gt;&gt;/*!*/ allocateStorage, 
             IList/*!*/ self, [DefaultProtocol]int start, [DefaultProtocol]int length) {
-            RubyUtils.RequiresNotFrozen(allocateStorage.Context, self);
+
             IList result = GetElements(allocateStorage, self, start, length);
             SetElement(arrayTryCast, self, start, length, null);
             return result;
@@ -1372,7 +1385,7 @@ namespace IronRuby.Builtins {
             // TODO: this is not optimal because it makes an extra array copy
             // (only affects sorting of .NET types, do we need our own quicksort?)
             IList result = CreateResultArray(allocateStorage, self);
-            Replace(comparisonStorage.Context, result, ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, block, ToArray(self)));
+            Replace(result, ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, block, ToArray(self)));
             return result;
         }
 
@@ -1383,13 +1396,12 @@ namespace IronRuby.Builtins {
             BinaryOpStorage/*!*/ greaterThanStorage,
             BlockParam block, IList/*!*/ self) {
 
-            RubyUtils.RequiresNotFrozen(comparisonStorage.Context, self);
             // this should always call ArrayOps.SortInPlace instead
             Debug.Assert(!(self is RubyArray));
 
             // TODO: this is not optimal because it makes an extra array copy
             // (only affects sorting of .NET types, do we need our own quicksort?)
-            Replace(comparisonStorage.Context, self, ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, block, ToArray(self)));
+            Replace(self, ArrayOps.SortInPlace(comparisonStorage, lessThanStorage, greaterThanStorage, block, ToArray(self)));
             return self;
         }
 
@@ -1410,9 +1422,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;reverse!&quot;)]
-        public static IList/*!*/ InPlaceReverse(RubyContext/*!*/ context, IList/*!*/ self) {
-            RubyUtils.RequiresNotFrozen(context, self);
-
+        public static IList/*!*/ InPlaceReverse(IList/*!*/ self) {
             int stop = self.Count / 2;
             int last = self.Count - 1;
             for (int i = 0; i &lt; stop; i++) {
@@ -1425,7 +1435,7 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;transpose&quot;)]
-        public static RubyArray/*!*/ Transpose(ConversionStorage&lt;IList&gt;/*!*/ arrayCast, RubyContext/*!*/ context, IList/*!*/ self) {
+        public static RubyArray/*!*/ Transpose(ConversionStorage&lt;IList&gt;/*!*/ arrayCast, IList/*!*/ self) {
             // Get the arrays. Note we need to check length as we go, so we call to_ary on all the
             // arrays we encounter before the error (if any).
             RubyArray result = new RubyArray();
@@ -1464,8 +1474,8 @@ namespace IronRuby.Builtins {
         }
 
         [RubyMethod(&quot;uniq!&quot;)]
-        public static IList UniqueSelf(RubyContext/*!*/ context, IList/*!*/ self) {
-            var seen = new Dictionary&lt;object, bool&gt;(context.EqualityComparer);
+        public static IList UniqueSelf(UnaryOpStorage/*!*/ hashStorage, BinaryOpStorage/*!*/ eqlStorage, IList/*!*/ self) {
+            var seen = new Dictionary&lt;object, bool&gt;(new EqualityComparer(hashStorage, eqlStorage));
             bool nilSeen = false;
             bool modified = false;
             int i = 0;
@@ -1478,9 +1488,6 @@ namespace IronRuby.Builtins {
                     nilSeen = true;
                     i++;
                 } else {
-                    if (context.IsObjectFrozen(self)) {
-                        throw RubyExceptions.CreateTypeError(&quot;can't modify frozen array&quot;);
-                    }
                     self.RemoveAt(i);
                     modified = true;
                 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Extensions/IListOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -2518,7 +2518,7 @@ namespace IronRuby.Builtins {
         
         private static void LoadKernel_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
             module.DefineLibraryMethod(&quot;__id__&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Int32&gt;(IronRuby.Builtins.KernelOps.GetObjectId)
+                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Object&gt;(IronRuby.Builtins.KernelOps.GetObjectId)
             );
             
             module.DefineLibraryMethod(&quot;__send__&quot;, 0x51, 
@@ -2690,7 +2690,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;id&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Int32&gt;(IronRuby.Builtins.KernelOps.GetId)
+                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Object&gt;(IronRuby.Builtins.KernelOps.GetId)
             );
             
             module.DefineLibraryMethod(&quot;initialize_copy&quot;, 0x52, 
@@ -2780,7 +2780,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;object_id&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Int32&gt;(IronRuby.Builtins.KernelOps.GetObjectId)
+                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Object, System.Object&gt;(IronRuby.Builtins.KernelOps.GetObjectId)
             );
             
             module.DefineLibraryMethod(&quot;open&quot;, 0x52, 
@@ -4247,7 +4247,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;hash&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Builtins.Range, System.Int32&gt;(IronRuby.Builtins.RangeOps.GetHashCode)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Builtins.Range, System.Int32&gt;(IronRuby.Builtins.RangeOps.GetHashCode)
             );
             
             module.DefineLibraryMethod(&quot;include?&quot;, 0x51, 
@@ -4828,11 +4828,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;eql?&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Builtins.RubyStruct, System.Object, System.Boolean&gt;(IronRuby.Builtins.RubyStructOps.Equal)
+                new System.Func&lt;IronRuby.Runtime.BinaryOpStorage, IronRuby.Builtins.RubyStruct, System.Object, System.Boolean&gt;(IronRuby.Builtins.RubyStructOps.Equal)
             );
             
             module.DefineLibraryMethod(&quot;hash&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Builtins.RubyStruct, System.Int32&gt;(IronRuby.Builtins.RubyStructOps.Hash)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, IronRuby.Builtins.RubyStruct, System.Int32&gt;(IronRuby.Builtins.RubyStructOps.Hash)
             );
             
             module.DefineLibraryMethod(&quot;initialize&quot;, 0x52, 
@@ -5135,11 +5135,11 @@ namespace IronRuby.Builtins {
         
         private static void LoadSystem__Collections__IList_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
             module.DefineLibraryMethod(&quot;-&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.BinaryOpStorage, IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Difference)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.BinaryOpStorage, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Difference)
             );
             
             module.DefineLibraryMethod(&quot;&amp;&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Intersection)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.BinaryOpStorage, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Intersection)
             );
             
             module.DefineLibraryMethod(&quot;*&quot;, 0x51, 
@@ -5155,13 +5155,13 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;[]=&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Int32, System.Object, System.Object&gt;(IronRuby.Builtins.IListOps.SetElement), 
+                new System.Func&lt;System.Collections.IList, System.Int32, System.Object, System.Object&gt;(IronRuby.Builtins.IListOps.SetElement), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, System.Collections.IList, System.Int32, System.Int32, System.Object, System.Object&gt;(IronRuby.Builtins.IListOps.SetElement), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, System.Collections.IList, IronRuby.Builtins.Range, System.Object, System.Object&gt;(IronRuby.Builtins.IListOps.SetElement)
             );
             
             module.DefineLibraryMethod(&quot;|&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Union)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.BinaryOpStorage, System.Collections.IList, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Union)
             );
             
             module.DefineLibraryMethod(&quot;+&quot;, 0x51, 
@@ -5169,7 +5169,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;&lt;&lt;&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Append)
+                new System.Func&lt;System.Collections.IList, System.Object, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Append)
             );
             
             module.DefineLibraryMethod(&quot;&lt;=&gt;&quot;, 0x51, 
@@ -5190,11 +5190,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;clear&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Clear)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Clear)
             );
             
             module.DefineLibraryMethod(&quot;collect!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.CollectInPlace)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.CollectInPlace)
             );
             
             module.DefineLibraryMethod(&quot;compact&quot;, 0x51, 
@@ -5202,11 +5202,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;compact!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.CompactInPlace)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.CompactInPlace)
             );
             
             module.DefineLibraryMethod(&quot;concat&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Concat)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Concat)
             );
             
             module.DefineLibraryMethod(&quot;delete&quot;, 0x51, 
@@ -5215,19 +5215,19 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;delete_at&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.DeleteAt)
+                new System.Func&lt;System.Collections.IList, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.DeleteAt)
             );
             
             module.DefineLibraryMethod(&quot;delete_if&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.DeleteIf)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.DeleteIf)
             );
             
             module.DefineLibraryMethod(&quot;each&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Each)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Each)
             );
             
             module.DefineLibraryMethod(&quot;each_index&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.EachIndex)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.EachIndex)
             );
             
             module.DefineLibraryMethod(&quot;empty?&quot;, 0x51, 
@@ -5243,12 +5243,12 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;fill&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object, System.Int32, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object, System.Int32, System.Int32, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
+                new System.Func&lt;System.Collections.IList, System.Object, System.Int32, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
+                new System.Func&lt;System.Collections.IList, System.Object, System.Int32, System.Int32, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, System.Collections.IList, System.Object, System.Object, System.Object, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, System.Collections.IList, System.Object, IronRuby.Builtins.Range, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Fill), 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.Fill), 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Int32, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.Fill), 
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.Fill), 
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Int32, System.Int32, System.Object&gt;(IronRuby.Builtins.IListOps.Fill), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object, System.Object, System.Object&gt;(IronRuby.Builtins.IListOps.Fill), 
                 new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Int32&gt;, IronRuby.Runtime.BlockParam, System.Collections.IList, IronRuby.Builtins.Range, System.Object&gt;(IronRuby.Builtins.IListOps.Fill)
             );
@@ -5259,11 +5259,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;flatten&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.CallSiteStorage&lt;System.Func&lt;System.Runtime.CompilerServices.CallSite, IronRuby.Builtins.RubyClass, System.Object&gt;&gt;, IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Flatten)
+                new System.Func&lt;IronRuby.Runtime.CallSiteStorage&lt;System.Func&lt;System.Runtime.CompilerServices.CallSite, IronRuby.Builtins.RubyClass, System.Object&gt;&gt;, IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Flatten)
             );
             
             module.DefineLibraryMethod(&quot;flatten!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.CallSiteStorage&lt;System.Func&lt;System.Runtime.CompilerServices.CallSite, IronRuby.Builtins.RubyClass, System.Object&gt;&gt;, IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.FlattenInPlace)
+                new System.Func&lt;IronRuby.Runtime.CallSiteStorage&lt;System.Func&lt;System.Runtime.CompilerServices.CallSite, IronRuby.Builtins.RubyClass, System.Object&gt;&gt;, IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.FlattenInPlace)
             );
             
             module.DefineLibraryMethod(&quot;hash&quot;, 0x51, 
@@ -5287,11 +5287,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;initialize_copy&quot;, 0x52, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Replace)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Replace)
             );
             
             module.DefineLibraryMethod(&quot;insert&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Int32, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Insert)
+                new System.Func&lt;System.Collections.IList, System.Int32, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Insert)
             );
             
             module.DefineLibraryMethod(&quot;inspect&quot;, 0x51, 
@@ -5313,7 +5313,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;map!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.CollectInPlace)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.CollectInPlace)
             );
             
             module.DefineLibraryMethod(&quot;nitems&quot;, 0x51, 
@@ -5321,11 +5321,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;pop&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Pop)
+                new System.Func&lt;System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Pop)
             );
             
             module.DefineLibraryMethod(&quot;push&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Push)
+                new System.Func&lt;System.Collections.IList, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Push)
             );
             
             module.DefineLibraryMethod(&quot;rassoc&quot;, 0x51, 
@@ -5333,11 +5333,11 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;reject!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.RejectInPlace)
+                new System.Func&lt;IronRuby.Runtime.BlockParam, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.RejectInPlace)
             );
             
             module.DefineLibraryMethod(&quot;replace&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Replace)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Replace)
             );
             
             module.DefineLibraryMethod(&quot;reverse&quot;, 0x51, 
@@ -5345,7 +5345,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;reverse!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.InPlaceReverse)
+                new System.Func&lt;System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.InPlaceReverse)
             );
             
             module.DefineLibraryMethod(&quot;rindex&quot;, 0x51, 
@@ -5353,7 +5353,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;shift&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Shift)
+                new System.Func&lt;System.Collections.IList, System.Object&gt;(IronRuby.Builtins.IListOps.Shift)
             );
             
             module.DefineLibraryMethod(&quot;size&quot;, 0x51, 
@@ -5393,7 +5393,7 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;transpose&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, IronRuby.Runtime.RubyContext, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Transpose)
+                new System.Func&lt;IronRuby.Runtime.ConversionStorage&lt;System.Collections.IList&gt;, System.Collections.IList, IronRuby.Builtins.RubyArray&gt;(IronRuby.Builtins.IListOps.Transpose)
             );
             
             module.DefineLibraryMethod(&quot;uniq&quot;, 0x51, 
@@ -5401,11 +5401,12 @@ namespace IronRuby.Builtins {
             );
             
             module.DefineLibraryMethod(&quot;uniq!&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.UniqueSelf)
+                new System.Func&lt;IronRuby.Runtime.UnaryOpStorage, IronRuby.Runtime.BinaryOpStorage, System.Collections.IList, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.UniqueSelf)
             );
             
             module.DefineLibraryMethod(&quot;unshift&quot;, 0x51, 
-                new System.Func&lt;IronRuby.Runtime.RubyContext, System.Collections.IList, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Unshift)
+                new System.Func&lt;System.Collections.IList, System.Object, System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Unshift), 
+                new System.Func&lt;System.Collections.IList, System.Object[], System.Collections.IList&gt;(IronRuby.Builtins.IListOps.Unshift)
             );
             
             module.DefineLibraryMethod(&quot;values_at&quot;, 0x51, </diff>
      <filename>Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -153,13 +153,13 @@ namespace IronRuby.Builtins {
 
         public static MutableString/*!*/ CreateMutable(string/*!*/ str, RubyEncoding/*!*/ encoding) {
             ContractUtils.RequiresNotNull(encoding, &quot;encoding&quot;);
-            return new MutableString(str.ToCharArray(), encoding);
+            return new MutableString(str, encoding);
         }
 
         public static MutableString/*!*/ Create(string/*!*/ str, RubyEncoding/*!*/ encoding) {
             ContractUtils.RequiresNotNull(str, &quot;str&quot;);
             ContractUtils.RequiresNotNull(encoding, &quot;encoding&quot;);
-            return new MutableString(str.ToCharArray(), encoding);
+            return new MutableString(str, encoding);
         }
 
         public static MutableString/*!*/ CreateBinary() {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/MutableString.cs</filename>
    </modified>
    <modified>
      <diff>@@ -25,43 +25,56 @@ using IronRuby.Runtime.Calls;
 namespace IronRuby.Builtins {
 
     /// &lt;summary&gt;
-    /// Array inherits from Object, mixes in Enumerable.
-    /// Ruby's Array is a List{object}, but it overrides Equals and GetHashCode so
-    /// .NET dictionaries will hash it correctly.
+    /// Implements Ruby array.
+    /// Not thread safe (even when frozen).
     /// &lt;/summary&gt;
     [DebuggerDisplay(&quot;{GetDebugView()}&quot;)]
-    public partial class RubyArray : List&lt;object&gt;, IDuplicable {
+    public partial class RubyArray : IList&lt;object&gt;, IList, IRubyObjectState, IDuplicable {
+        private readonly List&lt;object&gt;/*!*/ _content;
+
+        // The lowest bit is tainted flag.
+        // The version is set to FrozenVersion when the string is frozen. FrozenVersion is the maximum version, so any update to the version 
+        // triggers an OverflowException, which we convert to InvalidOperationException.
+        private uint _versionAndFlags;
+
+        private const uint IsTaintedFlag = 1;
+        private const int FlagCount = 1;
+        private const uint FlagsMask = (1U &lt;&lt; FlagCount) - 1;
+        private const uint VersionMask = ~FlagsMask;
+        private const uint FrozenVersion = VersionMask;
+
         #region Construction
 
         public RubyArray() {
+            _content = new List&lt;object&gt;();
         }
 
-        public RubyArray(int capacity)
-            : base(capacity) {
+        public RubyArray(int capacity) {
+            _content = new List&lt;object&gt;(capacity);
         }
 
-        public RubyArray(IEnumerable&lt;object&gt;/*!*/ collection)
-            : base(collection) {
+        public RubyArray(IEnumerable&lt;object&gt;/*!*/ collection) {
+            _content = new List&lt;object&gt;(collection);
         }
 
         public RubyArray(IEnumerable/*!*/ collection)
-            : base(CollectionUtils.ToEnumerable&lt;object&gt;(collection)) {
+            : this(CollectionUtils.ToEnumerable&lt;object&gt;(collection)) {
         }
 
-        public static RubyArray/*!*/ Create&lt;T&gt;(IList&lt;T&gt;/*!*/ list, int start, int count) {
+        public RubyArray(IList/*!*/ list, int start, int count) {
             ContractUtils.RequiresNotNull(list, &quot;list&quot;);
-            ContractUtils.RequiresArrayRange(list, start, count, &quot;start&quot;, &quot;count&quot;);
+            ContractUtils.RequiresArrayRange(list.Count, start, count, &quot;start&quot;, &quot;count&quot;);
 
-            RubyArray result = new RubyArray();
+            var data = new List&lt;object&gt;();
             for (int i = 0; i &lt; count; i++) {
-                result.Add(list[start + i]);
+                data.Add(list[start + i]);
             }
-            return result;
+            _content = data;
         }
 
         public static RubyArray/*!*/ Create(object item) {
             var result = new RubyArray();
-            result.Add(item);
+            result._content.Add(item);
             return result;
         }
 
@@ -89,6 +102,45 @@ namespace IronRuby.Builtins {
 
         #endregion
 
+        #region Versioning, Flags
+
+        private void Mutate() {
+            try {
+                checked { _versionAndFlags += (1 &lt;&lt; FlagCount); }
+            } catch (OverflowException) {
+                throw RubyExceptions.CreateTypeError(&quot;can't modify frozen object&quot;);
+            }
+        }
+
+        public bool IsTainted {
+            get {
+                return (_versionAndFlags &amp; IsTaintedFlag) != 0;
+            }
+            set {
+                Mutate();
+                _versionAndFlags = (_versionAndFlags &amp; ~IsTaintedFlag) | (value ? IsTaintedFlag : 0);
+            }
+        }
+
+        public bool IsFrozen {
+            get {
+                return (_versionAndFlags &amp; VersionMask) == FrozenVersion;
+            }
+        }
+
+        void IRubyObjectState.Freeze() {
+            Freeze();
+        }
+
+        public RubyArray/*!*/ Freeze() {
+            _versionAndFlags |= FrozenVersion;
+            return this;
+        }
+
+        #endregion
+
+        #region HashCode, Equality
+
         [MultiRuntimeAware]
         private static RubyUtils.RecursionTracker _HashTracker = new RubyUtils.RecursionTracker();
 
@@ -138,28 +190,220 @@ namespace IronRuby.Builtins {
             return true;
         }
 
+        #endregion
+
+        #region IList&lt;object&gt; Members
+
+        public int IndexOf(object item) {
+            return _content.IndexOf(item);
+        }
+
+        public object this[int index] {
+            get {
+                return _content[index];
+            }
+            set {
+                Mutate();
+                _content[index] = value;
+            }
+        }
+
+        public void Insert(int index, object item) {
+            Mutate();
+            _content.Insert(index, item);
+        }
+
+        public void RemoveAt(int index) {
+            Mutate();
+            _content.RemoveAt(index);
+        }
+
+        #endregion
+
+        #region ICollection&lt;object&gt; Members
+
+        public int Count {
+            get { return _content.Count; }
+        }
+
+        public bool IsReadOnly {
+            get { return IsFrozen; }
+        }
+
+        public bool Contains(object item) {
+            return _content.Contains(item);
+        }
+
+        public void CopyTo(object[]/*!*/ array, int arrayIndex) {
+            _content.CopyTo(array, arrayIndex);
+        }
+
+        public void Add(object item) {
+            Mutate();
+            _content.Add(item);
+        }
+
+        public void Clear() {
+            Mutate();
+            _content.Clear();
+        }
+
+        public bool Remove(object item) {
+            Mutate();
+            return _content.Remove(item);
+        }
+
+        #endregion
+
+        #region IEnumerable&lt;object&gt; Members
+
+        public IEnumerator&lt;object&gt;/*!*/ GetEnumerator() {
+            return _content.GetEnumerator();
+        }
+
+        #endregion
+
+        #region IEnumerable Members
+
+        IEnumerator/*!*/ IEnumerable.GetEnumerator() {
+            return ((IEnumerable)_content).GetEnumerator();
+        }
+
+        #endregion
+
+        #region IList Members
+
+        bool IList.IsFixedSize {
+            get { return IsReadOnly; }
+        }
+
+        void IList.Remove(object value) {
+            Remove(value);
+        }
+
+        int IList.Add(object value) {
+            Mutate();
+            int result = _content.Count;
+            _content.Add(value);
+            return result;
+        }
+
+        #endregion
+
+        #region ICollection Members (read-only)
+
+        void ICollection.CopyTo(Array array, int index) {
+            ((ICollection)_content).CopyTo(array, index);
+        }
+
+        bool ICollection.IsSynchronized {
+            get { return ((ICollection)_content).IsSynchronized; }
+        }
+
+        object ICollection.SyncRoot {
+            get { return ((ICollection)_content).SyncRoot; }
+        }
+
+        #endregion
+
+        #region List specific
+
+        // read-only //
+
+        public int Capacity {
+            get { return _content.Capacity; }
+            // cannot remove items:
+            set { _content.Capacity = value; }
+        }
+
+        public void CopyTo(object[]/*!*/ result) {
+            _content.CopyTo(result);
+        }
+
+        public int FindIndex(Predicate&lt;object&gt; match) {
+            return _content.FindIndex(match);
+        }
+
+#if !SILVERLIGHT
+        public int FindIndex(int startIndex, Predicate&lt;object&gt; match) {
+            return _content.FindIndex(startIndex, match);
+        }
+
+        public int FindIndex(int startIndex, int count, Predicate&lt;object&gt; match) {
+            return _content.FindIndex(startIndex, count, match);
+        }
+#endif
+        public int BinarySearch(object item) {
+            return _content.BinarySearch(item);
+        }
+
+        public int BinarySearch(object item, IComparer&lt;object&gt; comparer) {
+            return _content.BinarySearch(item, comparer);
+        }
+
+        public int BinarySearch(int index, int count, object item, IComparer&lt;object&gt; comparer) {
+            return _content.BinarySearch(index, count, item, comparer);
+        }
+
+        // mutating //
+
+        public void Reverse() {
+            Mutate();
+            _content.Reverse();
+        }
+
         public RubyArray/*!*/ AddMultiple(int count, object value) {
+            Mutate();
+            _content.Capacity += count;
             for (int i = 0; i &lt; count; i++) {
-                Add(value);
+                _content.Add(value);
             }
             return this;
         }
 
         public RubyArray/*!*/ AddRange(IList/*!*/ items) {
-            Capacity += items.Count;
-            for (int i = 0; i &lt; items.Count; i++) {
-                Add(items[i]);
+            Mutate();
+
+            // items could be equal to this =&gt; we need to capture the count before we iterate:
+            int count = items.Count;
+
+            _content.Capacity += count;
+            for (int i = 0; i &lt; count; i++) {
+                _content.Add(items[i]);
             }
             return this;
         }
 
         public RubyArray/*!*/ AddRange(IEnumerable/*!*/ items) {
+            Mutate();
             foreach (var item in items) {
-                Add(item);
+                _content.Add(item);
             }
             return this;
         }
 
+        public void InsertRange(int index, IEnumerable&lt;object&gt;/*!*/ collection) {
+            Mutate();
+            _content.InsertRange(index, collection);
+        }
+
+        public void RemoveRange(int index, int count) {
+            Mutate();
+            _content.RemoveRange(index, count);
+        }
+
+        public void Sort() {
+            Mutate();
+            _content.Sort();
+        }
+
+        public void Sort(Comparison&lt;object&gt;/*!*/ comparison) {
+            Mutate();
+            _content.Sort(comparison);
+        }
+
+        #endregion
+
         #region DebugView
 
         internal string/*!*/ GetDebugView() {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyArray.cs</filename>
    </modified>
    <modified>
      <diff>@@ -205,29 +205,18 @@ namespace IronRuby.Builtins {
             throw RubyExceptions.CreateNameError(String.Format(&quot;no member `{0}' in struct&quot;, name));
         }
 
-        public override int GetHashCode() {
+        public int GetHashCode(UnaryOpStorage/*!*/ hashStorage, ConversionStorage&lt;int&gt;/*!*/ fixnumCast) {
             // hash is: struct's hash, plus data hashes
-            int hash = StructInfo.GetHashCode();
-            foreach (object obj in _data) {
-                hash ^= RubyUtils.GetHashCode(obj);
-            }
-            return hash;
+            return StructInfo.GetHashCode() ^ RubyArray.GetHashCode(hashStorage, fixnumCast, _data);
         }
 
-        public override bool Equals(object obj) {
+        public bool Equals(BinaryOpStorage/*!*/ eqlStorage, object obj) {
             var other = obj as RubyStruct;
             if (!StructReferenceEquals(other)) {
                 return false;
             }
             
-            Debug.Assert(_data.Length == other._data.Length);
-            for (int i = 0; i &lt; _data.Length; i++) {
-                if (!RubyUtils.ValueEquals(_data[i], other._data[i])) {
-                    return false;
-                }
-            }
-
-            return true;
+            return RubyArray.Equals(eqlStorage, _data, other._data);
         }
 
         public bool StructReferenceEquals(RubyStruct other) {</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyStruct.cs</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ using System.Diagnostics;
 
 namespace IronRuby.Builtins {
 #if GENERATOR
-    Stateless = ['Hash', 'MatchData', 'Proc', 'Range', 'RubyRegex']
+    Stateless = ['MatchData', 'Proc', 'Range', 'RubyRegex']
 
     def generate
       Stateless.each do |cls| 
@@ -33,8 +33,8 @@ namespace IronRuby.Builtins {
       @class
     end
 #else
-    public partial class /*$Class{*/RubyArray/*}*/ {
-        public sealed partial class Subclass : /*$Class{*/RubyArray/*}*/, IRubyObject {
+    public partial class /*$Class{*/Hash/*}*/ {
+        public sealed partial class Subclass : /*$Class{*/Hash/*}*/, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -82,8 +82,8 @@ namespace IronRuby.Builtins {
     }
 #endif
 #region Generated by Subclasses.Generator.rb
-    public partial class Hash {
-        public sealed partial class Subclass : Hash, IRubyObject {
+    public partial class MatchData {
+        public sealed partial class Subclass : MatchData, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -129,8 +129,8 @@ namespace IronRuby.Builtins {
             }
         }
     }
-    public partial class MatchData {
-        public sealed partial class Subclass : MatchData, IRubyObject {
+    public partial class Proc {
+        public sealed partial class Subclass : Proc, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -176,8 +176,8 @@ namespace IronRuby.Builtins {
             }
         }
     }
-    public partial class Proc {
-        public sealed partial class Subclass : Proc, IRubyObject {
+    public partial class Range {
+        public sealed partial class Subclass : Range, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -223,8 +223,8 @@ namespace IronRuby.Builtins {
             }
         }
     }
-    public partial class Range {
-        public sealed partial class Subclass : Range, IRubyObject {
+    public partial class RubyRegex {
+        public sealed partial class Subclass : RubyRegex, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -270,8 +270,24 @@ namespace IronRuby.Builtins {
             }
         }
     }
-    public partial class RubyRegex {
-        public sealed partial class Subclass : RubyRegex, IRubyObject {
+#endregion
+
+#if GENERATOR
+    Stateful = ['RubyArray']
+
+    def generate
+      Stateful.each do |cls| 
+        @class = cls
+        super 
+      end
+    end
+
+    def Class *a
+      @class
+    end
+#else
+    public partial class /*$Class{*/MutableString/*}*/ {
+        public sealed partial class Subclass : /*$Class{*/MutableString/*}*/, IRubyObject {
             private RubyInstanceData _instanceData;
             private RubyClass/*!*/ _immediateClass;
             
@@ -295,19 +311,6 @@ namespace IronRuby.Builtins {
                 return _instanceData;
             }
 
-            public bool IsFrozen {
-                get { return _instanceData != null &amp;&amp; _instanceData.Frozen; }
-            }
-
-            public bool IsTainted {
-                get { return _instanceData != null &amp;&amp; _instanceData.Tainted; }
-                set { GetInstanceData().Tainted = value; }
-            }
-
-            public void Freeze() {
-                GetInstanceData().Freeze();
-            }
-
             public int BaseGetHashCode() {
                 return base.GetHashCode();
             }
@@ -317,14 +320,24 @@ namespace IronRuby.Builtins {
             }
         }
     }
-#endregion
-
-    public partial class MutableString {
-        public sealed partial class Subclass : MutableString, IRubyObject {
+#endif
+#region Generated by Subclasses.Generator.rb
+    public partial class RubyArray {
+        public sealed partial class Subclass : RubyArray, IRubyObject {
             private RubyInstanceData _instanceData;
-
+            private RubyClass/*!*/ _immediateClass;
+            
             [Emitted]
-            public RubyClass/*!*/ ImmediateClass { get; set; }
+            public RubyClass/*!*/ ImmediateClass {
+                get {
+                    return _immediateClass;
+                }
+                set {
+                    // once a singleton immediate class is set it can't be changed:
+                    Debug.Assert((_immediateClass == null || !_immediateClass.IsSingletonClass) &amp;&amp; value != null);
+                    _immediateClass = value;
+                }
+            }
 
             public RubyInstanceData/*!*/ GetInstanceData() {
                 return RubyOps.GetInstanceData(ref _instanceData);
@@ -343,4 +356,5 @@ namespace IronRuby.Builtins {
             }
         }
     }
+#endregion
 }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Builtins/Subclasses.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -733,13 +733,10 @@ namespace IronRuby.Runtime {
 
         [Emitted]
         public static IList/*!*/ SplatAppend(IList/*!*/ array, object splattee) {
-            IEnumerable&lt;object&gt; objList;
-            IEnumerable iList;
+            IList list;
 
-            if ((objList = splattee as IEnumerable&lt;object&gt;) != null) {
-                array.AddRange(objList);
-            } else if ((iList = splattee as IEnumerable) != null) {
-                array.AddRange(iList);
+            if ((list = splattee as IList) != null) {
+                Utils.AddRange(array, list);
             } else {
                 array.Add(splattee);
             }</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -41,16 +41,6 @@ namespace IronRuby.Runtime {
         public static readonly int TrueObjectId = 2;
         public static readonly int NilObjectId = 4;
 
-        // TODO: this is not correct, because it won't call singleton &quot;eql?&quot; methods
-        public static bool ValueEquals(object self, object other) {
-            return object.Equals(self, other);
-        }
-
-        // TODO: this is not correct, because it won't call singleton &quot;hash&quot; methods
-        public static int GetHashCode(object self) {
-            return self != null ? self.GetHashCode() : RubyUtils.NilObjectId;
-        }
-
         /// &lt;summary&gt;
         /// Determines whether the given object is a value type in Ruby (i.e. they have value equality)
         /// 
@@ -121,7 +111,7 @@ namespace IronRuby.Runtime {
             }
         }
 
-        public static MutableString/*!*/ FormatObjectPrefix(string/*!*/ className, int objectId, bool isTainted) {
+        public static MutableString/*!*/ FormatObjectPrefix(string/*!*/ className, long objectId, bool isTainted) {
             MutableString str = MutableString.CreateMutable();
             str.Append(&quot;#&lt;&quot;);
             str.Append(className);
@@ -134,7 +124,7 @@ namespace IronRuby.Runtime {
             return str;
         }
 
-        public static MutableString/*!*/ FormatObject(string/*!*/ className, int objectId, bool isTainted) {
+        public static MutableString/*!*/ FormatObject(string/*!*/ className, long objectId, bool isTainted) {
             return FormatObjectPrefix(className, objectId, isTainted).Append(&quot;&gt;&quot;);
         }
 
@@ -146,7 +136,7 @@ namespace IronRuby.Runtime {
             return FormatObjectPrefix(context.GetClassDisplayName(obj), GetObjectId(context, obj), context.IsObjectTainted(obj));
         }
 
-        public static MutableString/*!*/ AppendFormatHexObjectId(MutableString/*!*/ str, int objectId) {
+        public static MutableString/*!*/ AppendFormatHexObjectId(MutableString/*!*/ str, long objectId) {
             return str.AppendFormat(&quot;0x{0:x7}&quot;, 2 * objectId);
         }
 
@@ -183,11 +173,11 @@ namespace IronRuby.Runtime {
             return true;
         }        
 
-        public static int GetFixnumId(int number) {
-            return number * 2 + 1;
+        public static long GetFixnumId(int number) {
+            return ((long)number &lt;&lt; 1) + 1;
         }
 
-        public static int GetObjectId(RubyContext/*!*/ context, object obj) {
+        public static long GetObjectId(RubyContext/*!*/ context, object obj) {
             if (obj == null) return NilObjectId;
             if (obj is bool) return (bool)obj ? TrueObjectId : FalseObjectId;
             if (obj is int) return GetFixnumId((int)obj);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,7 @@ using System.Text;
 using System.Reflection;
 using System.Collections;
 using System.Collections.Generic;
+using IronRuby.Builtins;
 
 namespace IronRuby.Runtime {
     public static class Utils {
@@ -132,12 +133,6 @@ namespace IronRuby.Runtime {
             }
         }
 
-        private static void Copy(string/*!*/ src, int srcOffset, char[]/*!*/ dst, int dstOffset, int count) {
-            for (int i = 0; i &lt; count; i++) {
-                dst[dstOffset + i] = src[srcOffset + i];
-            }
-        }
-
         internal static int Append&lt;T&gt;(ref T[]/*!*/ array, int itemCount, T item, int repeatCount) {
             Resize(ref array, itemCount + repeatCount);
             Fill(array, itemCount, item, repeatCount);
@@ -147,7 +142,7 @@ namespace IronRuby.Runtime {
         internal static int Append(ref char[]/*!*/ array, int itemCount, string/*!*/ other, int start, int count) {
             int newCount = itemCount + count;
             Resize(ref array, newCount);
-            Copy(other, start, array, itemCount, count);
+            other.CopyTo(start, array, itemCount, count);
             return newCount;
         }
 
@@ -166,7 +161,7 @@ namespace IronRuby.Runtime {
 
         internal static int InsertAt(ref char[]/*!*/ array, int itemCount, int index, string/*!*/ other, int start, int count) {
             ResizeForInsertion(ref array, itemCount, index, count);
-            Copy(other, start, array, index, count);
+            other.CopyTo(start, array, index, count);
             return itemCount + count;
         }
 
@@ -344,25 +339,16 @@ namespace IronRuby.Runtime {
             return result;
         }
 
-        internal static void AddRange(this IList/*!*/ list, IEnumerable&lt;object&gt;/*!*/ range) {
-            Assert.NotNull(list, range);
-
-            List&lt;object&gt; objList;
-            if ((objList = list as List&lt;object&gt;) != null) {
-                objList.AddRange(range);
-            } else {
-                foreach (var item in range) {
-                    list.Add(item);
-                }
-            }
-        }
-
-        internal static void AddRange(this IList/*!*/ list, IEnumerable/*!*/ range) {
+        internal static void AddRange(IList/*!*/ list, IList/*!*/ range) {
             Assert.NotNull(list, range);
 
             List&lt;object&gt; objList;
-            if ((objList = list as List&lt;object&gt;) != null) {
-                objList.AddRange(range);
+            IEnumerable&lt;object&gt; enumerableRange;
+            RubyArray array;
+            if ((array = list as RubyArray) != null) {
+                array.AddRange(range);
+            } else if ((objList = list as List&lt;object&gt;) != null &amp;&amp; (enumerableRange = range as IEnumerable&lt;object&gt;) != null) {
+                objList.AddRange(enumerableRange);
             } else {
                 foreach (var item in range) {
                     list.Add(item);</diff>
      <filename>Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,7 @@ class IRTest
       :RubySpec_C =&gt; &quot;#{mspec_base} :core2 :lib2&quot;,
       :RubyGems =&gt; &quot;#{ir} #{@root}\\Languages\\Ruby\\Tests\\Scripts\\RubyGemsTests.rb&quot;,
       :Rake =&gt; &quot;#{ir} #{@root}\\Languages\\Ruby\\Tests\\Scripts\\RakeTests.rb&quot;,
+      :Yaml =&gt; &quot;#{ir} #{@root}\\..\\External.LCA_RESTRICTED\\Languages\\IronRuby\\yaml\\YamlTest\\yaml_test_suite.rb&quot;
     }
   end
 </diff>
      <filename>Merlin/Main/Languages/Ruby/Scripts/irtests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 require &quot;rubygems&quot;
 
-rake_tests_dir = File.expand_path(&quot;../External.LCA_RESTRICTED/Languages/Ruby/RakeTests&quot;, ENV[&quot;MERLIN_ROOT&quot;])
+rake_tests_dir = File.expand_path(&quot;../External.LCA_RESTRICTED/Languages/IronRuby/RakeTests&quot;, ENV[&quot;MERLIN_ROOT&quot;])
 all_test_files = Dir.glob(&quot;#{rake_tests_dir}/test/test*.rb&quot;) + Dir.glob(&quot;#{rake_tests_dir}/test/contrib/test*.rb&quot;) + Dir.glob(&quot;#{rake_tests_dir}/test/fun*.rb&quot;)
 # Do some sanity checks
 abort(&quot;Did not find enough Rake tests files...&quot;) unless all_test_files.size &gt; 25</diff>
      <filename>Merlin/Main/Languages/Ruby/Tests/Scripts/RakeTests.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,8 +52,8 @@ namespace :test do
     IRTest.test(:Legacy)
   end
 
-  desc &quot;Run app specific tests (Rubygems and Rake)&quot;
-  task :apps =&gt; [:gems, :rake]
+  desc &quot;Run app specific tests (Rubygems, Rake and YAML)&quot;
+  task :apps =&gt; [:gems, :rake, :yaml]
 
   desc &quot;Run rake tests&quot;
   task :rake =&gt; :happy do
@@ -65,6 +65,11 @@ namespace :test do
     IRTest.test(:RubyGems)
   end
 
+  desc &quot;Run Yaml tests&quot;
+  task :yaml =&gt; :happy do
+    IRTest.test(:Yaml)
+  end
+
   desc &quot;(NOT IMPLEMENTED) Run tests corresponding to samples&quot;
   task :samples =&gt; :happy do
 </diff>
      <filename>Merlin/Main/Languages/Ruby/rake/test.rake</filename>
    </modified>
    <modified>
      <diff>@@ -95,6 +95,7 @@ namespace Microsoft.Scripting.Generation {
                 return Expression.Lambda&lt;T&gt;(
                     body,
                     node.Name + &quot;$&quot; + Interlocked.Increment(ref _uniqueNameId),
+                    node.TailCall,
                     node.Parameters
                 );
 </diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Generation/ToDiskRewriter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -90,7 +90,7 @@ namespace Microsoft.Scripting.Interpreter {
             if (b == node.Body) {
                 return node;
             }
-            return Expression.Lambda&lt;T&gt;(b, node.Name, node.Parameters);
+            return Expression.Lambda&lt;T&gt;(b, node.Name, node.TailCall, node.Parameters);
         }
 
         protected override Expression VisitBlock(BlockExpression node) {</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Interpreter/LightLambdaClosureVisitor.cs</filename>
    </modified>
    <modified>
      <diff>@@ -93,17 +93,26 @@ namespace Microsoft.Scripting.Utils {
         /// &lt;summary&gt;
         /// Requires the range [offset, offset + count] to be a subset of [0, array.Count].
         /// &lt;/summary&gt;
-        /// &lt;exception cref=&quot;ArgumentNullException&quot;&gt;Array is &lt;c&gt;null&lt;/c&gt;.&lt;/exception&gt;
         /// &lt;exception cref=&quot;ArgumentOutOfRangeException&quot;&gt;Offset or count are out of range.&lt;/exception&gt;
         public static void RequiresArrayRange&lt;T&gt;(IList&lt;T&gt; array, int offset, int count, string offsetName, string countName) {
+            Assert.NotNull(array);
+            RequiresArrayRange(array.Count, offset, count, offsetName, countName);
+        }
+
+        /// &lt;summary&gt;
+        /// Requires the range [offset, offset + count] to be a subset of [0, array.Count].
+        /// &lt;/summary&gt;
+        /// &lt;exception cref=&quot;ArgumentOutOfRangeException&quot;&gt;Offset or count are out of range.&lt;/exception&gt;
+        public static void RequiresArrayRange(int arraySize, int offset, int count, string offsetName, string countName) {
             Assert.NotEmpty(offsetName);
             Assert.NotEmpty(countName);
-            Assert.NotNull(array);
+            Debug.Assert(arraySize &gt;= 0);
 
             if (count &lt; 0) throw new ArgumentOutOfRangeException(countName);
-            if (offset &lt; 0 || array.Count - offset &lt; count) throw new ArgumentOutOfRangeException(offsetName);
+            if (offset &lt; 0 || arraySize - offset &lt; count) throw new ArgumentOutOfRangeException(offsetName);
         }
 
+
         /// &lt;summary&gt;
         /// Requires the range [offset, offset + count] to be a subset of [0, array.Count].
         /// &lt;/summary&gt;</diff>
      <filename>Merlin/Main/Runtime/Microsoft.Scripting/Utils/ContractUtils.cs</filename>
    </modified>
    <modified>
      <diff>@@ -21,8 +21,6 @@ using System.Dynamic.Utils;
 using System.Linq.Expressions;
 using System.Linq.Expressions.Compiler;
 using System.Reflection;
-using System.Threading;
-using System.Collections;
 
 namespace System.Runtime.CompilerServices {
 
@@ -433,10 +431,7 @@ namespace System.Runtime.CompilerServices {
                 );
             }
 
-            Expression getRule = Expression.Assign(
-                rule,
-                Expression.ArrayAccess(applicable, index)
-            );
+            Expression getRule = Expression.Assign(rule, Expression.ArrayAccess(applicable, index));
 
             var @break = Expression.Label();
 
@@ -486,8 +481,12 @@ namespace System.Runtime.CompilerServices {
             ////
             //// Level 2 cache lookup
             ////
-            // i = 0;
-            // var cache = @this.Binder.GetRuleCache&lt;%(funcType)s&gt;();
+            //
+            ////
+            //// Any applicable rules in level 2 cache?
+            ////
+            // 
+            // var cache = CallSiteOps.GetRuleCache(@this);
 
             var cache = Expression.Variable(typeof(RuleCache&lt;T&gt;), &quot;cache&quot;);
             vars.Add(cache);
@@ -499,38 +498,17 @@ namespace System.Runtime.CompilerServices {
                 )
             );
 
-            body.Add(
-                Expression.Assign(
-                    index,
-                    Expression.Constant(0)
-                )
-            );
-
-            ////
-            //// Any applicable rules in level 2 cache?
-            ////
-            //    foreach (var cachedRule in CallSiteOps.GetCachedRules&lt;%(funcType)s&gt;(cache)) {
-
-            ParameterExpression enumerator = Expression.Parameter(typeof(IEnumerator&lt;&gt;).MakeGenericType(typeArgs), &quot;enum&quot;);
-            vars.Add(enumerator);
+            // applicable = cache.GetRules();
 
             body.Add(
                 Expression.Assign(
-                    enumerator,
-                    Expression.Call(
-                        Expression.Call(
-                            typeof(CallSiteOps),
-                            &quot;GetCachedRules&quot;,
-                            typeArgs,
-                            cache
-                        ),
-                        typeof(IEnumerable&lt;&gt;).MakeGenericType(typeArgs).GetMethod(&quot;GetEnumerator&quot;)
-                    )
+                    applicable,
+                    Expression.Call(typeof(CallSiteOps), &quot;GetCachedRules&quot;, typeArgs, cache)
                 )
             );
 
-
-            //        @this.Target = rule;
+            //   for (int i = 0, count = applicable.Length; i &lt; count; i++) {
+            //        @this.Target = rule = applicable[i];
             //
             //        //
             //        // Execute the rule
@@ -589,28 +567,13 @@ namespace System.Runtime.CompilerServices {
                 )
             );
 
-            body.Add(
-                Expression.Assign(index, Expression.Constant(0))
-            );
-
-            breakIfDone = Expression.IfThen(
-                Expression.Not(
-                    Expression.Call(
-                        enumerator,
-                        typeof(IEnumerator).GetMethod(&quot;MoveNext&quot;)
-                    )
-                ),
-                Expression.Break(@break)
-            );
-
             getRule = Expression.Assign(
-                rule,
-                Expression.Assign(
-                    Expression.Field(@this, &quot;Target&quot;),
-                    Expression.Property(enumerator, &quot;Current&quot;)
-                )
+                Expression.Field(@this, &quot;Target&quot;),
+                Expression.Assign(rule, Expression.ArrayAccess(applicable, index))
             );
 
+            body.Add(Expression.Assign(index, Expression.Constant(0)));
+            body.Add(Expression.Assign(count, Expression.ArrayLength(applicable)));
             body.Add(
                 Expression.Loop(
                     Expression.Block(
@@ -729,10 +692,5 @@ namespace System.Runtime.CompilerServices {
             }
             return Expression.Convert(arg, type);
         }
-
-        [System.Diagnostics.CodeAnalysis.SuppressMessage(&quot;Microsoft.Performance&quot;, &quot;CA1822:MarkMembersAsStatic&quot;)]
-        internal CallSiteRule&lt;T&gt; MakeRule(T target) {
-            return new CallSiteRule&lt;T&gt;(null, target);
-        }
     }
 }</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSite.cs</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,7 @@ using System.Dynamic;
 using System.Dynamic.Utils;
 using System.Linq.Expressions;
 using System.Threading;
+using System.Reflection;
 
 namespace System.Runtime.CompilerServices {
     /// &lt;summary&gt;
@@ -49,6 +50,34 @@ namespace System.Runtime.CompilerServices {
             get { return _updateLabel; }
         }
 
+        private sealed class LambdaSignature&lt;T&gt; where T : class {
+            internal static readonly LambdaSignature&lt;T&gt; Instance = new LambdaSignature&lt;T&gt;();
+
+            internal readonly ReadOnlyCollection&lt;ParameterExpression&gt; Parameters;
+            internal readonly LabelTarget ReturnLabel;
+
+            private LambdaSignature() {
+                Type target = typeof(T);
+                if (!typeof(Delegate).IsAssignableFrom(target)) {
+                    throw Error.TypeParameterIsNotDelegate(target);
+                }
+
+                MethodInfo invoke = target.GetMethod(&quot;Invoke&quot;);
+                ParameterInfo[] pis = invoke.GetParametersCached();
+                if (pis[0].ParameterType != typeof(CallSite)) {
+                    throw Error.FirstArgumentMustBeCallSite();
+                }
+
+                var @params = new ParameterExpression[pis.Length - 1];
+                for (int i = 0; i &lt; @params.Length; i++) {
+                    @params[i] = Expression.Parameter(pis[i + 1].ParameterType, &quot;$arg&quot; + i);
+                }
+
+                Parameters = new TrueReadOnlyCollection&lt;ParameterExpression&gt;(@params);
+                ReturnLabel = Expression.Label(invoke.GetReturnType());
+            }
+        }
+
         /// &lt;summary&gt;
         /// Performs the runtime binding of the dynamic operation on a set of arguments.
         /// &lt;/summary&gt;
@@ -89,7 +118,8 @@ namespace System.Runtime.CompilerServices {
             //
             // Get the Expression for the binding
             //
-            Expression binding = Bind(args, CallSiteRule&lt;T&gt;.Parameters, CallSiteRule&lt;T&gt;.ReturnLabel);
+            var signature = LambdaSignature&lt;T&gt;.Instance;
+            Expression binding = Bind(args, signature.Parameters, signature.ReturnLabel);
 
             //
             // Check the produced rule
@@ -99,37 +129,21 @@ namespace System.Runtime.CompilerServices {
             }
             
             //
-            // see if we have an old rule to template off
-            //
-            T oldTarget = site.Target;
-
-            RuleCache&lt;T&gt; cache = GetRuleCache&lt;T&gt;();
-            CallSiteRule&lt;T&gt; newRule = null;
-            foreach (CallSiteRule&lt;T&gt; cachedRule in cache.GetRules()) {
-                if ((object)cachedRule.Target == (object)oldTarget) {
-                    newRule = AutoRuleTemplate.CopyOrCreateTemplatedRule(cachedRule, binding);
-                    break;
-                }
-            }
-
-            //
             // finally produce the new rule if we need to
             //
-            if (newRule == null) {
 #if !MICROSOFT_SCRIPTING_CORE
-                // We cannot compile rules in the heterogeneous app domains since they
-                // may come from less trusted sources
-                if (!AppDomain.CurrentDomain.IsHomogenous) {
-                    throw Error.HomogenousAppDomainRequired();
-                }
-#endif
-                Expression&lt;T&gt; e = Stitch&lt;T&gt;(binding);
-                newRule = new CallSiteRule&lt;T&gt;(binding, e.Compile());
+            // We cannot compile rules in the heterogeneous app domains since they
+            // may come from less trusted sources
+            if (!AppDomain.CurrentDomain.IsHomogenous) {
+                throw Error.HomogenousAppDomainRequired();
             }
+#endif
+            Expression&lt;T&gt; e = Stitch(binding, signature);
+            T newRule = e.Compile();
 
-            cache.AddRule(newRule);
+            CacheTarget(newRule);
 
-            return newRule.Target;
+            return newRule;
         }
 
         /// &lt;summary&gt;
@@ -139,10 +153,10 @@ namespace System.Runtime.CompilerServices {
         /// &lt;typeparam name=&quot;T&quot;&gt;The type of target being added.&lt;/typeparam&gt;
         /// &lt;param name=&quot;target&quot;&gt;The target delegate to be added to the cache.&lt;/param&gt;
         protected void CacheTarget&lt;T&gt;(T target) where T : class {
-            GetRuleCache&lt;T&gt;().AddRule(new CallSiteRule&lt;T&gt;(null, target));
+            GetRuleCache&lt;T&gt;().AddRule(target);
         }
 
-        internal static Expression&lt;T&gt; Stitch&lt;T&gt;(Expression binding) where T : class {
+        private static Expression&lt;T&gt; Stitch&lt;T&gt;(Expression binding, LambdaSignature&lt;T&gt; signature) where T : class {
             Type targetType = typeof(T);
             Type siteType = typeof(CallSite&lt;T&gt;);
 
@@ -150,7 +164,7 @@ namespace System.Runtime.CompilerServices {
             body.Add(binding);
 
             var site = Expression.Parameter(typeof(CallSite), &quot;$site&quot;);
-            var @params = CallSiteRule&lt;T&gt;.Parameters.AddFirst(site);
+            var @params = signature.Parameters.AddFirst(site);
 
             Expression updLabel = Expression.Label(CallSiteBinder.UpdateLabel);
 
@@ -165,13 +179,13 @@ namespace System.Runtime.CompilerServices {
             body.Add(updLabel);
             body.Add(
                 Expression.Label(
-                    CallSiteRule&lt;T&gt;.ReturnLabel,
+                    signature.ReturnLabel,
                     Expression.Condition(
                         Expression.Call(
                             typeof(CallSiteOps).GetMethod(&quot;SetNotMatched&quot;),
                             @params.First()
                         ),
-                        Expression.Default(CallSiteRule&lt;T&gt;.ReturnLabel.Type),
+                        Expression.Default(signature.ReturnLabel.Type),
                         Expression.Invoke(
                             Expression.Property(
                                 Expression.Convert(site, siteType),</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSiteBinder.cs</filename>
    </modified>
    <modified>
      <diff>@@ -142,10 +142,8 @@ namespace System.Runtime.CompilerServices {
         /// &lt;param name=&quot;cache&quot;&gt;The cache.&lt;/param&gt;
         /// &lt;returns&gt;The collection of applicable rules.&lt;/returns&gt;
         [Obsolete(&quot;do not use this method&quot;, true), EditorBrowsable(EditorBrowsableState.Never)]
-        public static IEnumerable&lt;T&gt; GetCachedRules&lt;T&gt;(RuleCache&lt;T&gt; cache) where T : class {
-            foreach (CallSiteRule&lt;T&gt; rule in cache.GetRules()) {
-                yield return rule.Target;
-            }
+        public static T[] GetCachedRules&lt;T&gt;(RuleCache&lt;T&gt; cache) where T : class {
+            return cache.GetRules();
         }
 
         /// &lt;summary&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSiteOps.cs</filename>
    </modified>
    <modified>
      <diff>@@ -16,9 +16,8 @@
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Dynamic.Utils;
-using System.Runtime.CompilerServices;
 
-namespace System.Dynamic {
+namespace System.Runtime.CompilerServices {
     /// &lt;summary&gt;
     /// This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
     /// Represents a cache of runtime binding rules.
@@ -26,14 +25,14 @@ namespace System.Dynamic {
     /// &lt;typeparam name=&quot;T&quot;&gt;The delegate type.&lt;/typeparam&gt;
     [EditorBrowsable(EditorBrowsableState.Never), DebuggerStepThrough]
     public class RuleCache&lt;T&gt; where T : class {
-        private CallSiteRule&lt;T&gt;[] _rules = new CallSiteRule&lt;T&gt;[0];
+        private T[] _rules = new T[0];
         private readonly Object cacheLock = new Object();
 
         private const int MaxRules = 128;
 
         internal RuleCache() { }
 
-        internal CallSiteRule&lt;T&gt;[] GetRules() {
+        internal T[] GetRules() {
             return _rules;
         }
 
@@ -53,7 +52,7 @@ namespace System.Dynamic {
                 int oldIndex = -1;
                 int max = Math.Min(_rules.Length, i + count);
                 for (int index = i; index &lt; max; index++) {
-                    if (_rules[index].Target == rule) {
+                    if (_rules[index] == rule) {
                         oldIndex = index;
                         break;
                     }
@@ -61,21 +60,21 @@ namespace System.Dynamic {
                 if (oldIndex &lt; 0) {
                     return;
                 }
-                CallSiteRule&lt;T&gt; oldRule = _rules[oldIndex];
+                T oldRule = _rules[oldIndex];
                 _rules[oldIndex] = _rules[oldIndex - 1];
                 _rules[oldIndex - 1] = _rules[oldIndex - 2];
                 _rules[oldIndex - 2] = oldRule;
             }
         }
 
-        internal void AddRule(CallSiteRule&lt;T&gt; newRule) {
+        internal void AddRule(T newRule) {
             // need a lock to make sure we are not loosing rules.
             lock (cacheLock) {
                 _rules = AddOrInsert(_rules, newRule);
             }
         }
 
-        internal void ReplaceRule(CallSiteRule&lt;T&gt; oldRule, CallSiteRule&lt;T&gt; newRule) {
+        internal void ReplaceRule(T oldRule, T newRule) {
             // need a lock to make sure we are replacing the right rule
             lock (cacheLock) {
                 int i = Array.IndexOf(_rules, oldRule);
@@ -93,19 +92,19 @@ namespace System.Dynamic {
         // Adds to end or or inserts items at InsertPosition
         private const int InsertPosition = MaxRules / 2;
 
-        private static CallSiteRule&lt;T&gt;[] AddOrInsert(CallSiteRule&lt;T&gt;[] rules, CallSiteRule&lt;T&gt; item) {
+        private static T[] AddOrInsert(T[] rules, T item) {
             if (rules.Length &lt; InsertPosition) {
                 return rules.AddLast(item);
             }
 
-            CallSiteRule&lt;T&gt;[] newRules;
+            T[] newRules;
 
             int newLength = rules.Length + 1;
             if (newLength &gt; MaxRules) {
                 newLength = MaxRules;
                 newRules = rules;
             } else {
-                newRules = new CallSiteRule&lt;T&gt;[newLength];
+                newRules = new T[newLength];
             }
 
             Array.Copy(rules, 0, newRules, 0, InsertPosition);</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/RuleCache.cs</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-/* ****************************************************************************
+&#65279;/* ****************************************************************************
  *
  * Copyright (c) Microsoft Corporation. 
  *
@@ -86,9 +86,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -211,9 +211,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -336,9 +336,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -461,9 +461,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -586,9 +586,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -711,9 +711,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -836,9 +836,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -961,9 +961,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1086,9 +1086,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1211,9 +1211,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1336,9 +1336,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1460,9 +1460,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1584,9 +1584,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1708,9 +1708,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1832,9 +1832,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -1956,9 +1956,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -2080,9 +2080,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -2204,9 +2204,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -2328,9 +2328,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -2452,9 +2452,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule
@@ -2576,9 +2576,9 @@ namespace System.Dynamic {
 
             var cache = CallSiteOps.GetRuleCache(@this);
 
-            var cachedRules = cache.GetRules();
-            for (int i = 0; i &lt; cachedRules.Length; i++) {
-                rule = cachedRules[i].Target;
+            applicable = cache.GetRules();
+            for (int i = 0; i &lt; applicable.Length; i++) {
+                rule = applicable[i];
 
                 //
                 // Execute the rule</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/UpdateDelegates.Generated.cs</filename>
    </modified>
    <modified>
      <diff>@@ -384,7 +384,7 @@ namespace System.Linq.Expressions {
             if (b == node.Body &amp;&amp; p == node.Parameters) {
                 return node;
             }
-            return Expression.Lambda&lt;T&gt;(b, node.Name, p);
+            return Expression.Lambda&lt;T&gt;(b, node.Name, node.TailCall, p);
         }
 
         /// &lt;summary&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/ExpressionVisitor.cs</filename>
    </modified>
    <modified>
      <diff>@@ -525,6 +525,22 @@ namespace System.Linq.Expressions {
             }
         }
 
+        private static bool ValidateTryGetFuncActionArgs(Type[] typeArgs) {
+            if (typeArgs == null) {
+                throw new ArgumentNullException(&quot;typeArgs&quot;);
+            }
+            for (int i = 0, n = typeArgs.Length; i &lt; n; i++) {
+                var a = typeArgs[i];
+                if (a == null) {
+                    throw new ArgumentNullException(&quot;typeArgs&quot;);
+                }
+                if (a.IsByRef) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
         /// &lt;summary&gt;
         /// Creates a &lt;see cref=&quot;Type&quot;/&gt; object that represents a generic System.Func delegate type that has specific type arguments.
         /// The last type argument specifies the return type of the created delegate.
@@ -532,8 +548,8 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;typeArgs&quot;&gt;An array of Type objects that specify the type arguments for the System.Func delegate type.&lt;/param&gt;
         /// &lt;returns&gt;The type of a System.Func delegate that has the specified type arguments.&lt;/returns&gt;
         public static Type GetFuncType(params Type[] typeArgs) {
-            ContractUtils.RequiresNotNull(typeArgs, &quot;typeArgs&quot;);
-            ContractUtils.RequiresNotNullItems(typeArgs, &quot;typeArgs&quot;);
+            ContractUtils.Requires(ValidateTryGetFuncActionArgs(typeArgs), &quot;typeArgs&quot;, Strings.TypeMustNotBeByRef);
+
             Type result = DelegateHelpers.GetFuncType(typeArgs);
             if (result == null) {
                 throw Error.IncorrectNumberOfTypeArgsForFunc();
@@ -549,11 +565,11 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;funcType&quot;&gt;When this method returns, contains the generic System.Func delegate type that has specific type arguments. Contains null if there is no generic System.Func delegate that matches the &lt;paramref name=&quot;typeArgs&quot;/&gt;.This parameter is passed uninitialized.&lt;/param&gt;
         /// &lt;returns&gt;true if generic System.Func delegate type was created for specific &lt;paramref name=&quot;typeArgs&quot;/&gt;; false otherwise.&lt;/returns&gt;
         public static bool TryGetFuncType(Type[] typeArgs, out Type funcType) {
-            ContractUtils.RequiresNotNull(typeArgs, &quot;typeArgs&quot;);
-            ContractUtils.RequiresNotNullItems(typeArgs, &quot;typeArgs&quot;);
-            Type result;
-            funcType = result = DelegateHelpers.GetFuncType(typeArgs);
-            return result != null;
+            if (ValidateTryGetFuncActionArgs(typeArgs)) {
+                return (funcType = DelegateHelpers.GetFuncType(typeArgs)) != null;
+            }
+            funcType = null;
+            return false;
         }
 
         /// &lt;summary&gt;
@@ -562,8 +578,8 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;typeArgs&quot;&gt;An array of Type objects that specify the type arguments for the System.Action delegate type.&lt;/param&gt;
         /// &lt;returns&gt;The type of a System.Action delegate that has the specified type arguments.&lt;/returns&gt;
         public static Type GetActionType(params Type[] typeArgs) {
-            ContractUtils.RequiresNotNull(typeArgs, &quot;typeArgs&quot;);
-            ContractUtils.RequiresNotNullItems(typeArgs, &quot;typeArgs&quot;);
+            ContractUtils.Requires(ValidateTryGetFuncActionArgs(typeArgs), &quot;typeArgs&quot;, Strings.TypeMustNotBeByRef);
+
             Type result = DelegateHelpers.GetActionType(typeArgs);
             if (result == null) {
                 throw Error.IncorrectNumberOfTypeArgsForAction();
@@ -578,11 +594,11 @@ namespace System.Linq.Expressions {
         /// &lt;param name=&quot;actionType&quot;&gt;When this method returns, contains the generic System.Action delegate type that has specific type arguments. Contains null if there is no generic System.Action delegate that matches the &lt;paramref name=&quot;typeArgs&quot;/&gt;.This parameter is passed uninitialized.&lt;/param&gt;
         /// &lt;returns&gt;true if generic System.Action delegate type was created for specific &lt;paramref name=&quot;typeArgs&quot;/&gt;; false otherwise.&lt;/returns&gt;
         public static bool TryGetActionType(Type[] typeArgs, out Type actionType) {
-            ContractUtils.RequiresNotNull(typeArgs, &quot;typeArgs&quot;);
-            ContractUtils.RequiresNotNullItems(typeArgs, &quot;typeArgs&quot;);
-            Type result;
-            actionType = result = DelegateHelpers.GetActionType(typeArgs);
-            return result != null;
+            if (ValidateTryGetFuncActionArgs(typeArgs)) {
+                return (actionType = DelegateHelpers.GetActionType(typeArgs)) != null;
+            }
+            actionType = null;
+            return false;
         }
 
         /// &lt;summary&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/LambdaExpression.cs</filename>
    </modified>
    <modified>
      <diff>@@ -75,7 +75,7 @@ namespace System.Runtime.CompilerServices {
                 if (b == node.Body) {
                     return node;
                 }
-                return Expression.Lambda&lt;T&gt;(b, node.Name, node.Parameters);
+                return Expression.Lambda&lt;T&gt;(b, node.Name, node.TailCall, node.Parameters);
             }
 
             protected internal override Expression VisitBlock(BlockExpression node) {</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Compiler/ExpressionQuoter.cs</filename>
    </modified>
    <modified>
      <diff>@@ -114,7 +114,6 @@
     &lt;Compile Include=&quot;Actions\BinaryOperationBinder.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\CallSite.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\CallSiteBinder.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Actions\CallSiteRule.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\CallSiteHelpers.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\ConvertBinder.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\DeleteIndexBinder.cs&quot; /&gt;
@@ -150,7 +149,6 @@
     &lt;Compile Include=&quot;Compiler\RuntimeVariableList.cs&quot; /&gt;
     &lt;Compile Include=&quot;Actions\UpdateDelegates.Generated.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\DynamicExpression.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Actions\AutoRuleTemplate.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\BinaryExpression.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\BlockExpression.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\CatchBlock.cs&quot; /&gt;
@@ -180,7 +178,6 @@
     &lt;Compile Include=&quot;Ast\ParameterExpression.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\SwitchCase.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\SwitchExpression.cs&quot; /&gt;
-    &lt;Compile Include=&quot;Ast\TreeComparer.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\TryExpression.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\TypeBinaryExpression.cs&quot; /&gt;
     &lt;Compile Include=&quot;Ast\TypeUtils.cs&quot; /&gt;</diff>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Microsoft.Scripting.Core.csproj</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/README</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/bin/rake</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/install.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/capture_stdout.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/check_expansion.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/contrib/test_sys.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/chains/.cvsignore</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/chains/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/default/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/dryrun/.cvsignore</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/dryrun/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/file_creation_task/.cvsignore</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/file_creation_task/.gitignore</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/file_creation_task/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/imports/.cvsignore</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/imports/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/imports/deps.mf</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/imports/static_deps</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/multidesc/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/namespace/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/nosearch/dummy</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/rakelib/test1.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/rakelib/test2.rake</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/rbext/rakefile.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/sample.mf</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/statusreturn/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/sys/sys1.rake</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/unittest/Rakefile</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/data/unittest/subdir/README</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/filecreation.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/functional.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/in_environment.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/rake_test_setup.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/reqfile.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/reqfile2.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/reqfile3.rake</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/session_functional.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/shellcommand.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_application.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_clean.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_definitions.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_earlytime.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_extension.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_file_creation_task.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_file_task.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_filelist.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_fileutils.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_ftp.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_invocation_chain.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_makefile_loader.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_multitask.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_namespace.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_package_task.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_pathmap.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_rake.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_rdoc_task.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_require.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_rules.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_task_arguments.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_task_manager.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_tasklib.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_tasks.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_test_task.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_top_level_functions.rb</filename>
    </removed>
    <removed>
      <filename>Merlin/External.LCA_RESTRICTED/Languages/Ruby/RakeTests/test/test_win32.rb</filename>
    </removed>
    <removed>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/AutoRuleTemplate.cs</filename>
    </removed>
    <removed>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Actions/CallSiteRule.cs</filename>
    </removed>
    <removed>
      <filename>ndp/fx/src/Core/Microsoft/Scripting/Ast/TreeComparer.cs</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>33211840f7482ffaa4970a6e630725fad2a70f5d</id>
    </parent>
  </parents>
  <author>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </author>
  <url>http://github.com/ironruby/ironruby/commit/483c07b24e02bc67425a697f5fd686ef7825da12</url>
  <id>483c07b24e02bc67425a697f5fd686ef7825da12</id>
  <committed-date>2009-06-24T19:46:59-07:00</committed-date>
  <authored-date>2009-06-24T16:21:07-07:00</authored-date>
  <message>syncing to head of tfs</message>
  <tree>dfec6ffc44b47247129d9953c602961b10d34018</tree>
  <committer>
    <name>Jim Deville</name>
    <email>jdeville@microsoft.com</email>
  </committer>
</commit>
