Ejemplo n.º 1
0
        /// <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;
                }
            }
        }
Ejemplo n.º 2
0
        /// <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 ();
            }
        }
Ejemplo n.º 3
0
        /// <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();
            }
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Called when an methods's compilation ends
 /// </summary>
 /// <param name="compiler">The compiler</param>
 public virtual void OnMethodCompileEnd(MethodCompilerBase compiler)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Called when an methods's compilation begins
 /// </summary>
 /// <param name="compiler">The compiler</param>
 public virtual void OnMethodCompileBegin(MethodCompilerBase compiler)
 {
 }
Ejemplo n.º 7
0
 private void ScheduleMethod(MethodCompilerBase mcb)
 {
     _methodCompilers.Add(mcb);
 }
 private void ScheduleMethod(MethodCompilerBase mcb)
 {
     _methodCompilers.Add(mcb);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Called when an methods's compilation ends
 /// </summary>
 /// <param name="compiler">The compiler</param>
 public virtual void OnMethodCompileEnd(MethodCompilerBase compiler)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Called when an methods's compilation begins
 /// </summary>
 /// <param name="compiler">The compiler</param>
 public virtual void OnMethodCompileBegin(MethodCompilerBase compiler)
 {
 }