Commit 7780bea2 authored by vegorov@chromium.org's avatar vegorov@chromium.org

Virtually dispatched scavengers

Use virtually dispatched specialized scavengers instead of single generic ScavengeObjectSlow implementation.

Rollback of r5041 with assertion checking callback alignment removed. Map space is iterated in a special fashion during scavenges so special callback alignment is not required.

Review URL: http://codereview.chromium.org/2950003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5047 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ef8baf25
......@@ -812,6 +812,9 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
initial_map->set_instance_size(
initial_map->instance_size() + 5 * kPointerSize);
initial_map->set_instance_descriptors(*descriptors);
initial_map->set_scavenger(
Heap::GetScavenger(initial_map->instance_type(),
initial_map->instance_size()));
}
{ // -- J S O N
......
......@@ -277,6 +277,8 @@ Handle<Map> Factory::CopyMap(Handle<Map> src,
copy->set_inobject_properties(inobject_properties);
copy->set_unused_property_fields(inobject_properties);
copy->set_instance_size(copy->instance_size() + instance_size_delta);
copy->set_scavenger(Heap::GetScavenger(copy->instance_type(),
copy->instance_size()));
return copy;
}
......
This diff is collapsed.
......@@ -774,11 +774,12 @@ class Heap : public AllStatic {
DirtyRegionCallback visit_dirty_region,
ObjectSlotCallback callback);
// Iterate pointers to new space found in memory interval from start to end.
// Iterate pointers to from semispace of new space found in memory interval
// from start to end.
// Update dirty marks for page containing start address.
static void IterateAndMarkPointersToNewSpace(Address start,
Address end,
ObjectSlotCallback callback);
static void IterateAndMarkPointersToFromSpace(Address start,
Address end,
ObjectSlotCallback callback);
// Iterate pointers to new space found in memory interval from start to end.
// Return true if pointers to new space was found.
......@@ -985,6 +986,8 @@ class Heap : public AllStatic {
static void RecordStats(HeapStats* stats);
static Scavenger GetScavenger(int instance_type, int instance_size);
// Copy block of memory from src to dst. Size of block should be aligned
// by pointer size.
static inline void CopyBlock(Address dst, Address src, int byte_size);
......@@ -1232,17 +1235,7 @@ class Heap : public AllStatic {
set_instanceof_cache_function(the_hole_value());
}
// Helper function used by CopyObject to copy a source object to an
// allocated target object and update the forwarding pointer in the source
// object. Returns the target object.
static inline HeapObject* MigrateObject(HeapObject* source,
HeapObject* target,
int size);
#if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
// Record the copy of an object in the NewSpace's statistics.
static void RecordCopiedObject(HeapObject* obj);
// Record statistics before and after garbage collection.
static void ReportStatisticsBeforeGC();
static void ReportStatisticsAfterGC();
......
......@@ -425,8 +425,10 @@ void MarkCompactCollector::MarkMapContents(Map* map) {
// Since the descriptor array has been marked already, it is fine
// that one of these fields contains a pointer to it.
MarkingVisitor visitor; // Has no state or contents.
visitor.VisitPointers(HeapObject::RawField(map, Map::kPrototypeOffset),
HeapObject::RawField(map, Map::kSize));
visitor.VisitPointers(HeapObject::RawField(map,
Map::kPointerFieldsBeginOffset),
HeapObject::RawField(map,
Map::kPointerFieldsEndOffset));
}
......
......@@ -2060,6 +2060,21 @@ void ExternalFloatArray::set(int index, float value) {
ptr[index] = value;
}
inline Scavenger Map::scavenger() {
Scavenger callback = reinterpret_cast<Scavenger>(
READ_INTPTR_FIELD(this, kScavengerCallbackOffset));
ASSERT(callback == Heap::GetScavenger(instance_type(),
instance_size()));
return callback;
}
inline void Map::set_scavenger(Scavenger callback) {
WRITE_INTPTR_FIELD(this,
kScavengerCallbackOffset,
reinterpret_cast<intptr_t>(callback));
}
int Map::instance_size() {
return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2;
......
......@@ -2190,6 +2190,8 @@ Object* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
int new_instance_size = map()->instance_size() - instance_size_delta;
new_map->set_inobject_properties(0);
new_map->set_instance_size(new_instance_size);
new_map->set_scavenger(Heap::GetScavenger(new_map->instance_type(),
new_map->instance_size()));
Heap::CreateFillerObjectAt(this->address() + new_instance_size,
instance_size_delta);
}
......@@ -5033,7 +5035,7 @@ void Map::ClearNonLiveTransitions(Object* real_prototype) {
void Map::MapIterateBody(ObjectVisitor* v) {
// Assumes all Object* members are contiguously allocated!
IteratePointers(v, kPrototypeOffset, kCodeCacheOffset + kPointerSize);
IteratePointers(v, kPointerFieldsBeginOffset, kPointerFieldsEndOffset);
}
......
......@@ -2899,6 +2899,7 @@ class Code: public HeapObject {
DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
};
typedef void (*Scavenger)(Map* map, HeapObject** slot, HeapObject* object);
// All heap objects have a Map that describes their structure.
// A Map contains information about:
......@@ -3100,6 +3101,13 @@ class Map: public HeapObject {
void MapVerify();
#endif
inline Scavenger scavenger();
inline void set_scavenger(Scavenger callback);
inline void Scavenge(HeapObject** slot, HeapObject* obj) {
scavenger()(this, slot, obj);
}
static const int kMaxPreAllocatedPropertyFields = 255;
// Layout description.
......@@ -3110,7 +3118,8 @@ class Map: public HeapObject {
static const int kInstanceDescriptorsOffset =
kConstructorOffset + kPointerSize;
static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize;
static const int kPadStart = kCodeCacheOffset + kPointerSize;
static const int kScavengerCallbackOffset = kCodeCacheOffset + kPointerSize;
static const int kPadStart = kScavengerCallbackOffset + kPointerSize;
static const int kSize = MAP_POINTER_ALIGN(kPadStart);
// Layout of pointer fields. Heap iteration code relies on them
......
......@@ -673,6 +673,14 @@ void Deserializer::ReadObject(int space_number,
LOG(SnapshotPositionEvent(address, source_->position()));
}
ReadChunk(current, limit, space_number, address);
if (space == Heap::map_space()) {
ASSERT(size == Map::kSize);
HeapObject* obj = HeapObject::FromAddress(address);
Map* map = reinterpret_cast<Map*>(obj);
map->set_scavenger(Heap::GetScavenger(map->instance_type(),
map->instance_size()));
}
}
......
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