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 class PIC_Iterator;
00031 class PIC_contents;
00032
00033 class PIC {
00034 public:
00035 enum Consts {
00036 max_nof_entries = 4,
00037
00038
00039 PIC_methodOop_only_offset = 5,
00040 PIC_smi_nmethod_offset = 4,
00041
00042 PIC_nmethod_entry_offset = 11,
00043 PIC_nmethod_entry_size = 12,
00044 PIC_nmethod_klass_offset = 2,
00045 PIC_nmethod_offset = 8,
00046
00047 PIC_methodOop_entry_offset = 16,
00048 PIC_methodOop_entry_size = 8,
00049 PIC_methodOop_klass_offset = 0,
00050 PIC_methodOop_offset = 4,
00051
00052
00053 MIC_selector_offset = 5,
00054 MIC_code_size = 9,
00055 };
00056
00057 private:
00058 CompiledIC* _ic;
00059 short _code_size;
00060 short _number_of_targets;
00061
00062 static int nof_entries(char* pic_stub);
00063
00064 int code_for_methodOops_only (char* entry, PIC_contents* c);
00065 int code_for_polymorphic_case(char* entry, PIC_contents* c);
00066 int code_for_megamorphic_case(char* entry);
00067
00068 void shrink_and_generate(PIC* pic, klassOop klass, void* method);
00069
00070 bool contains(char* addr) { return entry() <= addr && addr < entry() + code_size(); }
00071
00072
00073 PIC(CompiledIC* ic, PIC_contents* contents, int allocated_code_size);
00074 PIC(CompiledIC* ic);
00075
00076 public:
00077 void* operator new(size_t size, int code_size);
00078
00079
00080 void operator delete (void* p);
00081
00082
00083 static PIC* allocate(CompiledIC* ic, klassOop klass, LookupResult result);
00084
00085
00086 static bool in_heap(char* addr);
00087
00088
00089 static PIC* find(char* addr);
00090
00091
00092 int code_size() const { return _code_size; }
00093
00094
00095
00096 CompiledIC* compiled_ic() const { return _ic; }
00097 int number_of_targets() const { return _number_of_targets; }
00098 symbolOop selector() const { return compiled_ic()->selector(); }
00099 char* entry() const { return (char*) (this+1); }
00100 bool is_monomorphic() const { return number_of_targets() == 1; }
00101 bool is_polymorphic() const { return number_of_targets() > 1; }
00102 bool is_megamorphic() const { return number_of_targets() == 0; }
00103
00104
00105 symbolOop* MIC_selector_address() const;
00106
00107
00108
00109
00110 PIC* replace(nmethod* nm);
00111
00112
00113
00114
00115
00116 PIC* cleanup(nmethod** nm);
00117
00118 GrowableArray<klassOop>* klasses() const;
00119
00120
00121 void oops_do(void f(oop*));
00122
00123
00124 void print();
00125
00126
00127 void verify();
00128
00129 friend class PIC_Iterator;
00130 };
00131
00132
00133
00134
00135
00136
00137
00138 class PIC_Iterator: public PrintableResourceObj {
00139 public:
00140 enum State { at_smi_nmethod,
00141 at_nmethod,
00142 at_methodOop,
00143 at_the_end
00144 };
00145
00146 private:
00147 PIC* _pic;
00148 char* _pos;
00149 enum State _state;
00150 int _methodOop_counter;
00151
00152 int* nmethod_disp_addr() const;
00153 void computeNextState();
00154
00155 public:
00156 PIC_Iterator(PIC* pic);
00157
00158
00159 void advance();
00160 State state() const { return _state; }
00161 bool at_end() const { return state() == at_the_end; }
00162
00163
00164 klassOop get_klass() const;
00165 char* get_call_addr() const;
00166 bool is_interpreted() const;
00167 bool is_compiled() const;
00168
00169 methodOop interpreted_method() const;
00170 nmethod* compiled_method() const;
00171
00172
00173 void set_klass(klassOop klass);
00174 void set_nmethod(nmethod* nm);
00175 void set_methodOop(methodOop method);
00176
00177
00178 methodOop* methodOop_addr() const;
00179 klassOop* klass_addr() const;
00180
00181
00182 void print();
00183 };
00184
00185
00186 class CompiledIC_Iterator: public IC_Iterator {
00187 private:
00188 CompiledIC* _ic;
00189 PIC_Iterator* _picit;
00190
00191 int _number_of_targets;
00192 IC_Shape _shape;
00193 int _index;
00194
00195 public:
00196 CompiledIC_Iterator(CompiledIC* ic);
00197
00198
00199 bool is_compiled_ic() const { return true; }
00200 bool is_super_send() const;
00201 int number_of_targets() const { return _number_of_targets; }
00202 IC_Shape shape() const { return _shape; }
00203 symbolOop selector() const { return _ic->selector(); }
00204 CompiledIC* compiled_ic() const { return _ic; }
00205
00206
00207 void init_iteration();
00208 void advance();
00209 bool at_end() const { return _index >= number_of_targets(); }
00210
00211
00212 klassOop klass() const;
00213
00214 bool is_interpreted() const;
00215 bool is_compiled() const;
00216
00217 methodOop interpreted_method() const;
00218 nmethod* compiled_method() const;
00219
00220
00221 void print();
00222 };
00223
00224
00225 #endif