Commit ef6cb2dd authored by vegorov@chromium.org's avatar vegorov@chromium.org

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

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

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5041 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4329a58b
......@@ -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,9 +774,10 @@ 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,
static void IterateAndMarkPointersToFromSpace(Address start,
Address end,
ObjectSlotCallback callback);
......@@ -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();
......
......@@ -2060,6 +2060,23 @@ void ExternalFloatArray::set(int index, float value) {
ptr[index] = value;
}
inline Scavenger Map::scavenger() {
Scavenger callback = reinterpret_cast<Scavenger>(
READ_INTPTR_FIELD(this, kIterateBodyCallbackOffset));
ASSERT(callback == Heap::GetScavenger(instance_type(),
instance_size()));
return callback;
}
inline void Map::set_scavenger(Scavenger callback) {
ASSERT(!reinterpret_cast<Object*>(
reinterpret_cast<intptr_t>(callback))->IsHeapObject());
WRITE_INTPTR_FIELD(this,
kIterateBodyCallbackOffset,
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);
}
......
......@@ -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 kIterateBodyCallbackOffset = kCodeCacheOffset + kPointerSize;
static const int kPadStart = kIterateBodyCallbackOffset + 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