OLD | NEW |
---|---|
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 // list in the next addToFreeList(). | 71 // list in the next addToFreeList(). |
72 const uint8_t reuseAllowedZapValue = 0x2a; | 72 const uint8_t reuseAllowedZapValue = 0x2a; |
73 // A zap value used for freed memory that is forbidden to be added to the free | 73 // A zap value used for freed memory that is forbidden to be added to the free |
74 // list in the next addToFreeList(). | 74 // list in the next addToFreeList(). |
75 const uint8_t reuseForbiddenZapValue = 0x2c; | 75 const uint8_t reuseForbiddenZapValue = 0x2c; |
76 | 76 |
77 // In non-production builds, memory is zapped when it's freed. The zapped | 77 // In non-production builds, memory is zapped when it's freed. The zapped |
78 // memory is zeroed out when the memory is reused in Heap::allocateObject(). | 78 // memory is zeroed out when the memory is reused in Heap::allocateObject(). |
79 // In production builds, memory is not zapped (for performance). The memory | 79 // In production builds, memory is not zapped (for performance). The memory |
80 // is just zeroed out when it is added to the free list. | 80 // is just zeroed out when it is added to the free list. |
81 #if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | 81 #if defined(MEMORY_SANITIZER) |
82 #define SET_MEMORY_INACCESSIBLE(address, size) \ | |
83 FreeList::zapFreedMemory(address, size); | |
Alexander Potapenko
2015/07/29 13:39:42
Please add a TODO here indicating that we actually
kojii
2015/07/29 14:30:06
Done.
| |
84 #define SET_MEMORY_ACCESSIBLE(address, size) \ | |
85 memset((address), 0, (size)) | |
86 #elif ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) | |
82 #define SET_MEMORY_INACCESSIBLE(address, size) \ | 87 #define SET_MEMORY_INACCESSIBLE(address, size) \ |
83 FreeList::zapFreedMemory(address, size); \ | 88 FreeList::zapFreedMemory(address, size); \ |
84 ASAN_POISON_MEMORY_REGION(address, size) | 89 ASAN_POISON_MEMORY_REGION(address, size) |
85 #define SET_MEMORY_ACCESSIBLE(address, size) \ | 90 #define SET_MEMORY_ACCESSIBLE(address, size) \ |
86 ASAN_UNPOISON_MEMORY_REGION(address, size); \ | 91 ASAN_UNPOISON_MEMORY_REGION(address, size); \ |
87 memset((address), 0, (size)) | 92 memset((address), 0, (size)) |
88 #else | 93 #else |
89 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size)) | 94 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size)) |
90 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false) | 95 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false) |
91 #endif | 96 #endif |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1388 size_t copySize = previousHeader->payloadSize(); | 1393 size_t copySize = previousHeader->payloadSize(); |
1389 if (copySize > size) | 1394 if (copySize > size) |
1390 copySize = size; | 1395 copySize = size; |
1391 memcpy(address, previous, copySize); | 1396 memcpy(address, previous, copySize); |
1392 return address; | 1397 return address; |
1393 } | 1398 } |
1394 | 1399 |
1395 } // namespace blink | 1400 } // namespace blink |
1396 | 1401 |
1397 #endif // Heap_h | 1402 #endif // Heap_h |
OLD | NEW |