summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2015-01-12 12:11:05 -0800
committerHiroshi Yamauchi <yamauchi@google.com>2015-01-13 11:19:36 -0800
commit312baf19603ff7d2b223fd7b1ef817171a97f9d0 (patch)
tree381ccdbaf0118cb2eefcfad77c9b842f41f7716c /runtime
parent6650de241f63f725830560ec09c5e1f13c0d8488 (diff)
downloadart-312baf19603ff7d2b223fd7b1ef817171a97f9d0.zip
art-312baf19603ff7d2b223fd7b1ef817171a97f9d0.tar.gz
art-312baf19603ff7d2b223fd7b1ef817171a97f9d0.tar.bz2
Follow up on CL 122665.
We now do the two-step memory protection strategy (first protect the from space with PROT_READ and later protect it with PROT_NONE) only if the from space is a rosalloc space (excluding the more common bump pointer space case). This strengthens the GC verification for the bump pointer space case as we avoid the case where mutators run while the from space is PROT_READ rather than PROT_NONE. Add a command line flag to override the minimum interval for the hspace compaction for OOM and set it to zero in the gcstress/gcverify run-tests to run the hspace compaction more frequently in tests. Fix some comments. Bug: 18960494 Change-Id: I518b011e026f578e53c4ec269cfb82865b0fae68
Diffstat (limited to 'runtime')
-rw-r--r--runtime/gc/collector/semi_space.cc20
-rw-r--r--runtime/parsed_options.cc6
2 files changed, 19 insertions, 7 deletions
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index 681bfaa..82d6992 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -251,13 +251,19 @@ void SemiSpace::MarkingPhase() {
// Note: Freed bytes can be negative if we copy form a compacted space to a free-list backed
// space.
RecordFree(ObjectBytePair(from_objects - to_objects, from_bytes - to_bytes));
- // Clear the from space. Protect it with PROT_READ here and if
- // kProtectFromSpace is true, will protect it with PROT_NONE later
- // in FinishPhase() so the rosalloc verification works (can read the
- // metadata magic number.)
+ // Clear and protect the from space.
from_space_->Clear();
- VLOG(heap) << "Protecting from_space_ with PROT_READ : " << *from_space_;
- from_space_->GetMemMap()->Protect(PROT_READ);
+ if (kProtectFromSpace && !from_space_->IsRosAllocSpace()) {
+ // Protect with PROT_NONE.
+ VLOG(heap) << "Protecting from_space_ : " << *from_space_;
+ from_space_->GetMemMap()->Protect(PROT_NONE);
+ } else {
+ // If RosAllocSpace, we'll leave it as PROT_READ here so the
+ // rosaloc verification can read the metadata magic number and
+ // protect it with PROT_NONE later in FinishPhase().
+ VLOG(heap) << "Protecting from_space_ with PROT_READ : " << *from_space_;
+ from_space_->GetMemMap()->Protect(PROT_READ);
+ }
heap_->PreSweepingGcVerification(this);
if (swap_semi_spaces_) {
heap_->SwapSemiSpaces();
@@ -752,7 +758,7 @@ void SemiSpace::SetFromSpace(space::ContinuousMemMapAllocSpace* from_space) {
void SemiSpace::FinishPhase() {
TimingLogger::ScopedTiming t(__FUNCTION__, GetTimings());
- if (kProtectFromSpace) {
+ if (kProtectFromSpace && from_space_->IsRosAllocSpace()) {
VLOG(heap) << "Protecting from_space_ with PROT_NONE : " << *from_space_;
from_space_->GetMemMap()->Protect(PROT_NONE);
}
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 4ba3cb9..efc4a71 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -413,6 +413,12 @@ bool ParsedOptions::Parse(const RuntimeOptions& options, bool ignore_unrecognize
use_homogeneous_space_compaction_for_oom_ = true;
} else if (option == "-XX:DisableHSpaceCompactForOOM") {
use_homogeneous_space_compaction_for_oom_ = false;
+ } else if (StartsWith(option, "-XX:HspaceCompactForOOMMinIntervalMs=")) {
+ unsigned int value;
+ if (!ParseUnsignedInteger(option, '=', &value)) {
+ return false;
+ }
+ min_interval_homogeneous_space_compaction_by_oom_ = MsToNs(value);
} else if (StartsWith(option, "-D")) {
properties_.push_back(option.substr(strlen("-D")));
} else if (StartsWith(option, "-Xjnitrace:")) {