Skip to content

Commit

Permalink
Merge r180814 - Remove unused PossiblyNull
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=142124

Reviewed by Andreas Kling.

* WTF.vcxproj/WTF.vcxproj: Removed the file.
* WTF.vcxproj/WTF.vcxproj.filters: Ditto.
* WTF.xcodeproj/project.pbxproj: Ditto.
* wtf/CMakeLists.txt: Ditto.
* wtf/PossiblyNull.h: Removed.

* wtf/FastMalloc.h: Moved everything to the left.
Moved member functions out of the TryMallocReturnValue class definition.
(WTF::TryMallocReturnValue::operator PossiblyNull<T>): Deleted.
(WTF::TryMallocReturnValue::getValue): Marked inline, changed to work
only with pointer types, not arbitrary non-pointer types.
  • Loading branch information
darinadler authored and carlosgcampos committed Mar 11, 2015
1 parent f1eda77 commit 30c1c6b
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 137 deletions.
19 changes: 19 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,22 @@
2015-02-27 Darin Adler <darin@apple.com>

Remove unused PossiblyNull
https://bugs.webkit.org/show_bug.cgi?id=142124

Reviewed by Andreas Kling.

* WTF.vcxproj/WTF.vcxproj: Removed the file.
* WTF.vcxproj/WTF.vcxproj.filters: Ditto.
* WTF.xcodeproj/project.pbxproj: Ditto.
* wtf/CMakeLists.txt: Ditto.
* wtf/PossiblyNull.h: Removed.

* wtf/FastMalloc.h: Moved everything to the left.
Moved member functions out of the TryMallocReturnValue class definition.
(WTF::TryMallocReturnValue::operator PossiblyNull<T>): Deleted.
(WTF::TryMallocReturnValue::getValue): Marked inline, changed to work
only with pointer types, not arbitrary non-pointer types.

2015-03-09 Mark Lam <mark.lam@apple.com>

8-bit version of weakCompareAndSwap() can cause an infinite loop.
Expand Down
3 changes: 1 addition & 2 deletions Source/WTF/WTF.vcxproj/WTF.vcxproj
Expand Up @@ -253,7 +253,6 @@
<ClInclude Include="..\wtf\PassRef.h" />
<ClInclude Include="..\wtf\PassRefPtr.h" />
<ClInclude Include="..\wtf\Platform.h" />
<ClInclude Include="..\wtf\PossiblyNull.h" />
<ClInclude Include="..\wtf\PrintStream.h" />
<ClInclude Include="..\wtf\RAMSize.h" />
<ClInclude Include="..\wtf\RandomNumber.h" />
Expand Down Expand Up @@ -776,4 +775,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
5 changes: 1 addition & 4 deletions Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
Expand Up @@ -567,9 +567,6 @@
<ClInclude Include="..\wtf\Platform.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\PossiblyNull.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\PrintStream.h">
<Filter>wtf</Filter>
</ClInclude>
Expand Down Expand Up @@ -733,4 +730,4 @@
<None Include="WTFPostBuild.cmd" />
<None Include="WTFPreBuild.cmd" />
</ItemGroup>
</Project>
</Project>
4 changes: 0 additions & 4 deletions Source/WTF/WTF.xcodeproj/project.pbxproj
Expand Up @@ -199,7 +199,6 @@
A8A47408151A825B004123FF /* ParallelJobsLibdispatch.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472E9151A825B004123FF /* ParallelJobsLibdispatch.h */; };
A8A4740B151A825B004123FF /* PassOwnPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472EC151A825B004123FF /* PassOwnPtr.h */; };
A8A4740C151A825B004123FF /* PassRefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472ED151A825B004123FF /* PassRefPtr.h */; };
A8A4740F151A825B004123FF /* PossiblyNull.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472F3151A825B004123FF /* PossiblyNull.h */; };
A8A47414151A825B004123FF /* RandomNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472FB151A825B004123FF /* RandomNumber.cpp */; };
A8A47415151A825B004123FF /* RandomNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472FC151A825B004123FF /* RandomNumber.h */; };
A8A47416151A825B004123FF /* RandomNumberSeed.h in Headers */ = {isa = PBXBuildFile; fileRef = A8A472FD151A825B004123FF /* RandomNumberSeed.h */; };
Expand Down Expand Up @@ -495,7 +494,6 @@
A8A472E9151A825B004123FF /* ParallelJobsLibdispatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParallelJobsLibdispatch.h; sourceTree = "<group>"; };
A8A472EC151A825B004123FF /* PassOwnPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassOwnPtr.h; sourceTree = "<group>"; };
A8A472ED151A825B004123FF /* PassRefPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PassRefPtr.h; sourceTree = "<group>"; };
A8A472F3151A825B004123FF /* PossiblyNull.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PossiblyNull.h; sourceTree = "<group>"; };
A8A472FB151A825B004123FF /* RandomNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomNumber.cpp; sourceTree = "<group>"; };
A8A472FC151A825B004123FF /* RandomNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomNumber.h; sourceTree = "<group>"; };
A8A472FD151A825B004123FF /* RandomNumberSeed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RandomNumberSeed.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -822,7 +820,6 @@
93B1AA7F180E5AF3004A2F05 /* PassRef.h */,
A8A472ED151A825B004123FF /* PassRefPtr.h */,
A876DBD7151816E500DADB95 /* Platform.h */,
A8A472F3151A825B004123FF /* PossiblyNull.h */,
0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
0F9D335E165DBA73005AD387 /* PrintStream.h */,
0FC4488216FE9FE100844BE9 /* ProcessID.h */,
Expand Down Expand Up @@ -1153,7 +1150,6 @@
A8A4740B151A825B004123FF /* PassOwnPtr.h in Headers */,
A8A4740C151A825B004123FF /* PassRefPtr.h in Headers */,
A876DBD8151816E500DADB95 /* Platform.h in Headers */,
A8A4740F151A825B004123FF /* PossiblyNull.h in Headers */,
0FB14E19180FA218009B6B4D /* Bag.h in Headers */,
0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */,
0FC4488316FE9FE100844BE9 /* ProcessID.h in Headers */,
Expand Down
1 change: 0 additions & 1 deletion Source/WTF/wtf/CMakeLists.txt
Expand Up @@ -71,7 +71,6 @@ set(WTF_HEADERS
PassRef.h
PassRefPtr.h
Platform.h
PossiblyNull.h
PrintStream.h
ProcessID.h
RAMSize.h
Expand Down
136 changes: 69 additions & 67 deletions Source/WTF/wtf/FastMalloc.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2005-2009, 2015 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand All @@ -23,76 +23,78 @@

#include <new>
#include <stdlib.h>
#include <wtf/PossiblyNull.h>
#include <wtf/StdLibExtras.h>

namespace WTF {

// These functions call CRASH() if an allocation fails.
WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
WTF_EXPORT_PRIVATE char* fastStrDup(const char*);
WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);

// Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
WTF_EXPORT_PRIVATE void fastAlignedFree(void*);

struct TryMallocReturnValue {
TryMallocReturnValue(void* data)
: m_data(data)
{
}
TryMallocReturnValue(const TryMallocReturnValue& source)
: m_data(source.m_data)
{
source.m_data = 0;
}
~TryMallocReturnValue() { ASSERT(!m_data); }
template <typename T> bool getValue(T& data) WARN_UNUSED_RETURN;
template <typename T> operator PossiblyNull<T>()
{
T value;
getValue(value);
return PossiblyNull<T>(value);
}
private:
mutable void* m_data;
};

template <typename T> bool TryMallocReturnValue::getValue(T& data)
{
union u { void* data; T target; } res;
res.data = m_data;
data = res.target;
bool returnValue = !!m_data;
m_data = 0;
return returnValue;
}

WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t n);
TryMallocReturnValue tryFastZeroedMalloc(size_t n);
WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size);
WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastRealloc(void* p, size_t n);

