001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.compilers.baseline;
014    
015    import org.jikesrvm.ArchitectureSpecific.BaselineCompilerImpl;
016    import org.jikesrvm.VM;
017    import org.jikesrvm.Callbacks;
018    import org.jikesrvm.adaptive.recompilation.CompilerDNA;
019    import org.jikesrvm.classloader.NormalMethod;
020    import org.jikesrvm.classloader.TypeReference;
021    import org.jikesrvm.compilers.common.BootImageCompiler;
022    import org.jikesrvm.compilers.common.CompiledMethod;
023    
024    /**
025     * Use baseline compiler to build virtual machine boot image.
026     */
027    public final class BaselineBootImageCompiler extends BootImageCompiler {
028    
029      /**
030       * Initialize boot image compiler.
031       * @param args command line arguments to the bootimage compiler
032       */
033      protected void initCompiler(String[] args) {
034        BaselineCompiler.initOptions();
035        // Process arguments specified by the user.
036        for (int i = 0, n = args.length; i < n; i++) {
037          String arg = args[i];
038          if (!BaselineCompilerImpl.options.processAsOption("-X:bc:", arg)) {
039            VM.sysWrite("BootImageCompiler(baseline): Unrecognized argument " + arg + "; ignoring\n");
040          }
041        }
042      }
043    
044      /**
045       * Compile a method with bytecodes.
046       * @param method the method to compile
047       * @return the compiled method
048       */
049      protected CompiledMethod compileMethod(NormalMethod method, TypeReference[] params) {
050        CompiledMethod cm;
051        Callbacks.notifyMethodCompile(method, CompiledMethod.BASELINE);
052        cm = BaselineCompiler.compile(method);
053    
054        if (VM.BuildForAdaptiveSystem) {
055          /* We can't accurately measure compilation time on Host JVM, so just approximate with DNA */
056          cm.setCompilationTime((float)CompilerDNA.estimateCompileTime(CompilerDNA.BASELINE, method));
057        }
058        return cm;
059      }
060    }