| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 28 matching lines...) Expand all Loading... |
| 39 #include "wtf/ThreadRestrictionVerifier.h" | 39 #include "wtf/ThreadRestrictionVerifier.h" |
| 40 #include "wtf/Vector.h" | 40 #include "wtf/Vector.h" |
| 41 #include "wtf/text/AtomicString.h" | 41 #include "wtf/text/AtomicString.h" |
| 42 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 43 | 43 |
| 44 namespace WTF { | 44 namespace WTF { |
| 45 | 45 |
| 46 #if ENABLE(ASSERT) || ENABLE(SECURITY_ASSERT) | 46 #if ENABLE(ASSERT) || ENABLE(SECURITY_ASSERT) |
| 47 // The debug/assertion version may get bigger. | 47 // The debug/assertion version may get bigger. |
| 48 struct SameSizeAsRefCounted { | 48 struct SameSizeAsRefCounted { |
| 49 int a; | 49 int a; |
| 50 #if ENABLE(SECURITY_ASSERT) | 50 #if ENABLE(SECURITY_ASSERT) |
| 51 bool b; | 51 bool b; |
| 52 #endif | 52 #endif |
| 53 #if ENABLE(ASSERT) | 53 #if ENABLE(ASSERT) |
| 54 bool c; | 54 bool c; |
| 55 ThreadRestrictionVerifier d; | 55 ThreadRestrictionVerifier d; |
| 56 #endif | 56 #endif |
| 57 }; | 57 }; |
| 58 #else | 58 #else |
| 59 struct SameSizeAsRefCounted { | 59 struct SameSizeAsRefCounted { |
| 60 int a; | 60 int a; |
| 61 // Don't add anything here because this should stay small. | 61 // Don't add anything here because this should stay small. |
| 62 }; | 62 }; |
| 63 #endif | 63 #endif |
| 64 template<typename T, unsigned inlineCapacity = 0> | 64 template <typename T, unsigned inlineCapacity = 0> |
| 65 struct SameSizeAsVectorWithInlineCapacity; | 65 struct SameSizeAsVectorWithInlineCapacity; |
| 66 | 66 |
| 67 template<typename T> | 67 template <typename T> |
| 68 struct SameSizeAsVectorWithInlineCapacity<T, 0> { | 68 struct SameSizeAsVectorWithInlineCapacity<T, 0> { |
| 69 void* bufferPointer; | 69 void* bufferPointer; |
| 70 unsigned capacity; | 70 unsigned capacity; |
| 71 unsigned size; | 71 unsigned size; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 template<typename T, unsigned inlineCapacity> | 74 template <typename T, unsigned inlineCapacity> |
| 75 struct SameSizeAsVectorWithInlineCapacity { | 75 struct SameSizeAsVectorWithInlineCapacity { |
| 76 SameSizeAsVectorWithInlineCapacity<T, 0> baseCapacity; | 76 SameSizeAsVectorWithInlineCapacity<T, 0> baseCapacity; |
| 77 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) | 77 #if !defined(ANNOTATE_CONTIGUOUS_CONTAINER) |
| 78 AlignedBuffer<inlineCapacity * sizeof(T), WTF_ALIGN_OF(T)> inlineBuffer; | 78 AlignedBuffer<inlineCapacity * sizeof(T), WTF_ALIGN_OF(T)> inlineBuffer; |
| 79 #endif | 79 #endif |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 static_assert(sizeof(OwnPtr<int>) == sizeof(int*), "OwnPtr should stay small"); | 82 static_assert(sizeof(OwnPtr<int>) == sizeof(int*), "OwnPtr should stay small"); |
| 83 static_assert(sizeof(PassRefPtr<RefCounted<int>>) == sizeof(int*), "PassRefPtr s
hould stay small"); | 83 static_assert(sizeof(PassRefPtr<RefCounted<int>>) == sizeof(int*), "PassRefPtr s
hould stay small"); |
| 84 static_assert(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), "RefCount
ed should stay small"); | 84 static_assert(sizeof(RefCounted<int>) == sizeof(SameSizeAsRefCounted), "RefCount
ed should stay small"); |
| 85 static_assert(sizeof(RefPtr<RefCounted<int>>) == sizeof(int*), "RefPtr should st
ay small"); | 85 static_assert(sizeof(RefPtr<RefCounted<int>>) == sizeof(int*), "RefPtr should st
ay small"); |
| 86 static_assert(sizeof(String) == sizeof(int*), "String should stay small"); | 86 static_assert(sizeof(String) == sizeof(int*), "String should stay small"); |
| 87 static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString should stay
small"); | 87 static_assert(sizeof(AtomicString) == sizeof(String), "AtomicString should stay
small"); |
| 88 static_assert(sizeof(Vector<int>) == sizeof(SameSizeAsVectorWithInlineCapacity<i
nt>), "Vector should stay small"); | 88 static_assert(sizeof(Vector<int>) == sizeof(SameSizeAsVectorWithInlineCapacity<i
nt>), "Vector should stay small"); |
| 89 static_assert(sizeof(Vector<int, 1>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 1>), "Vector should stay small"); | 89 static_assert(sizeof(Vector<int, 1>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 1>), "Vector should stay small"); |
| 90 static_assert(sizeof(Vector<int, 2>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 2>), "Vector should stay small"); | 90 static_assert(sizeof(Vector<int, 2>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 2>), "Vector should stay small"); |
| 91 static_assert(sizeof(Vector<int, 3>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 3>), "Vector should stay small"); | 91 static_assert(sizeof(Vector<int, 3>) == sizeof(SameSizeAsVectorWithInlineCapacit
y<int, 3>), "Vector should stay small"); |
| 92 } | 92 } |
| OLD | NEW |