Reviewers: Hannes Payer (OOO), Michael Lippautz,
Description:
[heap] No leakage of objects-visiting.h outside of heap.
This prevents the internal objects-visiting.h to be usable outisde of
the "heap" directory. The static object visitation is only usefull
within the GC and is now properly encapsulated.
[email protected],[email protected]
Please review this at https://codereview.chromium.org/1328003002/
Base URL:
https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-scavenger
Affected files (+33, -21 lines):
M src/heap/heap.h
M src/heap/heap.cc
M src/heap/heap-inl.h
M src/heap/mark-compact.h
M src/heap/mark-compact.cc
M src/heap/objects-visiting.h
M src/objects.cc
M src/objects-debug.cc
M src/objects-inl.h
Index: src/heap/heap-inl.h
diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h
index
7261106938d9c285c4a2ff2c072a28257be621b5..5e4180d0a5a2695cb5ad31102c0a08bd7ef582e2
100644
--- a/src/heap/heap-inl.h
+++ b/src/heap/heap-inl.h
@@ -11,7 +11,6 @@
#include "src/counters.h"
#include "src/heap/heap.h"
#include "src/heap/incremental-marking-inl.h"
-#include "src/heap/objects-visiting.h"
#include "src/heap/spaces-inl.h"
#include "src/heap/store-buffer.h"
#include "src/heap/store-buffer-inl.h"
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
22fde0c498cef9ae5c468d01a817a0ef60d9a050..dc01bd7c4d0ebbf79d37c2ecd93cec509bec98a5
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -2125,7 +2125,7 @@ AllocationResult Heap::AllocateMap(InstanceType
instance_type,
}
// Must be called only after |instance_type|, |instance_size| and
// |layout_descriptor| are set.
- map->set_visitor_id(StaticVisitorBase::GetVisitorId(map));
+ map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map));
map->set_bit_field(0);
map->set_bit_field2(1 << Map::kIsExtensible);
int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
@@ -6186,5 +6186,11 @@ bool Heap::GetObjectTypeName(size_t index, const
char** object_type,
return false;
}
+
+// static
+int Heap::GetStaticVisitorIdForMap(Map* map) {
+ return StaticVisitorBase::GetVisitorId(map);
+}
+
} // namespace internal
} // namespace v8
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
bb8f4ac23767d5eeb5cbee44330d2211fd1790df..dc1211470f464c622b08d9ceffc0ae7c8611a599
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -696,6 +696,9 @@ class Heap {
// The roots that have an index less than this are always in old space.
static const int kOldSpaceRoots = 0x20;
+ // The minimum size of a HeapObject on the heap.
+ static const int kMinObjectSizeInWords = 2;
+
STATIC_ASSERT(kUndefinedValueRootIndex ==
Internals::kUndefinedValueRootIndex);
STATIC_ASSERT(kNullValueRootIndex == Internals::kNullValueRootIndex);
@@ -754,6 +757,10 @@ class Heap {
// pointer size aligned addresses.
static inline void MoveBlock(Address dst, Address src, int byte_size);
+ // Determines a static visitor id based on the given {map} that can then
be
+ // stored on the map to facilitate fast dispatch for {StaticVisitorBase}.
+ static int GetStaticVisitorIdForMap(Map* map);
+
// Notifies the heap that is ok to start marking or other activities that
// should not happen during deserialization.
void NotifyDeserializationComplete();
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
6159796b4ba234726acb15cb2dd3b92d77f9bb79..c09f706d44825bdf5e458fb42181dcdcf1fb5c32
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -36,6 +36,11 @@ const char* Marking::kGreyBitPattern = "11";
const char* Marking::kImpossibleBitPattern = "01";
+// The following has to hold in order for {Marking::MarkBitFrom} to not
produce
+// invalid {kImpossibleBitPattern} in the marking bitmap by overlapping.
+STATIC_ASSERT(Heap::kMinObjectSizeInWords >= 2);
+
+
//
-------------------------------------------------------------------------
// MarkCompactCollector
Index: src/heap/mark-compact.h
diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h
index
f6df6f4a2e5394b30b22fdef668789ed50f73d19..7c438132b4b7657d3ee80a55004e680d3a8fb45b
100644
--- a/src/heap/mark-compact.h
+++ b/src/heap/mark-compact.h
@@ -117,10 +117,6 @@ class Marking : public AllStatic {
markbit.Next().Set();
}
- static void SetAllMarkBitsInRange(MarkBit start, MarkBit end);
- static void ClearAllMarkBitsOfCellsContainedInRange(MarkBit start,
- MarkBit end);
-
static void TransferMark(Heap* heap, Address old_start, Address
new_start);
#ifdef DEBUG
Index: src/heap/objects-visiting.h
diff --git a/src/heap/objects-visiting.h b/src/heap/objects-visiting.h
index
ff2e7df0faadb135b8b507d4d0ecb2b73faa15fb..1eba88731b38acfc643708be2c0b82ed3f1d3fac
100644
--- a/src/heap/objects-visiting.h
+++ b/src/heap/objects-visiting.h
@@ -6,6 +6,7 @@
#define V8_OBJECTS_VISITING_H_
#include "src/allocation.h"
+#include "src/heap/heap.h"
#include "src/heap/spaces.h"
#include "src/layout-descriptor.h"
@@ -99,7 +100,6 @@ class StaticVisitorBase : public AllStatic {
kVisitDataObject = kVisitDataObject2,
kVisitJSObject = kVisitJSObject2,
kVisitStruct = kVisitStruct2,
- kMinObjectSizeInWords = 2
};
// Visitor ID should fit in one byte.
@@ -121,15 +121,15 @@ class StaticVisitorBase : public AllStatic {
DCHECK((base == kVisitDataObject) || (base == kVisitStruct) ||
(base == kVisitJSObject));
DCHECK(IsAligned(object_size, kPointerSize));
- DCHECK(kMinObjectSizeInWords * kPointerSize <= object_size);
+ DCHECK(Heap::kMinObjectSizeInWords * kPointerSize <= object_size);
DCHECK(object_size <= Page::kMaxRegularHeapObjectSize);
DCHECK(!has_unboxed_fields || (base == kVisitJSObject));
if (has_unboxed_fields) return generic;
- int visitor_id =
- Min(base + (object_size >> kPointerSizeLog2) -
kMinObjectSizeInWords,
- static_cast<int>(generic));
+ int visitor_id = Min(
+ base + (object_size >> kPointerSizeLog2) -
Heap::kMinObjectSizeInWords,
+ static_cast<int>(generic));
return static_cast<VisitorId>(visitor_id);
}
@@ -171,8 +171,7 @@ class VisitorDispatchTable {
template <typename Visitor, StaticVisitorBase::VisitorId base,
StaticVisitorBase::VisitorId generic>
void RegisterSpecializations() {
- STATIC_ASSERT((generic - base +
StaticVisitorBase::kMinObjectSizeInWords) ==
- 10);
+ STATIC_ASSERT((generic - base + Heap::kMinObjectSizeInWords) == 10);
RegisterSpecialization<Visitor, base, generic, 2>();
RegisterSpecialization<Visitor, base, generic, 3>();
RegisterSpecialization<Visitor, base, generic, 4>();
Index: src/objects-debug.cc
diff --git a/src/objects-debug.cc b/src/objects-debug.cc
index
12b4ec7ba057dc987c4749a2b9755803326a029f..8209774d1510a7a5e84fd3712af3e47874ef00c1
100644
--- a/src/objects-debug.cc
+++ b/src/objects-debug.cc
@@ -343,7 +343,7 @@ void Map::DictionaryMapVerify() {
CHECK(is_dictionary_map());
CHECK(instance_descriptors()->IsEmpty());
CHECK_EQ(0, unused_property_fields());
- CHECK_EQ(StaticVisitorBase::GetVisitorId(this), visitor_id());
+ CHECK_EQ(Heap::GetStaticVisitorIdForMap(this), visitor_id());
}
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
bbcca262f0d5189ff63282222e9915d32f395b2d..c031ef96b5d40730e6a0ba1c600dc384f30880f6
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1812,7 +1812,7 @@ inline void
AllocationSite::set_memento_found_count(int count) {
// Verify that we can count more mementos than we can possibly find in
one
// new space collection.
DCHECK((GetHeap()->MaxSemiSpaceSize() /
- (StaticVisitorBase::kMinObjectSizeInWords * kPointerSize +
+ (Heap::kMinObjectSizeInWords * kPointerSize +
AllocationMemento::kSize)) < MementoFoundCountBits::kMax);
DCHECK(count < MementoFoundCountBits::kMax);
set_pretenure_data(
@@ -5357,11 +5357,11 @@ void Map::UpdateDescriptors(DescriptorArray*
descriptors,
// TODO(ishell): remove these checks from VERIFY_HEAP mode.
if (FLAG_verify_heap) {
CHECK(layout_descriptor()->IsConsistentWithMap(this));
- CHECK(visitor_id() == StaticVisitorBase::GetVisitorId(this));
+ CHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
}
#else
SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
- DCHECK(visitor_id() == StaticVisitorBase::GetVisitorId(this));
+ DCHECK(visitor_id() == Heap::GetStaticVisitorIdForMap(this));
#endif
}
}
@@ -5383,7 +5383,7 @@ void Map::InitializeDescriptors(DescriptorArray*
descriptors,
#else
SLOW_DCHECK(layout_descriptor()->IsConsistentWithMap(this));
#endif
- set_visitor_id(StaticVisitorBase::GetVisitorId(this));
+ set_visitor_id(Heap::GetStaticVisitorIdForMap(this));
}
}
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
c0539c493fa432fc0d8dde8993c02a3ded2c5178..718238c7a0d1c58cf637b3af67913863ac818def
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6915,7 +6915,7 @@ Handle<Map> Map::CopyInstallDescriptors(
#else
SLOW_DCHECK(result->layout_descriptor()->IsConsistentWithMap(*result));
#endif
- result->set_visitor_id(StaticVisitorBase::GetVisitorId(*result));
+ result->set_visitor_id(Heap::GetStaticVisitorIdForMap(*result));
}
Handle<Name> name = handle(descriptors->GetKey(new_descriptor));
@@ -7052,7 +7052,7 @@ Handle<Map> Map::Create(Isolate* isolate, int
inobject_properties) {
copy->SetInObjectProperties(inobject_properties);
copy->set_unused_property_fields(inobject_properties);
copy->set_instance_size(new_instance_size);
- copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
+ copy->set_visitor_id(Heap::GetStaticVisitorIdForMap(*copy));
return copy;
}
@@ -9821,7 +9821,7 @@ static void ShrinkInstanceSize(Map* map, void* data) {
map->set_instance_size(map->instance_size() - slack * kPointerSize);
// Visitor id might depend on the instance size, recalculate it.
- map->set_visitor_id(StaticVisitorBase::GetVisitorId(map));
+ map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.