| 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 // cycle or coalescing. This is helpful to detect use-after-free errors | 917 // cycle or coalescing. This is helpful to detect use-after-free errors |
| 918 // that could be caused by lazy sweeping etc. | 918 // that could be caused by lazy sweeping etc. |
| 919 size_t allowedCount = 0; | 919 size_t allowedCount = 0; |
| 920 size_t forbiddenCount = 0; | 920 size_t forbiddenCount = 0; |
| 921 for (size_t i = sizeof(FreeListEntry); i < size; i++) { | 921 for (size_t i = sizeof(FreeListEntry); i < size; i++) { |
| 922 if (address[i] == reuseAllowedZapValue) { | 922 if (address[i] == reuseAllowedZapValue) { |
| 923 allowedCount++; | 923 allowedCount++; |
| 924 } else if (address[i] == reuseForbiddenZapValue) { | 924 } else if (address[i] == reuseForbiddenZapValue) { |
| 925 forbiddenCount++; | 925 forbiddenCount++; |
| 926 } else { | 926 } else { |
| 927 // TODO(haraken): Remove these assertions once bug 537922 is fixed. | |
| 928 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(&addr
ess[i]); | |
| 929 ASSERT(header->checkHeader()); | |
| 930 if (header->isPromptlyFreed()) | |
| 931 ASSERT_NOT_REACHED(); | |
| 932 else if (header->isFree()) | |
| 933 ASSERT_NOT_REACHED(); | |
| 934 else if (header->isDead()) | |
| 935 ASSERT_NOT_REACHED(); | |
| 936 else if (header->isMarked()) | |
| 937 ASSERT_NOT_REACHED(); | |
| 938 ASSERT_NOT_REACHED(); | 927 ASSERT_NOT_REACHED(); |
| 939 } | 928 } |
| 940 } | 929 } |
| 941 size_t entryCount = size - sizeof(FreeListEntry); | 930 size_t entryCount = size - sizeof(FreeListEntry); |
| 942 if (forbiddenCount == entryCount) { | 931 if (forbiddenCount == entryCount) { |
| 943 // If all values in the memory region are reuseForbiddenZapValue, | 932 // If all values in the memory region are reuseForbiddenZapValue, |
| 944 // we flip them to reuseAllowedZapValue. This allows the next | 933 // we flip them to reuseAllowedZapValue. This allows the next |
| 945 // addToFreeList() to add the memory region to the free list | 934 // addToFreeList() to add the memory region to the free list |
| 946 // (unless someone concatenates the memory region with another memory | 935 // (unless someone concatenates the memory region with another memory |
| 947 // region that contains reuseForbiddenZapValue.) | 936 // region that contains reuseForbiddenZapValue.) |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 | 1555 |
| 1567 m_hasEntries = true; | 1556 m_hasEntries = true; |
| 1568 size_t index = hash(address); | 1557 size_t index = hash(address); |
| 1569 ASSERT(!(index & 1)); | 1558 ASSERT(!(index & 1)); |
| 1570 Address cachePage = roundToBlinkPageStart(address); | 1559 Address cachePage = roundToBlinkPageStart(address); |
| 1571 m_entries[index + 1] = m_entries[index]; | 1560 m_entries[index + 1] = m_entries[index]; |
| 1572 m_entries[index] = cachePage; | 1561 m_entries[index] = cachePage; |
| 1573 } | 1562 } |
| 1574 | 1563 |
| 1575 } // namespace blink | 1564 } // namespace blink |
| OLD | NEW |