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.compilers.opt.ir.operand; 014 015import java.util.Arrays; 016import org.jikesrvm.classloader.MemberReference; 017/** 018 * An InlinedOsrTypeInfoOperand object keeps necessary information 019 * to recover non-inlined status for an inlined method. 020 */ 021public final class InlinedOsrTypeInfoOperand extends Operand { 022 023 //////////////////////////////////////////// 024 // DATA Type // 025 //////////////////////////////////////////// 026 027 /* the type info is organized by calling sequences, e.g., 028 * a calls b calls c, then the type information is 029 * methodids: a_ids, b_ids, c_ids 030 * bcindexes: a_pc, b_pc, c_pc 031 * localsize: a_lsize, b_lsize, c_lsize 032 * stacksize: a_ssize, b_sszie, c_sszie 033 * localTypeCodes |-- a_lsize --|-- b_lsize --|-- c_lsize --| 034 * stackTypeCodes |-- a_ssize --|-- b_ssize --|-- c_ssize --| 035 */ 036 public int[] methodids; 037 public int[] bcindexes; 038 public byte[][] localTypeCodes; 039 public byte[][] stackTypeCodes; 040 041 public int validOps; 042 043 /* operands of OsrPoint is laid out as following: 044 | locals 1 | stacks 1 | locals 2 | stacks 2 | .... 045 */ 046 047 public InlinedOsrTypeInfoOperand(int[] mids, int[] cpcs, byte[][] ltypes, byte[][] stypes) { 048 this.methodids = mids; 049 this.bcindexes = cpcs; 050 this.localTypeCodes = ltypes; 051 this.stackTypeCodes = stypes; 052 } 053 054 @Override 055 public Operand copy() { 056 return new InlinedOsrTypeInfoOperand(methodids, bcindexes, localTypeCodes, stackTypeCodes); 057 } 058 059 @Override 060 public boolean similar(Operand op) { 061 boolean result = true; 062 063 if (!(op instanceof InlinedOsrTypeInfoOperand)) { 064 return false; 065 } 066 067 InlinedOsrTypeInfoOperand other = (InlinedOsrTypeInfoOperand) op; 068 069 result = 070 Arrays.equals(this.methodids, other.methodids) && 071 Arrays.equals(this.bcindexes, other.bcindexes) && 072 Arrays.equals(this.localTypeCodes, other.localTypeCodes) && 073 Arrays.equals(this.stackTypeCodes, other.stackTypeCodes); 074 075 return result; 076 } 077 078 /** 079 * Returns the string representation of this operand. 080 * 081 * @return a string representation of this operand. 082 */ 083 @Override 084 public String toString() { 085 StringBuilder buf = new StringBuilder("("); 086 087 for (int i = 0, n = methodids.length; i < n; i++) { 088 buf.append(bcindexes[i]).append('@').append(MemberReference.getMemberRef(methodids[i]).getName()).append(" : "); 089 090 for (int j = 0, m = localTypeCodes[i].length; j < m; j++) { 091 buf.append((char) localTypeCodes[i][j]); 092 } 093 094 buf.append(','); 095 for (int j = 0, m = stackTypeCodes[i].length; j < m; j++) { 096 buf.append((char) stackTypeCodes[i][j]); 097 } 098 099 if (i != n - 1) { 100 buf.append(" | "); 101 } 102 } 103 buf.append(')'); 104 return buf.toString(); 105 } 106}