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.common.assembler; 014 015import org.jikesrvm.architecture.MachineRegister; 016import org.jikesrvm.compilers.common.CodeArray; 017import org.vmmagic.pragma.NoInline; 018 019/** 020 * <p>This class has been created to work around a bug whereby the system seems to have gotten 021 * confused by the relationship between:</p> 022 * 023 * <p>ForwardReference -> ForwardReference.ShortBranch -> Assembler.ShortBranch, and Assembler</p> 024 * 025 * This problem does not exist under IA32 since there is no need for Assembler.ShortBranch. 026 */ 027public abstract class AbstractAssembler { 028 public abstract void patchShortBranch(int sourceMachinecodeIndex); 029 030 public abstract void patchUnconditionalBranch(int sourceMachinecodeIndex); 031 032 public abstract void patchConditionalBranch(int sourceMachinecodeIndex); 033 034 public abstract void patchSwitchCase(int sourceMachinecodeIndex); 035 036 public abstract void patchLoadReturnAddress(int sourceMachinecodeIndex); 037 038 public abstract int getMachineCodeIndex(); 039 040 public abstract CodeArray getMachineCodes(); 041 042 public abstract void resolveForwardReferences(int biStart); 043 044 public abstract void noteBytecode(int biStart, String msg); 045 046 @NoInline 047 public final void noteBytecode(int biStart, String bcode, int x) { 048 noteBytecode(biStart, bcode + " " + x); 049 } 050 051 @NoInline 052 public final void noteBytecode(int biStart, String bcode, long x) { 053 noteBytecode(biStart, bcode + " " + x); 054 } 055 056 @NoInline 057 public final void noteBytecode(int biStart, String bcode, Object o) { 058 noteBytecode(biStart, bcode + " " + o); 059 } 060 061 @NoInline 062 public final void noteBytecode(int biStart, String bcode, int x, int y) { 063 noteBytecode(biStart, bcode + " " + x + " " + y); 064 } 065 066 @NoInline 067 public final void noteBranchBytecode(int biStart, String bcode, int off, int bt) { 068 noteBytecode(biStart, bcode + " " + off + " [" + bt + "] "); 069 } 070 071 @NoInline 072 public final void noteTableswitchBytecode(int biStart, int l, int h, int d) { 073 noteBytecode(biStart, "tableswitch [" + l + "--" + h + "] " + d); 074 } 075 076 @NoInline 077 public final void noteLookupswitchBytecode(int biStart, int n, int d) { 078 noteBytecode(biStart, "lookupswitch [<" + n + ">]" + d); 079 } 080 081 /** 082 * The following method will emit code that moves a reference to an 083 * object's TIB into a destination register. 084 * 085 * @param dest the number of the destination register 086 * @param object the number of the register holding the object reference 087 */ 088 public abstract void baselineEmitLoadTIB(MachineRegister dest, MachineRegister object); 089}