From: <cap...@us...> - 2006-12-07 14:55:42
|
Revision: 1 http://svn.sourceforge.net/pearcolator/?rev=1&view=rev Author: captain5050 Date: 2006-12-07 06:54:50 -0800 (Thu, 07 Dec 2006) Log Message: ----------- Initial import Added Paths: ----------- LICENSE bin/ bin/dbt bin/jconfigure ext/ ext/com/ ext/com/ibm/ ext/com/ibm/jikesrvm/ ext/com/ibm/jikesrvm/opt/ ext/com/ibm/jikesrvm/opt/ir/ ext/com/ibm/jikesrvm/opt/ir/OPT_HIRGenerator.java src/ src/org/ src/org/binarytranslator/ src/org/binarytranslator/DBT_Options.java src/org/binarytranslator/Main.java src/org/binarytranslator/arch/ src/org/binarytranslator/arch/ppc/ src/org/binarytranslator/arch/ppc/decoder/ src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java src/org/binarytranslator/arch/ppc/decoder/PPC_Constants.java src/org/binarytranslator/arch/ppc/decoder/PPC_InstructionDecoder.java src/org/binarytranslator/arch/ppc/decoder/PPC_Laziness.java src/org/binarytranslator/arch/ppc/os/ src/org/binarytranslator/arch/ppc/os/abi/ src/org/binarytranslator/arch/ppc/os/abi/linux/ src/org/binarytranslator/arch/ppc/os/abi/linux/PPC_LinuxSystemCalls.java src/org/binarytranslator/arch/ppc/os/process/ src/org/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace.java src/org/binarytranslator/arch/ppc/os/process/linux/ src/org/binarytranslator/arch/ppc/os/process/linux/PPC_LinuxProcessSpace.java src/org/binarytranslator/arch/x86/ src/org/binarytranslator/arch/x86/decoder/ src/org/binarytranslator/arch/x86/decoder/X862IR.java src/org/binarytranslator/arch/x86/decoder/X86_Constants.java src/org/binarytranslator/arch/x86/decoder/X86_DecodedOperand.java src/org/binarytranslator/arch/x86/decoder/X86_FlagLaziness.java src/org/binarytranslator/arch/x86/decoder/X86_InstructionDecoder.java src/org/binarytranslator/arch/x86/decoder/X86_Laziness.java src/org/binarytranslator/arch/x86/decoder/X86_ModRM_Decoder.java src/org/binarytranslator/arch/x86/decoder/X86_RegisterSyncLaziness.java src/org/binarytranslator/arch/x86/decoder/X86_Registers.java src/org/binarytranslator/arch/x86/decoder/X86_SIB_Decoder.java src/org/binarytranslator/arch/x86/os/ src/org/binarytranslator/arch/x86/os/abi/ src/org/binarytranslator/arch/x86/os/abi/linux/ src/org/binarytranslator/arch/x86/os/abi/linux/X86_LinuxSystemCalls.java src/org/binarytranslator/arch/x86/os/process/ src/org/binarytranslator/arch/x86/os/process/X86_ProcessSpace.java src/org/binarytranslator/arch/x86/os/process/X86_Registers.java src/org/binarytranslator/arch/x86/os/process/linux/ src/org/binarytranslator/arch/x86/os/process/linux/X86_LinuxProcessSpace.java src/org/binarytranslator/generic/ src/org/binarytranslator/generic/branch/ src/org/binarytranslator/generic/branch/BranchLogic.java src/org/binarytranslator/generic/branch/CallAndReturnAddress.java src/org/binarytranslator/generic/branch/ProcedureInformation.java src/org/binarytranslator/generic/branch/ProcedureInformationComparator.java src/org/binarytranslator/generic/decoder/ src/org/binarytranslator/generic/decoder/DecoderUtils.java src/org/binarytranslator/generic/decoder/InstructionDecoder.java src/org/binarytranslator/generic/decoder/Laziness.java src/org/binarytranslator/generic/fault/ src/org/binarytranslator/generic/fault/BadInstructionException.java src/org/binarytranslator/generic/gdbstub/ src/org/binarytranslator/generic/gdbstub/GDBStub.java src/org/binarytranslator/generic/memory/ src/org/binarytranslator/generic/memory/ByteAddressedByteSwapMemory.java src/org/binarytranslator/generic/memory/ByteAddressedMemory.java src/org/binarytranslator/generic/memory/ByteAddressedReversedMemory.java src/org/binarytranslator/generic/memory/CallBasedMemory.java src/org/binarytranslator/generic/memory/IntAddressedByteSwapMemory.java src/org/binarytranslator/generic/memory/IntAddressedMemory.java src/org/binarytranslator/generic/memory/IntAddressedPreSwappedMemory.java src/org/binarytranslator/generic/memory/IntAddressedReversedMemory.java src/org/binarytranslator/generic/memory/Memory.java src/org/binarytranslator/generic/memory/MemoryMapException.java src/org/binarytranslator/generic/os/ src/org/binarytranslator/generic/os/abi/ src/org/binarytranslator/generic/os/abi/linux/ src/org/binarytranslator/generic/os/abi/linux/LinuxStackInitializer.java src/org/binarytranslator/generic/os/abi/linux/LinuxSystemCallGenerator.java src/org/binarytranslator/generic/os/abi/linux/LinuxSystemCalls.java src/org/binarytranslator/generic/os/loader/ src/org/binarytranslator/generic/os/loader/Loader.java src/org/binarytranslator/generic/os/loader/elf/ src/org/binarytranslator/generic/os/loader/elf/ELF_Loader.java src/org/binarytranslator/generic/os/process/ src/org/binarytranslator/generic/os/process/ProcessSpace.java src/org/binarytranslator/vmInterface/ src/org/binarytranslator/vmInterface/DBT_ConvertBinaryToHIR.java src/org/binarytranslator/vmInterface/DBT_OptimizingCompilerException.java src/org/binarytranslator/vmInterface/DBT_Trace.java src/org/binarytranslator/vmInterface/DynamicCodeRunner.java src/org/binarytranslator/vmInterface/TranslationHelper.java Added: LICENSE =================================================================== --- LICENSE (rev 0) +++ LICENSE 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,247 @@ + Common Public License - v 1.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF + THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + + 1. DEFINITIONS + + "Contribution" means: + + a) in the case of the initial Contributor, the initial code and + documentation distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + + i) changes to the Program, and + + ii) additions to the Program; + + where such changes and/or additions to the Program originate from + and are distributed by that particular Contributor. A Contribution + 'originates' from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's + behalf. Contributions do not include additions to the Program + which: (i) are separate modules of software distributed in + conjunction with the Program under their own license agreement, and + (ii) are not derivative works of the Program. + + "Contributor" means any person or entity that distributes the + Program. + + "Licensed Patents" mean patent claims licensable by a Contributor + which are necessarily infringed by the use or sale of its + Contribution alone or when combined with the Program. + + "Program" means the Contributions distributed in accordance with + this Agreement. + + "Recipient" means anyone who receives the Program under this + Agreement, including all Contributors. + + + 2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free + copyright license to reproduce, prepare derivative works of, + publicly display, publicly perform, distribute and sublicense + the Contribution of such Contributor, if any, and such + derivative works, in source code and object code form. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free + patent license under Licensed Patents to make, use, sell, offer + to sell, import and otherwise transfer the Contribution of such + Contributor, if any, in source code and object code form. This + patent license shall apply to the combination of the + Contribution and the Program if, at the time the Contribution + is added by the Contributor, such addition of the Contribution + causes such combination to be covered by the Licensed + Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se + is licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances + are provided by any Contributor that the Program does not + infringe the patent or other intellectual property rights of + any other entity. Each Contributor disclaims any liability to + Recipient for claims brought by any other entity based on + infringement of intellectual property rights or otherwise. As + a condition to exercising the rights and licenses granted + hereunder, each Recipient hereby assumes sole responsibility to + secure any other intellectual property rights needed, if any. + For example, if a third party patent license is required to + allow Recipient to distribute the Program, it is Recipient's + responsibility to acquire that license before distributing the + Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to + grant the copyright license set forth in this Agreement. + + 3. REQUIREMENTS + + A Contributor may choose to distribute the Program in object code + form under its own license agreement, provided that: + + a) it complies with the terms and conditions of this Agreement; and + + b) its license agreement: + + i) effectively disclaims on behalf of all Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) states that any provisions which differ from this Agreement + are offered by that Contributor alone and not by any other + party; and + + iv) states that source code for the Program is available from such + Contributor, and informs licensees how to obtain it in a + reasonable manner on or through a medium customarily used for + software exchange. + + When the Program is made available in source code form: + + a) it must be made available under this Agreement; and + + b) a copy of this Agreement must be included with each copy of the + Program. + + Contributors may not remove or alter any copyright notices + contained within the Program. + + Each Contributor must identify itself as the originator of its + Contribution, if any, in a manner that reasonably allows subsequent + Recipients to identify the originator of the Contribution. + + 4. COMMERCIAL DISTRIBUTION + + Commercial distributors of software may accept certain + responsibilities with respect to end users, business partners and + the like. While this license is intended to facilitate the + commercial use of the Program, the Contributor who includes the + Program in a commercial product offering should do so in a manner + which does not create potential liability for other + Contributors. Therefore, if a Contributor includes the Program in a + commercial product offering, such Contributor ("Commercial + Contributor") hereby agrees to defend and indemnify every other + Contributor ("Indemnified Contributor") against any losses, damages + and costs (collectively "Losses") arising from claims, lawsuits and + other legal actions brought by a third party against the + Indemnified Contributor to the extent caused by the acts or + omissions of such Commercial Contributor in connection with its + distribution of the Program in a commercial product offering. The + obligations in this section do not apply to any claims or Losses + relating to any actual or alleged intellectual property + infringement. In order to qualify, an Indemnified Contributor + must: a) promptly notify the Commercial Contributor in writing of + such claim, and b) allow the Commercial Contributor to control, and + cooperate with the Commercial Contributor in, the defense and any + related settlement negotiations. The Indemnified Contributor may + participate in any such claim at its own expense. + + For example, a Contributor might include the Program in a + commercial product offering, Product X. That Contributor is then a + Commercial Contributor. If that Commercial Contributor then makes + performance claims, or offers warranties related to Product X, + those performance claims and warranties are such Commercial + Contributor's responsibility alone. Under this section, the + Commercial Contributor would have to defend claims against the + other Contributors related to those performance claims and + warranties, and if a court requires any other Contributor to pay + any damages as a result, the Commercial Contributor must pay those + damages. + + 5. NO WARRANTY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS + PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF + ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, + ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each + Recipient is solely responsible for determining the appropriateness + of using and distributing the Program and assumes all risks + associated with its exercise of rights under this Agreement, + including but not limited to the risks and costs of program errors, + compliance with applicable laws, damage to or loss of data, + programs or equipment, and unavailability or interruption of + operations. + + 6. DISCLAIMER OF LIABILITY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT + NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY + RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGES. + + 7. GENERAL + + If any provision of this Agreement is invalid or unenforceable + under applicable law, it shall not affect the validity or + enforceability of the remainder of the terms of this Agreement, and + without further action by the parties hereto, such provision shall + be reformed to the minimum extent necessary to make such provision + valid and enforceable. + + If Recipient institutes patent litigation against a Contributor + with respect to a patent applicable to software (including a + cross-claim or counterclaim in a lawsuit), then any patent licenses + granted by that Contributor to such Recipient under this Agreement + shall terminate as of the date such litigation is filed. In + addition, if Recipient institutes patent litigation against any + entity (including a cross-claim or counterclaim in a lawsuit) + alleging that the Program itself (excluding combinations of the + Program with other software or hardware) infringes such Recipient's + patent(s), then such Recipient's rights granted under Section 2(b) + shall terminate as of the date such litigation is filed. + + All Recipient's rights under this Agreement shall terminate if it + fails to comply with any of the material terms or conditions of + this Agreement and does not cure such failure in a reasonable + period of time after becoming aware of such noncompliance. If all + Recipient's rights under this Agreement terminate, Recipient agrees + to cease use and distribution of the Program as soon as reasonably + practicable. However, Recipient's obligations under this Agreement + and any licenses granted by Recipient relating to the Program shall + continue and survive. + + Everyone is permitted to copy and distribute copies of this + Agreement, but in order to avoid inconsistency the Agreement is + copyrighted and may only be modified in the following manner. The + Agreement Steward reserves the right to publish new versions + (including revisions) of this Agreement from time to time. No one + other than the Agreement Steward has the right to modify this + Agreement. IBM is the initial Agreement Steward. IBM may assign + the responsibility to serve as the Agreement Steward to a suitable + separate entity. Each new version of the Agreement will be given a + distinguishing version number. The Program (including + Contributions) may always be distributed subject to the version of + the Agreement under which it was received. In addition, after a new + version of the Agreement is published, Contributor may elect to + distribute the Program (including its Contributions) under the new + version. Except as expressly stated in Sections 2(a) and 2(b) + above, Recipient receives no rights or licenses to the intellectual + property of any Contributor under this Agreement, whether + expressly, by implication, estoppel or otherwise. All rights in the + Program not expressly granted under this Agreement are reserved. + + This Agreement is governed by the laws of the State of New York and + the intellectual property laws of the United States of America. No + party to this Agreement will bring a legal action under this + Agreement more than one year after the cause of action arose. Each + party waives its rights to a jury trial in any resulting + litigation. Added: bin/dbt =================================================================== --- bin/dbt (rev 0) +++ bin/dbt 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,11 @@ +#! /usr/bin/env bash +# +# This file is part of binarytranslator.org. The binarytranslator.org +# project is distributed under the Common Public License (CPL). +# A copy of the license is included in the distribution, and is also +# available at http://www.opensource.org/licenses/cpl1.0.php +# +# (C) Copyright Ian Rogers, The University of Manchester 2003-2006 +# +# Run the org.binarytranslator emulator aka PearColator +$RVM_ROOT/rvm/bin/rvm org.binarytranslator.Main $@ Property changes on: bin/dbt ___________________________________________________________________ Name: svn:executable + Added: bin/jconfigure =================================================================== --- bin/jconfigure (rev 0) +++ bin/jconfigure 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,352 @@ +#! /usr/bin/env bash +# +# This file is part of binarytranslator.org. The binarytranslator.org +# project is distributed under the Common Public License (CPL). +# A copy of the license is included in the distribution, and is also +# available at http://www.opensource.org/licenses/cpl1.0.php +# +# (C) Copyright Ian Rogers, The University of Manchester 2003-2006 +# +# Configure the Jikes RVM with binary translation support +# +# This script is organized into the following sections: +# 0 - Simple checks +# 1 - Run RVM jconfigure +# 2 - Patch RVM.sources so that jbuild.copy copies DBT files +# 3 - Create jbuild.dbt to patch copied RVM files that require DBT modifications +# 4 - Modify jbuild to call jbuild.dbt +# +# @author Ian Rogers +# @date 24/06/2005 + +# What is our name? +# Bash internal shorthand that works like the "basename" command. +ME="${0##*/}" + +#-------------------------------------- +echo "Step 0: Simple checks" +if [[ ! -x ${RVM_ROOT}/rvm/bin/jconfigure ]]; then + echo >&2 "$ME: ERROR: Unable to find Jikes RVM jconfigure. Make sure RVM_ROOT is set correctly." + exit 2 +fi + +if [[ $1 = "" ]]; then + echo >&2 "$ME: ERROR: You must specify a Jikes RVM build configuration" + exit 2 +fi + +#-------------------------------------- +echo "Step 1: Run Jikes RVM jconfigure" + +cd ${RVM_ROOT}/rvm/bin +./jconfigure $1 +cd ${RVM_ROOT}/dbt/bin + +if [[ ! -f ${RVM_BUILD}/RVM.sources ]]; then + echo >&2 "$ME: ERROR: Unable to find valid RVM.sources in RVM_BUILD directory. Did Jikes RVM jconfigure fail?" + exit 2 +fi + +#-------------------------------------- +echo "Step 2: Patch RVM.sources" + +function emitDBTdirectories (){ + find ${RVM_ROOT}/dbt/src -type d | grep -v CVS + find ${RVM_ROOT}/dbt/ext -type d | grep -v CVS + echo ${RVM_ROOT}/rvm/src/vm/arch/powerPC/disassembler +} + +emitDBTdirectories >> ${RVM_BUILD}/RVM.sources + +#-------------------------------------- +echo "Step 3: Create jbuild.dbt" + +function emitDBT (){ + cat <<EOF2 +#! /usr/bin/env bash +# +# This file patches the copied Jikes RVM sources to make them suitable for use inside a DBT. + +# What is our name? +# Bash internal shorthand that works like the "basename" command. +ME="\${0##*/}" +. ${RVM_ROOT}/rvm/bin/libjconfigure.bash + +while (( \$# > 0 )); do + arg="\$1" + if [[ \$arg = -- ]]; then + shift # The end of the flag arguments + break; + fi + [[ \$arg != --?* ]] || arg="\${arg#-}" + if [[ \$arg == -trace* ]]; then + TRACE_FLAG="\$arg" + elif [[ \$arg = -v ]]; then + VFLAG=-v + elif [[ \$arg = -x ]]; then + XFLAG=-x + elif [[ \$arg = -clean ]]; then + CLEAN_FLAG=-clean + else + show_mesg >&2 "Unknown argument: \$arg" + trap '' EXIT + exit 33 + fi + shift +done + +if [[ ! \$CLEAN_FLAG ]]; then + if tracing jbuild; then + echo "\$ME: Modifying source files to make them amenable to building as a DBT" + fi + cd RVM.classes + # --- VM_NormalMethod --- + file=com/ibm/JikesRVM/classloader/VM_NormalMethod.java + # Make HIR generation phase alterable + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -5,6 +5,9 @@ + package com.ibm.JikesRVM.classloader; + + import com.ibm.JikesRVM.*; ++import com.ibm.JikesRVM.opt.ir.OPT_HIRGenerator; ++import com.ibm.JikesRVM.opt.ir.OPT_BC2IR; ++import com.ibm.JikesRVM.opt.ir.OPT_GenerationContext; + import java.io.DataInputStream; + import java.io.IOException; + import org.vmmagic.pragma.*; +@@ -324,6 +327,24 @@ + } + //-#endif RVM_WITH_OSR + ++ /** ++ * Create an optimizing compiler HIR code generator for this type of ++ * method ++ * @param context the generation context for the HIR generation ++ * @return a HIR generator ++ */ ++ public OPT_HIRGenerator createHIRGenerator(OPT_GenerationContext context){ ++ return new OPT_BC2IR(context); ++ } ++ ++ /** ++ * Must this method be OPT compiled? ++ * @param context the generation context for the HIR generation ++ * @return a HIR generator ++ */ ++ public boolean optCompileOnly() { ++ return false; ++ } + + /* + * Methods to access and compute method summary information +EOF + # Make VM_NormalMethod HAS fields accessible to DBT_Trace + run sed -i -e's/private static final int HAS_/protected static final int HAS_/g' \$file + # Make VM_NormalMethod non-final + run sed -i -e's/public final class VM_NormalMethod/public class VM_NormalMethod/g' \$file + # Make constructor public + run sed -i -e's/VM_NormalMethod(VM_TypeReference dc, VM_MemberReference mr,/public VM_NormalMethod(VM_TypeReference dc, VM_MemberReference mr,/g' \$file + # Make summary protected + run sed -i -e's/private int summary;/protected int summary;/g' \$file + # Make bytecodes public + run sed -i -e's/private final byte\[\] bytecodes;/public final byte\[\] bytecodes;/g' \$file + # Make genCode public + run sed -i -e's/protected VM_CompiledMethod genCode() throws VerifyError/public VM_CompiledMethod genCode() throws VerifyError/g' \$file + + # --- VM_RuntimeCompiler --- + file=com/ibm/JikesRVM/VM_RuntimeCompiler.java + # Make HIR generation phase alterable + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -792,3 +792,3 @@ + } +- if (VM_Controller.options.optIRC()) { ++ if (VM_Controller.options.optIRC() || method.optCompileOnly()) { + if (// will only run once: don't bother optimizing +@@ -811,3 +811,18 @@ + } +- cm = optCompileWithFallBack(method, compPlan); ++ if(!method.optCompileOnly()) { ++ cm = optCompileWithFallBack(method, compPlan); ++ } ++ else { ++ compilationInProgress = true; ++ try { ++ cm = optCompile(method, compPlan); ++ } catch (OPT_OptimizingCompilerException e) { ++ String msg = "Optimizing compiler " ++ +"(on method that can only be optimizing compiler compiled): " ++ +"can't optimize \"" + method + "\""; ++ throw new Error(msg, e); ++ } finally { ++ compilationInProgress = false; ++ } ++ } + } +EOF + # --- OPT_BC2IR --- + file=com/ibm/JikesRVM/opt/ir/OPT_BC2IR.java + # Make HIR generation phase alterable + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -61 +61,2 @@ +- OPT_Constants ++ OPT_Constants, ++ OPT_HIRGenerator +EOF + # Make OPT_BC2IR 'generateHIR' method public + run sed -i -e's/private void generateHIR()/public void generateHIR()/' \$file + # Make OPT_BC2IR constructor public + run sed -i -e's/private OPT_BC2IR(OPT_GenerationContext context)/public OPT_BC2IR(OPT_GenerationContext context)/' \$file + + # --- OPT_ConvertBCtoHIR --- + file=com/ibm/JikesRVM/opt/ir/OPT_ConvertBCtoHIR.java + # Make HIR generation phase alterable + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -28,7 +28,7 @@ + OPT_GenerationContext gc = + new OPT_GenerationContext(ir.method, ir.compiledMethod, + ir.options, ir.inlinePlan); +- OPT_BC2IR.generateHIR(gc); ++ ir.method.createHIRGenerator(gc).generateHIR(); + // Transfer HIR and misc state from gc to the ir object + ir.gc = gc; + ir.cfg = gc.cfg; +EOF + + # --- VM_Member --- + file=com/ibm/JikesRVM/classloader/VM_Member.java + # Make modifiers public + run sed -i -e's/protected final int modifiers;/public final int modifiers;/g' \$file + + # --- VM_Method --- + file=com/ibm/JikesRVM/classloader/VM_Method.java + # Make replaceCompiledMethod non-final + run sed -i -e's/public final synchronized void replaceCompiledMethod/public synchronized void replaceCompiledMethod/g' \$file + + # --- VM_DynamicBridge --- + file=com/ibm/JikesRVM/VM_DynamicBridge.java + # Make VM_DynamicBridge accessible to DynamicCodeRunner + run sed -i -e's/interface VM_DynamicBridge/public interface VM_DynamicBridge/' \$file + + # --- OPT_GenerationContext --- + file=com/ibm/JikesRVM/opt/ir/OPT_GenerationContext.java + # Make OPT_GenerationContext 'method' field public + run sed -i -e's/VM_NormalMethod method/public VM_NormalMethod method/' \$file + # Make OPT_GenerationContext 'temps' field public + run sed -i -e's/OPT_RegisterPool temps/public OPT_RegisterPool temps/' \$file + # Make OPT_GenerationContext 'arguments' field public + run sed -i -e's/OPT_Operand\[\] arguments/public OPT_Operand\[\] arguments/' \$file + # Make OPT_GenerationContext 'options' field public + run sed -i -e's/OPT_Options options/public OPT_Options options/' \$file + # Make OPT_GenerationContext 'epilogue' field public + run sed -i -e's/OPT_BasicBlock epilogue/public OPT_BasicBlock epilogue/' \$file + # Make OPT_GenerationContext 'prologue' field public + run sed -i -e's/OPT_BasicBlock prologue/public OPT_BasicBlock prologue/' \$file + # Make OPT_GenerationContext 'cfg' field public + run sed -i -e's/OPT_ControlFlowGraph cfg/public OPT_ControlFlowGraph cfg/' \$file + # Make OPT_GenerationContext 'resultReg' field public + run sed -i -e's/OPT_Register resultReg/public OPT_Register resultReg/' \$file + + # --- OPT_ConditionOperand --- + # Direct creation of floating point compares required by DBT + file=com/ibm/JikesRVM/opt/ir/OPT_ConditionOperand.java + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -150,6 +150,51 @@ + } + + /** ++ * Create the condition code operand for CMPL_EQUAL ++ * ++ * @return a newly created condition code operand ++ */ ++ public static OPT_ConditionOperand CMPL_EQUAL() { ++ return new OPT_ConditionOperand(CMPL_EQUAL); ++ } ++ ++ /** ++ * Create the condition code operand for CMPL_NOT_EQUAL ++ * ++ * @return a newly created condition code operand ++ */ ++ public static OPT_ConditionOperand CMPL_NOT_EQUAL() { ++ return new OPT_ConditionOperand(CMPL_NOT_EQUAL); ++ } ++ ++ /** ++ * Create the condition code operand for CMPL_GREATER ++ * ++ * @return a newly created condition code operand ++ */ ++ public static OPT_ConditionOperand CMPL_GREATER() { ++ return new OPT_ConditionOperand(CMPL_GREATER); ++ } ++ ++ /** ++ * Create the condition code operand for CMPL_GREATER_EQUAL ++ * ++ * @return a newly created condition code operand ++ */ ++ public static OPT_ConditionOperand CMPL_GREATER_EQUAL() { ++ return new OPT_ConditionOperand(CMPL_GREATER_EQUAL); ++ } ++ ++ /** ++ * Create the condition code operand for CMPG_LESS ++ * ++ * @return a newly created condition code operand ++ */ ++ public static OPT_ConditionOperand CMPG_LESS() { ++ return new OPT_ConditionOperand(CMPG_LESS); ++ } ++ ++ /** + * Is the condition code EQUAL? + * + * @return <code>true</code> if it is or <code>false</code> if it is not +EOF + + # --- PPC_Disassembler --- + # Allow disassembler to exist outside of PPC backend + file=com/ibm/JikesRVM/PPC_Disassembler.java + run patch -u -p0 -l <<EOF +--- \$file ++++ \$file +@@ -121,2 +121,13 @@ + static final int FPSCRX = 148; ++ static final String GPR_NAMES[] = { "R0", "R1", "R2", "R3", "R4", "R5", ++ "R6", "R7","R8", "R9", "R10", "R11", ++ "R12", "R13","R14", "R15","R16", "R17", ++ "R18", "R19", "R20", "R21", "R22", "R23", ++ "R24", "R25", "R26", "R27", "R28", "R29", "R30", "R31" ++ }; ++ static final String FPR_NAMES[] = { "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7", ++ "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", ++ "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", ++ "F24", "F25", "F26", "F27", "F28", "F29", "F30", "F31" ++ }; + +EOF +fi + +trap '' EXIT +EOF2 +} + +emitDBT > ${RVM_BUILD}/jbuild.dbt +chmod +x ${RVM_BUILD}/jbuild.dbt +#-------------------------------------- +echo "Step 4: Patch jbuild" + +# Add jbuild.dbt to be performed after all cases of jbuild.copy +sed -i -e's/\(.*\)jbuild.copy\(.*\)/\1jbuild.copy\2\n\1jbuild.dbt\2/g' ${RVM_BUILD}/jbuild +# Add binary translator main to the list of jikes compiled sources +sed -i -e's/Dummy.java/Dummy.java org\/binarytranslator\/Main.java/' ${RVM_BUILD}/jbuild.compile Property changes on: bin/jconfigure ___________________________________________________________________ Name: svn:executable + Added: ext/com/ibm/jikesrvm/opt/ir/OPT_HIRGenerator.java =================================================================== --- ext/com/ibm/jikesrvm/opt/ir/OPT_HIRGenerator.java (rev 0) +++ ext/com/ibm/jikesrvm/opt/ir/OPT_HIRGenerator.java 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,15 @@ +/* + * (C) The University of Manchester 2003 - 2006 + */ +package com.ibm.jikesrvm.opt.ir; + +/** + * Interface implemented by all optimizing compiler HIR generators + * such as OPT_BC2HIR and DBT_HIRGenerator + */ +public interface OPT_HIRGenerator { + /** + * Method to create the HIR + */ + public void generateHIR(); +} Added: src/org/binarytranslator/DBT_Options.java =================================================================== --- src/org/binarytranslator/DBT_Options.java (rev 0) +++ src/org/binarytranslator/DBT_Options.java 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,222 @@ +/* + * This file is part of binarytranslator.org. The binarytranslator.org + * project is distributed under the Common Public License (CPL). + * A copy of the license is included in the distribution, and is also + * available at http://www.opensource.org/licenses/cpl1.0.php + * + * (C) Copyright Ian Rogers, The University of Manchester 2003-2006 + */ +package org.binarytranslator; + +/** + * Options for controlling the emulator + */ +public class DBT_Options { + // -oO Runtime settings Oo- + + /** + * Debug binary loading + */ + public final static boolean debugLoader=true; + + /** + * Are unimplemented system calls are fatal? + */ + public final static boolean unimplementedSystemCallsFatal = true; + + // -oO Translation settings Oo- + + /** + * The initial optimisation level + */ + public static int initialOptLevel=0; + + /** + * Instructions to translate for an optimisation level 0 trace + */ + public static int instrOpt0 = 684; + + /** + * Instructions to translate for an optimisation level 1 trace + */ + public static int instrOpt1 = 1500; + + /** + * Instructions to translate for an optimisation level 2 trace + */ + public static int instrOpt2 = 1500; + + /** + * Favour backward branch optimization. Translate backward branch + * addresses before the next instructions (this is the manner of the + * 601's branch predictor). + */ + public final static boolean optimizeBackwardBranches = true; + + /** + * Set this to true to record uncaught bclr instructions + */ + public static boolean plantUncaughtBclrWatcher = false; + + /** + * Set this to true to record uncaught bcctr instructions + */ + public static boolean plantUncaughtBcctrWatcher = true; + + /** + * Should all branches (excluding to lr and ctr) be resolved in one + * big go or one at at a time + */ + public static boolean resolveBranchesAtOnce = true; + + /** + * Should procedures (branches to ctr and lr) be given precedent over + * more local branches + */ + public static boolean resolveProceduresBeforeBranches = true; + + /** + * Use global branch information rather than local (within the + * trace) information when optimisation level is greater than or + * equal to this value + */ + public static int globalBranchLevel = 3; + + /** + * Set this to true to translate only one instruction at a + * time. + */ + public static boolean singleInstrTranslation=true; + + /** + * Eliminate unneeded filling of register + */ + public final static boolean eliminateRegisterFills = true; + + // -oO Translation debugging options Oo- + + /** + * Print dissassembly of translated instructions. + */ + public static boolean debugInstr=true; + + /** + * In PPC2IR, print information about lazy resolution... + */ + public final static boolean debugLazy=false; + + /** + * In PPC2IR, print cfg. + */ + public final static boolean debugCFG=false; + + // -oO Runtime debugging options Oo- + + /** + * Debug using GDB? + */ + public static boolean gdbStub = false; + + /** + * GDB stub port + */ + public static int gdbStubPort = 1234; + + /** + * In ProcessSpace, print syscall numbers. + */ + public static boolean debugSyscall=false; + + /** + * In ProcessSpace, print syscall numbers. + */ + public static boolean debugSyscallMore=false; + + /** + * Print out various messages about the emulator starting. + */ + public static boolean debugRuntime=true; + + /** + * Print out messages from the memory system + */ + public static boolean debugMemory=false; + + /** + * Print out process space between instructions + */ + public final static boolean debugPS=false; + + /** + * When printing process space, omit floating point registers. + */ + public final static boolean debugPS_OmitFP=false; + + /** + * The user ID for the user running the command + */ + public final static int UID = 1000; + + /** + * The group ID for the user running the command + */ + public final static int GID = 100; + + /** + * Process a command line option + * @arg the command line argument starting "-X:dbt:" + */ + public static void processArgument(String arg) { + if(arg.startsWith("-X:dbt:debugInstr=true")) { + debugInstr = true; + } + else if(arg.startsWith("-X:dbt:debugRuntime=true")) { + debugRuntime = true; + } + else if(arg.startsWith("-X:dbt:debugSyscall=true")) { + debugSyscall = true; + } + else if(arg.startsWith("-X:dbt:debugSyscallMore=true")) { + debugSyscallMore = true; + } + else if(arg.startsWith("-X:dbt:globalBranchLevel=")) { + globalBranchLevel = Integer.parseInt(arg.substring(25)); + } + else if(arg.startsWith("-X:dbt:initialOptLevel=")) { + initialOptLevel = Integer.parseInt(arg.substring(23)); + } + else if(arg.startsWith("-X:dbt:instrOpt0=")) { + instrOpt0 = Integer.parseInt(arg.substring(17)); + } + else if(arg.startsWith("-X:dbt:instrOpt1=")) { + instrOpt1 = Integer.parseInt(arg.substring(17)); + } + else if(arg.startsWith("-X:dbt:instrOpt2=")) { + instrOpt2 = Integer.parseInt(arg.substring(17)); + } + else if(arg.startsWith("-X:dbt:singleInstrTranslation=true")) { + singleInstrTranslation = true; + } + else if(arg.startsWith("-X:dbt:resolveBranchesAtOnce=true")) { + resolveBranchesAtOnce = true; + } + else if(arg.startsWith("-X:dbt:resolveBranchesAtOnce=false")) { + resolveBranchesAtOnce = false; + } + else if(arg.startsWith("-X:dbt:resolveProceduresBeforeBranches=true")) { + resolveProceduresBeforeBranches = true; + } + else if(arg.startsWith("-X:dbt:resolveProceduresBeforeBranches=false")) { + resolveProceduresBeforeBranches = false; + } + else if(arg.startsWith("-X:dbt:gdbStub=true")) { + gdbStub = true; + } + else if(arg.startsWith("-X:dbt:gdbStubPort=")) { + gdbStubPort = Integer.parseInt(arg.substring(19)); + } + else { + throw new Error("DBT Options: Unrecongised emulator option " + arg); + } + } +} Added: src/org/binarytranslator/Main.java =================================================================== --- src/org/binarytranslator/Main.java (rev 0) +++ src/org/binarytranslator/Main.java 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,106 @@ +/* + * This file is part of binarytranslator.org. The binarytranslator.org + * project is distributed under the Common Public License (CPL). + * A copy of the license is included in the distribution, and is also + * available at http://www.opensource.org/licenses/cpl1.0.php + * + * (C) Copyright Ian Rogers, The University of Manchester 2003-2006 + */ +package org.binarytranslator; + +import org.binarytranslator.generic.os.process.ProcessSpace; +import org.binarytranslator.generic.os.loader.Loader; + +/** + * The runtime system for the emulator. + * + * @author Ian Rogers, Richard Matley, Jon Burcham + * + */ +public class Main +{ + /* + * Variables required for an instance of the emulator + */ + + /** + * A process space encapsulating the execution of a process + */ + ProcessSpace ps; + + /* + * Utility functions + */ + + /** + * Debug information + * @param s string of debug information + */ + private static void report(String s){ + if (DBT_Options.debugRuntime) { + System.out.print("Main:"); + System.out.println(s); + } + } + + /** + * Usage + */ + public static void usage () + { + System.out.println("org.binarytranslator.Main [-X:dbt:...] <program> <args...>"); + } + + /** + * Constructor - should only be run from main + * @param args command line arguments. args[0] is the program to load. + */ + private Main(String[] args) { + // Check we have a file to load + if(args.length < 1) { + usage(); + } + else { + // Set up and load the process space + try { + report("Loading " + args[0]); + Loader loader = Loader.getLoader(args[0]); + ps = loader.readBinary(args); + } + catch(java.io.IOException e) { + usage(); + throw new Error("Error accessing file: " + args[0], e); + } + report ("Sucessfully created process"); + } + } + + /** + * Main method + * + * @param args command line arguments (see usage()) + */ + public static void main(String[] args) { + // Process any arguments for the emulator + for (int i=0; i < args.length; i++) { + if(args[i].startsWith("-X:dbt:")) { + DBT_Options.processArgument(args[i]); + } + else { + if (i != 0) { + String new_args[] = new String[args.length-i]; + for (int j=0; j < (args.length-i); j++) { + new_args[j]=args[i+j]; + } + args = new_args; + } + break; + } + } + Main runtime = new Main(args); + for (int i=0; i < args.length; i++) { + report("Argument " + i + ": " + args[i]); + } + runtime.ps.run(); + } +} Added: src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java =================================================================== --- src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java (rev 0) +++ src/org/binarytranslator/arch/ppc/decoder/PPC2IR.java 2006-12-07 14:54:50 UTC (rev 1) @@ -0,0 +1,1172 @@ +/* + * This file is part of binarytranslator.org. The binarytranslator.org + * project is distributed under the Common Public License (CPL). + * A copy of the license is included in the distribution, and is also + * available at http://www.opensource.org/licenses/cpl1.0.php + * + * (C) Copyright Ian Rogers, The University of Manchester 2003-2006 + */ +package org.binarytranslator.arch.ppc.decoder; + +// DBT classes +import org.binarytranslator.arch.ppc.os.process.PPC_ProcessSpace; +import org.binarytranslator.vmInterface.TranslationHelper; +import org.binarytranslator.vmInterface.DBT_Trace; +import org.binarytranslator.DBT_Options; +import org.binarytranslator.generic.decoder.DecoderUtils; +import org.binarytranslator.generic.decoder.Laziness; +// General VM class +import com.ibm.jikesrvm.VM; +// Classes to get at class types +import com.ibm.jikesrvm.classloader.VM_Class; +import com.ibm.jikesrvm.classloader.VM_Method; +import com.ibm.jikesrvm.classloader.VM_TypeReference; +import com.ibm.jikesrvm.classloader.VM_MethodReference; +import com.ibm.jikesrvm.classloader.VM_MemberReference; +import com.ibm.jikesrvm.classloader.VM_FieldReference; +import com.ibm.jikesrvm.classloader.VM_BootstrapClassLoader; +import com.ibm.jikesrvm.classloader.VM_Atom; +// OPT interface +import com.ibm.jikesrvm.opt.OPT_Constants; +import com.ibm.jikesrvm.opt.ir.OPT_GenerationContext; +import com.ibm.jikesrvm.opt.ir.OPT_HIRGenerator; +import com.ibm.jikesrvm.opt.ir.OPT_IR; +// Instructions +import com.ibm.jikesrvm.opt.ir.OPT_Instruction; +import com.ibm.jikesrvm.opt.ir.OPT_Operator; +import com.ibm.jikesrvm.opt.ir.OPT_Operators; +import com.ibm.jikesrvm.opt.ir.Athrow; +import com.ibm.jikesrvm.opt.ir.Binary; +import com.ibm.jikesrvm.opt.ir.BBend; +import com.ibm.jikesrvm.opt.ir.BooleanCmp; +import com.ibm.jikesrvm.opt.ir.Call; +import com.ibm.jikesrvm.opt.ir.CondMove; +import com.ibm.jikesrvm.opt.ir.GetField; +import com.ibm.jikesrvm.opt.ir.Goto; +import com.ibm.jikesrvm.opt.ir.IfCmp; +import com.ibm.jikesrvm.opt.ir.Move; +import com.ibm.jikesrvm.opt.ir.New; +import com.ibm.jikesrvm.opt.ir.LookupSwitch; +import com.ibm.jikesrvm.opt.ir.PutField; +import com.ibm.jikesrvm.opt.ir.Unary; +// Operands +import com.ibm.jikesrvm.opt.ir.OPT_AddressConstantOperand; +import com.ibm.jikesrvm.opt.ir.OPT_BasicBlock; +import com.ibm.jikesrvm.opt.ir.OPT_BranchOperand; +import com.ibm.jikesrvm.opt.ir.OPT_BranchProfileOperand; +import com.ibm.jikesrvm.opt.ir.OPT_ConditionOperand; +import com.ibm.jikesrvm.opt.ir.OPT_IntConstantOperand; +import com.ibm.jikesrvm.opt.ir.OPT_LocationOperand; +import com.ibm.jikesrvm.opt.ir.OPT_MethodOperand; +import com.ibm.jikesrvm.opt.ir.OPT_Operand; +import com.ibm.jikesrvm.opt.ir.OPT_Register; +import com.ibm.jikesrvm.opt.ir.OPT_RegisterOperand; +import com.ibm.jikesrvm.opt.ir.OPT_TrueGuardOperand; +import com.ibm.jikesrvm.opt.ir.OPT_TypeOperand; +// Java utilities +import java.util.Enumeration; +import java.util.NoSuchElementException; +import java.util.ArrayList; +import java.util.Set; +import java.util.Iterator; +import java.util.HashSet; + +/** + * Translation from PPC machine code to HIR. + * + * @author Richard Matley, Ian Rogers + */ +public final class PPC2IR extends DecoderUtils implements OPT_HIRGenerator, OPT_Operators, OPT_Constants { + + /** + * Construct the PPC2IR object for the generation context; then + * we'll be ready to start generating the HIR. + */ + public PPC2IR(OPT_GenerationContext context) { + super(context); + // Create register maps PPC -> OPT_Register + intRegMap = new OPT_Register[32]; + intRegInUseMap = new boolean[32]; + fpRegMap = new OPT_Register[32]; + fpRegInUseMap = new boolean[32]; + crFieldMap_Lt = new OPT_Register[8]; + crFieldMap_Gt = new OPT_Register[8]; + crFieldMap_Eq = new OPT_Register[8]; + crFieldMap_SO = new OPT_Register[8]; + crFieldInUseMap = new boolean[8]; + + // Debug + if(DBT_Options.debugCFG) { + report("CFG at end of constructor:\n" + gc.cfg); + } + } + + /** + * Translate the instruction at the given pc + * @param lazy the status of the lazy evaluation + * @param pc the program counter for the instruction + * @return the next instruction address or -1 + */ + protected int translateInstruction(Laziness lazy, int pc) { + return PPC_InstructionDecoder.translateInstruction(this, (PPC_ProcessSpace)ps, (PPC_Laziness)lazy, pc); + } + + // -oO Creations for being a PPC translator Oo- + + // -oO PPC register to HIR register mappings Oo- + + /** + * The mapping of PPC general purpose registers to HIR + * registers. All GP registers are loaded into these by the preFill + * block. This avoids potential inconsistencies caused by using lazy + * allocation and backward branches. + */ + private OPT_Register intRegMap[]; + /** + * Which PPC general purpose registers are in use + */ + private boolean intRegInUseMap[]; + + /** + * The mapping of PPC floating point registers to HIR registers. + */ + private OPT_Register fpRegMap[]; + /** + * Which PPC floating point registers are in use + */ + private boolean fpRegInUseMap[]; + + /** + * The HIR register holding the PPC FPSCR register. + */ + private OPT_Register fpscrRegMap; + /** + * Is the PPC FPSCR register in use + */ + private boolean fpscrRegInUse; + + /** + * The HIR register holding the PPC CTR register. + */ + private OPT_Register ctrRegMap; + /** + * Is the PPC CTR register in use + */ + private boolean ctrRegInUse; + + /** + * The HIR register holding the PPC LR register. + */ + private OPT_Register lrRegMap; + /** + * Is the PPC LR register in use + */ + private boolean lrRegInUse; + + /** + * The HIR register holding the PPC XER register when it is combined + * in a fillAll or spillAll block + */ + private OPT_Register xerRegMap; + + /** + * The HIR register holding the PPC XER register's byte count (bits + * 25 to 31) + */ + private OPT_Register xerRegMap_ByteCount; + + /** + * The HIR boolean register holding thr PPC XER CA (carry) bit. + */ + private OPT_Register xerRegMap_CA; + + /** + * The HIR register holding thr PPC XER OV (overflow) bit. If this + * register is non-zero then the OV bit should be set. + */ + private OPT_Register xerRegMap_OV; + /** + * The HIR register holding thr PPC XER SO (summary overflow) + * bit. If this register is non-zero then the SO bit should be set. + */ + private OPT_Register xerRegMap_SO; + /** + * Is the PPC XER register in use + */ + private boolean xerRegInUse; + + /** + * These 8 registers hold a zero or non-zero value depending on the + * value of the corresponding condition register field's SO + * bit. + */ + private OPT_Register crFieldMap_Lt[]; + + /** + * These 8 registers hold a zero or non-zero value depending on the + * value of the corresponding condition register field's SO + * bit. + */ + private OPT_Register crFieldMap_Gt[]; + + /** + * These 8 registers hold a zero or non-zero value depending on the + * value of the corresponding condition register field's SO + * bit. + */ + private OPT_Register crFieldMap_Eq[]; + + /** + * These 8 registers hold a zero or non-zero value depending on the + * value of the corresponding condition register field's SO + * bit. + */ + private OPT_Register crFieldMap_SO[]; + + /** + * What condition register fields are in use? + */ + private boolean crFieldInUseMap[]; + + // -oO Fill/spill registers between OPT_Registers and the PPC_ProcessSpace Oo- + + /** + * Copy the value of a general purpose (int) register into its + * temporary location from the PPC_ProcessSpace. + * @param r the number of the register to fill. + */ + private void fillGPRegister(int r) { + if (VM.VerifyAssertions) VM._assert(r < 32); + + OPT_RegisterOperand result; + if (intRegMap[r] == null) { + result = gc.temps.makeTempInt(); + intRegMap[r]=result.register; // Set mapping + } + else { + result = new OPT_RegisterOperand(intRegMap[r], VM_TypeReference.Int); + } + + VM_TypeReference psTref = VM_TypeReference.findOrCreate(VM_BootstrapClassLoader.getBootstrapClassLoader(), + VM_Atom.findOrCreateAsciiAtom("Lorg/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace;") + ); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("r"+r), + VM_Atom.findOrCreateAsciiAtom("I") + ).asFieldReference(); + appendInstructionToCurrentBlock(GetField.create(GETFIELD, result, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + new OPT_TrueGuardOperand()) + ); + } + + + /** + * Copy the value of a general purpose (int) register into the + * PPC_ProcessSpace from its temporary location. + * @param r the number of the register to spill. + */ + private void spillGPRegister(int r) { + if (VM.VerifyAssertions) VM._assert(r < 32); + if (VM.VerifyAssertions) VM._assert(intRegMap[r] != null); + + OPT_RegisterOperand regOp = new OPT_RegisterOperand(intRegMap[r], VM_TypeReference.Int); + + VM_TypeReference psTref = VM_TypeReference.findOrCreate(VM_BootstrapClassLoader.getBootstrapClassLoader(), + VM_Atom.findOrCreateAsciiAtom("Lorg/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace;") + ); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("r"+r), + VM_Atom.findOrCreateAsciiAtom("I") + ).asFieldReference(); + appendInstructionToCurrentBlock(PutField.create(PUTFIELD, regOp, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + new OPT_TrueGuardOperand()) + ); + } + + + /** + * Copy the value of a floating point register into its temporary + * location from the PPC_ProcessSpace. + * @param r the number of the register to fill. + */ + private void fillFPRegister(int r) { + if (VM.VerifyAssertions) VM._assert(r < 32); + + OPT_RegisterOperand result; + if (fpRegMap[r] == null) { + result = gc.temps.makeTempDouble(); + fpRegMap[r]=result.register; // Set mapping + } + else { + result = new OPT_RegisterOperand(fpRegMap[r], VM_TypeReference.Double); + } + + VM_TypeReference psTref = VM_TypeReference.findOrCreate(VM_BootstrapClassLoader.getBootstrapClassLoader(), + VM_Atom.findOrCreateAsciiAtom("Lorg/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace;") + ); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("f"+r), + VM_Atom.findOrCreateAsciiAtom("D") + ).asFieldReference(); + appendInstructionToCurrentBlock(GetField.create(GETFIELD, result, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + new OPT_TrueGuardOperand()) + ); + } + + + /** + * Copy the value of a floating point register into the + * PPC_ProcessSpace from its temporary location. + * @param r the number of the register to spill. + */ + private void spillFPRegister(int r) { + if (VM.VerifyAssertions) VM._assert(r < 32); + if (VM.VerifyAssertions) VM._assert(fpRegMap[r] != null); + + OPT_RegisterOperand regOp = new OPT_RegisterOperand(fpRegMap[r], VM_TypeReference.Double); + + VM_TypeReference psTref = VM_TypeReference.findOrCreate(VM_BootstrapClassLoader.getBootstrapClassLoader(), + VM_Atom.findOrCreateAsciiAtom("Lorg/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace;") + ); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("f"+r), + VM_Atom.findOrCreateAsciiAtom("D") + ).asFieldReference(); + appendInstructionToCurrentBlock(PutField.create(PUTFIELD, regOp, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + new OPT_TrueGuardOperand()) + ); + } + + /** + * Copy the values of the condition register field into its + * temporary locations from the PPC_ProcessSpace. + * @param crf the condition register field to copy + */ + private void fillCRRegister(int crf) + { + if (crFieldMap_Lt[crf] == null) { + crFieldMap_Lt[crf] = gc.temps.getReg(VM_TypeReference.Boolean); + crFieldMap_Gt[crf] = gc.temps.getReg(VM_TypeReference.Boolean); + crFieldMap_Eq[crf] = gc.temps.getReg(VM_TypeReference.Boolean); + crFieldMap_SO[crf] = gc.temps.getReg(VM_TypeReference.Boolean); + } + OPT_RegisterOperand lt = new OPT_RegisterOperand(crFieldMap_Lt[crf], VM_TypeReference.Boolean); + OPT_RegisterOperand gt = new OPT_RegisterOperand(crFieldMap_Gt[crf], VM_TypeReference.Boolean); + OPT_RegisterOperand lt = new OPT_RegisterOperand(crFieldMap_Eq[crf], VM_TypeReference.Boolean); + OPT_RegisterOperand so = new OPT_RegisterOperand(crFieldMap_SO[crf], VM_TypeReference.Boolean); + + OPT_RegisterOperand arrayref = gc.temps.makeTemp(VM_TypeReference.BooleanArray); + + VM_TypeReference psTref = VM_TypeReference.findOrCreate(VM_BootstrapClassLoader.getBootstrapClassLoader(), + VM_Atom.findOrCreateAsciiAtom("Lorg/binarytranslator/arch/ppc/os/process/PPC_ProcessSpace;") + ); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("crf_lt"), + VM_Atom.findOrCreateAsciiAtom("[Z") + ).asFieldReference(); + appendInstructionToCurrentBlock(GetField.create(GETFIELD, arrayref, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + new OPT_TrueGuardOperand()) + ); + appendInstructionToCurrentBlock(ALoad.create(UBYTE_ALOAD, lt, + arrayref, new OPT_IntegerConstantOperand(crf), + new OPT_LocationOperand(VM_TypeReference.BooleanArray), + new OPT_TrueGuardOperand())); + VM_FieldReference ref = VM_MemberReference.findOrCreate(psTref,VM_Atom.findOrCreateAsciiAtom("crf_gt"), + VM_Atom.findOrCreateAsciiAtom("[Z") + ).asFieldReference(); + appendInstructionToCurrentBlock(GetField.create(GETFIELD, arrayref, + gc.makeLocal(1,psTref), + new OPT_AddressConstantOperand(ref.peekResolvedField().getOffset()), + new OPT_LocationOperand(ref), + ... [truncated message content] |