Commit 6b29f1cf authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Minor MC: Support ThinString

No-try: true
Bug: chromium:651354, chromium:788113
Change-Id: I53cc2f04974671982371d1c26c71bd559450a5aa
Reviewed-on: https://chromium-review.googlesource.com/800176Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49752}
parent 9ac877fa
......@@ -1452,9 +1452,11 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
buffer_(LocalAllocationBuffer::InvalidBuffer()),
promoted_size_(0),
semispace_copied_size_(0),
local_pretenuring_feedback_(local_pretenuring_feedback) {}
local_pretenuring_feedback_(local_pretenuring_feedback),
is_incremental_marking_(heap->incremental_marking()->IsMarking()) {}
inline bool Visit(HeapObject* object, int size) override {
if (TryEvacuateWithoutCopy(object)) return true;
HeapObject* target_object = nullptr;
if (heap_->ShouldBePromoted(object->address()) &&
TryEvacuateObject(OLD_SPACE, object, size, &target_object)) {
......@@ -1474,6 +1476,21 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
intptr_t semispace_copied_size() { return semispace_copied_size_; }
private:
inline bool TryEvacuateWithoutCopy(HeapObject* object) {
if (is_incremental_marking_) return false;
// Some objects can be evacuated without creating a copy.
if (object->IsThinString()) {
HeapObject* actual = ThinString::cast(object)->actual();
base::Relaxed_Store(
reinterpret_cast<base::AtomicWord*>(object->address()),
reinterpret_cast<base::AtomicWord>(
MapWord::FromForwardingAddress(actual).ToMap()));
return true;
}
// TODO(mlippautz): Handle ConsString.
return false;
}
inline AllocationSpace AllocateTargetObject(HeapObject* old_object, int size,
HeapObject** target_object) {
AllocationAlignment alignment = old_object->RequiredAlignment();
......@@ -1505,6 +1522,7 @@ class EvacuateNewSpaceVisitor final : public EvacuateVisitorBase {
intptr_t promoted_size_;
intptr_t semispace_copied_size_;
Heap::PretenuringFeedbackMap* local_pretenuring_feedback_;
bool is_incremental_marking_;
};
template <PageEvacuationMode mode>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment