Commit a0bc7651 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[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.

R=hpayer@chromium.org,mlippautz@chromium.org

Review URL: https://codereview.chromium.org/1328003002

Cr-Commit-Position: refs/heads/master@{#30716}
parent 28235e94
......@@ -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"
......
......@@ -2037,7 +2037,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) |
......@@ -6104,5 +6104,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
......@@ -698,6 +698,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);
......@@ -756,6 +759,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();
......@@ -1495,8 +1502,9 @@ class Heap {
AllocationAlignment alignment);
// ===========================================================================
// ArrayBufferTracker. =======================================================
// ArrayBuffer tracking. =====================================================
// ===========================================================================
void RegisterNewArrayBuffer(JSArrayBuffer* buffer);
void UnregisterArrayBuffer(JSArrayBuffer* buffer);
......
......@@ -37,6 +37,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
......
......@@ -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
......
......@@ -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>();
......
......@@ -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());
}
......
......@@ -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(
......@@ -5362,11 +5362,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
}
}
......@@ -5388,7 +5388,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));
}
}
......
......@@ -7103,7 +7103,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));
......@@ -7240,7 +7240,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;
}
......@@ -10009,7 +10009,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));
}
......
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