00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_tempDecoder.cpp.incl"
00026
00027 #define NEXT \
00028 pos++; \
00029 if (pos > len) return; \
00030 current = tempInfo->obj_at(pos)
00031
00032 void TempDecoder::decode(methodOop method, int bci) {
00033
00034
00035
00036
00037
00038
00039
00040 objArrayOop tempInfo = method->tempInfo();
00041 if (tempInfo == NULL) {
00042 no_debug_info();
00043 return;
00044 }
00045 int len = tempInfo->length();
00046 if (len == 0) return;
00047
00048 int pos = 1;
00049 oop current = tempInfo->obj_at(pos);
00050
00051 {
00052 num_of_params = 0;
00053 while (current->is_byteArray()) {
00054 parameter(byteArrayOop(current), num_of_params++);
00055 NEXT;
00056 }
00057 }
00058
00059 {
00060 assert_smi(current, "expecting smi");
00061 int offset = smiOop(current)->value();
00062 NEXT;
00063 while (current->is_byteArray()) {
00064 stack_temp(byteArrayOop(current), offset++);
00065 NEXT;
00066 }
00067 }
00068
00069 {
00070 assert_smi(current, "expecting smi");
00071 assert(smiOop(current)->value() == 0, "should be zero")
00072 int fno = smiOop(current)->value();
00073 NEXT;
00074 while (current->is_byteArray()) {
00075 stack_float_temp(byteArrayOop(current), fno++);
00076 NEXT;
00077 }
00078 }
00079
00080 {
00081 assert_smi(current, "expecting smi");
00082 int offset = smiOop(current)->value();
00083 NEXT;
00084 while (current->is_byteArray()) {
00085 if (is_heap_parameter(byteArrayOop(current), tempInfo)) {
00086 heap_parameter(byteArrayOop(current), offset++);
00087 } else {
00088 heap_temp(byteArrayOop(current), offset++);
00089 }
00090 NEXT;
00091 }
00092 }
00093 {
00094 while(1) {
00095 assert_smi(current, "expecting smi");
00096 int begin = smiOop(current)->value();
00097 NEXT;
00098 assert_smi(current, "expecting smi");
00099 int end = smiOop(current)->value();
00100 NEXT;
00101
00102 assert_smi(current, "expecting smi");
00103 int offset = smiOop(current)->value();
00104 NEXT;
00105 while (current->is_byteArray()) {
00106 if ((begin <= bci) && (bci <= end)) {
00107 stack_temp(byteArrayOop(current), offset);
00108 }
00109 offset++;
00110 NEXT;
00111 }
00112
00113 assert_smi(current, "expecting smi");
00114 offset = smiOop(current)->value();
00115 NEXT;
00116 while (current->is_byteArray()) {
00117 if ((begin <= bci) && (bci <= end)) {
00118 stack_float_temp(byteArrayOop(current), offset);
00119 }
00120 offset++;
00121 NEXT;
00122 }
00123 }
00124 }
00125 }
00126
00127 bool TempDecoder::is_heap_parameter(byteArrayOop name, objArrayOop tempInfo) {
00128 assert(name->is_symbol(), "Must be symbol");
00129 for (int index = 1; index <= num_of_params; index++) {
00130 byteArrayOop par = byteArrayOop(tempInfo->obj_at(index));
00131 assert(par->is_symbol(), "Must be symbol");
00132 if (name == par) return true;
00133 }
00134 return false;
00135 }
00136
00137 void TempPrinter::decode(methodOop method, int bci) {
00138 std->print_cr("TempDecoding:");
00139 TempDecoder::decode(method, bci);
00140 }
00141
00142 void TempPrinter::parameter(byteArrayOop name, int index) {
00143 std->print_cr(" param: %s@%d", name->as_string(), index);
00144 }
00145
00146 void TempPrinter::stack_temp(byteArrayOop name, int no) {
00147 std->print_cr(" stack temp: %s@%d", name->as_string(), no);
00148 }
00149
00150 void TempPrinter::stack_float_temp(byteArrayOop name, int fno) {
00151 std->print_cr(" stack float temp: %s@%d", name->as_string(), fno);
00152 }
00153
00154 void TempPrinter::heap_temp(byteArrayOop name, int no){
00155 std->print_cr(" heap temp: %s@%d", name->as_string(), no);
00156 }
00157
00158 void TempPrinter::heap_parameter(byteArrayOop name, int no){
00159 std->print_cr(" heap param: %s@%d", name->as_string(), no);
00160 }
00161
00162 void TempPrinter::no_debug_info() {
00163 std->print_cr("method has no debug information");
00164 }
00165
00166
00167 class FindParam : public TempDecoder {
00168 private:
00169 int the_no;
00170 public:
00171 byteArrayOop result;
00172
00173 void find(methodOop method, int no) {
00174 result = NULL;
00175 the_no = no;
00176 decode(method, 0);
00177 }
00178 void parameter(byteArrayOop name, int no) {
00179 if (the_no == no) result = name;
00180 }
00181 };
00182
00183 byteArrayOop find_parameter_name(methodOop method, int no) {
00184 FindParam p;
00185 p.find(method, no);
00186 return p.result;
00187 }
00188
00189 class FindStackTemp : public TempDecoder {
00190 private:
00191 int the_no;
00192 public:
00193 byteArrayOop result;
00194
00195 void find(methodOop method, int bci, int no) {
00196 result = NULL;
00197 the_no = no;
00198 TempDecoder::decode(method, bci);
00199 }
00200 void stack_temp(byteArrayOop name, int no) {
00201 if (the_no == no) result = name;
00202 }
00203 };
00204
00205 class FindStackFloatTemp : public TempDecoder {
00206 private:
00207 int the_fno;
00208 public:
00209 byteArrayOop result;
00210
00211 void find(methodOop method, int bci, int fno) {
00212 result = NULL;
00213 the_fno = fno;
00214 TempDecoder::decode(method, bci);
00215 }
00216 void stack_float_temp(byteArrayOop name, int fno) {
00217 if (the_fno == fno) result = name;
00218 }
00219 };
00220
00221 class FindHeapTemp : public TempDecoder {
00222 private:
00223 int the_no;
00224 public:
00225 byteArrayOop result;
00226
00227 void find(methodOop method, int bci, int no) {
00228 result = NULL;
00229 the_no = no;
00230 TempDecoder::decode(method, bci);
00231 }
00232 void heap_temp(byteArrayOop name, int no) {
00233 if (the_no == no) result = name;
00234 }
00235 void heap_parameter(byteArrayOop name, int no) {
00236 if (the_no == no) result = name;
00237 }
00238
00239 };
00240
00241 byteArrayOop find_stack_temp(methodOop method, int bci, int no) {
00242 FindStackTemp p;
00243 p.find(method, bci, no);
00244 return p.result;
00245 }
00246
00247 byteArrayOop find_heap_temp(methodOop method, int bci, int no) {
00248 FindHeapTemp p;
00249 p.find(method, bci, no);
00250 return p.result;
00251 }
00252
00253 byteArrayOop find_stack_float_temp(methodOop method, int bci, int fno) {
00254 FindStackFloatTemp p;
00255 p.find(method, bci, fno);
00256 return p.result;
00257 }