| 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_WRITE_BARRIER_INL_H_ | 28 #ifndef V8_STORE_BUFFER_INL_H_ |
| 29 #define V8_WRITE_BARRIER_INL_H_ | 29 #define V8_STORE_BUFFER_INL_H_ |
| 30 | 30 |
| 31 #include "v8.h" | |
| 32 #include "store-buffer.h" | 31 #include "store-buffer.h" |
| 33 | 32 |
| 34 namespace v8 { | 33 namespace v8 { |
| 35 namespace internal { | 34 namespace internal { |
| 36 | 35 |
| 37 Address StoreBuffer::TopAddress() { | 36 Address StoreBuffer::TopAddress() { |
| 38 return reinterpret_cast<Address>(Heap::store_buffer_top_address()); | 37 return reinterpret_cast<Address>(Heap::store_buffer_top_address()); |
| 39 } | 38 } |
| 40 | 39 |
| 41 | 40 |
| 42 void StoreBuffer::Mark(Address addr) { | 41 void StoreBuffer::Mark(Address addr) { |
| 42 ASSERT(!Heap::cell_space()->Contains(addr)); |
| 43 ASSERT(!Heap::code_space()->Contains(addr)); |
| 43 Address* top = reinterpret_cast<Address*>(Heap::store_buffer_top()); | 44 Address* top = reinterpret_cast<Address*>(Heap::store_buffer_top()); |
| 44 *top++ = addr; | 45 *top++ = addr; |
| 45 Heap::public_set_store_buffer_top(top); | 46 Heap::public_set_store_buffer_top(top); |
| 46 if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) { | 47 if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) { |
| 47 ASSERT(top == limit_); | 48 ASSERT(top == limit_); |
| 48 Compact(); | 49 Compact(); |
| 49 } else { | 50 } else { |
| 50 ASSERT(top < limit_); | 51 ASSERT(top < limit_); |
| 51 } | 52 } |
| 52 } | 53 } |
| 53 | 54 |
| 54 | 55 |
| 55 void StoreBuffer::set_store_buffer_mode(StoreBuffer::StoreBufferMode mode) { | |
| 56 if (FLAG_trace_gc) { | |
| 57 if (mode != store_buffer_mode_) { | |
| 58 if (mode == kStoreBufferDisabled) { | |
| 59 PrintF("Store buffer overflowed.\n"); | |
| 60 } else if (mode == kStoreBufferBeingRebuilt) { | |
| 61 PrintF("Store buffer being rebuilt.\n"); | |
| 62 } else if (mode == kStoreBufferFunctional) { | |
| 63 PrintF("Store buffer reenabled.\n"); | |
| 64 } | |
| 65 } | |
| 66 } | |
| 67 store_buffer_mode_ = mode; | |
| 68 } | |
| 69 | |
| 70 | |
| 71 void StoreBuffer::EnterDirectlyIntoStoreBuffer(Address addr) { | 56 void StoreBuffer::EnterDirectlyIntoStoreBuffer(Address addr) { |
| 72 if (store_buffer_rebuilding_enabled_) { | 57 if (store_buffer_rebuilding_enabled_) { |
| 58 ASSERT(!Heap::cell_space()->Contains(addr)); |
| 59 ASSERT(!Heap::code_space()->Contains(addr)); |
| 60 ASSERT(!Heap::old_data_space()->Contains(addr)); |
| 73 Address* top = old_top_; | 61 Address* top = old_top_; |
| 74 *top++ = addr; | 62 *top++ = addr; |
| 75 old_top_ = top; | 63 old_top_ = top; |
| 64 old_buffer_is_sorted_ = false; |
| 65 old_buffer_is_filtered_ = false; |
| 76 if (top >= old_limit_) { | 66 if (top >= old_limit_) { |
| 77 Counters::store_buffer_overflows.Increment(); | 67 ASSERT(callback_ != NULL); |
| 78 set_store_buffer_mode(kStoreBufferDisabled); | 68 (*callback_)(MemoryChunk::FromAnyPointerAddress(addr), |
| 79 old_top_ = old_start_; | 69 kStoreBufferFullEvent); |
| 80 } | 70 } |
| 81 old_buffer_is_sorted_ = false; | |
| 82 } | 71 } |
| 83 } | 72 } |
| 84 | 73 |
| 85 | 74 |
| 86 } } // namespace v8::internal | 75 } } // namespace v8::internal |
| 87 | 76 |
| 88 #endif // V8_WRITE_BARRIER_INL_H_ | 77 #endif // V8_STORE_BUFFER_INL_H_ |
| OLD | NEW |