1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 
  25 package org.graalvm.compiler.lir.gen;
  26 
  27 import org.graalvm.compiler.lir.LIRInstruction;
  28 import org.graalvm.compiler.lir.StandardOp.SaveRegistersOp;
  29 import jdk.vm.ci.code.Register;
  30 import jdk.vm.ci.code.RegisterConfig;
  31 import jdk.vm.ci.code.StackSlot;
  32 import jdk.vm.ci.meta.JavaConstant;
  33 import jdk.vm.ci.meta.Value;
  34 
  35 public interface DiagnosticLIRGeneratorTool {
  36     LIRInstruction createBenchmarkCounter(String name, String group, Value increment);
  37 
  38     LIRInstruction createMultiBenchmarkCounter(String[] names, String[] groups, Value[] increments);
  39 
  40     /**
  41      * Creates a {@link SaveRegistersOp} that fills a given set of registers with known garbage
  42      * value.
  43      *
  44      * The set of registers actually touched might be {@link SaveRegistersOp#remove reduced} later.
  45      *
  46      * @param zappedRegisters registers to be zapped
  47      * @param zapValues values used for zapping
  48      *
  49      * @see DiagnosticLIRGeneratorTool#createZapRegisters()
  50      */
  51     SaveRegistersOp createZapRegisters(Register[] zappedRegisters, JavaConstant[] zapValues);
  52 
  53     /**
  54      * Creates a {@link SaveRegistersOp} that fills all
  55      * {@link RegisterConfig#getAllocatableRegisters() allocatable registers} with a
  56      * {@link LIRGenerator#zapValueForKind known garbage value}.
  57      *
  58      * The set of registers actually touched might be {@link SaveRegistersOp#remove reduced} later.
  59      *
  60      * @see DiagnosticLIRGeneratorTool#createZapRegisters(Register[], JavaConstant[])
  61      */
  62     SaveRegistersOp createZapRegisters();
  63 
  64     /**
  65      * Marker interface for {@link LIRInstruction instructions} that should be succeeded with a
  66      * {@link DiagnosticLIRGeneratorTool#createZapRegisters() ZapRegisterOp} if assertions are
  67      * enabled.
  68      */
  69     interface ZapRegistersAfterInstruction {
  70     }
  71 
  72     /**
  73      * Marker interface for {@link LIRInstruction instructions} that should be preceded with a
  74      * {@link DiagnosticLIRGeneratorTool#zapArgumentSpace ZapArgumentSpaceOp} if assertions are
  75      * enabled.
  76      */
  77     interface ZapStackArgumentSpaceBeforeInstruction {
  78     }
  79 
  80     LIRInstruction createZapArgumentSpace(StackSlot[] zappedStack, JavaConstant[] zapValues);
  81 
  82     LIRInstruction zapArgumentSpace();
  83 }