Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: runtime/vm/scavenger.h

Issue 2951333002: Moves the top_ and end_ words of the Scavenger into mutator thread. (Closed)
Patch Set: Address comments from CL Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/scavenger.h
diff --git a/runtime/vm/scavenger.h b/runtime/vm/scavenger.h
index fd4663de7decf7680a9cd26dc3581d2af389e295..4d35158ef392fa108c6c0ac52d3f01401f734a6b 100644
--- a/runtime/vm/scavenger.h
+++ b/runtime/vm/scavenger.h
@@ -123,14 +123,18 @@ class Scavenger {
RawObject* FindObject(FindObjectVisitor* visitor) const;
- uword TryAllocate(intptr_t size) {
+ uword TryAllocate(intptr_t size) { return TryAllocateGC(size); }
+
+ uword TryAllocateGC(intptr_t size) {
ASSERT(Utils::IsAligned(size, kObjectAlignment));
ASSERT(heap_ != Dart::vm_isolate()->heap());
+
#if defined(DEBUG)
if (FLAG_gc_at_alloc && !scavenging_) {
Scavenge();
}
#endif
+
uword result = top_;
intptr_t remaining = end_ - top_;
if (remaining < size) {
@@ -141,6 +145,39 @@ class Scavenger {
top_ += size;
ASSERT(to_->Contains(top_) || (top_ == to_->end()));
+
+ return result;
+ }
+
+ uword TryAllocateInTLAB(Thread* thread, intptr_t size) {
+ ASSERT(Utils::IsAligned(size, kObjectAlignment));
+ ASSERT(heap_ != Dart::vm_isolate()->heap());
+
+ ASSERT(thread->IsMutatorThread());
+ ASSERT(thread->heap() == heap_);
+
+#if defined(DEBUG)
+ if (FLAG_gc_at_alloc && !scavenging_) {
+ Scavenge();
+ }
+#endif
+
+ uword top = thread->top();
+ uword end = thread->end();
+
+ uword result = top;
+ intptr_t remaining = end - top;
+ if (remaining < size) {
+ return 0;
+ }
+
+ ASSERT(to_->Contains(result));
+ ASSERT((result & kObjectAlignmentMask) == object_alignment_);
+
+ top += size;
+ ASSERT(to_->Contains(top) || (top == to_->end()));
+
+ thread->set_top(top);
return result;
}
@@ -149,13 +186,20 @@ class Scavenger {
void Scavenge(bool invoke_api_callbacks);
// Promote all live objects.
- void Evacuate();
+ void Evacuate(Thread* thread);
// Accessors to generate code for inlined allocation.
rmacnak 2017/07/12 17:10:22 Remove TopAddress and EndAddress.
danunez 2017/07/12 18:23:38 Done.
uword* TopAddress() { return &top_; }
uword* EndAddress() { return &end_; }
- static intptr_t top_offset() { return OFFSET_OF(Scavenger, top_); }
- static intptr_t end_offset() { return OFFSET_OF(Scavenger, end_); }
+
+ uword top() { return top_; }
+ uword end() { return end_; }
+
+ void set_top(uword value) { top_ = value; }
+ void set_end(uword value) {
+ ASSERT(to_->end() == value);
+ end_ = value;
+ }
int64_t UsedInWords() const {
return (top_ - FirstObjectStart()) >> kWordSizeLog2;
@@ -192,6 +236,8 @@ class Scavenger {
void AllocateExternal(intptr_t size);
void FreeExternal(intptr_t size);
+ void FlushTLS() const;
+
private:
// Ids for time and data records in Heap::GCStats.
enum {
@@ -231,14 +277,18 @@ class Scavenger {
// not consume space in the to space they leave enough room for this stack.
void PushToPromotedStack(uword addr) {
ASSERT(scavenging_);
+
rmacnak 2017/07/12 17:10:22 Remove spurious whitespace changes.
danunez 2017/07/12 18:23:38 Done.
end_ -= sizeof(addr);
+
ASSERT(end_ > top_);
*reinterpret_cast<uword*>(end_) = addr;
}
uword PopFromPromotedStack() {
ASSERT(scavenging_);
+
uword result = *reinterpret_cast<uword*>(end_);
end_ += sizeof(result);
+
ASSERT(end_ <= to_->end());
return result;
}
@@ -294,6 +344,7 @@ class Scavenger {
intptr_t external_size_;
bool failed_to_promote_;
+ Mutex* space_lock_;
friend class ScavengerVisitor;
friend class ScavengerWeakVisitor;
« no previous file with comments | « runtime/vm/object_graph.cc ('k') | runtime/vm/scavenger.cc » ('j') | runtime/vm/scavenger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698