Commit 4024e6a1 authored by hpayer's avatar hpayer Committed by Commit bot

[heap] Take page lock when scavenging old to new references in Scavenger.

BUG=v8:5807

Review-Url: https://codereview.chromium.org/2781363002
Cr-Commit-Position: refs/heads/master@{#44268}
parent 1200cc2c
......@@ -1723,12 +1723,14 @@ void Heap::Scavenge() {
{
// Copy objects reachable from the old generation.
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::Iterate(this, [this](Address addr) {
return Scavenger::CheckAndScavengeObject(this, addr);
});
RememberedSet<OLD_TO_NEW>::Iterate(
this, SYNCHRONIZED, [this](Address addr) {
return Scavenger::CheckAndScavengeObject(this, addr);
});
RememberedSet<OLD_TO_NEW>::IterateTyped(
this, [this](SlotType type, Address host_addr, Address addr) {
this, SYNCHRONIZED,
[this](SlotType type, Address host_addr, Address addr) {
return UpdateTypedSlotHelper::UpdateTypedSlot(
isolate(), type, addr, [this](Object** addr) {
// We expect that objects referenced by code are long living.
......
......@@ -2369,11 +2369,12 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
{
TRACE_GC(heap()->tracer(),
GCTracer::Scope::MINOR_MC_MARK_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::Iterate(heap(), [this](Address addr) {
return CheckAndMarkObject(heap(), addr);
});
RememberedSet<OLD_TO_NEW>::Iterate(
heap(), NON_SYNCHRONIZED,
[this](Address addr) { return CheckAndMarkObject(heap(), addr); });
RememberedSet<OLD_TO_NEW>::IterateTyped(
heap(), [this](SlotType type, Address host_addr, Address addr) {
heap(), NON_SYNCHRONIZED,
[this](SlotType type, Address host_addr, Address addr) {
return UpdateTypedSlotHelper::UpdateTypedSlot(
isolate(), type, addr, [this](Object** addr) {
return CheckAndMarkObject(heap(),
......
......@@ -13,6 +13,8 @@
namespace v8 {
namespace internal {
enum RememberedSetIterationMode { SYNCHRONIZED, NON_SYNCHRONIZED };
// TODO(ulan): Investigate performance of de-templatizing this class.
template <RememberedSetType type>
class RememberedSet : public AllStatic {
......@@ -98,9 +100,13 @@ class RememberedSet : public AllStatic {
// Iterates and filters the remembered set with the given callback.
// The callback should take (Address slot) and return SlotCallbackResult.
template <typename Callback>
static void Iterate(Heap* heap, Callback callback) {
IterateMemoryChunks(
heap, [callback](MemoryChunk* chunk) { Iterate(chunk, callback); });
static void Iterate(Heap* heap, RememberedSetIterationMode mode,
Callback callback) {
IterateMemoryChunks(heap, [mode, callback](MemoryChunk* chunk) {
if (mode == SYNCHRONIZED) chunk->mutex()->Lock();
Iterate(chunk, callback);
if (mode == SYNCHRONIZED) chunk->mutex()->Unlock();
});
}
// Iterates over all memory chunks that contains non-empty slot sets.
......@@ -177,9 +183,12 @@ class RememberedSet : public AllStatic {
// The callback should take (SlotType slot_type, SlotAddress slot) and return
// SlotCallbackResult.
template <typename Callback>
static void IterateTyped(Heap* heap, Callback callback) {
IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) {
static void IterateTyped(Heap* heap, RememberedSetIterationMode mode,
Callback callback) {
IterateMemoryChunks(heap, [mode, callback](MemoryChunk* chunk) {
if (mode == SYNCHRONIZED) chunk->mutex()->Lock();
IterateTyped(chunk, callback);
if (mode == SYNCHRONIZED) chunk->mutex()->Unlock();
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment