Index: base/allocator/partition_allocator/partitions.cc |
diff --git a/third_party/WebKit/Source/wtf/allocator/Partitions.cpp b/base/allocator/partition_allocator/partitions.cc |
similarity index 63% |
rename from third_party/WebKit/Source/wtf/allocator/Partitions.cpp |
rename to base/allocator/partition_allocator/partitions.cc |
index 5b31dcfbeaeeafef7018b6932bc9adfa196233c3..d87c8e0aac43f3d0c52872979f959866983b0061 100644 |
--- a/third_party/WebKit/Source/wtf/allocator/Partitions.cpp |
+++ b/base/allocator/partition_allocator/partitions.cc |
@@ -1,44 +1,19 @@ |
-/* |
- * Copyright (C) 2013 Google Inc. All rights reserved. |
- * |
- * Redistribution and use in source and binary forms, with or without |
- * modification, are permitted provided that the following conditions are |
- * met: |
- * |
- * * Redistributions of source code must retain the above copyright |
- * notice, this list of conditions and the following disclaimer. |
- * * Redistributions in binary form must reproduce the above |
- * copyright notice, this list of conditions and the following disclaimer |
- * in the documentation and/or other materials provided with the |
- * distribution. |
- * * Neither the name of Google Inc. nor the names of its |
- * contributors may be used to endorse or promote products derived from |
- * this software without specific prior written permission. |
- * |
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-#include "wtf/allocator/Partitions.h" |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#include "base/allocator/partition_allocator/partitions.h" |
+ |
+#include "base/allocator/partition_allocator/partition_allocator.h" |
+#include "base/compiler_specific.h" |
#include "base/debug/alias.h" |
-#include "wtf/allocator/PartitionAllocator.h" |
-namespace WTF { |
+namespace base { |
const char* const Partitions::kAllocatedObjectPoolName = |
"partition_alloc/allocated_objects"; |
-SpinLock Partitions::s_initializationLock; |
+subtle::SpinLock Partitions::s_initializationLock; |
bool Partitions::s_initialized = false; |
PartitionAllocatorGeneric Partitions::m_fastMallocAllocator; |
@@ -49,7 +24,7 @@ Partitions::ReportPartitionAllocSizeFunction Partitions::m_reportSizeFunction = |
void Partitions::initialize( |
ReportPartitionAllocSizeFunction reportSizeFunction) { |
- SpinLock::Guard guard(s_initializationLock); |
+ subtle::SpinLock::Guard guard(s_initializationLock); |
if (!s_initialized) { |
partitionAllocGlobalInit(&Partitions::handleOutOfMemory); |
@@ -62,10 +37,10 @@ void Partitions::initialize( |
} |
void Partitions::shutdown() { |
- SpinLock::Guard guard(s_initializationLock); |
+ subtle::SpinLock::Guard guard(s_initializationLock); |
- // We could ASSERT here for a memory leak within the partition, but it leads |
- // to very hard to diagnose ASSERTs, so it's best to leave leak checking for |
+ // We could DCHECK here for a memory leak within the partition, but it leads |
+ // to very hard to diagnose DCHECK, so it's best to leave leak checking for |
// the valgrind and heapcheck bots, which run without partitions. |
if (s_initialized) { |
(void)m_layoutAllocator.shutdown(); |
@@ -75,7 +50,7 @@ void Partitions::shutdown() { |
} |
void Partitions::decommitFreeableMemory() { |
- RELEASE_ASSERT(isMainThread()); |
+ CHECK(isMainThread()); |
if (!s_initialized) |
return; |
@@ -106,7 +81,7 @@ void Partitions::dumpMemoryStats(bool isLightDump, |
PartitionStatsDumper* partitionStatsDumper) { |
// Object model and rendering partitions are not thread safe and can be |
// accessed only on the main thread. |
- ASSERT(isMainThread()); |
+ DCHECK(isMainThread()); |
decommitFreeableMemory(); |
partitionDumpStatsGeneric(fastMallocPartition(), "fast_malloc", isLightDump, |
@@ -117,55 +92,55 @@ void Partitions::dumpMemoryStats(bool isLightDump, |
partitionStatsDumper); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing2G() { |
+static NOINLINE void partitionsOutOfMemoryUsing2G() { |
size_t signature = 2UL * 1024 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing1G() { |
+static NOINLINE void partitionsOutOfMemoryUsing1G() { |
size_t signature = 1UL * 1024 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing512M() { |
+static NOINLINE void partitionsOutOfMemoryUsing512M() { |
size_t signature = 512 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing256M() { |
+static NOINLINE void partitionsOutOfMemoryUsing256M() { |
size_t signature = 256 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing128M() { |
+static NOINLINE void partitionsOutOfMemoryUsing128M() { |
size_t signature = 128 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing64M() { |
+static NOINLINE void partitionsOutOfMemoryUsing64M() { |
size_t signature = 64 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing32M() { |
+static NOINLINE void partitionsOutOfMemoryUsing32M() { |
size_t signature = 32 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsing16M() { |
+static NOINLINE void partitionsOutOfMemoryUsing16M() { |
size_t signature = 16 * 1024 * 1024; |
base::debug::Alias(&signature); |
OOM_CRASH(); |
} |
-static NEVER_INLINE void partitionsOutOfMemoryUsingLessThan16M() { |
+static NOINLINE void partitionsOutOfMemoryUsingLessThan16M() { |
size_t signature = 16 * 1024 * 1024 - 1; |
base::debug::Alias(&signature); |
DLOG(FATAL) << "ParitionAlloc: out of memory with < 16M usage (error:" |
@@ -196,4 +171,4 @@ void Partitions::handleOutOfMemory() { |
partitionsOutOfMemoryUsingLessThan16M(); |
} |
-} // namespace WTF |
+} // namespace base |