blob: 1b3fcb0a98b22ea5bb254c596e5cfe1ab7e1dadb [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2011 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Ben Murdoch3ef787d2012-04-12 10:51:47 +01004
5#ifndef V8_STORE_BUFFER_H_
6#define V8_STORE_BUFFER_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/allocation.h"
9#include "src/base/logging.h"
10#include "src/base/platform/platform.h"
11#include "src/globals.h"
Ben Murdoch097c5b22016-05-18 11:27:45 +010012#include "src/heap/slot-set.h"
Ben Murdoch3ef787d2012-04-12 10:51:47 +010013
14namespace v8 {
15namespace internal {
16
Ben Murdoch097c5b22016-05-18 11:27:45 +010017// Intermediate buffer that accumulates old-to-new stores from the generated
18// code. On buffer overflow the slots are moved to the remembered set.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010019class StoreBuffer {
20 public:
Ben Murdochda12d292016-06-02 14:46:10 +010021 static const int kStoreBufferSize = 1 << (14 + kPointerSizeLog2);
22 static const int kStoreBufferMask = kStoreBufferSize - 1;
23
Ben Murdoch3ef787d2012-04-12 10:51:47 +010024 static void StoreBufferOverflow(Isolate* isolate);
Ben Murdochda12d292016-06-02 14:46:10 +010025
26 explicit StoreBuffer(Heap* heap);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010027 void SetUp();
28 void TearDown();
29
Ben Murdochda12d292016-06-02 14:46:10 +010030 // Used to add entries from generated code.
31 inline Address* top_address() { return reinterpret_cast<Address*>(&top_); }
Ben Murdoch3ef787d2012-04-12 10:51:47 +010032
Ben Murdoch097c5b22016-05-18 11:27:45 +010033 void MoveEntriesToRememberedSet();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000034
Ben Murdoch3ef787d2012-04-12 10:51:47 +010035 private:
36 Heap* heap_;
37
Ben Murdochda12d292016-06-02 14:46:10 +010038 Address* top_;
39
Ben Murdoch097c5b22016-05-18 11:27:45 +010040 // The start and the limit of the buffer that contains store slots
41 // added from the generated code.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010042 Address* start_;
43 Address* limit_;
44
Ben Murdochb8a8cc12014-11-26 15:28:44 +000045 base::VirtualMemory* virtual_memory_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000046};
47
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000048} // namespace internal
49} // namespace v8
Ben Murdoch3ef787d2012-04-12 10:51:47 +010050
51#endif // V8_STORE_BUFFER_H_