| 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 // TODO(kojii): We actually need __msan_poison/unpoison here, but it'll be |
| 83 // added later. |
| 84 #define SET_MEMORY_INACCESSIBLE(address, size) \ |
| 85 FreeList::zapFreedMemory(address, size); |
| 86 #define SET_MEMORY_ACCESSIBLE(address, size) \ |
| 87 memset((address), 0, (size)) |
| 88 #elif ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER) |
| 82 #define SET_MEMORY_INACCESSIBLE(address, size) \ | 89 #define SET_MEMORY_INACCESSIBLE(address, size) \ |
| 83 FreeList::zapFreedMemory(address, size); \ | 90 FreeList::zapFreedMemory(address, size); \ |
| 84 ASAN_POISON_MEMORY_REGION(address, size) | 91 ASAN_POISON_MEMORY_REGION(address, size) |
| 85 #define SET_MEMORY_ACCESSIBLE(address, size) \ | 92 #define SET_MEMORY_ACCESSIBLE(address, size) \ |
| 86 ASAN_UNPOISON_MEMORY_REGION(address, size); \ | 93 ASAN_UNPOISON_MEMORY_REGION(address, size); \ |
| 87 memset((address), 0, (size)) | 94 memset((address), 0, (size)) |
| 88 #else | 95 #else |
| 89 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size)) | 96 #define SET_MEMORY_INACCESSIBLE(address, size) memset((address), 0, (size)) |
| 90 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false) | 97 #define SET_MEMORY_ACCESSIBLE(address, size) do { } while (false) |
| 91 #endif | 98 #endif |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 size_t copySize = previousHeader->payloadSize(); | 1395 size_t copySize = previousHeader->payloadSize(); |
| 1389 if (copySize > size) | 1396 if (copySize > size) |
| 1390 copySize = size; | 1397 copySize = size; |
| 1391 memcpy(address, previous, copySize); | 1398 memcpy(address, previous, copySize); |
| 1392 return address; | 1399 return address; |
| 1393 } | 1400 } |
| 1394 | 1401 |
| 1395 } // namespace blink | 1402 } // namespace blink |
| 1396 | 1403 |
| 1397 #endif // Heap_h | 1404 #endif // Heap_h |
| OLD | NEW |