Commit 9fbbe2a4 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] Full MC/Minor MC: Add support for ThinString

This reverts commit b4d2f3eb.

Bug: chromium:651354, chromium:788113
Change-Id: I04b7541e7eb69f737d45e90bbfec591cf8f8190f
Reviewed-on: https://chromium-review.googlesource.com/800552Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49765}
parent 1385b092
......@@ -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,26 @@ 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;
Map* map = object->map();
// Some objects can be evacuated without creating a copy.
if (map->visitor_id() == kVisitThinString) {
HeapObject* actual = ThinString::cast(object)->unchecked_actual();
if (MarkCompactCollector::IsOnEvacuationCandidate(actual)) return false;
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 +1527,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>
......
......@@ -525,6 +525,10 @@ void ConsString::set_second(String* value, WriteBarrierMode mode) {
ACCESSORS(ThinString, actual, String, kActualOffset);
HeapObject* ThinString::unchecked_actual() const {
return reinterpret_cast<HeapObject*>(READ_FIELD(this, kActualOffset));
}
bool ExternalString::is_short() {
InstanceType type = map()->instance_type();
return (type & kShortExternalStringMask) == kShortExternalStringTag;
......
......@@ -631,6 +631,7 @@ class ThinString : public String {
public:
// Actual string that this ThinString refers to.
inline String* actual() const;
inline HeapObject* unchecked_actual() const;
inline void set_actual(String* s,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
......
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