diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 7727a4b0e3..cc5958d3b5 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -302,7 +302,7 @@ DEFINE_bool(lazy_sweeping, true, "Use lazy sweeping for old pointer and data spaces") DEFINE_bool(never_compact, false, "Never perform compaction on full GC - testing only") -DEFINE_bool(compact_code_space, false, +DEFINE_bool(compact_code_space, true, "Compact code space on full non-incremental collections") DEFINE_bool(cleanup_code_caches_at_gc, true, "Flush inline caches prior to mark compact collection and " diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 40333fe1f8..2661a83c50 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -1325,6 +1325,16 @@ class StaticMarkingVisitor : public StaticVisitorBase { re->SetDataAtUnchecked(JSRegExp::saved_code_index(is_ascii), code, heap); + + // Saving a copy might create a pointer into compaction candidate + // that was not observed by marker. This might happen if JSRegExp data + // was marked through the compilation cache before marker reached JSRegExp + // object. + FixedArray* data = FixedArray::cast(re->data()); + Object** slot = data->data_start() + JSRegExp::saved_code_index(is_ascii); + heap->mark_compact_collector()-> + RecordSlot(slot, slot, code); + // Set a number in the 0-255 range to guarantee no smi overflow. re->SetDataAtUnchecked(JSRegExp::code_index(is_ascii), Smi::FromInt(heap->sweep_generation() & 0xff),