Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: Source/platform/heap/Heap.h

Issue 559733004: remove template c++11'ism in Heap.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove code duplication Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // FIXME: remove this once c++11 is allowed everywhere:
1108 template<typename T> static Address allocate(size_t);
1109
1107 template<typename T> static Address reallocate(void* previous, size_t); 1110 template<typename T> static Address reallocate(void* previous, size_t);
1108 1111
1109 static void collectGarbage(ThreadState::StackState); 1112 static void collectGarbage(ThreadState::StackState);
1110 static void collectGarbageForTerminatingThread(ThreadState*); 1113 static void collectGarbageForTerminatingThread(ThreadState*);
1111 static void collectAllGarbage(); 1114 static void collectAllGarbage();
1112 static void processMarkingStackEntries(int* numberOfMarkingThreads); 1115 static void processMarkingStackEntries(int* numberOfMarkingThreads);
1113 static void processMarkingStackOnMultipleThreads(); 1116 static void processMarkingStackOnMultipleThreads();
1114 static void processMarkingStackInParallel(); 1117 static void processMarkingStackInParallel();
1115 template<CallbackInvocationMode Mode> static void processMarkingStack(); 1118 template<CallbackInvocationMode Mode> static void processMarkingStack();
1116 static void postMarkingProcessing(); 1119 static void postMarkingProcessing();
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 { 1570 {
1568 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); 1571 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
1569 ASSERT(state->isAllocationAllowed()); 1572 ASSERT(state->isAllocationAllowed());
1570 const GCInfo* gcInfo = GCInfoTrait<T>::get(); 1573 const GCInfo* gcInfo = GCInfoTrait<T>::get();
1571 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer()); 1574 int heapIndex = HeapTraits::index(gcInfo->hasFinalizer());
1572 BaseHeap* heap = state->heap(heapIndex); 1575 BaseHeap* heap = state->heap(heapIndex);
1573 return static_cast<typename HeapTraits::HeapType*>(heap)->allocate(size, gcI nfo); 1576 return static_cast<typename HeapTraits::HeapType*>(heap)->allocate(size, gcI nfo);
1574 } 1577 }
1575 1578
1576 template<typename T> 1579 template<typename T>
1580 Address Heap::allocate(size_t size)
1581 {
1582 return allocate<T, HeapTypeTrait<T> >(size);
1583 }
1584
1585 template<typename T>
1577 Address Heap::reallocate(void* previous, size_t size) 1586 Address Heap::reallocate(void* previous, size_t size)
1578 { 1587 {
1579 if (!size) { 1588 if (!size) {
1580 // If the new size is 0 this is equivalent to either 1589 // If the new size is 0 this is equivalent to either
1581 // free(previous) or malloc(0). In both cases we do 1590 // free(previous) or malloc(0). In both cases we do
1582 // nothing and return 0. 1591 // nothing and return 0.
1583 return 0; 1592 return 0;
1584 } 1593 }
1585 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(); 1594 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
1586 ASSERT(state->isAllocationAllowed()); 1595 ASSERT(state->isAllocationAllowed());
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 }; 2577 };
2569 2578
2570 template<typename T> 2579 template<typename T>
2571 struct IfWeakMember<WeakMember<T> > { 2580 struct IfWeakMember<WeakMember<T> > {
2572 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); } 2581 static bool isDead(Visitor* visitor, const WeakMember<T>& t) { return !visit or->isAlive(t.get()); }
2573 }; 2582 };
2574 2583
2575 } 2584 }
2576 2585
2577 #endif // Heap_h 2586 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698