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
00031
00032 # define BASIC_FLAG_DEF(name, prot) \
00033 protected: \
00034 static const int CONC(name,Bit); \
00035 prot \
00036 bool CONC(is,name)() const { return flags & CONC(name,Bit) ? true : false; } \
00037 void CONC(set,name)(bool b) { \
00038 if (b) flags |= CONC(name,Bit); else flags &= ~CONC(name,Bit); } \
00039
00040 # define FLAG_DEF(name) BASIC_FLAG_DEF(name, public:)
00041 # define PFLAG_DEF(name) BASIC_FLAG_DEF(name, protected:)
00042
00043 class Expr : public PrintableResourceObj {
00044 protected:
00045 PReg* _preg;
00046 Node* _node;
00047 InlinedScope* unlikelyScope;
00048 int unlikelyBCI;
00049
00050 public:
00051 Expr* next;
00052 int flags;
00053
00054 Expr(PReg* p, Node* n);
00055
00056 virtual bool isUnknownExpr() const { return false; }
00057 virtual bool isNoResultExpr() const { return false; }
00058 virtual bool isKlassExpr() const { return false; }
00059 virtual bool isBlockExpr() const { return false; }
00060 virtual bool isConstantExpr() const { return false; }
00061 virtual bool isMergeExpr() const { return false; }
00062 virtual bool isContextExpr() const { return false; }
00063
00064 virtual bool hasKlass() const { return false; }
00065 virtual int nklasses() const = 0;
00066 virtual bool really_hasKlass(InlinedScope* s) const { Unused(s); return hasKlass(); }
00067 virtual klassOop klass() const { ShouldNotCallThis(); return 0; }
00068 virtual bool hasConstant() const { return false; }
00069 virtual oop constant() const { ShouldNotCallThis(); return 0; }
00070 virtual bool containsUnknown() = 0;
00071 virtual Expr* makeUnknownUnlikely(InlinedScope* s) {
00072 Unused(s); ShouldNotCallThis(); return 0;}
00073 virtual bool isUnknownUnlikely() const { return false; }
00074 virtual bool needsStoreCheck() const { return true; }
00075
00076 virtual UnknownExpr* findUnknown() const { return NULL; }
00077 virtual Expr* findKlass(klassOop map) const { Unused(map); return NULL; }
00078
00079 virtual Expr* asReceiver() const;
00080 virtual KlassExpr* asKlassExpr() const { ShouldNotCallThis(); return NULL; }
00081 virtual ConstantExpr* asConstantExpr() const { ShouldNotCallThis(); return NULL; }
00082 virtual MergeExpr* asMergeExpr() const { ShouldNotCallThis(); return NULL; }
00083
00084 virtual Expr* shallowCopy(PReg* p, Node* n) const = 0;
00085 virtual Expr* copyWithout(Expr* e) const = 0;
00086 virtual Expr* mergeWith(Expr* other, Node* n) = 0;
00087 virtual Expr* convertToKlass(PReg* p, Node* n) const = 0;
00088 virtual bool equals(Expr* other) const = 0;
00089
00090 Node* node() const { return _node; }
00091 PReg* preg() const { return _preg; }
00092 void setNode(Node* n, PReg* p) { _node = n; _preg = p; }
00093 bool is_smi() const { return hasKlass() && klass() == smiKlassObj; }
00094
00095 InlinedScope* scope() const;
00096 virtual NameNode* nameNode(bool mustBeLegal = true) const;
00097 virtual void verify() const;
00098
00099 protected:
00100 void print_helper(char* type);
00101 };
00102
00103
00104 class UnknownExpr : public Expr {
00105 public:
00106 UnknownExpr(PReg* p, Node* n = NULL, bool u = false) : Expr(p, n) {
00107 setUnlikely(u); }
00108 bool isUnknownExpr() const { return true; }
00109 bool containsUnknown() { return true; }
00110 FLAG_DEF(Unlikely);
00111
00112 UnknownExpr* findUnknown() const { return (UnknownExpr*)this; }
00113 bool isUnknownUnlikely() const { return isUnlikely(); }
00114 int nklasses() const { return 0; }
00115 Expr* shallowCopy(PReg* p, Node* n) const;
00116 Expr* copyWithout(Expr* e) const { return (Expr*)this; }
00117 Expr* mergeWith(Expr* other, Node* n);
00118 Expr* convertToKlass(PReg* p, Node* n) const { return shallowCopy(p, n); };
00119 Expr* makeUnknownUnlikely(InlinedScope* s);
00120 bool equals(Expr* other) const;
00121 void print();
00122 };
00123
00124
00125
00126
00127 class NoResultExpr : public Expr {
00128 public:
00129 NoResultExpr(Node* n = NULL);
00130 bool isNoResultExpr() const { return true; }
00131 int nklasses() const { return 0; }
00132 bool containsUnknown() { return false; }
00133 Expr* shallowCopy(PReg* p, Node* n) const;
00134 Expr* copyWithout(Expr* e) const { return (Expr*)this; }
00135 Expr* mergeWith(Expr* other, Node* n);
00136 Expr* convertToKlass(PReg* p, Node* n) const { return shallowCopy(p, n); };
00137 bool equals(Expr* other) const;
00138 void print();
00139 };
00140
00141
00142
00143 class KlassExpr : public Expr {
00144 protected:
00145 klassOop _klass;
00146 public:
00147 KlassExpr(klassOop m, PReg* p, Node* n);
00148
00149 bool isKlassExpr() const { return true; }
00150 bool containsUnknown() { return false; }
00151
00152 KlassExpr* asKlassExpr() const { return (KlassExpr*)this; }
00153 bool hasKlass() const { return true; }
00154 int nklasses() const { return 1; }
00155 klassOop klass() const { return _klass; }
00156 virtual bool needsStoreCheck() const;
00157 Expr* shallowCopy(PReg* p, Node* n) const;
00158 Expr* copyWithout(Expr* e) const;
00159 Expr* mergeWith(Expr* other, Node* n);
00160 Expr* convertToKlass(PReg* p, Node* n) const { return shallowCopy(p, n); };
00161 Expr* findKlass(klassOop map) const { return _klass == map ? (Expr*)this : NULL; }
00162 bool equals(Expr* other) const;
00163 void print();
00164 virtual void verify() const;
00165 };
00166
00167
00168 class BlockExpr : public KlassExpr {
00169 protected:
00170 InlinedScope* _blockScope;
00171 public:
00172 BlockExpr(BlockPReg* p, Node* n);
00173 bool isBlockExpr() const { return true; }
00174 InlinedScope* blockScope() const { return _blockScope; }
00175 BlockPReg* preg() const { return (BlockPReg*)_preg; }
00176 int nklasses() const { return 1; }
00177 Expr* shallowCopy(PReg* p, Node* n) const;
00178 Expr* mergeWith(Expr* other, Node* n);
00179 bool equals(Expr* other) const;
00180 void print();
00181 virtual void verify() const;
00182 };
00183
00184
00185 class ConstantExpr : public Expr {
00186 oop _c;
00187 public:
00188 ConstantExpr(oop c, PReg* p, Node* n) : Expr(p, n) { _c = c; }
00189
00190 bool isConstantExpr() const { return true; }
00191 bool containsUnknown() { return false; }
00192 bool hasKlass() const { return true; }
00193 KlassExpr* asKlassExpr() const;
00194 klassOop klass() const { return _c->klass(); }
00195 int nklasses() const { return 1; }
00196 ConstantExpr* asConstantExpr() const { return (ConstantExpr*)this; }
00197 bool hasConstant() const { return true; }
00198 oop constant() const { return _c; }
00199 virtual bool needsStoreCheck() const;
00200 NameNode* nameNode(bool mustBeLegal = true) const;
00201 Expr* shallowCopy(PReg* p, Node* n) const;
00202 Expr* copyWithout(Expr* e) const;
00203 Expr* mergeWith(Expr* other, Node* n);
00204 Expr* convertToKlass(PReg* p, Node* n) const;
00205 Expr* findKlass(klassOop map) const;
00206 bool equals(Expr* other) const;
00207 void print();
00208 virtual void verify() const;
00209 };
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 class MergeExpr : public Expr {
00221 public:
00222 GrowableArray<Expr*>* exprs;
00223
00224 MergeExpr(Expr* e1, Expr* e2, PReg* p, Node* n);
00225 MergeExpr(PReg* p, Node* n);
00226
00227
00228
00229
00230
00231
00232
00233 bool isMergeExpr() const { return true; }
00234 FLAG_DEF(Splittable);
00235 PFLAG_DEF(UnknownSet);
00236 PFLAG_DEF(ContainingUnknown);
00237 public:
00238 bool containsUnknown();
00239 MergeExpr* asMergeExpr() const { return (MergeExpr*)this; }
00240 bool hasKlass() const;
00241 int nklasses() const;
00242 KlassExpr* asKlassExpr() const;
00243 bool really_hasKlass(InlinedScope* s) const;
00244 klassOop klass() const;
00245 Expr* asReceiver() const;
00246 bool hasConstant() const;
00247 oop constant() const;
00248 Expr* shallowCopy(PReg* p, Node* n) const;
00249 Expr* copyWithout(Expr* e) const;
00250 Expr* mergeWith(Expr* other, Node* n);
00251 Expr* convertToKlass(PReg* p, Node* n) const;
00252 Expr* makeUnknownUnlikely(InlinedScope* s);
00253 bool equals(Expr* other) const;
00254 void print();
00255 virtual void verify() const;
00256
00257 UnknownExpr* findUnknown() const;
00258 Expr* findKlass(klassOop map) const;
00259
00260 protected:
00261 void initialize();
00262 void mergeInto(Expr* other, Node* n);
00263 void add(Expr* s);
00264 };
00265
00266
00267
00268
00269 class ContextExpr : public Expr {
00270 public:
00271 ContextExpr(PReg* r);
00272 bool isContextExpr() const { return true; }
00273 bool containsUnknown() { ShouldNotCallThis(); return false; }
00274 int nklasses() const { ShouldNotCallThis(); return 1; }
00275 Expr* shallowCopy(PReg* p, Node* n) const { ShouldNotCallThis(); return (Expr*)this; }
00276 Expr* copyWithout(Expr* e) const { ShouldNotCallThis(); return (Expr*)this; }
00277 Expr* mergeWith(Expr* other, Node* n) { ShouldNotCallThis(); return (Expr*)this; }
00278 Expr* convertToKlass(PReg* p, Node* n) const { return shallowCopy(p, n); };
00279 bool equals(Expr* other) const { ShouldNotCallThis(); return false; }
00280 void print();
00281 virtual void verify() const;
00282 };
00283
00284
00285 class ExprStack : public GrowableArray<Expr*> {
00286
00287
00288 private:
00289 InlinedScope* _scope;
00290 public:
00291 ExprStack(InlinedScope* scope, int size);
00292 void push(Expr* expr, InlinedScope* currentScope, int bci);
00293 void push2nd(Expr* expr, InlinedScope* currentScope, int bci);
00294 void assign_top(Expr* expr);
00295 Expr* pop();
00296 void pop(int nofExprsToPop);
00297 void print();
00298 };
00299
00300 # undef BASIC_FLAG_DEF
00301 # undef FLAG_DEF
00302 # undef PFLAG_DEF
00303
00304 # endif