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      @Override
030      protected void initCompiler(String[] args) {
031        BaselineCompiler.initOptions();
032        // Process arguments specified by the user.
033        for (int i = 0, n = args.length; i < n; i++) {
034          String arg = args[i];
035          if (!BaselineCompilerImpl.options.processAsOption("-X:bc:", arg)) {
036            VM.sysWrite("BootImageCompiler(baseline): Unrecognized argument " + arg + "; ignoring\n");
037          }
038        }
039      }
040    
041      @Override
042      protected CompiledMethod compileMethod(NormalMethod method, TypeReference[] params) {
043        CompiledMethod cm;
044        Callbacks.notifyMethodCompile(method, CompiledMethod.BASELINE);
045        cm = BaselineCompiler.compile(method);
046    
047        if (VM.BuildForAdaptiveSystem) {
048          /* We can't accurately measure compilation time on Host JVM, so just approximate with DNA */
049          cm.setCompilationTime((float)CompilerDNA.estimateCompileTime(CompilerDNA.BASELINE, method));
050        }
051        return cm;
052      }
053    }