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.osr.bytecodes;
014
015import static org.jikesrvm.osr.OSRConstants.PSEUDO_LoadRetAddrConst;
016
017/**
018 * artificial instruction, load a PC on the stack.
019 */
020public class LoadRetAddrConst extends PseudoBytecode {
021  private static final int bsize = 6;
022  private int bcindex;
023
024  public LoadRetAddrConst(int off) {
025    this.bcindex = off;
026  }
027
028  @Override
029  public byte[] getBytes() {
030    byte[] codes = initBytes(bsize, PSEUDO_LoadRetAddrConst);
031    int2bytes(codes, 2, bcindex);
032    return codes;
033  }
034
035  @Override
036  public int getSize() {
037    return bsize;
038  }
039
040  public int getOffset() {
041    return bcindex;
042  }
043
044  @Override
045  public int stackChanges() {
046    return +1;
047  }
048
049  public void patch(int off) {
050    this.bcindex = off;
051  }
052
053  @Override
054  public String toString() {
055    return "LoadRetAddrConst " + bcindex;
056  }
057}