< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.code/src/jdk/vm/ci/code/site/Mark.java

Print this page


   1 /*
   2  * Copyright (c) 2016, 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 package jdk.vm.ci.code.site;
  24 
  25 import java.util.Objects;
  26 
  27 /**
  28  * Represents a mark in the machine code that can be used by the runtime for its own purposes. A
  29  * mark can reference other marks.

  30  */
  31 public final class Mark extends Site {
  32 



  33     public final Object id;
  34 






  35     public Mark(int pcOffset, Object id) {
  36         super(pcOffset);
  37         this.id = id;
  38     }
  39 
  40     @Override
  41     public String toString() {
  42         if (id == null) {
  43             return String.format("%d[<mar>]", pcOffset);
  44         } else if (id instanceof Integer) {
  45             return String.format("%d[<mark with id %s>]", pcOffset, Integer.toHexString((Integer) id));
  46         } else {
  47             return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
  48         }
  49     }
  50 
  51     @Override
  52     public boolean equals(Object obj) {
  53         if (this == obj) {
  54             return true;
  55         }
  56         if (obj instanceof Mark) {
  57             Mark that = (Mark) obj;
  58             if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
  59                 return true;
  60             }
  61         }
  62         return false;
  63     }
   1 /*
   2  * Copyright (c) 2009, 2016, 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 package jdk.vm.ci.code.site;
  24 
  25 import java.util.Objects;
  26 
  27 /**
  28  * Associates arbitrary information with a position in machine code. For example, HotSpot specific
  29  * code in a compiler backend may use this to denote the position of a safepoint, exception handler
  30  * entry point, verified entry point etc.
  31  */
  32 public final class Mark extends Site {
  33 
  34     /**
  35      * An object denoting extra semantic information about the machine code position of this mark.
  36      */
  37     public final Object id;
  38 
  39     /**
  40      * Creates a mark that associates {@code id} with the machine code position {@code pcOffset}.
  41      *
  42      * @param pcOffset
  43      * @param id
  44      */
  45     public Mark(int pcOffset, Object id) {
  46         super(pcOffset);
  47         this.id = id;
  48     }
  49 
  50     @Override
  51     public String toString() {
  52         if (id == null) {
  53             return String.format("%d[<mark>]", pcOffset);
  54         } else if (id instanceof Integer) {
  55             return String.format("%d[<mark with id %s>]", pcOffset, Integer.toHexString((Integer) id));
  56         } else {
  57             return String.format("%d[<mark with id %s>]", pcOffset, id.toString());
  58         }
  59     }
  60 
  61     @Override
  62     public boolean equals(Object obj) {
  63         if (this == obj) {
  64             return true;
  65         }
  66         if (obj instanceof Mark) {
  67             Mark that = (Mark) obj;
  68             if (this.pcOffset == that.pcOffset && Objects.equals(this.id, that.id)) {
  69                 return true;
  70             }
  71         }
  72         return false;
  73     }
< prev index next >