OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 visitor->checkGCInfo(const_cast<T*>(t), GCInfoTrait<T>::get()); | 600 visitor->checkGCInfo(const_cast<T*>(t), GCInfoTrait<T>::get()); |
601 } | 601 } |
602 #endif | 602 #endif |
603 }; | 603 }; |
604 | 604 |
605 template<typename T> | 605 template<typename T> |
606 class DefaultTraceTrait<T, true> { | 606 class DefaultTraceTrait<T, true> { |
607 public: | 607 public: |
608 static void mark(Visitor* visitor, const T* self) | 608 static void mark(Visitor* visitor, const T* self) |
609 { | 609 { |
610 if (self) | 610 if (!self) |
611 self->adjustAndMark(visitor); | 611 return; |
| 612 |
| 613 // Before doing adjustAndMark we need to check if the page is orphaned |
| 614 // since we cannot call adjustAndMark if so, as there will be no vtable. |
| 615 // If orphaned just mark the page as traced. |
| 616 BaseHeapPage* heapPage = pageHeaderFromObject(self); |
| 617 if (heapPage->orphaned()) { |
| 618 heapPage->setTracedAfterOrphaned(); |
| 619 return; |
| 620 } |
| 621 self->adjustAndMark(visitor); |
612 } | 622 } |
613 | 623 |
614 #ifndef NDEBUG | 624 #ifndef NDEBUG |
615 static void checkGCInfo(Visitor*, const T*) { } | 625 static void checkGCInfo(Visitor*, const T*) { } |
616 #endif | 626 #endif |
617 }; | 627 }; |
618 | 628 |
619 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultObjectAli
veTrait; | 629 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultObjectAli
veTrait; |
620 | 630 |
621 template<typename T> | 631 template<typename T> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 struct GCInfoTrait { | 743 struct GCInfoTrait { |
734 static const GCInfo* get() | 744 static const GCInfo* get() |
735 { | 745 { |
736 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 746 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
737 } | 747 } |
738 }; | 748 }; |
739 | 749 |
740 } | 750 } |
741 | 751 |
742 #endif | 752 #endif |
OLD | NEW |