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

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

Issue 251163002: Deinline PartitionAlloc from DefaultAllocator to reduce code size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@dummy
Patch Set: fix linking by properly exporting symbols Created 6 years, 7 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 | Source/wtf/DefaultAllocator.cpp » ('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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 struct VectorBackingHelper { 66 struct VectorBackingHelper {
67 typedef void Type; 67 typedef void Type;
68 }; 68 };
69 template<typename T> 69 template<typename T>
70 struct HashTableBackingHelper { 70 struct HashTableBackingHelper {
71 typedef void Type; 71 typedef void Type;
72 }; 72 };
73 template <typename Return, typename Metadata> 73 template <typename Return, typename Metadata>
74 static Return backingMalloc(size_t size) 74 static Return backingMalloc(size_t size)
75 { 75 {
76 return reinterpret_cast<Return>(partitionAllocGeneric(Partitions::getBuf ferPartition(), size)); 76 return reinterpret_cast<Return>(backingAllocate(size));
77 } 77 }
78 template <typename Return, typename Metadata> 78 template <typename Return, typename Metadata>
79 static Return zeroedBackingMalloc(size_t size) 79 static Return zeroedBackingMalloc(size_t size)
80 { 80 {
81 void* result = partitionAllocGeneric(Partitions::getBufferPartition(), s ize); 81 void* result = backingAllocate(size);
82 memset(result, 0, size); 82 memset(result, 0, size);
83 return reinterpret_cast<Return>(result); 83 return reinterpret_cast<Return>(result);
84 } 84 }
85 template <typename Return, typename Metadata> 85 template <typename Return, typename Metadata>
86 static Return malloc(size_t size) 86 static Return malloc(size_t size)
87 { 87 {
88 return reinterpret_cast<Return>(fastMalloc(size)); 88 return reinterpret_cast<Return>(fastMalloc(size));
89 } 89 }
90 static void backingFree(void* address) 90 WTF_EXPORT static void backingFree(void* address);
91 {
92 partitionFreeGeneric(Partitions::getBufferPartition(), address);
93 }
94 static void free(void* address) 91 static void free(void* address)
95 { 92 {
96 fastFree(address); 93 fastFree(address);
97 } 94 }
98 template<typename T> 95 template<typename T>
99 static void* newArray(size_t bytes) 96 static void* newArray(size_t bytes)
100 { 97 {
101 return malloc<void*, void>(bytes); 98 return malloc<void*, void>(bytes);
102 } 99 }
103 static void 100 static void
(...skipping 21 matching lines...) Expand all
125 template<typename T> 122 template<typename T>
126 struct OtherType { 123 struct OtherType {
127 typedef T* Type; 124 typedef T* Type;
128 }; 125 };
129 126
130 template<typename T> 127 template<typename T>
131 static T& getOther(T* other) 128 static T& getOther(T* other)
132 { 129 {
133 return *other; 130 return *other;
134 } 131 }
132
133 private:
134 WTF_EXPORT static void* backingAllocate(size_t);
135 }; 135 };
136 136
137 // The Windows compiler seems to be very eager to instantiate things it won't 137 // The Windows compiler seems to be very eager to instantiate things it won't
138 // need, so unless we have this class we get compile errors. 138 // need, so unless we have this class we get compile errors.
139 class DefaultAllocatorDummyVisitor { 139 class DefaultAllocatorDummyVisitor {
140 public: 140 public:
141 template<typename T> inline bool isAlive(T obj) 141 template<typename T> inline bool isAlive(T obj)
142 { 142 {
143 ASSERT_NOT_REACHED(); 143 ASSERT_NOT_REACHED();
144 return false; 144 return false;
(...skipping 15 matching lines...) Expand all
160 { \ 160 { \
161 ASSERT(location); \ 161 ASSERT(location); \
162 return location; \ 162 return location; \
163 } \ 163 } \
164 private: \ 164 private: \
165 typedef int __thisIsHereToForceASemicolonAfterThisMacro 165 typedef int __thisIsHereToForceASemicolonAfterThisMacro
166 166
167 using WTF::DefaultAllocator; 167 using WTF::DefaultAllocator;
168 168
169 #endif // WTF_DefaultAllocator_h 169 #endif // WTF_DefaultAllocator_h
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/DefaultAllocator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698