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 */
013 package org.jikesrvm.compilers.common;
014
015 import org.jikesrvm.ArchitectureSpecific;
016 import org.jikesrvm.SizeConstants;
017 import org.jikesrvm.mm.mminterface.GCMapIterator;
018 import org.jikesrvm.runtime.Magic;
019 import org.vmmagic.pragma.Uninterruptible;
020 import org.vmmagic.unboxed.Address;
021 import org.vmmagic.unboxed.Offset;
022 import org.vmmagic.unboxed.WordArray;
023
024 /**
025 * Iterator for stack frames inserted by hardware trap handler.
026 * Such frames are purely used as markers.
027 * They contain no object references or JSR return addresses.
028 */
029 @Uninterruptible
030 public final class HardwareTrapGCMapIterator extends GCMapIterator implements SizeConstants {
031
032 public HardwareTrapGCMapIterator(WordArray registerLocations) {
033 this.registerLocations = registerLocations;
034 }
035
036 public void setupIterator(CompiledMethod compiledMethod, Offset instructionOffset, Address framePtr) {
037 this.framePtr = framePtr;
038 }
039
040 public Address getNextReferenceAddress() {
041 // update register locations, noting that the trap handler represented by this stackframe
042 // saved all registers into the thread's "exceptionRegisters" object
043 //
044 Address registerLocation = Magic.objectAsAddress(thread.getExceptionRegisters().gprs);
045 for (int i = 0; i < ArchitectureSpecific.ArchConstants.NUM_GPRS; ++i) {
046 registerLocations.set(i, registerLocation.toWord());
047 registerLocation = registerLocation.plus(BYTES_IN_ADDRESS);
048 }
049 return Address.zero();
050 }
051
052 public Address getNextReturnAddressAddress() {
053 return Address.zero();
054 }
055
056 public void reset() {}
057
058 public void cleanupPointers() {}
059
060 public int getType() {
061 return CompiledMethod.TRAP;
062 }
063 }