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

Unified Diff: src/heap/heap.cc

Issue 2097023002: Reland [heap] Avoid the use of cells to point from code to new-space objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase. Created 4 years, 6 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/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 5806ce10161a83f50a92502d438bd0a2f64fb321..8161056681a97066c8a9c27f8bacebc1df319273 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -1469,38 +1469,6 @@ void Heap::MarkCompactPrologue() {
}
-#ifdef VERIFY_HEAP
-// Visitor class to verify pointers in code or data space do not point into
-// new space.
-class VerifyNonPointerSpacePointersVisitor : public ObjectVisitor {
- public:
- explicit VerifyNonPointerSpacePointersVisitor(Heap* heap) : heap_(heap) {}
-
- void VisitPointers(Object** start, Object** end) override {
- for (Object** current = start; current < end; current++) {
- if ((*current)->IsHeapObject()) {
- CHECK(!heap_->InNewSpace(HeapObject::cast(*current)));
- }
- }
- }
-
- private:
- Heap* heap_;
-};
-
-
-static void VerifyNonPointerSpacePointers(Heap* heap) {
- // Verify that there are no pointers to new space in spaces where we
- // do not expect them.
- VerifyNonPointerSpacePointersVisitor v(heap);
- HeapObjectIterator code_it(heap->code_space());
- for (HeapObject* object = code_it.Next(); object != NULL;
- object = code_it.Next())
- object->Iterate(&v);
-}
-#endif // VERIFY_HEAP
-
-
void Heap::CheckNewSpaceExpansionCriteria() {
if (FLAG_experimental_new_space_growth_heuristic) {
if (new_space_.TotalCapacity() < new_space_.MaximumCapacity() &&
@@ -1613,10 +1581,6 @@ void Heap::Scavenge() {
mark_compact_collector()->sweeper().EnsureNewSpaceCompleted();
-#ifdef VERIFY_HEAP
- if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this);
-#endif
-
gc_state_ = SCAVENGE;
// Implements Cheney's copying algorithm
@@ -2859,6 +2823,10 @@ void Heap::CreateInitialObjects() {
*WeakHashTable::New(isolate(), 16, USE_DEFAULT_MINIMUM_CAPACITY,
TENURED));
+ set_weak_new_space_object_to_code_list(
+ ArrayList::cast(*(factory->NewFixedArray(16, TENURED))));
+ weak_new_space_object_to_code_list()->SetLength(0);
+
set_script_list(Smi::FromInt(0));
Handle<SeededNumberDictionary> slow_element_dictionary =
@@ -2918,7 +2886,6 @@ void Heap::CreateInitialObjects() {
CreateFixedStubs();
}
-
bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {
switch (root_index) {
case kNumberStringCacheRootIndex:
@@ -2933,6 +2900,7 @@ bool Heap::RootCanBeWrittenAfterInitialization(Heap::RootListIndex root_index) {
case kMicrotaskQueueRootIndex:
case kDetachedContextsRootIndex:
case kWeakObjectToCodeTableRootIndex:
+ case kWeakNewSpaceObjectToCodeListRootIndex:
case kRetainedMapsRootIndex:
case kNoScriptSharedFunctionInfosRootIndex:
case kWeakStackTraceListRootIndex:
@@ -5565,6 +5533,18 @@ void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallback callback) {
}
// TODO(ishell): Find a better place for this.
+void Heap::AddWeakNewSpaceObjectToCodeDependency(Handle<HeapObject> obj,
+ Handle<WeakCell> code) {
+ DCHECK(InNewSpace(*obj));
+ DCHECK(!InNewSpace(*code));
+ Handle<ArrayList> list(weak_new_space_object_to_code_list(), isolate());
+ list = ArrayList::Add(list, isolate()->factory()->NewWeakCell(obj), code);
+ if (*list != weak_new_space_object_to_code_list()) {
+ set_weak_new_space_object_to_code_list(*list);
+ }
+}
+
+// TODO(ishell): Find a better place for this.
void Heap::AddWeakObjectToCodeDependency(Handle<HeapObject> obj,
Handle<DependentCode> dep) {
DCHECK(!InNewSpace(*obj));
@@ -5719,6 +5699,26 @@ void Heap::ClearRecordedSlotRange(Address start, Address end) {
}
}
+void Heap::RecordWriteIntoCodeSlow(Code* host, RelocInfo* rinfo,
+ Object* value) {
+ DCHECK(InNewSpace(value));
+ Page* source_page = Page::FromAddress(reinterpret_cast<Address>(host));
+ RelocInfo::Mode rmode = rinfo->rmode();
+ Address addr = rinfo->pc();
+ SlotType slot_type = SlotTypeForRelocInfoMode(rmode);
+ if (rinfo->IsInConstantPool()) {
+ addr = rinfo->constant_pool_entry_address();
+ if (RelocInfo::IsCodeTarget(rmode)) {
+ slot_type = CODE_ENTRY_SLOT;
+ } else {
+ DCHECK(RelocInfo::IsEmbeddedObject(rmode));
+ slot_type = OBJECT_SLOT;
+ }
+ }
+ RememberedSet<OLD_TO_NEW>::InsertTyped(
+ source_page, reinterpret_cast<Address>(host), slot_type, addr);
+}
+
Space* AllSpaces::next() {
switch (counter_++) {
case NEW_SPACE:
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698