Reviewers: Hannes Payer,
Description:
Do not dereference handles during relocation.
[email protected]
BUG=
Please review this at https://chromiumcodereview.appspot.com/13982023/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/handles-inl.h
M src/heap-inl.h
M src/heap.h
M src/heap.cc
M src/hydrogen.cc
M src/mark-compact.cc
M src/optimizing-compiler-thread.cc
Index: src/handles-inl.h
diff --git a/src/handles-inl.h b/src/handles-inl.h
index
f12a811fd5b2e3a0048d14adb19273cd4eb24881..5a3e9ed2744ac9c0a0ef1c319648d23e174508f1
100644
--- a/src/handles-inl.h
+++ b/src/handles-inl.h
@@ -91,6 +91,10 @@ bool Handle<T>::IsDereferenceAllowed(bool
allow_deferred) const {
handle < roots_array_start + Heap::kStrongRootListLength) {
return true;
}
+ if (isolate->optimizing_compiler_thread()->IsOptimizerThread() &&
+ !Heap::RelocationLock::IsLockedByOptimizerThread(isolate->heap())) {
+ return false;
+ }
switch (isolate->HandleDereferenceGuardState()) {
case HandleDereferenceGuard::ALLOW:
return true;
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index
ab1fdb4cfe6edec5f28ad39da55d44b9c2a73fcc..f937426186c8099fb9c2f5469f3c32eb4eb97355
100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -211,6 +211,7 @@ MaybeObject*
Heap::CopyFixedDoubleArray(FixedDoubleArray* src) {
MaybeObject* Heap::AllocateRaw(int size_in_bytes,
AllocationSpace space,
AllocationSpace retry_space) {
+
SLOW_ASSERT(!isolate_->optimizing_compiler_thread()->IsOptimizerThread());
ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC);
ASSERT(space != NEW_SPACE ||
retry_space == OLD_POINTER_SPACE ||
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
7976cf8aa7f1a4965dc844c21d4254f07580a8df..f2f0b9bac7421f2441a0aa8787d0babeffea83ac
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1300,6 +1300,8 @@ class ScavengeWeakObjectRetainer : public
WeakObjectRetainer {
void Heap::Scavenge() {
+ RelocationLock relocation_lock(this);
+
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) VerifyNonPointerSpacePointers();
#endif
@@ -6635,6 +6637,11 @@ bool Heap::SetUp() {
store_buffer()->SetUp();
+ if (FLAG_parallel_recompilation) relocation_mutex_ = OS::CreateMutex();
+#ifdef DEBUG
+ relocation_mutex_locked_by_optimizer_thread_ = false;
+#endif // DEBUG
+
return true;
}
@@ -6737,6 +6744,8 @@ void Heap::TearDown() {
incremental_marking()->TearDown();
isolate_->memory_allocator()->TearDown();
+
+ delete relocation_mutex_;
}
@@ -7866,4 +7875,15 @@ void Heap::CheckpointObjectStats() {
ClearObjectStats();
}
+
+Heap::RelocationLock::RelocationLock(Heap* heap) : heap_(heap) {
+ if (FLAG_parallel_recompilation) {
+ heap_->relocation_mutex_->Lock();
+#ifdef DEBUG
+ heap_->relocation_mutex_locked_by_optimizer_thread_ =
+
heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
+#endif // DEBUG
+ }
+}
+
} } // namespace v8::internal
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
5b8610f945423b0c282e70c1a76d8bd820624ea2..f3a5b776e9f1d98122455e8c621ccf72a743ba83
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1856,6 +1856,31 @@ class Heap {
void CheckpointObjectStats();
+ // We don't use a ScopedLock here since we want to lock the heap
+ // only when FLAG_parallel_recompilation is true.
+ class RelocationLock {
+ public:
+ explicit RelocationLock(Heap* heap);
+
+ ~RelocationLock() {
+ if (FLAG_parallel_recompilation) {
+#ifdef DEBUG
+ heap_->relocation_mutex_locked_by_optimizer_thread_ = false;
+#endif // DEBUG
+ heap_->relocation_mutex_->Unlock();
+ }
+ }
+
+#ifdef DEBUG
+ static bool IsLockedByOptimizerThread(Heap* heap) {
+ return heap->relocation_mutex_locked_by_optimizer_thread_;
+ }
+#endif // DEBUG
+
+ private:
+ Heap* heap_;
+ };
+
private:
Heap();
@@ -2330,6 +2355,11 @@ class Heap {
MemoryChunk* chunks_queued_for_free_;
+ Mutex* relocation_mutex_;
+#ifdef DEBUG
+ bool relocation_mutex_locked_by_optimizer_thread_;
+#endif // DEBUG;
+
friend class Factory;
friend class GCTracer;
friend class DisallowAllocationFailure;
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
9ca78ccc84454c2f20140f22614b5951b79911e9..dd071944c55874b52b14dd8564d291c5abbbad7a
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -511,6 +511,7 @@ class ReachabilityAnalyzer BASE_EMBEDDED {
void HGraph::Verify(bool do_full_verify) const {
+ Heap::RelocationLock(isolate()->heap());
ALLOW_HANDLE_DEREF(isolate(), "debug mode verification");
for (int i = 0; i < blocks_.length(); i++) {
HBasicBlock* block = blocks_.at(i);
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
5685ab5de2964d9a56abe0dac7520344cd2b4256..62dee4847265f489423b101d9dc708c410ebffbf
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -3125,6 +3125,8 @@ void
MarkCompactCollector::ProcessInvalidatedCode(ObjectVisitor* visitor) {
void MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
+ Heap::RelocationLock relocation_lock(heap());
+
bool code_slots_filtering_required;
{ GCTracer::Scope gc_scope(tracer_, GCTracer::Scope::MC_SWEEP_NEWSPACE);
code_slots_filtering_required = MarkInvalidatedCode();
Index: src/optimizing-compiler-thread.cc
diff --git a/src/optimizing-compiler-thread.cc
b/src/optimizing-compiler-thread.cc
index
b982b94198f617549d995699b8cd34169c95e490..1e2e0a85df11a195fdced7f8911d76055bc4d708
100644
--- a/src/optimizing-compiler-thread.cc
+++ b/src/optimizing-compiler-thread.cc
@@ -88,7 +88,9 @@ void OptimizingCompilerThread::CompileNext() {
// The function may have already been optimized by OSR. Simply continue.
// Mark it for installing before queuing so that we can be sure of the
write
// order: marking first and (after being queued) installing code second.
-
optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
+ { Heap::RelocationLock relocation_lock(isolate_->heap());
+
optimizing_compiler->info()->closure()->MarkForInstallingRecompiledCode();
+ }
output_queue_.Enqueue(optimizing_compiler);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.