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.mm.mmtk;
014
015import org.mmtk.policy.Space;
016
017import org.jikesrvm.VM;
018import org.jikesrvm.scheduler.RVMThread;
019
020import org.vmmagic.pragma.*;
021
022@Uninterruptible public class Assert extends org.mmtk.vm.Assert {
023  @Override
024  protected final boolean getVerifyAssertionsConstant() {
025    return VM.VerifyAssertions;
026  }
027
028  /**
029   * This method should be called whenever an error is encountered.
030   *
031   * @param str A string describing the error condition.
032   */
033  public final void error(String str) {
034    Space.printUsagePages();
035    Space.printUsageMB();
036    fail(str);
037  }
038
039  @Override
040  public final void fail(String message) {
041    Space.printUsagePages();
042    Space.printUsageMB();
043    VM.sysFail(message);
044  }
045
046  @Uninterruptible
047  public final void exit(int rc) {
048    VM.sysExit(rc);
049  }
050
051  @Override
052  @Inline(value = Inline.When.AllArgumentsAreConstant)
053  public final void _assert(boolean cond) {
054    if (!org.mmtk.vm.VM.VERIFY_ASSERTIONS)
055      VM.sysFail("All assertions must be guarded by VM.VERIFY_ASSERTIONS: please check the failing assertion");
056    //CHECKSTYLE:OFF - Checkstyle assertion plugin would warn otherwise
057    VM._assert(cond);
058    //CHECKSTYLE:ON
059  }
060
061  @Override
062  @Inline(value = Inline.When.ArgumentsAreConstant, arguments = {1})
063  public final void _assert(boolean cond, String message) {
064    if (!org.mmtk.vm.VM.VERIFY_ASSERTIONS)
065      VM.sysFail("All assertions must be guarded by VM.VERIFY_ASSERTIONS: please check the failing assertion");
066    if (!cond) VM.sysWriteln(message);
067    //CHECKSTYLE:OFF - Checkstyle assertion plugin would warn otherwise
068    VM._assert(cond);
069    //CHECKSTYLE:ON
070  }
071
072  @Override
073  public final void dumpStack() {
074    RVMThread.dumpStack();
075  }
076}