1 /*
   2  * Copyright (c) 2015, 2019, 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 org.graalvm.compiler.lir.StandardOp.ZapRegistersOp;
  30 
  31 import jdk.vm.ci.code.Register;
  32 import jdk.vm.ci.code.RegisterConfig;
  33 import jdk.vm.ci.code.StackSlot;
  34 import jdk.vm.ci.meta.JavaConstant;
  35 import jdk.vm.ci.meta.Value;
  36 
  37 public interface DiagnosticLIRGeneratorTool {
  38     LIRInstruction createBenchmarkCounter(String name, String group, Value increment);
  39 
  40     LIRInstruction createMultiBenchmarkCounter(String[] names, String[] groups, Value[] increments);
  41 
  42     /**
  43      * Creates a {@link SaveRegistersOp} that fills a given set of registers with known garbage
  44      * value.
  45      *
  46      * @param zappedRegisters registers to be zapped
  47      * @param zapValues values used for zapping
  48      *
  49      * @see DiagnosticLIRGeneratorTool#createZapRegisters()
  50      */
  51     ZapRegistersOp createZapRegisters(Register[] zappedRegisters, JavaConstant[] zapValues);
  52 
  53     /**
  54      * Creates a {@link SaveRegistersOp} that fills a given set of registers with a
  55      * {@link LIRGenerator#zapValueForKind known garbage value}.
  56      *
  57      * @param zappedRegisters registers to be zapped
  58      *
  59      * @see DiagnosticLIRGeneratorTool#createZapRegisters()
  60      */
  61     ZapRegistersOp createZapRegisters(Register[] zappedRegisters);
  62 
  63     /**
  64      * Creates a {@link ZapRegistersOp} that fills all
  65      * {@link RegisterConfig#getAllocatableRegisters() allocatable registers} with a
  66      * {@link LIRGenerator#zapValueForKind known garbage value}.
  67      *
  68      * @see DiagnosticLIRGeneratorTool#createZapRegisters(Register[], JavaConstant[])
  69      */
  70     ZapRegistersOp createZapRegisters();
  71 
  72     /**
  73      * Marker interface for {@link LIRInstruction instructions} that should be succeeded with a
  74      * {@link DiagnosticLIRGeneratorTool#createZapRegisters() ZapRegisterOp} if assertions are
  75      * enabled.
  76      */
  77     interface ZapRegistersAfterInstruction {
  78     }
  79 
  80     /**
  81      * Marker interface for {@link LIRInstruction instructions} that should be preceded with a
  82      * {@link DiagnosticLIRGeneratorTool#zapArgumentSpace ZapArgumentSpaceOp} if assertions are
  83      * enabled.
  84      */
  85     interface ZapStackArgumentSpaceBeforeInstruction {
  86     }
  87 
  88     LIRInstruction createZapArgumentSpace(StackSlot[] zappedStack, JavaConstant[] zapValues);
  89 
  90     LIRInstruction zapArgumentSpace();
  91 }