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() { ...@@ -1723,12 +1723,14 @@ void Heap::Scavenge() {
{ {
// Copy objects reachable from the old generation. // Copy objects reachable from the old generation.
TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::Iterate(this, [this](Address addr) { RememberedSet<OLD_TO_NEW>::Iterate(
return Scavenger::CheckAndScavengeObject(this, addr); this, SYNCHRONIZED, [this](Address addr) {
}); return Scavenger::CheckAndScavengeObject(this, addr);
});
RememberedSet<OLD_TO_NEW>::IterateTyped( 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( return UpdateTypedSlotHelper::UpdateTypedSlot(
isolate(), type, addr, [this](Object** addr) { isolate(), type, addr, [this](Object** addr) {
// We expect that objects referenced by code are long living. // We expect that objects referenced by code are long living.
......
...@@ -2369,11 +2369,12 @@ void MinorMarkCompactCollector::MarkLiveObjects() { ...@@ -2369,11 +2369,12 @@ void MinorMarkCompactCollector::MarkLiveObjects() {
{ {
TRACE_GC(heap()->tracer(), TRACE_GC(heap()->tracer(),
GCTracer::Scope::MINOR_MC_MARK_OLD_TO_NEW_POINTERS); GCTracer::Scope::MINOR_MC_MARK_OLD_TO_NEW_POINTERS);
RememberedSet<OLD_TO_NEW>::Iterate(heap(), [this](Address addr) { RememberedSet<OLD_TO_NEW>::Iterate(
return CheckAndMarkObject(heap(), addr); heap(), NON_SYNCHRONIZED,
}); [this](Address addr) { return CheckAndMarkObject(heap(), addr); });
RememberedSet<OLD_TO_NEW>::IterateTyped( 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( return UpdateTypedSlotHelper::UpdateTypedSlot(
isolate(), type, addr, [this](Object** addr) { isolate(), type, addr, [this](Object** addr) {
return CheckAndMarkObject(heap(), return CheckAndMarkObject(heap(),
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
enum RememberedSetIterationMode { SYNCHRONIZED, NON_SYNCHRONIZED };
// TODO(ulan): Investigate performance of de-templatizing this class. // TODO(ulan): Investigate performance of de-templatizing this class.
template <RememberedSetType type> template <RememberedSetType type>
class RememberedSet : public AllStatic { class RememberedSet : public AllStatic {
...@@ -98,9 +100,13 @@ class RememberedSet : public AllStatic { ...@@ -98,9 +100,13 @@ class RememberedSet : public AllStatic {
// Iterates and filters the remembered set with the given callback. // Iterates and filters the remembered set with the given callback.
// The callback should take (Address slot) and return SlotCallbackResult. // The callback should take (Address slot) and return SlotCallbackResult.
template <typename Callback> template <typename Callback>
static void Iterate(Heap* heap, Callback callback) { static void Iterate(Heap* heap, RememberedSetIterationMode mode,
IterateMemoryChunks( Callback callback) {
heap, [callback](MemoryChunk* chunk) { Iterate(chunk, 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. // Iterates over all memory chunks that contains non-empty slot sets.
...@@ -177,9 +183,12 @@ class RememberedSet : public AllStatic { ...@@ -177,9 +183,12 @@ class RememberedSet : public AllStatic {
// The callback should take (SlotType slot_type, SlotAddress slot) and return // The callback should take (SlotType slot_type, SlotAddress slot) and return
// SlotCallbackResult. // SlotCallbackResult.
template <typename Callback> template <typename Callback>
static void IterateTyped(Heap* heap, Callback callback) { static void IterateTyped(Heap* heap, RememberedSetIterationMode mode,
IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) { Callback callback) {
IterateMemoryChunks(heap, [mode, callback](MemoryChunk* chunk) {
if (mode == SYNCHRONIZED) chunk->mutex()->Lock();
IterateTyped(chunk, callback); 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