Implement and enable zapping of code space while sweeping.
R=danno@chromium.org, hpayer@chromium.org BUG= Review URL: https://codereview.chromium.org/181513004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19568 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
44da745247
commit
947a5e6b3a
@ -572,6 +572,8 @@ DEFINE_bool(cleanup_code_caches_at_gc, true,
|
|||||||
DEFINE_bool(use_marking_progress_bar, true,
|
DEFINE_bool(use_marking_progress_bar, true,
|
||||||
"Use a progress bar to scan large objects in increments when "
|
"Use a progress bar to scan large objects in increments when "
|
||||||
"incremental marking is active.")
|
"incremental marking is active.")
|
||||||
|
DEFINE_bool(zap_code_space, true,
|
||||||
|
"Zap free memory in code space with 0xCC while sweeping.")
|
||||||
DEFINE_int(random_seed, 0,
|
DEFINE_int(random_seed, 0,
|
||||||
"Default seed for initializing random generator "
|
"Default seed for initializing random generator "
|
||||||
"(0, the default, means to use system random).")
|
"(0, the default, means to use system random).")
|
||||||
|
@ -3204,13 +3204,21 @@ enum SkipListRebuildingMode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum FreeSpaceTreatmentMode {
|
||||||
|
IGNORE_FREE_SPACE,
|
||||||
|
ZAP_FREE_SPACE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Sweep a space precisely. After this has been done the space can
|
// Sweep a space precisely. After this has been done the space can
|
||||||
// be iterated precisely, hitting only the live objects. Code space
|
// be iterated precisely, hitting only the live objects. Code space
|
||||||
// is always swept precisely because we want to be able to iterate
|
// is always swept precisely because we want to be able to iterate
|
||||||
// over it. Map space is swept precisely, because it is not compacted.
|
// over it. Map space is swept precisely, because it is not compacted.
|
||||||
// Slots in live objects pointing into evacuation candidates are updated
|
// Slots in live objects pointing into evacuation candidates are updated
|
||||||
// if requested.
|
// if requested.
|
||||||
template<SweepingMode sweeping_mode, SkipListRebuildingMode skip_list_mode>
|
template<SweepingMode sweeping_mode,
|
||||||
|
SkipListRebuildingMode skip_list_mode,
|
||||||
|
FreeSpaceTreatmentMode free_space_mode>
|
||||||
static void SweepPrecisely(PagedSpace* space,
|
static void SweepPrecisely(PagedSpace* space,
|
||||||
Page* p,
|
Page* p,
|
||||||
ObjectVisitor* v) {
|
ObjectVisitor* v) {
|
||||||
@ -3244,6 +3252,9 @@ static void SweepPrecisely(PagedSpace* space,
|
|||||||
for ( ; live_objects != 0; live_objects--) {
|
for ( ; live_objects != 0; live_objects--) {
|
||||||
Address free_end = cell_base + offsets[live_index++] * kPointerSize;
|
Address free_end = cell_base + offsets[live_index++] * kPointerSize;
|
||||||
if (free_end != free_start) {
|
if (free_end != free_start) {
|
||||||
|
if (free_space_mode == ZAP_FREE_SPACE) {
|
||||||
|
memset(free_start, 0xcc, static_cast<int>(free_end - free_start));
|
||||||
|
}
|
||||||
space->Free(free_start, static_cast<int>(free_end - free_start));
|
space->Free(free_start, static_cast<int>(free_end - free_start));
|
||||||
#ifdef ENABLE_GDB_JIT_INTERFACE
|
#ifdef ENABLE_GDB_JIT_INTERFACE
|
||||||
if (FLAG_gdbjit && space->identity() == CODE_SPACE) {
|
if (FLAG_gdbjit && space->identity() == CODE_SPACE) {
|
||||||
@ -3275,6 +3286,9 @@ static void SweepPrecisely(PagedSpace* space,
|
|||||||
*cell = 0;
|
*cell = 0;
|
||||||
}
|
}
|
||||||
if (free_start != p->area_end()) {
|
if (free_start != p->area_end()) {
|
||||||
|
if (free_space_mode == ZAP_FREE_SPACE) {
|
||||||
|
memset(free_start, 0xcc, static_cast<int>(p->area_end() - free_start));
|
||||||
|
}
|
||||||
space->Free(free_start, static_cast<int>(p->area_end() - free_start));
|
space->Free(free_start, static_cast<int>(p->area_end() - free_start));
|
||||||
#ifdef ENABLE_GDB_JIT_INTERFACE
|
#ifdef ENABLE_GDB_JIT_INTERFACE
|
||||||
if (FLAG_gdbjit && space->identity() == CODE_SPACE) {
|
if (FLAG_gdbjit && space->identity() == CODE_SPACE) {
|
||||||
@ -3520,12 +3534,23 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
|
|||||||
SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p);
|
SweepConservatively<SWEEP_SEQUENTIALLY>(space, NULL, p);
|
||||||
break;
|
break;
|
||||||
case OLD_POINTER_SPACE:
|
case OLD_POINTER_SPACE:
|
||||||
SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS, IGNORE_SKIP_LIST>(
|
SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS,
|
||||||
|
IGNORE_SKIP_LIST,
|
||||||
|
IGNORE_FREE_SPACE>(
|
||||||
space, p, &updating_visitor);
|
space, p, &updating_visitor);
|
||||||
break;
|
break;
|
||||||
case CODE_SPACE:
|
case CODE_SPACE:
|
||||||
SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS, REBUILD_SKIP_LIST>(
|
if (FLAG_zap_code_space) {
|
||||||
space, p, &updating_visitor);
|
SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS,
|
||||||
|
REBUILD_SKIP_LIST,
|
||||||
|
ZAP_FREE_SPACE>(
|
||||||
|
space, p, &updating_visitor);
|
||||||
|
} else {
|
||||||
|
SweepPrecisely<SWEEP_AND_VISIT_LIVE_OBJECTS,
|
||||||
|
REBUILD_SKIP_LIST,
|
||||||
|
IGNORE_FREE_SPACE>(
|
||||||
|
space, p, &updating_visitor);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@ -4145,10 +4170,15 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
|
|||||||
PrintF("Sweeping 0x%" V8PRIxPTR " precisely.\n",
|
PrintF("Sweeping 0x%" V8PRIxPTR " precisely.\n",
|
||||||
reinterpret_cast<intptr_t>(p));
|
reinterpret_cast<intptr_t>(p));
|
||||||
}
|
}
|
||||||
if (space->identity() == CODE_SPACE) {
|
if (space->identity() == CODE_SPACE && FLAG_zap_code_space) {
|
||||||
SweepPrecisely<SWEEP_ONLY, REBUILD_SKIP_LIST>(space, p, NULL);
|
SweepPrecisely<SWEEP_ONLY, REBUILD_SKIP_LIST, ZAP_FREE_SPACE>(
|
||||||
|
space, p, NULL);
|
||||||
|
} else if (space->identity() == CODE_SPACE) {
|
||||||
|
SweepPrecisely<SWEEP_ONLY, REBUILD_SKIP_LIST, IGNORE_FREE_SPACE>(
|
||||||
|
space, p, NULL);
|
||||||
} else {
|
} else {
|
||||||
SweepPrecisely<SWEEP_ONLY, IGNORE_SKIP_LIST>(space, p, NULL);
|
SweepPrecisely<SWEEP_ONLY, IGNORE_SKIP_LIST, IGNORE_FREE_SPACE>(
|
||||||
|
space, p, NULL);
|
||||||
}
|
}
|
||||||
pages_swept++;
|
pages_swept++;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user