00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 # ifdef DELTA_COMPILER
00025
00026
00027
00028
00029
00030 enum Mode {
00031
00032
00033 specialLoc,
00034 registerLoc,
00035 stackLoc,
00036 contextLoc1,
00037 contextLoc2,
00038 floatLoc,
00039 };
00040
00041
00042 class Location: public ResourceObj {
00043 private:
00044 int _loc;
00045
00046
00047 enum {
00048 _f1Pos = 3, _f1Len = 7, _f1Mask = (1<<_f1Len) - 1,
00049 _f2Pos = _f1Pos + _f1Len, _f2Len = 7, _f2Mask = (1<<_f2Len) - 1,
00050 _f3Pos = _f2Pos + _f2Len, _f3Len = 15, _f3Mask = (1<<_f3Len) - 1,
00051 _fPos = _f1Pos, _fLen = 29, _fMask = (1<<_fLen ) - 1,
00052 };
00053
00054 void overflow(Mode mode, int f1, int f2, int f3);
00055
00056 public:
00057
00058 Location() { specialLocation(0); }
00059 Location(int l) { _loc = l; }
00060 Location(Mode mode, int f);
00061 Location(Mode mode, int f1, int f2, int f3);
00062
00063
00064 static Location specialLocation(int id) { return Location(specialLoc, id); }
00065 static Location registerLocation(int number) { return Location(registerLoc, number); }
00066 static Location stackLocation(int offset) { return Location(stackLoc, offset); }
00067 static Location compiledContextLocation(int contextNo, int tempNo, int id) { return Location(contextLoc1, contextNo, tempNo, id); }
00068 static Location runtimeContextLocation(int contextNo, int tempNo, int offs) { return Location(contextLoc2, contextNo, tempNo, offs); }
00069 static Location floatLocation(int scopeNo, int tempNo) { return Location(floatLoc, 0, tempNo, scopeNo); }
00070
00071
00072 Mode mode() const { return (Mode)(_loc & ((1<<_f1Pos) - 1)); }
00073
00074 int id() const {
00075 assert(mode() == specialLoc, "not a special location");
00076 return (_loc>>_fPos) & _fMask;
00077 }
00078
00079 int number() const {
00080 assert(mode() == registerLoc, "not a register location");
00081 return (_loc>>_fPos) & _fMask;
00082 }
00083
00084 int offset() const {
00085 assert(mode() == stackLoc, "not a stack location");
00086 int t = _loc>>_fPos;
00087 return _loc < 0 ? (t | ~_fMask) : t;
00088 }
00089
00090 int contextNo() const {
00091 assert(mode() == contextLoc1 || mode() == contextLoc2, "not a context location");
00092 return (_loc>>_f1Pos) & _f1Mask;
00093 }
00094
00095 int tempNo() const {
00096 assert(mode() == contextLoc1 || mode() == contextLoc2, "not a context location");
00097 return (_loc>>_f2Pos) & _f2Mask;
00098 }
00099
00100 int scopeID() const {
00101 assert(mode() == contextLoc1, "not a compiled context location");
00102 return (_loc>>_f3Pos) & _f3Mask;
00103 }
00104
00105 int scopeOffs() const {
00106 assert(mode() == contextLoc2, "not a runtime context location");
00107 return (_loc>>_f3Pos) & _f3Mask;
00108 }
00109
00110 int floatNo() const {
00111 assert(mode() == floatLoc, "not a float location");
00112 return (_loc>>_f2Pos) & _f2Mask;
00113 }
00114
00115 int scopeNo() const {
00116 assert(mode() == floatLoc, "not a float location");
00117 return (_loc>>_f3Pos) & _f3Mask;
00118 }
00119
00120
00121 char* name() const;
00122
00123
00124 bool isSpecialLocation() const { return mode() == specialLoc; }
00125 bool isRegisterLocation() const { return mode() == registerLoc; }
00126 bool isStackLocation() const { return mode() == stackLoc; }
00127 bool isContextLocation() const { return mode() == contextLoc1 || mode() == contextLoc2; }
00128 bool isFloatLocation() const { return mode() == floatLoc; }
00129 bool isTopOfStack() const;
00130 bool equals(Location y) const { return _loc == y._loc; }
00131
00132 friend bool operator == (Location x, Location y) {return x._loc == y._loc; }
00133 friend bool operator != (Location x, Location y) {return x._loc != y._loc; }
00134
00135 bool isTemporaryRegister() const;
00136 bool isTrashedRegister() const;
00137 bool isLocalRegister() const;
00138
00139
00140 friend class LocationName;
00141 friend class MemoizedName;
00142 friend class nmethodScopes;
00143 friend class DebugInfoWriter;
00144 };
00145
00146
00147
00148 const int nofSpecialLocations = 6;
00149 const Location illegalLocation = Location::specialLocation(0);
00150 const Location unAllocated = Location::specialLocation(1);
00151 const Location noRegister = Location::specialLocation(2);
00152 const Location topOfStack = Location::specialLocation(3);
00153 const Location resultOfNLR = Location::specialLocation(4);
00154 const Location topOfFloatStack = Location::specialLocation(5);
00155
00156
00157
00158
00159
00160
00161 class IntFreeList : public PrintableResourceObj {
00162 protected:
00163 int _first;
00164 GrowableArray<int>* _list;
00165
00166 void grow();
00167
00168 public:
00169 IntFreeList(int size);
00170
00171 int allocate();
00172 int allocated();
00173 void release(int i);
00174 int length();
00175 void print();
00176 };
00177
00178
00179 # endif