| 664 | } |
| 665 | |
| 666 | void postCollect(Thread* t) |
| 667 | { |
| 668 | #ifdef VM_STRESS |
| 669 | t->m->heap->free(t->defaultHeap, ThreadHeapSizeInBytes); |
| 670 | t->defaultHeap |
| 671 | = static_cast<uintptr_t*>(t->m->heap->allocate(ThreadHeapSizeInBytes)); |
| 672 | memset(t->defaultHeap, 0, ThreadHeapSizeInBytes); |
| 673 | #endif |
| 674 | |
| 675 | if (t->heap == t->defaultHeap) { |
| 676 | memset(t->defaultHeap, 0, t->heapIndex * BytesPerWord); |
| 677 | } else { |
| 678 | memset(t->defaultHeap, 0, ThreadHeapSizeInBytes); |
| 679 | t->heap = t->defaultHeap; |
| 680 | } |
| 681 | |
| 682 | t->heapOffset = 0; |
| 683 | |
| 684 | if (t->m->heap->limitExceeded()) { |
| 685 | // if we're out of memory, pretend the thread-local heap is |
| 686 | // already full so we don't make things worse: |
| 687 | t->heapIndex = ThreadHeapSizeInWords; |
| 688 | } else { |
| 689 | t->heapIndex = 0; |
| 690 | } |
| 691 | |
| 692 | if (t->getFlags() & Thread::UseBackupHeapFlag) { |
| 693 | memset(t->backupHeap, 0, ThreadBackupHeapSizeInBytes); |
| 694 | |
| 695 | t->clearFlag(Thread::UseBackupHeapFlag); |
| 696 | t->backupHeapIndex = 0; |
| 697 | } |
| 698 | |
| 699 | for (Thread* c = t->child; c; c = c->peer) { |
| 700 | postCollect(c); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | uint64_t invoke(Thread* t, uintptr_t* arguments) |
| 705 | { |