206 } 207 } 208 #endif 209 210 //============================================================================= 211 // Do we Match on this edge index or not? Match only target address & method 212 uint TailCallNode::match_edge(uint idx) const { 213 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; 214 } 215 216 //============================================================================= 217 // Do we Match on this edge index or not? Match only target address & oop 218 uint TailJumpNode::match_edge(uint idx) const { 219 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; 220 } 221 222 //============================================================================= 223 JVMState::JVMState(ciMethod* method, JVMState* caller) { 224 assert(method != NULL, "must be valid call site"); 225 _method = method; 226 debug_only(_bci = -99); // random garbage value 227 debug_only(_map = (SafePointNode*)-1); 228 _caller = caller; 229 _depth = 1 + (caller == NULL ? 0 : caller->depth()); 230 _locoff = TypeFunc::Parms; 231 _stkoff = _locoff + _method->max_locals(); 232 _monoff = _stkoff + _method->max_stack(); 233 _scloff = _monoff; 234 _endoff = _monoff; 235 _sp = 0; 236 } 237 JVMState::JVMState(int stack_size) { 238 _method = NULL; 239 _bci = InvocationEntryBci; 240 debug_only(_map = (SafePointNode*)-1); 241 _caller = NULL; 242 _depth = 1; 243 _locoff = TypeFunc::Parms; 244 _stkoff = _locoff; 245 _monoff = _stkoff + stack_size; 246 _scloff = _monoff; 247 _endoff = _monoff; 248 _sp = 0; 249 } 250 251 //--------------------------------of_depth------------------------------------- 252 JVMState* JVMState::of_depth(int d) const { 253 const JVMState* jvmp = this; 254 assert(0 < d && (uint)d <= depth(), "oob"); 255 for (int skip = depth() - d; skip > 0; skip--) { 256 jvmp = jvmp->caller(); 257 } 258 assert(jvmp->depth() == (uint)d, "found the right one"); 259 return (JVMState*)jvmp; 260 } 261 262 //-----------------------------same_calls_as----------------------------------- 263 bool JVMState::same_calls_as(const JVMState* that) const { 264 if (this == that) return true; 265 if (this->depth() != that->depth()) return false; 266 const JVMState* p = this; 267 const JVMState* q = that; 268 for (;;) { 269 if (p->_method != q->_method) return false; 270 if (p->_method == NULL) return true; // bci is irrelevant 271 if (p->_bci != q->_bci) return false; 272 p = p->caller(); 273 q = q->caller(); 274 if (p == q) return true; 275 assert(p != NULL && q != NULL, "depth check ensures we don't run off end"); 276 } 277 } 278 279 //------------------------------debug_start------------------------------------ 280 uint JVMState::debug_start() const { 281 debug_only(JVMState* jvmroot = of_depth(1)); 282 assert(jvmroot->locoff() <= this->locoff(), "youngest JVMState must be last"); 283 return of_depth(1)->locoff(); 284 } 285 286 //-------------------------------debug_end------------------------------------- 287 uint JVMState::debug_end() const { 288 debug_only(JVMState* jvmroot = of_depth(1)); 289 assert(jvmroot->endoff() <= this->endoff(), "youngest JVMState must be last"); 290 return endoff(); 291 } 473 // The JVMS dumps make really, really long lines. 474 // Take out the most boring parts, which are the package prefixes. 475 char buf[500]; 476 stringStream namest(buf, sizeof(buf)); 477 _method->print_short_name(&namest); 478 if (namest.count() < sizeof(buf)) { 479 const char* name = namest.base(); 480 if (name[0] == ' ') ++name; 481 const char* endcn = strchr(name, ':'); // end of class name 482 if (endcn == NULL) endcn = strchr(name, '('); 483 if (endcn == NULL) endcn = name + strlen(name); 484 while (endcn > name && endcn[-1] != '.' && endcn[-1] != '/') 485 --endcn; 486 st->print(" %s", endcn); 487 printed = true; 488 } 489 } 490 if (!printed) 491 _method->print_short_name(st); 492 st->print(" @ bci:%d",_bci); 493 } else { 494 st->print(" runtime stub"); 495 } 496 if (caller() != NULL) caller()->dump_spec(st); 497 } 498 499 500 void JVMState::dump_on(outputStream* st) const { 501 if (_map && !((uintptr_t)_map & 1)) { 502 if (_map->len() > _map->req()) { // _map->has_exceptions() 503 Node* ex = _map->in(_map->req()); // _map->next_exception() 504 // skip the first one; it's already being printed 505 while (ex != NULL && ex->len() > ex->req()) { 506 ex = ex->in(ex->req()); // ex->next_exception() 507 ex->dump(1); 508 } 509 } 510 _map->dump(2); 511 } 512 st->print("JVMS depth=%d loc=%d stk=%d mon=%d scalar=%d end=%d mondepth=%d sp=%d bci=%d method=", 513 depth(), locoff(), stkoff(), monoff(), scloff(), endoff(), monitor_depth(), sp(), bci()); 514 if (_method == NULL) { 515 st->print_cr("(none)"); 516 } else { 517 _method->print_name(st); 518 st->cr(); 519 if (bci() >= 0 && bci() < _method->code_size()) { 520 st->print(" bc: "); 521 _method->print_codes_on(bci(), bci()+1, st); 522 } 523 } 524 if (caller() != NULL) { 525 caller()->dump_on(st); 526 } 527 } 528 529 // Extra way to dump a jvms from the debugger, 530 // to avoid a bug with C++ member function calls. 531 void dump_jvms(JVMState* jvms) { 532 jvms->dump(); 533 } 534 #endif 535 536 //--------------------------clone_shallow-------------------------------------- 537 JVMState* JVMState::clone_shallow(Compile* C) const { 538 JVMState* n = has_method() ? new (C) JVMState(_method, _caller) : new (C) JVMState(0); 539 n->set_bci(_bci); 540 n->set_locoff(_locoff); 541 n->set_stkoff(_stkoff); 542 n->set_monoff(_monoff); 543 n->set_scloff(_scloff); 544 n->set_endoff(_endoff); 545 n->set_sp(_sp); 546 n->set_map(_map); 547 return n; 548 } 549 550 //---------------------------clone_deep---------------------------------------- 551 JVMState* JVMState::clone_deep(Compile* C) const { 552 JVMState* n = clone_shallow(C); 553 for (JVMState* p = n; p->_caller != NULL; p = p->_caller) { 554 p->_caller = p->_caller->clone_shallow(C); 555 } 556 assert(n->depth() == depth(), "sanity"); 557 assert(n->debug_depth() == debug_depth(), "sanity"); 558 return n; 559 } | 206 } 207 } 208 #endif 209 210 //============================================================================= 211 // Do we Match on this edge index or not? Match only target address & method 212 uint TailCallNode::match_edge(uint idx) const { 213 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; 214 } 215 216 //============================================================================= 217 // Do we Match on this edge index or not? Match only target address & oop 218 uint TailJumpNode::match_edge(uint idx) const { 219 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; 220 } 221 222 //============================================================================= 223 JVMState::JVMState(ciMethod* method, JVMState* caller) { 224 assert(method != NULL, "must be valid call site"); 225 _method = method; 226 _reexecute = false; 227 debug_only(_bci = -99); // random garbage value 228 debug_only(_map = (SafePointNode*)-1); 229 _caller = caller; 230 _depth = 1 + (caller == NULL ? 0 : caller->depth()); 231 _locoff = TypeFunc::Parms; 232 _stkoff = _locoff + _method->max_locals(); 233 _monoff = _stkoff + _method->max_stack(); 234 _scloff = _monoff; 235 _endoff = _monoff; 236 _sp = 0; 237 } 238 JVMState::JVMState(int stack_size) { 239 _method = NULL; 240 _bci = InvocationEntryBci; 241 _reexecute = false; 242 debug_only(_map = (SafePointNode*)-1); 243 _caller = NULL; 244 _depth = 1; 245 _locoff = TypeFunc::Parms; 246 _stkoff = _locoff; 247 _monoff = _stkoff + stack_size; 248 _scloff = _monoff; 249 _endoff = _monoff; 250 _sp = 0; 251 } 252 253 //--------------------------------of_depth------------------------------------- 254 JVMState* JVMState::of_depth(int d) const { 255 const JVMState* jvmp = this; 256 assert(0 < d && (uint)d <= depth(), "oob"); 257 for (int skip = depth() - d; skip > 0; skip--) { 258 jvmp = jvmp->caller(); 259 } 260 assert(jvmp->depth() == (uint)d, "found the right one"); 261 return (JVMState*)jvmp; 262 } 263 264 //-----------------------------same_calls_as----------------------------------- 265 bool JVMState::same_calls_as(const JVMState* that) const { 266 if (this == that) return true; 267 if (this->depth() != that->depth()) return false; 268 const JVMState* p = this; 269 const JVMState* q = that; 270 for (;;) { 271 if (p->_method != q->_method) return false; 272 if (p->_method == NULL) return true; // bci is irrelevant 273 if (p->_bci != q->_bci) return false; 274 if (p->_reexecute != q->_reexecute) return false; 275 p = p->caller(); 276 q = q->caller(); 277 if (p == q) return true; 278 assert(p != NULL && q != NULL, "depth check ensures we don't run off end"); 279 } 280 } 281 282 //------------------------------debug_start------------------------------------ 283 uint JVMState::debug_start() const { 284 debug_only(JVMState* jvmroot = of_depth(1)); 285 assert(jvmroot->locoff() <= this->locoff(), "youngest JVMState must be last"); 286 return of_depth(1)->locoff(); 287 } 288 289 //-------------------------------debug_end------------------------------------- 290 uint JVMState::debug_end() const { 291 debug_only(JVMState* jvmroot = of_depth(1)); 292 assert(jvmroot->endoff() <= this->endoff(), "youngest JVMState must be last"); 293 return endoff(); 294 } 476 // The JVMS dumps make really, really long lines. 477 // Take out the most boring parts, which are the package prefixes. 478 char buf[500]; 479 stringStream namest(buf, sizeof(buf)); 480 _method->print_short_name(&namest); 481 if (namest.count() < sizeof(buf)) { 482 const char* name = namest.base(); 483 if (name[0] == ' ') ++name; 484 const char* endcn = strchr(name, ':'); // end of class name 485 if (endcn == NULL) endcn = strchr(name, '('); 486 if (endcn == NULL) endcn = name + strlen(name); 487 while (endcn > name && endcn[-1] != '.' && endcn[-1] != '/') 488 --endcn; 489 st->print(" %s", endcn); 490 printed = true; 491 } 492 } 493 if (!printed) 494 _method->print_short_name(st); 495 st->print(" @ bci:%d",_bci); 496 st->print(" reexecute:%s", _reexecute?"true":"false"); 497 } else { 498 st->print(" runtime stub"); 499 } 500 if (caller() != NULL) caller()->dump_spec(st); 501 } 502 503 504 void JVMState::dump_on(outputStream* st) const { 505 if (_map && !((uintptr_t)_map & 1)) { 506 if (_map->len() > _map->req()) { // _map->has_exceptions() 507 Node* ex = _map->in(_map->req()); // _map->next_exception() 508 // skip the first one; it's already being printed 509 while (ex != NULL && ex->len() > ex->req()) { 510 ex = ex->in(ex->req()); // ex->next_exception() 511 ex->dump(1); 512 } 513 } 514 _map->dump(2); 515 } 516 st->print("JVMS depth=%d loc=%d stk=%d mon=%d scalar=%d end=%d mondepth=%d sp=%d bci=%d reexecute=%s method=", 517 depth(), locoff(), stkoff(), monoff(), scloff(), endoff(), monitor_depth(), sp(), bci(), should_reexecute()?"true":"false"); 518 if (_method == NULL) { 519 st->print_cr("(none)"); 520 } else { 521 _method->print_name(st); 522 st->cr(); 523 if (bci() >= 0 && bci() < _method->code_size()) { 524 st->print(" bc: "); 525 _method->print_codes_on(bci(), bci()+1, st); 526 } 527 } 528 if (caller() != NULL) { 529 caller()->dump_on(st); 530 } 531 } 532 533 // Extra way to dump a jvms from the debugger, 534 // to avoid a bug with C++ member function calls. 535 void dump_jvms(JVMState* jvms) { 536 jvms->dump(); 537 } 538 #endif 539 540 //--------------------------clone_shallow-------------------------------------- 541 JVMState* JVMState::clone_shallow(Compile* C) const { 542 JVMState* n = has_method() ? new (C) JVMState(_method, _caller) : new (C) JVMState(0); 543 n->set_bci(_bci); 544 n->set_reexecute(_reexecute); 545 n->set_locoff(_locoff); 546 n->set_stkoff(_stkoff); 547 n->set_monoff(_monoff); 548 n->set_scloff(_scloff); 549 n->set_endoff(_endoff); 550 n->set_sp(_sp); 551 n->set_map(_map); 552 return n; 553 } 554 555 //---------------------------clone_deep---------------------------------------- 556 JVMState* JVMState::clone_deep(Compile* C) const { 557 JVMState* n = clone_shallow(C); 558 for (JVMState* p = n; p->_caller != NULL; p = p->_caller) { 559 p->_caller = p->_caller->clone_shallow(C); 560 } 561 assert(n->depth() == depth(), "sanity"); 562 assert(n->debug_depth() == debug_depth(), "sanity"); 563 return n; 564 } |