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.classloader.BytecodeConstants.JBC_istore;
016
017/**
018 * BC_IntStore : {@code istore_<?>}, {@code istore}
019 * <pre>
020 *      Local number            Instruction
021 *      [0, 3]                  istore_&lt;i&gt;
022 *      other                   istore, wide istore
023 * </pre>
024 */
025public class IntStore extends PseudoBytecode {
026  private int bsize;
027  private byte[] codes;
028  private final int lnum;
029
030  public IntStore(int local) {
031    this.lnum = local;
032    if (local <= 255) {
033      bsize = 2;
034      codes = makeOUcode(JBC_istore, local);
035    } else {
036      bsize = 4;
037      codes = makeWOUUcode(JBC_istore, local);
038    }
039  }
040
041  @Override
042  public byte[] getBytes() {
043    return codes;
044  }
045
046  @Override
047  public int getSize() {
048    return bsize;
049  }
050
051  @Override
052  public int stackChanges() {
053    return -1;
054  }
055
056  @Override
057  public String toString() {
058    return "istore " + lnum;
059  }
060}