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/_methodPrinter.cpp.incl"
00026
00027 MethodPrinterClosure::MethodPrinterClosure(outputStream* stream) {
00028 st = stream ? stream : std;
00029 }
00030
00031 void MethodPrinterClosure::indent() {
00032 if (WizardMode) {
00033 st->indent();
00034 st->print(" <");
00035 GrowableArray<int>* map = method()->expression_stack_mapping(bci());
00036 for (int i = 0; i < map->length(); i++)
00037 st->print(" %d", map->at(i));
00038 st->print_cr(" >");
00039 }
00040 st->indent();
00041 st->print("[%3d] ", bci());
00042 }
00043
00044 void MethodPrinterClosure::show(char* str) {
00045 st->indent();
00046 st->print_cr(" %s", str);
00047 }
00048
00049 void MethodPrinterClosure::print_sendtype(Bytecodes::SendType type) {
00050 st->print("(");
00051 switch (type) {
00052 case Bytecodes::interpreted_send: st->print("interpreted"); break;
00053 case Bytecodes::compiled_send : st->print("compiled" ); break;
00054 case Bytecodes::polymorphic_send: st->print("polymorphic"); break;
00055 case Bytecodes::megamorphic_send: st->print("megamorphic"); break;
00056 case Bytecodes::predicted_send : st->print("predicted" ); break;
00057 case Bytecodes::accessor_send : st->print("access" ); break;
00058 default : ShouldNotReachHere(); break;
00059 }
00060 st->print(")");
00061 }
00062
00063 void MethodPrinterClosure::if_node(IfNode* node) {
00064 indent();
00065 node->selector()->print_symbol_on(st);
00066 st->print_cr(" {%d} [", node->end_bci());
00067 MethodIterator mi(node->then_code(), this);
00068 if (node->else_code() && !node->ignore_else_while_printing()) {
00069 show("] [");
00070 MethodIterator mi(node->else_code(), this);
00071 }
00072 show("]");
00073 }
00074
00075 void MethodPrinterClosure::cond_node(CondNode* node) {
00076 indent();
00077 node->selector()->print_symbol_on(st);
00078 st->cr();
00079 show("[");
00080 MethodIterator mi(node->expr_code(), this);
00081 show("]");
00082 }
00083
00084 void MethodPrinterClosure::while_node(WhileNode* node) {
00085 indent();
00086 node->selector()->print_symbol_on(st);
00087 st->print_cr(" {%d} [", node->end_bci());
00088 if (node->body_code()) {
00089 MethodIterator mi(node->body_code(), this);
00090 show("] [");
00091 }
00092 MethodIterator mi(node->expr_code(), this);
00093 show("]");
00094 }
00095
00096 void MethodPrinterClosure::primitive_call_node(PrimitiveCallNode* node) {
00097 indent();
00098 st->print_cr("primitive call '%s'", node->pdesc()->name());
00099 if (node->failure_code()) {
00100 MethodIterator mi(node->failure_code(), this);
00101 show("]");
00102 }
00103 }
00104
00105
00106 void MethodPrinterClosure::dll_call_node(DLLCallNode* node) {
00107 indent();
00108 st->print("dll call <");
00109 node->dll_name()->print_symbol_on(st);
00110 st->print(",");
00111 node->function_name()->print_symbol_on(st);
00112 st->print_cr(",%d>", node->nofArgs());
00113 if (node->failure_code()) {
00114 show("[");
00115 MethodIterator mi(node->failure_code(), this);
00116 show("]");
00117 }
00118 }
00119
00120
00121 void MethodPrinterClosure::allocate_temporaries(int nofTemps) {
00122 indent();
00123 st->print_cr("allocate %d temporaries", nofTemps);
00124 }
00125
00126 void MethodPrinterClosure::push_self() {
00127 indent();
00128 st->print_cr("push self");
00129 }
00130
00131 void MethodPrinterClosure::push_tos() {
00132 indent();
00133 st->print_cr("push tos");
00134 }
00135
00136 void MethodPrinterClosure::push_literal(oop obj) {
00137 indent();
00138 st->print("push literal ");
00139 obj->print_value_on(st);
00140 st->cr();
00141 }
00142
00143 void MethodPrinterClosure::push_argument(int no) {
00144 indent();
00145 st->print_cr("push arg %d", no);
00146 }
00147
00148 void MethodPrinterClosure::push_temporary(int no) {
00149 indent();
00150 st->print_cr("push temp %d", no);
00151 }
00152
00153 void MethodPrinterClosure::push_temporary(int no, int context) {
00154 indent();
00155 st->print_cr("push temp %d [%d]", no, context);
00156 }
00157
00158 void MethodPrinterClosure::push_instVar(int offset) {
00159 indent();
00160 st->print_cr("push instVar %d", offset);
00161 }
00162
00163 void MethodPrinterClosure::push_instVar_name(symbolOop name) {
00164 indent();
00165 st->print("push instVar ");
00166 name->print_value_on(st);
00167 st->cr();
00168 }
00169
00170 void MethodPrinterClosure::push_classVar(associationOop assoc) {
00171 indent();
00172 st->print("store classVar ");
00173 assoc->key()->print_value_on(st);
00174 st->cr();
00175 }
00176
00177 void MethodPrinterClosure::push_classVar_name(symbolOop name) {
00178 indent();
00179 st->print("store classVar ");
00180 name->print_value_on(st);
00181 st->cr();
00182 }
00183
00184 void MethodPrinterClosure::push_global(associationOop obj) {
00185 indent();
00186 st->print("push global ");
00187 obj->print_value_on(st);
00188 st->cr();
00189 }
00190
00191 void MethodPrinterClosure::store_temporary(int no) {
00192 indent();
00193 st->print_cr("store temp %d", no);
00194 }
00195
00196 void MethodPrinterClosure::store_temporary(int no, int context) {
00197 indent();
00198 st->print_cr("store temp %d [%d]", no, context);
00199 }
00200
00201 void MethodPrinterClosure::store_instVar(int offset) {
00202 indent();
00203 st->print_cr("store instVar %d", offset);
00204 }
00205
00206 void MethodPrinterClosure::store_instVar_name(symbolOop name) {
00207 indent();
00208 st->print("store instVar ");
00209 name->print_value_on(st);
00210 st->cr();
00211 }
00212
00213 void MethodPrinterClosure::store_classVar(associationOop assoc) {
00214 indent();
00215 st->print("store classVar ");
00216 assoc->key()->print_value_on(st);
00217 st->cr();
00218 }
00219
00220 void MethodPrinterClosure::store_classVar_name(symbolOop name) {
00221 indent();
00222 st->print("store classVar ");
00223 name->print_value_on(st);
00224 st->cr();
00225 }
00226
00227 void MethodPrinterClosure::store_global(associationOop obj) {
00228 indent();
00229 st->print("store global ");
00230 obj->print_value_on(st);
00231 st->cr();
00232 }
00233
00234 void MethodPrinterClosure::pop() {
00235 indent();
00236 st->print_cr("pop");
00237 }
00238
00239 void MethodPrinterClosure::normal_send(InterpretedIC* ic) {
00240 indent();
00241 st->print("normal send ");
00242 print_sendtype(ic->send_type());
00243 st->print(" ");
00244 oop s = oop(ic->selector());
00245 if (!s->is_smi() && Universe::is_heap((oop*) s)) {
00246 assert_symbol(ic->selector(), "selector in ic must be a symbol");
00247 ic->selector()->print_value_on(st);
00248 } else {
00249 st->print("INVALID SELECTOR, 0x%lx", s);
00250 }
00251 st->cr();
00252 }
00253
00254 void MethodPrinterClosure::self_send(InterpretedIC* ic) {
00255 indent();
00256 st->print("self send ");
00257 print_sendtype(ic->send_type());
00258 ic->selector()->print_value_on(st);
00259 st->cr();
00260 }
00261
00262 void MethodPrinterClosure::super_send(InterpretedIC* ic) {
00263 indent();
00264 st->print("super send ");
00265 print_sendtype(ic->send_type());
00266 ic->selector()->print_value_on(st);
00267 st->cr();
00268 }
00269
00270 void MethodPrinterClosure::double_equal() {
00271 indent();
00272 st->print_cr("hardwired ==");
00273 }
00274
00275 void MethodPrinterClosure::double_not_equal() {
00276 indent();
00277 st->print_cr("hardwired ~~");
00278 }
00279
00280 void MethodPrinterClosure::method_return(int nofArgs) {
00281 indent();
00282 st->print_cr("return (pop %d args)", nofArgs);
00283 }
00284
00285 void MethodPrinterClosure::nonlocal_return(int nofArgs) {
00286 indent();
00287 st->print_cr("non-local return (pop %d args)", nofArgs);
00288 }
00289
00290 void MethodPrinterClosure::allocate_closure(AllocationType type, int nofArgs, methodOop meth) {
00291 indent();
00292 st->print("allocate closure");
00293 switch (type) {
00294 case tos_as_scope:
00295 st->print("{tos}"); break;
00296 case context_as_scope:
00297 st->print("{context}"); break;
00298 }
00299 st->print_cr(" %d args", nofArgs);
00300
00301 {
00302 st->inc();
00303 st->inc();
00304 MethodIterator it(meth, &MethodPrinterClosure(st));
00305 st->dec();
00306 st->dec();
00307 }
00308 }
00309
00310 void MethodPrinterClosure::allocate_context(int nofTemps, bool forMethod) {
00311 indent();
00312 st->print_cr("allocate %s context with %d temporaries", forMethod ? "method" : "block", nofTemps);
00313 }
00314
00315 void MethodPrinterClosure::set_self_via_context() {
00316 indent();
00317 st->print_cr("set self via context");
00318 }
00319
00320
00321 void MethodPrinterClosure::copy_self_into_context() {
00322 indent();
00323 st->print_cr("copy self into context");
00324 }
00325
00326 void MethodPrinterClosure::copy_argument_into_context(int argNo, int no) {
00327 indent();
00328 st->print_cr("copy argument %d into context at %d", argNo, no);
00329 }
00330
00331 void MethodPrinterClosure::zap_scope() {
00332 indent();
00333 st->print_cr("zap block");
00334 }
00335
00336 void MethodPrinterClosure::predict_prim_call(primitive_desc* pdesc, int failure_start) {
00337 indent();
00338 st->print_cr("predicted prim method");
00339 }
00340
00341 void MethodPrinterClosure::float_allocate(int nofFloatTemps, int nofFloatExprs) {
00342 indent();
00343 st->print_cr("float allocate temps=%d, expr=%d", nofFloatTemps, nofFloatExprs);
00344 }
00345
00346 void MethodPrinterClosure::float_floatify(Floats::Function f, int tof) {
00347 indent();
00348 st->print("float floatify ");
00349 Floats::selector_for(f)->print_value_on(st);
00350 st->print_cr(" tof=%d", tof);
00351 }
00352
00353 void MethodPrinterClosure::float_move(int tof, int from) {
00354 indent();
00355 st->print_cr("float move tof=%d, from=%d", tof, from);
00356 }
00357
00358 void MethodPrinterClosure::float_set(int tof, doubleOop value) {
00359 indent();
00360 st->print_cr("float set tof=%d, value=%1.6g", tof, value->value());
00361 }
00362
00363 void MethodPrinterClosure::float_nullary(Floats::Function f, int tof) {
00364 indent();
00365 st->print("float nullary ");
00366 Floats::selector_for(f)->print_value_on(st);
00367 st->print_cr(" tof=%d", tof);
00368 }
00369
00370 void MethodPrinterClosure::float_unary(Floats::Function f, int tof) {
00371 indent();
00372 st->print("float unary ");
00373 Floats::selector_for(f)->print_value_on(st);
00374 st->print_cr(" tof=%d", tof);
00375 }
00376
00377 void MethodPrinterClosure::float_binary(Floats::Function f, int tof) {
00378 indent();
00379 st->print("float binary ");
00380 Floats::selector_for(f)->print_value_on(st);
00381 st->print_cr(" tof=%d", tof);
00382 }
00383
00384 void MethodPrinterClosure::float_unaryToOop(Floats::Function f, int tof) {
00385 indent();
00386 st->print("float unaryToOop ");
00387 Floats::selector_for(f)->print_value_on(st);
00388 st->print_cr(" tof=%d", tof);
00389 }
00390
00391 void MethodPrinterClosure::float_binaryToOop(Floats::Function f, int tof) {
00392 indent();
00393 st->print("float binaryToOop ");
00394 Floats::selector_for(f)->print_value_on(st);
00395 st->print_cr(" tof=%d", tof);
00396 }