Chromium Code Reviews| 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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 // with the visitor and the closure pointer. Returns false when there is | 1096 // with the visitor and the closure pointer. Returns false when there is |
| 1097 // nothing more to do. | 1097 // nothing more to do. |
| 1098 static bool popAndInvokeWeakPointerCallback(Visitor*); | 1098 static bool popAndInvokeWeakPointerCallback(Visitor*); |
| 1099 | 1099 |
| 1100 // Register an ephemeron table for fixed-point iteration. | 1100 // Register an ephemeron table for fixed-point iteration. |
| 1101 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe meronCallback); | 1101 static void registerWeakTable(void* containerObject, EphemeronCallback, Ephe meronCallback); |
| 1102 #if ENABLE(ASSERT) | 1102 #if ENABLE(ASSERT) |
| 1103 static bool weakTableRegistered(const void*); | 1103 static bool weakTableRegistered(const void*); |
| 1104 #endif | 1104 #endif |
| 1105 | 1105 |
| 1106 template<typename T, typename HeapTraits = HeapTypeTrait<T> > static Address allocate(size_t); | 1106 template<typename T, typename HeapTraits> static Address allocate(size_t); |
| 1107 // TODO(mostynb) remove this once c++11 is allowed, in favour of the one | |
|
haraken
2014/09/10 00:51:10
TODO(mostynb) => FIXME
Mostyn Bramley-Moore
2014/09/10 08:09:16
Done.
| |
| 1108 // above: | |
| 1109 template<typename T> static Address allocate(size_t); | |
| 1110 | |
| 1107 template<typename T> static Address reallocate(void* previous, size_t); | 1111 template<typename T> static Address reallocate(void* previous, size_t); |
| 1108 | 1112 |
| 1109 static void collectGarbage(ThreadState::StackState); | 1113 static void collectGarbage(ThreadState::StackState); |
| 1110 static void collectGarbageForTerminatingThread(ThreadState*); | 1114 static void collectGarbageForTerminatingThread(ThreadState*); |
| 1111 static void collectAllGarbage(); | 1115 static void collectAllGarbage(); |
| 1112 static void processMarkingStackEntries(int* numberOfMarkingThreads); | 1116 static void processMarkingStackEntries(int* numberOfMarkingThreads); |
| 1113 static void processMarkingStackOnMultipleThreads(); | 1117 static void processMarkingStackOnMultipleThreads(); |
| 1114 static void processMarkingStackInParallel(); | 1118 static void processMarkingStackInParallel(); |
| 1115 template<CallbackInvocationMode Mode> static void processMarkingStack(); | 1119 template<CallbackInvocationMode Mode> static void processMarkingStack(); |
| 1116 static void postMarkingProcessing(); | 1120 static void postMarkingProcessing(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1566 Address Heap::allocate(size_t size) | 1570 Address Heap::allocate(size_t size) |
| 1567 { | 1571 { |
| 1568 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); | 1572 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); |
| 1569 ASSERT(state->isAllocationAllowed()); | 1573 ASSERT(state->isAllocationAllowed()); |
| 1570 const GCInfo* gcInfo = GCInfoTrait<T>::get(); | 1574 const GCInfo* gcInfo = GCInfoTrait<T>::get(); |
| 1571 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer()); | 1575 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer()); |
| 1572 BaseHeap* heap = state->heap(heapIndex); | 1576 BaseHeap* heap = state->heap(heapIndex); |
| 1573 return static_cast<typename HeapTraits::HeapType*>(heap)->allocate(size, gcI nfo); | 1577 return static_cast<typename HeapTraits::HeapType*>(heap)->allocate(size, gcI nfo); |
| 1574 } | 1578 } |
| 1575 | 1579 |
| 1580 // TODO(mostynb) remove this once c++11 is allowed, in favour of the one above: | |
|
haraken
2014/09/10 00:51:10
Ditto.
Mostyn Bramley-Moore
2014/09/10 08:09:16
Done.
| |
| 1581 template<typename T> | |
| 1582 Address Heap::allocate(size_t size) | |
| 1583 { | |
| 1584 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); | |
| 1585 ASSERT(state->isAllocationAllowed()); | |
| 1586 const GCInfo* gcInfo = GCInfoTrait<T>::get(); | |
| 1587 int heapIndex = HeapTypeTrait<T>::index(gcInfo->hasFinalizer()); | |
| 1588 BaseHeap* heap = state->heap(heapIndex); | |
| 1589 return static_cast<typename HeapTypeTrait<T>::HeapType*>(heap)->allocate(siz e, gcInfo); | |
| 1590 } | |
| 1591 | |
| 1576 template<typename T> | 1592 template<typename T> |
| 1577 Address Heap::reallocate(void* previous, size_t size) | 1593 Address Heap::reallocate(void* previous, size_t size) |
| 1578 { | 1594 { |
| 1579 if (!size) { | 1595 if (!size) { |
| 1580 // If the new size is 0 this is equivalent to either | 1596 // If the new size is 0 this is equivalent to either |
| 1581 // free(previous) or malloc(0). In both cases we do | 1597 // free(previous) or malloc(0). In both cases we do |
| 1582 // nothing and return 0. | 1598 // nothing and return 0. |
| 1583 return 0; | 1599 return 0; |
| 1584 } | 1600 } |
| 1585 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); | 1601 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2568 }; | 2584 }; |
| 2569 | 2585 |
| 2570 template<typename T> | 2586 template<typename T> |
| 2571 struct IfWeakMember<WeakMember<T> > { | 2587 struct IfWeakMember<WeakMember<T> > { |
| 2572 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); } | 2588 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); } |
| 2573 }; | 2589 }; |
| 2574 | 2590 |
| 2575 } | 2591 } |
| 2576 | 2592 |
| 2577 #endif // Heap_h | 2593 #endif // Heap_h |
| OLD | NEW |