/// <summary> /// Compilations the thread proc. /// </summary> private static void CompilationThreadProc() { MethodCompilerBase compiler = null; WaitHandle[] waitHandles = new WaitHandle[] { _compilerPending, _abort }; while (0 == WaitHandle.WaitAny(waitHandles)) { lock (_syncObject) { if (0 != _compilerQueue.Count) { compiler = _compilerQueue.Dequeue(); } } if (null != compiler) { Debug.WriteLine("Compiling " + compiler.Method); compiler.Compile(); compiler = null; } } }
/// <summary> /// Schedules the specified compiler. /// </summary> /// <param name="compiler">The compiler.</param> public static void Schedule(MethodCompilerBase compiler) { if (null == compiler) throw new ArgumentNullException ("compiler"); if (null == _compilerPending) Setup (1); lock (_syncObject) { _compilerQueue.Enqueue (compiler); _compilerPending.Set (); } }
/// <summary> /// Schedules the specified compiler. /// </summary> /// <param name="compiler">The compiler.</param> public static void Schedule(MethodCompilerBase compiler) { if (null == compiler) { throw new ArgumentNullException("compiler"); } if (null == _compilerPending) { Setup(1); } lock (_syncObject) { _compilerQueue.Enqueue(compiler); _compilerPending.Set(); } }
void IAssemblyCompilerStage.Run(AssemblyCompiler compiler) { // Retrieve the provider provider ReadOnlyRuntimeTypeListView types = RuntimeBase.Instance.TypeLoader.GetTypesFromModule(compiler.Assembly); foreach (RuntimeType type in types) { // Do not compile generic types if (type.IsGeneric) { continue; } foreach (RuntimeMethod method in type.Methods) { if (method.IsGeneric) { continue; } if (method.IsNative) { Debug.WriteLine("Skipping native method: " + type + "." + method.Name); Debug.WriteLine("Method will not be available in compiled image."); continue; } // FIXME: Create a method implementation for this method... //MethodImplementation methodImpl = provider.GetRow<MethodImplementation>(method); //methodImpl.OwnerType = type; //Debug.WriteLine("\tMethod: " + method.ToString()); // Schedule the method for compilation... // FIXME: Do we really want to do it this way? Shouldn't we use some compilation service for this? // REFACTOR out of the AssemblyCompiler class MethodCompilerBase mcb = compiler.CreateMethodCompiler(type, method); ScheduleMethod(mcb); } } }
/// <summary> /// Called when an methods's compilation ends /// </summary> /// <param name="compiler">The compiler</param> public virtual void OnMethodCompileEnd(MethodCompilerBase compiler) { }
/// <summary> /// Called when an methods's compilation begins /// </summary> /// <param name="compiler">The compiler</param> public virtual void OnMethodCompileBegin(MethodCompilerBase compiler) { }
private void ScheduleMethod(MethodCompilerBase mcb) { _methodCompilers.Add(mcb); }
private void ScheduleMethod(MethodCompilerBase mcb) { _methodCompilers.Add(mcb); }
/// <summary> /// Called when an methods's compilation ends /// </summary> /// <param name="compiler">The compiler</param> public virtual void OnMethodCompileEnd(MethodCompilerBase compiler) { }
/// <summary> /// Called when an methods's compilation begins /// </summary> /// <param name="compiler">The compiler</param> public virtual void OnMethodCompileBegin(MethodCompilerBase compiler) { }