comparison agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @ 13431:a4f036ef52e8

8029395: SA: jstack throws WrongTypeException Summary: SA missed some TLABs Reviewed-by: dsamersoff, mgerdin, brutisso
author sla
date Wed, 04 Dec 2013 14:43:50 +0100
parents 49618582fc5b
children de6a9e811145
comparison
equal deleted inserted replaced
13430:9a60f4ac6a37 13431:a4f036ef52e8
362 } 362 }
363 } 363 }
364 } 364 }
365 catch (AddressException e) { 365 catch (AddressException e) {
366 // This is okay at the top of these regions 366 // This is okay at the top of these regions
367 } 367 }
368 catch (UnknownOopException e) { 368 catch (UnknownOopException e) {
369 // This is okay at the top of these regions 369 // This is okay at the top of these regions
370 } 370 }
371 } 371 }
372 372
373 visitor.epilogue(); 373 visitor.epilogue();
374 } 374 }
375 375
376 private void addLiveRegions(List input, List output) { 376 private void addLiveRegions(String name, List input, List output) {
377 for (Iterator itr = input.iterator(); itr.hasNext();) { 377 for (Iterator itr = input.iterator(); itr.hasNext();) {
378 MemRegion reg = (MemRegion) itr.next(); 378 MemRegion reg = (MemRegion) itr.next();
379 Address top = reg.end(); 379 Address top = reg.end();
380 Address bottom = reg.start(); 380 Address bottom = reg.start();
381 if (Assert.ASSERTS_ENABLED) { 381 if (Assert.ASSERTS_ENABLED) {
384 if (Assert.ASSERTS_ENABLED) { 384 if (Assert.ASSERTS_ENABLED) {
385 Assert.that(bottom != null, "bottom address in a live region should not be null"); 385 Assert.that(bottom != null, "bottom address in a live region should not be null");
386 } 386 }
387 output.add(top); 387 output.add(top);
388 output.add(bottom); 388 output.add(bottom);
389 if (DEBUG) {
390 System.err.println("Live region: " + name + ": " + bottom + ", " + top);
391 }
389 } 392 }
390 } 393 }
391 394
392 private class LiveRegionsCollector implements SpaceClosure { 395 private class LiveRegionsCollector implements SpaceClosure {
393 LiveRegionsCollector(List l) { 396 LiveRegionsCollector(List l) {
394 liveRegions = l; 397 liveRegions = l;
395 } 398 }
396 399
397 public void doSpace(Space s) { 400 public void doSpace(Space s) {
398 addLiveRegions(s.getLiveRegions(), liveRegions); 401 addLiveRegions(s.toString(), s.getLiveRegions(), liveRegions);
399 } 402 }
400 private List liveRegions; 403 private List liveRegions;
401 } 404 }
402 405
403 // Returns a List<Address> where the addresses come in pairs. These 406 // Returns a List<Address> where the addresses come in pairs. These
424 } 427 }
425 } else if (heap instanceof ParallelScavengeHeap) { 428 } else if (heap instanceof ParallelScavengeHeap) {
426 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap; 429 ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
427 PSYoungGen youngGen = psh.youngGen(); 430 PSYoungGen youngGen = psh.youngGen();
428 // Add eden space 431 // Add eden space
429 addLiveRegions(youngGen.edenSpace().getLiveRegions(), liveRegions); 432 addLiveRegions("eden", youngGen.edenSpace().getLiveRegions(), liveRegions);
430 // Add from-space but not to-space 433 // Add from-space but not to-space
431 addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions); 434 addLiveRegions("from", youngGen.fromSpace().getLiveRegions(), liveRegions);
432 PSOldGen oldGen = psh.oldGen(); 435 PSOldGen oldGen = psh.oldGen();
433 addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions); 436 addLiveRegions("old ", oldGen.objectSpace().getLiveRegions(), liveRegions);
434 } else if (heap instanceof G1CollectedHeap) { 437 } else if (heap instanceof G1CollectedHeap) {
435 G1CollectedHeap g1h = (G1CollectedHeap) heap; 438 G1CollectedHeap g1h = (G1CollectedHeap) heap;
436 g1h.heapRegionIterate(lrc); 439 g1h.heapRegionIterate(lrc);
437 } else { 440 } else {
438 if (Assert.ASSERTS_ENABLED) { 441 if (Assert.ASSERTS_ENABLED) {
449 // Theoretically only need to stop at TLAB's top and resume at its 452 // Theoretically only need to stop at TLAB's top and resume at its
450 // end. 453 // end.
451 454
452 if (VM.getVM().getUseTLAB()) { 455 if (VM.getVM().getUseTLAB()) {
453 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) { 456 for (JavaThread thread = VM.getVM().getThreads().first(); thread != null; thread = thread.next()) {
454 if (thread.isJavaThread()) { 457 ThreadLocalAllocBuffer tlab = thread.tlab();
455 ThreadLocalAllocBuffer tlab = thread.tlab(); 458 if (tlab.start() != null) {
456 if (tlab.start() != null) { 459 if ((tlab.top() == null) || (tlab.end() == null)) {
457 if ((tlab.top() == null) || (tlab.end() == null)) { 460 System.err.print("Warning: skipping invalid TLAB for thread ");
458 System.err.print("Warning: skipping invalid TLAB for thread "); 461 thread.printThreadIDOn(System.err);
462 System.err.println();
463 } else {
464 if (DEBUG) {
465 System.err.print("TLAB for " + thread.getThreadName() + ", #");
459 thread.printThreadIDOn(System.err); 466 thread.printThreadIDOn(System.err);
460 System.err.println(); 467 System.err.print(": ");
461 } else { 468 tlab.printOn(System.err);
462 // Go from:
463 // - below start() to start()
464 // - start() to top()
465 // - end() and above
466 liveRegions.add(tlab.start());
467 liveRegions.add(tlab.start());
468 liveRegions.add(tlab.top());
469 liveRegions.add(tlab.hardEnd());
470 } 469 }
470 // Go from:
471 // - below start() to start()
472 // - start() to top()
473 // - end() and above
474 liveRegions.add(tlab.start());
475 liveRegions.add(tlab.start());
476 liveRegions.add(tlab.top());
477 liveRegions.add(tlab.hardEnd());
471 } 478 }
472 } 479 }
473 } 480 }
474 } 481 }
475 482
476 // Now sort live regions 483 // Now sort live regions
477 sortLiveRegions(liveRegions); 484 sortLiveRegions(liveRegions);
478 485
479 if (Assert.ASSERTS_ENABLED) { 486 if (Assert.ASSERTS_ENABLED) {
480 Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries"); 487 Assert.that(liveRegions.size() % 2 == 0, "Must have even number of region boundaries");
488 }
489
490 if (DEBUG) {
491 System.err.println("liveRegions:");
492 for (int i = 0; i < liveRegions.size(); i += 2) {
493 Address bottom = (Address) liveRegions.get(i);
494 Address top = (Address) liveRegions.get(i+1);
495 System.err.println(" " + bottom + " - " + top);
496 }
481 } 497 }
482 498
483 return liveRegions; 499 return liveRegions;
484 } 500 }
485 501