Index: runtime/vm/scavenger.h |
diff --git a/runtime/vm/scavenger.h b/runtime/vm/scavenger.h |
index fd4663de7decf7680a9cd26dc3581d2af389e295..f4cf90bc545212033c249f106cdb1797c1408369 100644 |
--- a/runtime/vm/scavenger.h |
+++ b/runtime/vm/scavenger.h |
@@ -123,9 +123,12 @@ class Scavenger { |
RawObject* FindObject(FindObjectVisitor* visitor) const; |
- uword TryAllocate(intptr_t size) { |
+ uword TryAllocate(intptr_t size) { return TryAllocateGC(size); } |
rmacnak
2017/07/12 20:30:06
Dead code, remove.
danunez
2017/07/12 21:02:12
Done.
|
+ |
+ uword TryAllocateGC(intptr_t size) { |
rmacnak
2017/07/12 20:30:06
No "Try". Allocation during a scavenge always succ
danunez
2017/07/12 21:02:12
Done.
|
ASSERT(Utils::IsAligned(size, kObjectAlignment)); |
ASSERT(heap_ != Dart::vm_isolate()->heap()); |
+ |
#if defined(DEBUG) |
if (FLAG_gc_at_alloc && !scavenging_) { |
rmacnak
2017/07/12 20:30:06
Remove, this is always called during a GC.
ASSERT
danunez
2017/07/12 21:02:12
Done.
|
Scavenge(); |
@@ -138,12 +141,36 @@ class Scavenger { |
} |
ASSERT(to_->Contains(result)); |
ASSERT((result & kObjectAlignmentMask) == object_alignment_); |
- |
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; |
+ } |
+ |
// Collect the garbage in this scavenger. |
void Scavenge(); |
void Scavenge(bool invoke_api_callbacks); |
@@ -151,11 +178,14 @@ class Scavenger { |
// Promote all live objects. |
void Evacuate(); |
- // Accessors to generate code for inlined allocation. |
- 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 +222,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 { |
@@ -254,12 +286,6 @@ class Scavenger { |
intptr_t NewSizeInWords(intptr_t old_size_in_words) const; |
- // Accessed from generated code. |
- // ** This block of fields must come first! ** |
- // For AOT cross-compilation, we rely on these members having the same offsets |
- // in SIMARM(IA32) and ARM, and the same offsets in SIMARM64(X64) and ARM64. |
- // We use only word-sized fields to avoid differences in struct packing on the |
- // different architectures. See also CheckOffsets in dart.cc. |
uword top_; |
uword end_; |