| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 // duplicates will remain. We have two hash sets with different hash | 680 // duplicates will remain. We have two hash sets with different hash |
| 681 // functions to reduce the number of unnecessary clashes. | 681 // functions to reduce the number of unnecessary clashes. |
| 682 hash_sets_are_empty_ = false; // Hash sets are in use. | 682 hash_sets_are_empty_ = false; // Hash sets are in use. |
| 683 for (Address* current = start_; current < top; current++) { | 683 for (Address* current = start_; current < top; current++) { |
| 684 ASSERT(!heap_->cell_space()->Contains(*current)); | 684 ASSERT(!heap_->cell_space()->Contains(*current)); |
| 685 ASSERT(!heap_->code_space()->Contains(*current)); | 685 ASSERT(!heap_->code_space()->Contains(*current)); |
| 686 ASSERT(!heap_->old_data_space()->Contains(*current)); | 686 ASSERT(!heap_->old_data_space()->Contains(*current)); |
| 687 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); | 687 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); |
| 688 // Shift out the last bits including any tags. | 688 // Shift out the last bits including any tags. |
| 689 int_addr >>= kPointerSizeLog2; | 689 int_addr >>= kPointerSizeLog2; |
| 690 int hash1 = | 690 // The upper part of an address is basically random because of ASLR and OS |
| 691 ((int_addr ^ (int_addr >> kHashSetLengthLog2)) & (kHashSetLength - 1)); | 691 // non-determinism, so we use only the bits within a page for hashing to |
| 692 // make v8's behavior (more) deterministic. |
| 693 uintptr_t hash_addr = |
| 694 int_addr & (Page::kPageAlignmentMask >> kPointerSizeLog2); |
| 695 int hash1 = ((hash_addr ^ (hash_addr >> kHashSetLengthLog2)) & |
| 696 (kHashSetLength - 1)); |
| 692 if (hash_set_1_[hash1] == int_addr) continue; | 697 if (hash_set_1_[hash1] == int_addr) continue; |
| 693 uintptr_t hash2 = (int_addr - (int_addr >> kHashSetLengthLog2)); | 698 uintptr_t hash2 = (hash_addr - (hash_addr >> kHashSetLengthLog2)); |
| 694 hash2 ^= hash2 >> (kHashSetLengthLog2 * 2); | 699 hash2 ^= hash2 >> (kHashSetLengthLog2 * 2); |
| 695 hash2 &= (kHashSetLength - 1); | 700 hash2 &= (kHashSetLength - 1); |
| 696 if (hash_set_2_[hash2] == int_addr) continue; | 701 if (hash_set_2_[hash2] == int_addr) continue; |
| 697 if (hash_set_1_[hash1] == 0) { | 702 if (hash_set_1_[hash1] == 0) { |
| 698 hash_set_1_[hash1] = int_addr; | 703 hash_set_1_[hash1] = int_addr; |
| 699 } else if (hash_set_2_[hash2] == 0) { | 704 } else if (hash_set_2_[hash2] == 0) { |
| 700 hash_set_2_[hash2] = int_addr; | 705 hash_set_2_[hash2] = int_addr; |
| 701 } else { | 706 } else { |
| 702 // Rather than slowing down we just throw away some entries. This will | 707 // Rather than slowing down we just throw away some entries. This will |
| 703 // cause some duplicates to remain undetected. | 708 // cause some duplicates to remain undetected. |
| 704 hash_set_1_[hash1] = int_addr; | 709 hash_set_1_[hash1] = int_addr; |
| 705 hash_set_2_[hash2] = 0; | 710 hash_set_2_[hash2] = 0; |
| 706 } | 711 } |
| 707 old_buffer_is_sorted_ = false; | 712 old_buffer_is_sorted_ = false; |
| 708 old_buffer_is_filtered_ = false; | 713 old_buffer_is_filtered_ = false; |
| 709 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 714 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
| 710 ASSERT(old_top_ <= old_limit_); | 715 ASSERT(old_top_ <= old_limit_); |
| 711 } | 716 } |
| 712 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 717 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
| 713 CheckForFullBuffer(); | 718 CheckForFullBuffer(); |
| 714 } | 719 } |
| 715 | 720 |
| 716 | 721 |
| 717 void StoreBuffer::CheckForFullBuffer() { | 722 void StoreBuffer::CheckForFullBuffer() { |
| 718 EnsureSpace(kStoreBufferSize * 2); | 723 EnsureSpace(kStoreBufferSize * 2); |
| 719 } | 724 } |
| 720 | 725 |
| 721 } } // namespace v8::internal | 726 } } // namespace v8::internal |
| OLD | NEW |