1c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// Copyright 2011 the V8 project authors. All rights reserved.
2c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// Redistribution and use in source and binary forms, with or without
3c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// modification, are permitted provided that the following conditions are
4c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// met:
5c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//
6c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//     * Redistributions of source code must retain the above copyright
7c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       notice, this list of conditions and the following disclaimer.
8c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//     * Redistributions in binary form must reproduce the above
9c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       copyright notice, this list of conditions and the following
10c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       disclaimer in the documentation and/or other materials provided
11c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       with the distribution.
12c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//     * Neither the name of Google Inc. nor the names of its
13c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       contributors may be used to endorse or promote products derived
14c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//       from this software without specific prior written permission.
15c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com//
16c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
28c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com#ifndef V8_STORE_BUFFER_INL_H_
29c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com#define V8_STORE_BUFFER_INL_H_
30c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
31c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com#include "store-buffer.h"
32c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
33c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comnamespace v8 {
34c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comnamespace internal {
35c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
36c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comAddress StoreBuffer::TopAddress() {
37c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  return reinterpret_cast<Address>(heap_->store_buffer_top_address());
38c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com}
39c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
40c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
41c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comvoid StoreBuffer::Mark(Address addr) {
42c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  ASSERT(!heap_->cell_space()->Contains(addr));
43c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  ASSERT(!heap_->code_space()->Contains(addr));
44a2e1a40f85577979749d4c0d6de30e992d996659mstarzinger@chromium.org  ASSERT(!heap_->old_data_space()->Contains(addr));
45c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
46c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  *top++ = addr;
47c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  heap_->public_set_store_buffer_top(top);
48c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  if ((reinterpret_cast<uintptr_t>(top) & kStoreBufferOverflowBit) != 0) {
49c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    ASSERT(top == limit_);
50c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    Compact();
51c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  } else {
52c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    ASSERT(top < limit_);
53c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  }
54c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com}
55c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
56c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
57c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.comvoid StoreBuffer::EnterDirectlyIntoStoreBuffer(Address addr) {
58c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  if (store_buffer_rebuilding_enabled_) {
59394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com    SLOW_ASSERT(!heap_->cell_space()->Contains(addr) &&
60394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                !heap_->code_space()->Contains(addr) &&
61394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                !heap_->old_data_space()->Contains(addr) &&
62394dbcf9009cf5203b6d85e8b515fcff072040f3erik.corry@gmail.com                !heap_->new_space()->Contains(addr));
63c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    Address* top = old_top_;
64c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    *top++ = addr;
65c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    old_top_ = top;
66c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    old_buffer_is_sorted_ = false;
67c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    old_buffer_is_filtered_ = false;
68c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    if (top >= old_limit_) {
69c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com      ASSERT(callback_ != NULL);
70c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com      (*callback_)(heap_,
71c5d4971574b7a205fa0e788d8121dc79485e5e67hpayer@chromium.org                   MemoryChunk::FromAnyPointerAddress(heap_, addr),
72c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com                   kStoreBufferFullEvent);
73c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com    }
74c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com  }
75c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com}
76c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
77c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
78169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.orgvoid StoreBuffer::ClearDeadObject(HeapObject* object) {
79169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org  Address& map_field = Memory::Address_at(object->address());
80169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org  if (heap_->map_space()->Contains(map_field)) {
81169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org    map_field = NULL;
82169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org  }
83169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org}
84169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org
85169691d93a961c8b511f8ac8fd8ee33d081ca10fdanno@chromium.org
86c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com} }  // namespace v8::internal
87c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com
88c3b670ff19220959730d7886892bc4beb95d2ebaerik.corry@gmail.com#endif  // V8_STORE_BUFFER_INL_H_
89