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 */
013package org.jikesrvm.compilers.baseline;
014
015import org.jikesrvm.VM;
016import org.jikesrvm.adaptive.recompilation.CompilerDNA;
017import org.jikesrvm.classloader.NormalMethod;
018import org.jikesrvm.classloader.TypeReference;
019import org.jikesrvm.compilers.common.BootImageCompiler;
020import org.jikesrvm.compilers.common.CompiledMethod;
021import org.jikesrvm.runtime.Callbacks;
022
023/**
024 * Use baseline compiler to build virtual machine boot image.
025 */
026public final class BaselineBootImageCompiler extends BootImageCompiler {
027
028  @Override
029  protected void initCompiler(String[] args) {
030    BaselineCompiler.initOptions();
031    // Process arguments specified by the user.
032    for (int i = 0, n = args.length; i < n; i++) {
033      String arg = args[i];
034      if (!BaselineCompiler.options.processAsOption("-X:bc:", arg)) {
035        VM.sysWrite("BootImageCompiler(baseline): Unrecognized argument " + arg + "; ignoring\n");
036      }
037    }
038  }
039
040  @Override
041  protected CompiledMethod compileMethod(NormalMethod method, TypeReference[] params) {
042    CompiledMethod cm;
043    Callbacks.notifyMethodCompile(method, CompiledMethod.BASELINE);
044    cm = BaselineCompiler.compile(method);
045
046    if (VM.BuildForAdaptiveSystem) {
047      /* We can't accurately measure compilation time on Host JVM, so just approximate with DNA */
048      cm.setCompilationTime((float)CompilerDNA.estimateCompileTime(CompilerDNA.BASELINE, method));
049    }
050    return cm;
051  }
052}