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

Unified Diff: src/heap/scavenger.cc

Issue 2549773002: Internalize strings in-place (Closed)
Patch Set: rebased Created 3 years, 11 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
« no previous file with comments | « src/heap/objects-visiting-inl.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/scavenger.cc
diff --git a/src/heap/scavenger.cc b/src/heap/scavenger.cc
index f2722e81de5e27a1d415991b955ce3f91cc1e38f..d4e191ade48f36f4c136b82c4147fc63c0d5ce04 100644
--- a/src/heap/scavenger.cc
+++ b/src/heap/scavenger.cc
@@ -30,6 +30,7 @@ class ScavengingVisitor : public StaticVisitorBase {
table_.Register(kVisitSeqOneByteString, &EvacuateSeqOneByteString);
table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString);
table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate);
+ table_.Register(kVisitThinString, &EvacuateThinString);
table_.Register(kVisitByteArray, &EvacuateByteArray);
table_.Register(kVisitFixedArray, &EvacuateFixedArray);
table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray);
@@ -89,6 +90,12 @@ class ScavengingVisitor : public StaticVisitorBase {
return &table_;
}
+ static void EvacuateThinStringNoShortcut(Map* map, HeapObject** slot,
+ HeapObject* object) {
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
+ ThinString::kSize);
+ }
+
private:
enum ObjectContents { DATA_OBJECT, POINTER_OBJECT };
@@ -339,6 +346,22 @@ class ScavengingVisitor : public StaticVisitorBase {
object_size);
}
+ static inline void EvacuateThinString(Map* map, HeapObject** slot,
+ HeapObject* object) {
+ if (marks_handling == IGNORE_MARKS) {
+ HeapObject* actual = ThinString::cast(object)->actual();
+ *slot = actual;
+ // ThinStrings always refer to internalized strings, which are
+ // always in old space.
+ DCHECK(!map->GetHeap()->InNewSpace(actual));
+ object->set_map_word(MapWord::FromForwardingAddress(actual));
+ return;
+ }
+
+ EvacuateObject<POINTER_OBJECT, kWordAligned>(map, slot, object,
+ ThinString::kSize);
+ }
+
template <ObjectContents object_contents>
class ObjectEvacuationStrategy {
public:
@@ -423,6 +446,10 @@ void Scavenger::SelectScavengingVisitorsTable() {
StaticVisitorBase::kVisitShortcutCandidate,
scavenging_visitors_table_.GetVisitorById(
StaticVisitorBase::kVisitConsString));
+ scavenging_visitors_table_.Register(
+ StaticVisitorBase::kVisitThinString,
+ &ScavengingVisitor<TRANSFER_MARKS, LOGGING_AND_PROFILING_DISABLED>::
+ EvacuateThinStringNoShortcut);
}
}
}
« no previous file with comments | « src/heap/objects-visiting-inl.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698