edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BlockTests.cs;C533798
File: BlockTests.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BlockTests.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/IronRuby.Tests/Runtime/BlockTests.cs;InterpretedSites7-PartI
@@ -653,11 +653,13 @@
   end
 end
 
+c = C.new
+
 $has_to_proc = false
-1.times(&C.new) rescue puts 'error'
+1.times(&c) rescue puts 'error'
 
 $has_to_proc = true
-1.times(&C.new)
+1.times(&c)
 ");
             }, @"
 to_proc
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;C533798
File: RubyClass.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyClass.cs;InterpretedSites7-PartI
@@ -454,23 +454,28 @@
             var newInstanceVariable = metaBuilder.GetTemporary(invoke.Type, "#instance");
 
             if (args.Signature.HasBlock) {
-                // frame is needed: the frame of the 'new' call could be the block's proc-converter;
+                // A frame is needed: the frame of the 'new' call could be the block's proc-converter;
                 // (we could actually check this property at run-time and add the check into rule test, 
-                // but's that's probably not worth additional complexity)
+                // but that's probably not worth additional complexity)
                 var rfcVariable = metaBuilder.GetTemporary(typeof(RuntimeFlowControl), "#rfc");
                 var methodUnwinder = metaBuilder.GetTemporary(typeof(MethodUnwinder), "#unwinder");
                 var resultVariable = metaBuilder.GetTemporary(typeof(object), "#result");
 
                 return Ast.Comma(
                     Ast.Assign(newInstanceVariable, invoke),
+                    
                     AstFactory.MakeUserMethodBody(args.GetBlockExpression(), rfcVariable, methodUnwinder, 
-                        Ast.Assign(resultVariable, MakeInitializerCall(metaBuilder, args, newInstanceVariable))
+                        // call to the initializer and propagate retry singleton or return the new instance:
+                        Ast.Assign(resultVariable, Ast.Call(RuntimeFlowControl.GetMethod("PropagateRetrySingleton"), 
+                            MakeInitializerCall(metaBuilder, args, newInstanceVariable), 
+                            Ast.Convert(newInstanceVariable, typeof(object))
+                        )),
+
+                        // save the body result (or unwinder result) into the resultVariable:
+                        ResultOperation.Store(resultVariable)
                     ),
-                    Ast.Condition(
-                        Ast.Call(RuntimeFlowControl.GetMethod("IsRetrySingleton"), resultVariable),
-                        resultVariable,
-                        Ast.Convert(newInstanceVariable, typeof(object))
-                    )
+                    
+                    resultVariable
                 );
             } else {
                 return Ast.Comma(
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C538150
File: RubyModule.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;C538150  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyModule.cs;InterpretedSites7-PartI
@@ -185,8 +185,8 @@
 
             _methods = new Dictionary<SymbolId, RubyMemberInfo>();
 
-            Debug.WriteLine(SymbolTable.IdToString(_name) ?? "<anonymous>", "INITED");
-
+            Utils.Log(SymbolTable.IdToString(_name) ?? "<anonymous>", "INITED");
+            
             _state = State.Initializing;
             try {
                 if (_initializer != null) {
@@ -234,7 +234,7 @@
             int counter = Updated(ref affectedModules);
 
             if (affectedModules > 1) {
-                Debug.WriteLine(String.Format("{0,-50} {1,-30} affected={2,-5} total={3,-5}", Name, reason, affectedModules, counter), "UPDATED");
+                Utils.Log(String.Format("{0,-50} {1,-30} affected={2,-5} total={3,-5}", Name, reason, affectedModules, counter), "UPDATED");
             }
         }
 
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;C533798
File: RubyRegex.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyRegex.cs;InterpretedSites7-PartI
@@ -99,11 +99,11 @@
             try {
                 _regex = new Regex(transformed, RubyRegex.ToClrOptions(options));
             } catch (ArgumentException e) {
-                Debug.WriteLine("-- original ---" + new String('-', 50), "REGEX ERROR");
-                Debug.WriteLine(pattern, "REGEX ERROR");
-                Debug.WriteLine("-- transformed " + new String('-', 50), "REGEX ERROR");
-                Debug.WriteLine(transformed, "REGEX ERROR");
-                Debug.WriteLine("---------------" + new String('-', 50), "REGEX ERROR");
+                Utils.Log("-- original ---" + new String('-', 50), "REGEX_ERROR");
+                Utils.Log(pattern, "REGEX_ERROR");
+                Utils.Log("-- transformed " + new String('-', 50), "REGEX_ERROR");
+                Utils.Log(transformed, "REGEX_ERROR");
+                Utils.Log("---------------" + new String('-', 50), "REGEX_ERROR");
                 throw new RegexpError(e.Message, e);
             }
         }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;C533798
File: AstFactory.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/AstFactory.cs;InterpretedSites7-PartI
@@ -17,6 +17,7 @@
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Reflection;
+using System.Scripting;
 using Microsoft.Scripting.Actions;
 using Microsoft.Scripting.Ast;
 using Microsoft.Scripting.Generation;
@@ -51,12 +52,19 @@
 
         #region Control Flow
 
-        public static MSA.Expression/*!*/ MakeUserMethodBody(MSA.Expression/*!*/ blockParameter, MSA.Expression/*!*/ rfcVariable, 
-            MSA.VariableExpression/*!*/ methodUnwinder,
-            MSA.Expression/*!*/ bodyStatement) {
+        public static MSA.Expression/*!*/ MakeUserMethodBody(MSA.Expression/*!*/ blockParameter, MSA.Expression/*!*/ rfcVariable,
+            MSA.VariableExpression/*!*/ methodUnwinder, MSA.Expression/*!*/ bodyStatement, ResultOperation resultOperation) {
 
             Assert.NotNull(blockParameter, rfcVariable, bodyStatement, methodUnwinder);
+            Debug.Assert(!resultOperation.IsIgnore, "return value should not be ignored");
 
+            MSA.Expression resultExpression = Ast.Field(methodUnwinder, MethodUnwinder.ReturnValueField);
+            if (resultOperation.Variable != null) {
+                resultExpression = Ast.Assign(resultOperation.Variable, resultExpression);
+            } else {
+                resultExpression = Ast.Return(resultExpression);
+            }
+
             return AstUtils.Try(
                 // initialize frame (RFC):
                 Ast.Assign(rfcVariable, Ast.Call(RuntimeFlowControl.GetMethod("CreateForMethod"), Ast.ConvertHelper(blockParameter, typeof(Proc)))),
@@ -64,7 +72,7 @@
             ).Filter(typeof(MethodUnwinder), methodUnwinder, AstFactory.Equal(methodUnwinder, MethodUnwinder.TargetFrameField, rfcVariable, null),
 
                 // return unwinder.ReturnValue;
-                Ast.Return(Ast.Field(methodUnwinder, MethodUnwinder.ReturnValueField))
+                resultExpression
 
             ).Finally(
                 Ast.AssignField(rfcVariable, RuntimeFlowControl.IsActiveMethodField, Ast.False())
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Declarations/MethodDeclaration.cs;C533798
File: MethodDeclaration.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Declarations/MethodDeclaration.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Ast/Declarations/MethodDeclaration.cs;InterpretedSites7-PartI
@@ -117,7 +117,8 @@
                     _parameters.TransformOptionalsInitialization(gen),
                     gen.TraceEnabled ? AstFactory.OpCall("TraceMethodCall", scopeVariable, Ast.Constant(gen.SourceUnit.Path), Ast.Constant(Location.Start.Line)) : Ast.Empty(),
                     Body.TransformToStatement(gen, ResultOperation.Return)
-                )
+                ),
+                ResultOperation.Return
             );
 
             gen.LeaveMethodDefinition();
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs;C533798
File: RubyTypeBuilder.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Compiler/Generation/RubyTypeBuilder.cs;InterpretedSites7-PartI
@@ -77,7 +77,7 @@
 
             string typeName = GetName();
             _tb = Snippets.Shared.DefinePublicType(typeName, _baseType);
-            Debug.WriteLine(typeName, "TYPE BUILDER");
+            Utils.Log(typeName, "TYPE_BUILDER");
 
             // fields:
             _classField = _tb.DefineField("_class", typeof(RubyClass), FieldAttributes.Private | FieldAttributes.InitOnly);
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;C540252
File: RubyOptionsParser.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;C540252  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Hosting/RubyOptionsParser.cs;InterpretedSites7-PartI
@@ -34,6 +34,46 @@
     public sealed class RubyOptionsParser : OptionsParser<ConsoleOptions> {
         private readonly List<string>/*!*/ _loadPaths = new List<string>();
 
+#if DEBUG && !SILVERLIGHT
+        private ConsoleTraceListener _debugListener;
+
+        private sealed class CustomTraceFilter : TraceFilter {
+            public readonly Dictionary<string, bool>/*!*/ Categories = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
+
+            public bool EnableAll { get; set; }
+
+            public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string category, object[] args, object data1, object[] data) {
+                string message = data1 as string;
+                if (message == null) return true;
+
+                bool enabled;
+                if (Categories.TryGetValue(category, out enabled)) {
+                    return enabled;
+                } else {
+                    return EnableAll;
+                }
+            }
+        }
+
+        private void SetTraceFilter(string/*!*/ arg, bool enable) {
+            string[] categories = arg.Split(new[] { ';', ','}, StringSplitOptions.RemoveEmptyEntries);
+
+            if (categories.Length == 0 && !enable) {
+                Debug.Listeners.Clear();
+                return;
+            }
+
+            if (_debugListener == null) {
+                _debugListener = new ConsoleTraceListener { IndentSize = 4, Filter = new CustomTraceFilter { EnableAll = categories.Length == 0 } };
+                Debug.Listeners.Add(_debugListener);
+            } 
+          
+            foreach (var category in categories) {
+                ((CustomTraceFilter)_debugListener.Filter).Categories[category] = enable;
+            }
+        }
+#endif
+
         /// <exception cref="Exception">On error.</exception>
         protected override void ParseArgument(string arg) {
             ContractUtils.RequiresNotNull(arg, "arg");
@@ -48,6 +88,24 @@
                     LanguageSetup.Options["RequiredLibraries"] = libPath;
                     break;
 
+
+#if DEBUG
+                case "-DT*":
+                    SetTraceFilter(String.Empty, false);
+                    break;
+
+                case "-DT":
+                    SetTraceFilter(PopNextArg(), false);
+                    break;
+
+                case "-ET*":
+                    SetTraceFilter(String.Empty, true);
+                    break;
+
+                case "-ET":
+                    SetTraceFilter(PopNextArg(), true);
+                    break;
+#endif
                 case "-I":
                     _loadPaths.AddRange(PopNextArg().Split(Path.PathSeparator));
                     break;
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/InstanceDataWeakTable.cs;C538150
File: InstanceDataWeakTable.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/InstanceDataWeakTable.cs;C538150  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/InstanceDataWeakTable.cs;InterpretedSites7-PartI
@@ -183,7 +183,7 @@
 #endif      
             _TableType = typeof(WeakTable<object, RubyInstanceData>);
 
-            Debug.WriteLine(_TableType.FullName, "WEAK TABLE");
+            Utils.Log(_TableType.FullName, "WEAK_TABLE");
 
             _TryGetValueMethod = _TableType.GetMethod("TryGetValue", new Type[] { typeof(object), typeof(RubyInstanceData).MakeByRefType() });
             _AddMethod = _TableType.GetMethod("Add", new Type[] { typeof(object), typeof(RubyInstanceData) });
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;C540252
File: Loader.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;C540252  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Loader.cs;InterpretedSites7-PartI
@@ -28,6 +28,7 @@
 using IronRuby.Runtime.Calls;
 using System.Scripting.Actions;
 using System.Security;
+using System.Threading;
 
 namespace IronRuby.Runtime {
     [Flags]
@@ -81,12 +82,9 @@
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
         private int _compiledFileCount;
 
-        private Stopwatch _totalILGenerationTime = new Stopwatch();
-        private Stopwatch _totalAstGenerationTime = new Stopwatch();
+        internal static long _ILGenerationTimeTicks;
+        internal static long _ScriptCodeGenerationTimeTicks;
 
-        internal Stopwatch TotalILGenerationTime { get { return _totalILGenerationTime; } }
-        internal Stopwatch TotalAstGenerationTime { get { return _totalAstGenerationTime; } }
-
         /// <summary>
         /// TODO: Thread safety: the user of this object is responsible for locking it.
         /// </summary>
@@ -157,7 +155,7 @@
             Debug.Assert(_executionContext.Context.RubyOptions.LoadFromDisk);
 
             Dictionary<string, CompiledFile> result = new Dictionary<string, CompiledFile>();
-            Debug.WriteLine("LOADING", "LOADER");
+            Utils.Log("LOADING", "LOADER");
 
             ScriptCode[] codes = ScriptCode.LoadFromAssembly(_executionContext.Context.DomainManager,
                 Assembly.LoadFrom("IronRubyApplication.dll")
@@ -175,7 +173,7 @@
         internal void SaveCompiledCode() {
             if (_executionContext.Context.RubyOptions.SaveToDisk) {
                 lock (_compiledFileMutex) {
-                    Debug.WriteLine("SAVING", "LOADER");
+                    Utils.Log("SAVING", "LOADER");
 
                     // TODO: allocate eagerly (as soon as config gets fixed)
                     if (_compiledFiles == null) {
@@ -382,18 +380,19 @@
             string fullPath = Platform.GetFullPath(sourceUnit.Path);
             CompiledFile compiledFile;
             if (TryGetCompiledFile(fullPath, out compiledFile)) {
-                Debug.WriteLine(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD CACHED");
+                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");
                 compiledFile.CompiledCode.Run(scope.GlobalScope);
             } else {
-                Debug.WriteLine(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD COMPILED");
+                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");
 
                 RubyCompilerOptions options = new RubyCompilerOptions();
                 options.IsIncluded = true;
                 options.IsWrapped = (flags & LoadFlags.LoadIsolated) != 0;
 
-                _totalAstGenerationTime.Start();
+                long ts1 = Stopwatch.GetTimestamp();
                 ScriptCode compiledCode = sourceUnit.Compile(options, _executionContext.RuntimeErrorSink);
-                _totalAstGenerationTime.Stop();
+                long ts2 = Stopwatch.GetTimestamp();
+                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);
 
                 AddCompiledFile(fullPath, compiledCode);
 
@@ -402,9 +401,10 @@
         }
 
         internal object CompileAndRun(RubyScope/*!*/ scope, ScriptCode/*!*/ code, bool tryEvaluate) {
-            _totalILGenerationTime.Start();
+            long ts1 = Stopwatch.GetTimestamp();
             code.EnsureCompiled();
-            _totalILGenerationTime.Stop();
+            long ts2 = Stopwatch.GetTimestamp();
+            Interlocked.Add(ref _ILGenerationTimeTicks, ts2 - ts1);
 
             return code.Run(scope.GlobalScope);
         }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;C540252
File: RubyContext.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;C540252  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyContext.cs;InterpretedSites7-PartI
@@ -124,17 +124,52 @@
             }
         }
 
+#if MEASURE
+        private static readonly object _TransformationLock = new object();
+        private static readonly Dictionary<ExpressionType, int> _TransformationHistogram = new Dictionary<ExpressionType,int>();
+#endif
+
+        private static long _ParseTimeTicks;
+        private static long _AstGenerationTimeTicks;
+
         internal LambdaExpression ParseSourceCode(SourceUnit/*!*/ sourceUnit, CompilerOptions/*!*/ options, ErrorSink/*!*/ errorSink) {
             CompilerContext context = new CompilerContext(sourceUnit, options, errorSink);
+
+            long ts1, ts2;
+
+            ts1 = Stopwatch.GetTimestamp();
             SourceUnitTree ast = new Parser().Parse(context);
+            ts2 = Stopwatch.GetTimestamp();
+
+            Interlocked.Add(ref _ParseTimeTicks, ts2 - ts1);
+
             if (ast == null) {
                 return null;
             }
 
-            return ast.Transform(
-                new AstGenerator(context, Snippets.Shared.SaveSnippets, DomainManager.Configuration.DebugMode, RubyOptions.EnableTracing),
-                sourceUnit.Kind
-            );
+            LambdaExpression lambda;
+#if MEASURE
+            lock (_TransformationLock) {
+                var oldHistogram = System.Linq.Expressions.Expression.Histogram;
+                System.Linq.Expressions.Expression.Histogram = _TransformationHistogram;
+                try {
+#endif
+                    ts1 = Stopwatch.GetTimestamp();
+                    lambda = ast.Transform(
+                        new AstGenerator(context, Snippets.Shared.SaveSnippets, DomainManager.Configuration.DebugMode, RubyOptions.EnableTracing),
+                        sourceUnit.Kind
+                    );
+                    ts2 = Stopwatch.GetTimestamp();
+                    Interlocked.Add(ref _AstGenerationTimeTicks, ts2 - ts1);
+
+#if MEASURE
+                } finally {
+                    System.Linq.Expressions.Expression.Histogram = oldHistogram;
+                }
+            }
+#endif
+
+                    return lambda;
         }
 
         public override CompilerOptions/*!*/ GetCompilerOptions() {
@@ -225,16 +260,36 @@
 #if !SILVERLIGHT
             _upTime.Stop();
             if (Options.PerfStats) {
-                Debug.WriteLine(String.Format(@"
-  total: {0}
-  il:    {1}
-  ast:   {2}
+                Console.WriteLine(String.Format(@"
+  total:         {0}
+  parse:         {1}
+  ast transform: {2}
+  script code:   {3}
+  il:            {4}
+  binding:       {5}
 ",
                     _upTime.Elapsed,
-                    _executionContext.Loader.TotalILGenerationTime.Elapsed,
-                    _executionContext.Loader.TotalAstGenerationTime.Elapsed),
-                    "SHUTDOWN"
+                    new TimeSpan(_ParseTimeTicks),
+                    new TimeSpan(_AstGenerationTimeTicks),
+                    new TimeSpan(Loader._ScriptCodeGenerationTimeTicks),
+                    new TimeSpan(Loader._ILGenerationTimeTicks),
+#if MEASURE
+                    new TimeSpan(MetaAction.BindingTimeTicks)            
+#else
+                    "N/A"
+#endif
+                )
 );
+
+#if MEASURE
+                Console.WriteLine();
+                Console.WriteLine("---- Ruby Parser generated Expression Trees ----");
+                Console.WriteLine();
+                
+                PerfTrack.DumpHistogram(_TransformationHistogram);
+
+                Console.WriteLine();
+#endif
                 PerfTrack.DumpStats();
             }
 #endif
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;C538150
File: RubyUtils.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;C538150  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RubyUtils.cs;InterpretedSites7-PartI
@@ -523,7 +523,7 @@
             RubyExecutionContext ec = targetScope.ExecutionContext;
             RubyMethodScope methodScope = targetScope.GetInnerMostMethodScope();
 
-            Debug.WriteLine(Interlocked.Increment(ref _stringEvalCounter).ToString(), "EVAL");
+            Utils.Log(Interlocked.Increment(ref _stringEvalCounter).ToString(), "EVAL");
 
             // we want to create a new top-level local scope:
             RubyCompilerOptions options = new RubyCompilerOptions();
@@ -537,10 +537,10 @@
             try {
                 lambda = ec.Context.ParseSourceCode(source, options, ec.RuntimeErrorSink);
             } catch (SyntaxError e) {
-                Debug.WriteLine(e.Message, "EVAL ERROR");
-                Debug.WriteLine(new String('-', 50), "EVAL ERROR");
-                Debug.WriteLine(source.GetCode(), "EVAL ERROR");
-                Debug.WriteLine(new String('-', 50), "EVAL ERROR");
+                Utils.Log(e.Message, "EVAL_ERROR");
+                Utils.Log(new String('-', 50), "EVAL_ERROR");
+                Utils.Log(source.GetCode(), "EVAL_ERROR");
+                Utils.Log(new String('-', 50), "EVAL_ERROR");
                 throw;
             }
             Debug.Assert(lambda != null);
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RuntimeFlowControl.cs;C533798
File: RuntimeFlowControl.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RuntimeFlowControl.cs;C533798  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/RuntimeFlowControl.cs;InterpretedSites7-PartI
@@ -370,6 +370,11 @@
         }
 
         // emitted:
+        public static object PropagateRetrySingleton(object possibleRetrySingleton, object other) {
+            return IsRetrySingleton(possibleRetrySingleton) ? possibleRetrySingleton : other;
+        }
+
+        // emitted:
         public static object GetRetrySingleton() {
             return RetrySingleton;
         }
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C538150
File: Utils.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;C538150  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Utils.cs;InterpretedSites7-PartI
@@ -15,6 +15,7 @@
 
 using System;
 using Microsoft.Scripting.Utils;
+using System.Diagnostics;
 
 namespace IronRuby.Runtime {
     public static class Utils {
@@ -36,6 +37,13 @@
                 return -1;
             }
         }
+
+        [Conditional("DEBUG")]
+        public static void Log(string/*!*/ message, string/*!*/ category) {
+#if !SILVERLIGHT
+            Debug.WriteLine((object)message, category);
+#endif
+        }
     }
 }
 
@@ -47,6 +55,10 @@
 
         public void Stop() {
         }
+
+        public static long GetTimestamp() {
+            return 0;
+        }
     }
 }
 #endif
===================================================================
edit: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/ProtocolConversionAction.cs;C537338
File: ProtocolConversionAction.cs
===================================================================
--- $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/ProtocolConversionAction.cs;C537338  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/Merlin/Main/Languages/Ruby/Ruby/Runtime/Calls/ProtocolConversionAction.cs;InterpretedSites7-PartI
@@ -112,10 +112,10 @@
 
             // slow path: invoke respond_to?, to_xxx and result validation:
 
-            // TODO: bug in DLR AST rewriter?
-            // rule.Target = rule.MakeReturn(binder, If ... Then OpCall(...) Else Throw);
+            Expression opCall;
+            metaBuilder.Result = Ast.Condition(
+                // If
 
-            metaBuilder.Result = AstUtils.If(
                 // respond_to?()
                 AstFactory.OpCall("IsTrue",
                     Ast.Dynamic(
@@ -128,16 +128,23 @@
                 // Then
 
                 // to_xxx():
-                Ast.Return(AstFactory.OpCall(ConversionResultValidator,
+                opCall = AstFactory.OpCall(ConversionResultValidator,
                     Ast.Constant(targetClassName),
                     Ast.Dynamic(
                         RubyCallAction.Make(toMethodName, RubyCallSignature.Simple(0)),
                         typeof(object),
                         args.CodeContextExpression, args.TargetExpression
                     )
-                ))
-            ).Else(
-                Ast.Throw(AstFactory.OpCall("CreateTypeConversionError", Ast.Constant(targetClassName), Ast.Constant(TargetTypeName)))
+                ),
+
+                // Else
+
+                Ast.Convert(
+                    Ast.Convert(
+                        Ast.Throw(AstFactory.OpCall("CreateTypeConversionError", Ast.Constant(targetClassName), Ast.Constant(TargetTypeName))),
+                        typeof(object)
+                    ),
+                opCall.Type)
             );
         }
     }
===================================================================
edit: $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/ConstantExpression.cs;C535596
File: ConstantExpression.cs
===================================================================
--- $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/ConstantExpression.cs;C535596  (server)    8/25/2008 6:20 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/ConstantExpression.cs;InterpretedSites7-PartI
@@ -20,6 +20,11 @@
 namespace System.Linq.Expressions {
     //CONFORMING
     public sealed class ConstantExpression : Expression {
+        internal static readonly ConstantExpression TrueLiteral = new ConstantExpression(Annotations.Empty, true, typeof(bool));
+        internal static readonly ConstantExpression FalseLiteral = new ConstantExpression(Annotations.Empty, false, typeof(bool));
+        internal static readonly ConstantExpression ZeroLiteral = new ConstantExpression(Annotations.Empty, 0, typeof(int));
+        internal static readonly ConstantExpression NullLiteral = new ConstantExpression(Annotations.Empty, null, typeof(object));
+
         private readonly object _value;
 
         internal ConstantExpression(Annotations annotations, object value, Type type)
@@ -53,19 +58,19 @@
 
     public partial class Expression {
         public static ConstantExpression True() {
-            return new ConstantExpression(Annotations.Empty, true, typeof(bool));
+            return ConstantExpression.TrueLiteral;
         }
 
         public static ConstantExpression False() {
-            return new ConstantExpression(Annotations.Empty, false, typeof(bool));
+            return ConstantExpression.FalseLiteral;
         }
 
         public static ConstantExpression Zero() {
-            return new ConstantExpression(Annotations.Empty, 0, typeof(int));
+            return ConstantExpression.ZeroLiteral;
         }
 
         public static ConstantExpression Null() {
-            return new ConstantExpression(Annotations.Empty, null, typeof(object));
+            return ConstantExpression.NullLiteral;
         }
 
         public static ConstantExpression Null(Type type) {
===================================================================
edit: $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/EmptyStatement.cs;C535596
File: EmptyStatement.cs
===================================================================
--- $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/EmptyStatement.cs;C535596  (server)    8/25/2008 5:58 PM
+++ Shelved Change: $/Dev10/feature/vs_langs01/ndp/fx/src/Core/Microsoft/Scripting/Ast/EmptyStatement.cs;InterpretedSites7-PartI
@@ -15,6 +15,7 @@
 
 namespace System.Linq.Expressions {
     public sealed class EmptyStatement : Expression {
+        internal static readonly EmptyStatement Instance = new EmptyStatement(Annotations.Empty);
 
         internal EmptyStatement(Annotations annotations)
             : base(ExpressionType.EmptyStatement, typeof(void), annotations) {
@@ -23,7 +24,7 @@
 
     public partial class Expression {
         public static EmptyStatement Empty() {
-            return Empty(Annotations.Empty);
+            return EmptyStatement.Instance;
         }
 
         public static EmptyStatement Empty(Annotations annotations) {
===================================================================
