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

Side by Side Diff: Source/wtf/DefaultAllocator.h

Issue 177213007: Simplify DefaultAllocator::Quantizer using partitionAllocActualSize() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased + adjusted PurgeableVector test Created 6 years, 10 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 | « Source/platform/PurgeableVectorTest.cpp ('k') | Source/wtf/QuantizedAllocation.h » ('j') | 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 20 matching lines...) Expand all
31 #ifndef WTF_DefaultAllocator_h 31 #ifndef WTF_DefaultAllocator_h
32 #define WTF_DefaultAllocator_h 32 #define WTF_DefaultAllocator_h
33 33
34 // This is the allocator that is used for allocations that are not on the 34 // This is the allocator that is used for allocations that are not on the
35 // traced, garbage collected heap. It uses FastMalloc for collections, 35 // traced, garbage collected heap. It uses FastMalloc for collections,
36 // but uses the partition allocator for the backing store of the collections. 36 // but uses the partition allocator for the backing store of the collections.
37 37
38 #include "wtf/Assertions.h" 38 #include "wtf/Assertions.h"
39 #include "wtf/FastAllocBase.h" 39 #include "wtf/FastAllocBase.h"
40 #include "wtf/PartitionAlloc.h" 40 #include "wtf/PartitionAlloc.h"
41 #include "wtf/QuantizedAllocation.h"
42 #include "wtf/WTF.h" 41 #include "wtf/WTF.h"
43 42
44 #include <string.h> 43 #include <string.h>
45 44
46 namespace WTF { 45 namespace WTF {
47 46
48 class DefaultAllocatorDummyVisitor; 47 class DefaultAllocatorDummyVisitor;
49 48
49 class DefaultAllocatorQuantizer {
50 public:
51 template<typename T>
52 static size_t quantizedSize(size_t count)
53 {
54 RELEASE_ASSERT(count <= kMaxUnquantizedAllocation / sizeof(T));
55 return partitionAllocActualSize(Partitions::getBufferPartition(), count * sizeof(T));
56 }
57 static const size_t kMaxUnquantizedAllocation = kGenericMaxDirectMapped;
58 };
59
50 class DefaultAllocator { 60 class DefaultAllocator {
51 public: 61 public:
52 typedef WTF::QuantizedAllocation Quantizer; 62 typedef DefaultAllocatorQuantizer Quantizer;
53 typedef DefaultAllocatorDummyVisitor Visitor; 63 typedef DefaultAllocatorDummyVisitor Visitor;
54 static const bool isGarbageCollected = false; 64 static const bool isGarbageCollected = false;
55 template<typename T, typename Traits> 65 template<typename T, typename Traits>
56 struct VectorBackingHelper { 66 struct VectorBackingHelper {
57 typedef void Type; 67 typedef void Type;
58 }; 68 };
59 template<typename T, typename U, typename V, typename W, typename X> 69 template<typename T, typename U, typename V, typename W, typename X>
60 struct HashTableBackingHelper { 70 struct HashTableBackingHelper {
61 typedef void Type; 71 typedef void Type;
62 }; 72 };
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 ASSERT_NOT_REACHED(); 143 ASSERT_NOT_REACHED();
134 return false; 144 return false;
135 } 145 }
136 }; 146 };
137 147
138 } // namespace WTF 148 } // namespace WTF
139 149
140 using WTF::DefaultAllocator; 150 using WTF::DefaultAllocator;
141 151
142 #endif // WTF_DefaultAllocator_h 152 #endif // WTF_DefaultAllocator_h
OLDNEW
« no previous file with comments | « Source/platform/PurgeableVectorTest.cpp ('k') | Source/wtf/QuantizedAllocation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698