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 SendKind { NormalSend, SelfSend, SuperSend };
00031
00032 class Inliner: public PrintableResourceObj {
00033 protected:
00034 InlinedScope* sender;
00035 SendKind kind;
00036 InlinedScope* callee;
00037 SendInfo* _info;
00038 Expr* res;
00039 SAPReg* resultPR;
00040 NodeBuilder* gen;
00041 MergeNode* merge;
00042 char* _msg;
00043 bool lastLookupFailed;
00044 public:
00045 int depth;
00046
00047 Inliner(InlinedScope* s) { this->sender = s; initialize(); }
00048
00049
00050
00051
00052 Expr* inlineNormalSend (SendInfo* info);
00053 Expr* inlineSuperSend (SendInfo* info);
00054 Expr* inlineSelfSend (SendInfo* info);
00055 Expr* inlineBlockInvocation (SendInfo* info);
00056
00057 SendInfo* info() const { return _info; }
00058 char* msg() const { return _msg; }
00059 void print();
00060
00061 protected:
00062 void initialize();
00063 void initialize(SendInfo* info, SendKind kind);
00064 Expr* inlineSend();
00065 void tryInlineSend();
00066 Expr* inlineMerge(SendInfo* info);
00067 Expr* picPredict ();
00068 Expr* picPredictUnlikely(SendInfo* info, RUntakenScope* uscope);
00069 Expr* typePredict();
00070 Expr* genRealSend();
00071 InlinedScope* tryLookup(Expr* rcvr);
00072 Expr* doInline(Node* start);
00073 char* checkSendInPrimFailure();
00074 InlinedScope* notify(const char* msg);
00075 RScope* makeBlockRScope(const Expr* rcvr, LookupKey* key, const methodOop method);
00076 InlinedScope* makeScope(const Expr* rcvr, const klassOop klass, const LookupKey* key, const methodOop method);
00077 Expr* makeResult(Expr* res);
00078 bool checkSenderPath(Scope* here, ScopeDesc* there) const;
00079
00080 friend class InliningPolicy;
00081 };
00082
00083
00084 class InliningPolicy : public ResourceObj {
00085
00086 protected:
00087 methodOop method;
00088 public:
00089 int calleeCost;
00090
00091 InliningPolicy() { method = NULL; }
00092 char* basic_shouldInline(methodOop method);
00093
00094
00095
00096 static bool isCriticalSmiSelector (const symbolOop sel);
00097 static bool isCriticalArraySelector (const symbolOop sel);
00098 static bool isCriticalBoolSelector (const symbolOop sel);
00099
00100
00101 static bool isPredictedSmiSelector (const symbolOop sel);
00102 static bool isPredictedArraySelector(const symbolOop sel);
00103 static bool isPredictedBoolSelector (const symbolOop sel);
00104
00105
00106 static bool isInterpreterPredictedSmiSelector (const symbolOop sel);
00107 static bool isInterpreterPredictedArraySelector(const symbolOop sel);
00108 static bool isInterpreterPredictedBoolSelector (const symbolOop sel);
00109
00110 protected:
00111 virtual klassOop receiverKlass() const = 0;
00112 virtual klassOop nthArgKlass(int nth) const = 0;
00113 bool shouldNotInline() const;
00114 bool isBuiltinMethod() const;
00115 };
00116
00117
00118
00119 class CompilerInliningPolicy : public InliningPolicy {
00120 protected:
00121 InlinedScope* sender;
00122 Expr* rcvr;
00123
00124 klassOop receiverKlass() const;
00125 klassOop nthArgKlass(int n) const;
00126 public:
00127 char* shouldInline(InlinedScope* sender, InlinedScope* callee);
00128
00129 };
00130
00131
00132
00133
00134 class RecompilerInliningPolicy : public InliningPolicy {
00135 protected:
00136 deltaVFrame* _vf;
00137 klassOop receiverKlass() const;
00138 klassOop nthArgKlass(int n) const;
00139 char* shouldInline(nmethod* nm);
00140
00141 public:
00142 char* shouldInline(RFrame* rf);
00143
00144 };
00145
00146 # endif