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_LoadWordConst;
016import static org.jikesrvm.runtime.UnboxedSizeConstants.BYTES_IN_ADDRESS;
017
018import org.vmmagic.unboxed.Word;
019
020/**
021 * load a word constant on the stack
022 */
023public class LoadWordConst extends PseudoBytecode {
024  private static final int bsize = 2 + BYTES_IN_ADDRESS;
025  private final Word wbits;
026
027  public LoadWordConst(Word bits) {
028    this.wbits = bits;
029  }
030
031  @Override
032  public byte[] getBytes() {
033    byte[] codes = initBytes(bsize, PSEUDO_LoadWordConst);
034    word2bytes(codes, 2, wbits);
035    return codes;
036  }
037
038  @Override
039  public int getSize() {
040    return bsize;
041  }
042
043  @Override
044  public int stackChanges() {
045    return +1;
046  }
047
048  @Override
049  public String toString() {
050    return "LoadWord 0x" + Long.toHexString(wbits.toLong());
051  }
052}