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.runtime;
014
015import org.vmmagic.unboxed.Address;
016
017/**
018 * Facility for remapping object addresses across virtual machine address
019 * spaces.  Used by boot image writer to map local (JDK) objects into remote
020 * (boot image) addresses.  Used by debugger to map local (JDK) objects into
021 * remote (debugee VM) addresses.
022 *
023 * See also Magic.setObjectAddressRemapper()
024 */
025public interface ObjectAddressRemapper {
026  /**
027   * Map an object to an address.
028   * @param <T> the object's type
029   * @param object in "local" virtual machine
030   * @return its address in a foreign virtual machine
031   */
032  <T> Address objectAsAddress(T object);
033
034  /**
035   * Map an address to an object.
036   * @param address value obtained from "objectAsAddress"
037   * @return corresponding object
038   */
039  Object addressAsObject(Address address);
040
041  /**
042   * Avoid duplicates of certain objects
043   * @param <T> the object's type
044   * @param object to intern
045   * @return interned object
046   */
047  <T> T intern(T object);
048
049  /**
050   * Identity hash code of an object
051   *
052   * @param object the object to generate the identity hash code for
053   * @return the identity hash code
054   */
055  int identityHashCode(Object object);
056}