WTF_EXPORT_PRIVATE void fastFree(void*);

WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemory();
WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemoryForThisThread();

struct FastMallocStatistics {
size_t reservedVMBytes;
size_t committedVMBytes;
size_t freeListBytes;
};
WTF_EXPORT_PRIVATE FastMallocStatistics fastMallocStatistics();

// This defines a type which holds an unsigned integer and is the same
// size as the minimally aligned memory allocation.
typedef unsigned long long AllocAlignmentInteger;
class TryMallocReturnValue {
public:
TryMallocReturnValue(void*);
TryMallocReturnValue(TryMallocReturnValue&&);
~TryMallocReturnValue();
template<typename T> bool getValue(T*&) WARN_UNUSED_RETURN;
private:
void operator=(TryMallocReturnValue&&) = delete;
mutable void* m_data;
};

// These functions call CRASH() if an allocation fails.
WTF_EXPORT_PRIVATE void* fastMalloc(size_t);
WTF_EXPORT_PRIVATE void* fastZeroedMalloc(size_t);
WTF_EXPORT_PRIVATE void* fastCalloc(size_t numElements, size_t elementSize);
WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t);
WTF_EXPORT_PRIVATE char* fastStrDup(const char*);

WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t);
TryMallocReturnValue tryFastZeroedMalloc(size_t);
WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastCalloc(size_t numElements, size_t elementSize);
WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastRealloc(void*, size_t);

WTF_EXPORT_PRIVATE void fastFree(void*);

// Allocations from fastAlignedMalloc() must be freed using fastAlignedFree().
WTF_EXPORT_PRIVATE void* fastAlignedMalloc(size_t alignment, size_t);
WTF_EXPORT_PRIVATE void fastAlignedFree(void*);

WTF_EXPORT_PRIVATE size_t fastMallocSize(const void*);
WTF_EXPORT_PRIVATE size_t fastMallocGoodSize(size_t);

WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemory();
WTF_EXPORT_PRIVATE void releaseFastMallocFreeMemoryForThisThread();

struct FastMallocStatistics {
size_t reservedVMBytes;
size_t committedVMBytes;
size_t freeListBytes;
};
WTF_EXPORT_PRIVATE FastMallocStatistics fastMallocStatistics();

// This defines a type which holds an unsigned integer and is the same
// size as the minimally aligned memory allocation.
typedef unsigned long long AllocAlignmentInteger;

inline TryMallocReturnValue::TryMallocReturnValue(void* data)
: m_data(data)
{
}

inline TryMallocReturnValue::TryMallocReturnValue(TryMallocReturnValue&& source)
: m_data(source.m_data)
{
source.m_data = nullptr;
}

inline TryMallocReturnValue::~TryMallocReturnValue()
{
ASSERT(!m_data);
}

template<typename T> inline bool TryMallocReturnValue::getValue(T*& data)
{
data = static_cast<T*>(m_data);
m_data = nullptr;
return data;
}

} // namespace WTF

Expand Down
59 changes: 0 additions & 59 deletions Source/WTF/wtf/PossiblyNull.h

This file was deleted.

0 comments on commit 30c1c6b

Please sign in to comment.