00001 /* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.27 $ */ 00002 /* Copyright (c) 2006, Sun Microsystems, Inc. 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 00006 following conditions are met: 00007 00008 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 00010 disclaimer in the documentation and/or other materials provided with the distribution. 00011 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 00012 from this software without specific prior written permission. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00020 00021 00022 */ 00023 00024 # ifdef DELTA_COMPILER 00025 00026 // Register usage 00027 const int nofArgRegisters = 0; // max. number of arguments (excl. receiver) passed in registers 00028 const int nofLocalRegisters = 3; // max. number of temporaries allocated in registers 00029 00030 00031 // Temporaries on the stack 00032 const int first_temp_offset = -1; // offset of first temporary relative to ebp if there are no floats 00033 const int first_float_offset = -4; // offset of first float relative to 8byte aligned ebp value (= base) 00034 00035 00036 // Mapping specifies the x86 architecture specific constants and 00037 // code sequences that are valid machine-independently. 00038 00039 class Mapping: AllStatic { 00040 private: 00041 static Location _localRegisters[nofLocalRegisters+1]; // the list of local registers 00042 static int _localRegisterIndex[nofRegisters+1]; // the inverse of localRegisters[] 00043 00044 public: 00045 // initialization 00046 static void initialize(); 00047 00048 // register allocation 00049 static Location localRegister(int i); // the i.th local register (i = 0 .. nofLocalRegisters-1) 00050 static int localRegisterIndex(Location l); // the index of local register l (localRegisterIndex(localRegister(i)) = i) 00051 00052 // parameter passing 00053 static Location incomingArg(int i, int nofArgs); // incoming argument (excluding receiver; i >= 0, 0 = first arg) 00054 static Location outgoingArg(int i, int nofArgs); // outgoing argument (excluding receiver; i >= 0, 0 = first arg) 00055 00056 // stack allocation 00057 static Location localTemporary(int i); // the i.th local temporary (i >= 0) 00058 static int localTemporaryIndex(Location l); // the index of the local temporary l (localTemporaryIndex(localTemporary(i)) = i) 00059 static Location floatTemporary(int scope_id, int i); // the i.th float temporary within a scope (i >= 0) 00060 00061 // context temporaries 00062 static int contextOffset(int tempNo); // the byte offset of temp from the contextOop 00063 static Location contextTemporary(int contextNo, int i, int scope_id); // the i.th context temporary (i >= 0) 00064 static Location* new_contextTemporary(int contextNo, int i, int scope_id); // ditto, but allocated in resource area 00065 00066 // conversion functions 00067 static Location asLocation(Register reg) { return Location::registerLocation(reg.number()); } 00068 static Register asRegister(Location loc) { return Register(loc.number(), ' '); } 00069 00070 // predicates 00071 static bool isTemporaryRegister(const Location loc) { return false; } // fix this 00072 static bool isLocalRegister(const Location loc) { return _localRegisterIndex[loc.number()] != -1; } 00073 static bool isTrashedRegister(const Location loc) { return true; } // fix this 00074 00075 static bool isNormalTemporary(Location loc); 00076 static bool isFloatTemporary(Location loc); 00077 00078 // helper functions for code generation 00079 // 00080 // needsStoreCheck determines whether a store check is needed when storing into a context location 00081 // (e.g., no storeCheck is needed when initializing individual context fields because there's one 00082 // store check after context creation). 00083 static void load(Location src, Register dst); 00084 static void store(Register src, Location dst, Register temp1, Register temp2, bool needsStoreCheck); 00085 static void storeO(oop obj, Location dst, Register temp1, Register temp2, bool needsStoreCheck); 00086 00087 // helper functions for float code 00088 static void fload(Location src, Register base); 00089 static void fstore(Location dst, Register base); 00090 }; 00091 00092 00093 // calls 00094 const Register self_reg = eax; // incoming receiver location (in prologue of callee) 00095 const Register receiver_reg = eax; // outgoing receiver location (before call) 00096 const Register result_reg = eax; // outgoing result location (before exit) 00097 const Register frame_reg = ebp; // activation frame pointer 00098 00099 const Location selfLoc = Mapping::asLocation(self_reg); 00100 const Location receiverLoc = Mapping::asLocation(receiver_reg); 00101 const Location resultLoc = Mapping::asLocation(result_reg); 00102 const Location frameLoc = Mapping::asLocation(frame_reg); 00103 00104 00105 // non-local returns (make sure to adjust the corresponding constants in interpreter_asm.asm when changing these) 00106 const Register NLR_result_reg = eax; // result being returned 00107 const Register NLR_home_reg = edi; // frame ptr of home frame (stack) 00108 const Register NLR_homeId_reg = esi; // scope id of home scope (inlining) 00109 00110 const Location NLRResultLoc = Mapping::asLocation(NLR_result_reg); 00111 const Location NLRHomeLoc = Mapping::asLocation(NLR_home_reg); 00112 const Location NLRHomeIdLoc = Mapping::asLocation(NLR_homeId_reg); 00113 00114 00115 // temporaries for local code generation (within one Node only) 00116 // note: these locations must not intersect with any location used 00117 // for non-local returns! 00118 const Register temp1 = ebx; 00119 const Register temp2 = ecx; 00120 const Register temp3 = edx; 00121 00122 00123 # endif