| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 void WriteBuffer::Compact() { | 79 void WriteBuffer::Compact() { |
| 80 memset(reinterpret_cast<void*>(hash_map_1_), | 80 memset(reinterpret_cast<void*>(hash_map_1_), |
| 81 0, | 81 0, |
| 82 sizeof(uintptr_t) * kHashMapLength); | 82 sizeof(uintptr_t) * kHashMapLength); |
| 83 memset(reinterpret_cast<void*>(hash_map_2_), | 83 memset(reinterpret_cast<void*>(hash_map_2_), |
| 84 0, | 84 0, |
| 85 sizeof(uintptr_t) * kHashMapLength); | 85 sizeof(uintptr_t) * kHashMapLength); |
| 86 ASSERT(top_ <= limit_); |
| 86 Address* stop = top_; | 87 Address* stop = top_; |
| 87 top_ = start_; | 88 top_ = start_; |
| 88 // Goes through the addresses in the write buffer attempting to remove | 89 // Goes through the addresses in the write buffer attempting to remove |
| 89 // duplicates. In the interest of speed this is a lossy operation. Some | 90 // duplicates. In the interest of speed this is a lossy operation. Some |
| 90 // duplicates will remain. We have two hash tables with different hash | 91 // duplicates will remain. We have two hash tables with different hash |
| 91 // functions to reduce the number of unnecessary clashes. | 92 // functions to reduce the number of unnecessary clashes. |
| 92 for (Address* current = start_; current < stop; current++) { | 93 for (Address* current = start_; current < stop; current++) { |
| 93 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); | 94 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); |
| 94 // Shift out the last bits including any tags. | 95 // Shift out the last bits including any tags. |
| 95 int_addr >>= kPointerSizeLog2; | 96 int_addr >>= kPointerSizeLog2; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 123 if (limit_ - top_ < (top_ - start_) >> 1) { | 124 if (limit_ - top_ < (top_ - start_) >> 1) { |
| 124 // Compression did not free up at least one quarter. | 125 // Compression did not free up at least one quarter. |
| 125 // TODO(gc): Set a flag to scan all of memory. | 126 // TODO(gc): Set a flag to scan all of memory. |
| 126 top_ = start_; | 127 top_ = start_; |
| 127 Counters::write_buffer_overflows.Increment(); | 128 Counters::write_buffer_overflows.Increment(); |
| 128 } | 129 } |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 } } // namespace v8::internal | 133 } } // namespace v8::internal |
| OLD | NEW |