-#define DEFINE_HEAP_INDEX_TRAIT(Type) \
- class Type; \
- template<> \
- struct HeapTrait<class Type> { \
- static const int index = Type##Heap; \
- typedef ThreadHeap<HeapObjectHeader> HeapType; \
- };
+// HeapIndexTrait defines properties for each heap in the TypesHeaps enum.
+template<int index>
+struct HeapIndexTrait;
+
+template<>
+struct HeapIndexTrait<GeneralHeap> : public HeapIndexTraitBase<GeneralHeap> { };
+template<>
+struct HeapIndexTrait<GeneralHeapNonFinalized> : public HeapIndexTrait<GeneralHeap> { };
+
+template<>
+struct HeapIndexTrait<CollectionBackingHeap> : public HeapIndexTraitBase<CollectionBackingHeap> { };
+template<>
+struct HeapIndexTrait<CollectionBackingHeapNonFinalized> : public HeapIndexTrait<CollectionBackingHeap> { };
+
+#define DEFINE_TYPED_HEAP_INDEX_TRAIT(Type) \
+ template<> \
+ struct HeapIndexTrait<Type##Heap> : public HeapIndexTraitBase<Type##Heap> { \
+ typedef HeapObjectHeader HeaderType; \
+ typedef ThreadHeap<HeaderType> HeapType; \
+ }; \
+ template<> \
+ struct HeapIndexTrait<Type##HeapNonFinalized> : public HeapIndexTrait<Type##Heap> { };
+FOR_EACH_TYPED_HEAP(DEFINE_TYPED_HEAP_INDEX_TRAIT)
+#undef DEFINE_TYPED_HEAP_INDEX_TRAIT
+
+// HeapTypeTrait defines which heap to use for particular types.
+// By default objects are allocated in the GeneralHeap.
+template<typename T>
+struct HeapTypeTrait : public HeapIndexTrait<GeneralHeap> { };
+
+// We don't have any type-based mappings to the CollectionBackingHeap.