Logo
Distributed Genetic Programming Framework
print print

File org.dgpf.gp.vm.optimization.CodeOptimizer.java

Here you can find all the information about the file org.dgpf.gp.vm.optimization.CodeOptimizer.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-07-04 17:45:24
 * Original Filename: org.dgpf.gp.vm.optimization.CodeOptimizer.java
 * Version          : 1.0.0
 * Last modification: 2006-07-04
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.dgpf.gp.vm.optimization;

import org.dgpf.gp.vm.base.Instruction;
import org.dgpf.gp.vm.base.VMContext;
import org.sfc.utils.Typesafe;

/**
 * The code optimizer optimizes code, obviously.
 *
 * @author Thomas Weise
 */

public final class CodeOptimizer
  {
  
/**
 * No instances of this class, hun.
 */

  private CodeOptimizer()
    {
    Typesafe.do_not_call();
    }
  
  
/**
 * Optimize a program by removing unnecessary instructions.
 * @param p_code      The program code.
 * @param p_context   The virtual machine context to be used.
 * @return  The optimized program code.
 */

  public  static  final Instruction[][] optimize(
                                    Instruction[][] p_code,
                              final VMContext       p_context)
    {
    Instruction[][] l_x; 
    boolean         l_b;
    
    if(p_code.length <= 0) return O1.EMPTY;
    
    do
      {
      l_b = false;
      l_x = O1.optimize(p_code, p_context);
      
      if(l_x != p_code)
        {
        if(l_x.length <= 0) return O1.EMPTY;
        p_code = l_x;
        l_b    = true;
        }
             
      if(O2.optimize(p_code, p_context)) l_b = true;      
      if(O3.optimize(p_code, p_context)) l_b = true;     
      if(O4.optimize(p_code, p_context)) l_b = true;
      
      } while(l_b);
    
    return p_code;
    }

  }

File Information:

file name:CodeOptimizer.java
package:org.dgpf.gp.vm.optimization
qualified name:org.dgpf.gp.vm.optimization.CodeOptimizer.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/dgpf/gp/vm/optimization/CodeOptimizer.java
size:2.473 KB (2533 B)
uploaded: 2015-07-22 04:10:58 GMT+0000
last update: 2006-07-12 02:23:46 GMT+0000
last access: 2017-11-19 02:49:06 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2017-11-19 02:49:06 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo