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

Side by Side Diff: src/mark-compact.cc

Issue 39973003: Merge bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: again Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/macros.py ('k') | src/math.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 1563
1564 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray( 1564 void MarkCompactMarkingVisitor::ObjectStatsCountFixedArray(
1565 FixedArrayBase* fixed_array, 1565 FixedArrayBase* fixed_array,
1566 FixedArraySubInstanceType fast_type, 1566 FixedArraySubInstanceType fast_type,
1567 FixedArraySubInstanceType dictionary_type) { 1567 FixedArraySubInstanceType dictionary_type) {
1568 Heap* heap = fixed_array->map()->GetHeap(); 1568 Heap* heap = fixed_array->map()->GetHeap();
1569 if (fixed_array->map() != heap->fixed_cow_array_map() && 1569 if (fixed_array->map() != heap->fixed_cow_array_map() &&
1570 fixed_array->map() != heap->fixed_double_array_map() && 1570 fixed_array->map() != heap->fixed_double_array_map() &&
1571 fixed_array != heap->empty_fixed_array()) { 1571 fixed_array != heap->empty_fixed_array()) {
1572 if (fixed_array->IsDictionary()) { 1572 if (fixed_array->IsDictionary()) {
1573 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1573 heap->RecordFixedArraySubTypeStats(dictionary_type,
1574 dictionary_type, 1574 fixed_array->Size());
1575 fixed_array->Size());
1576 } else { 1575 } else {
1577 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1576 heap->RecordFixedArraySubTypeStats(fast_type,
1578 fast_type, 1577 fixed_array->Size());
1579 fixed_array->Size());
1580 } 1578 }
1581 } 1579 }
1582 } 1580 }
1583 1581
1584 1582
1585 void MarkCompactMarkingVisitor::ObjectStatsVisitBase( 1583 void MarkCompactMarkingVisitor::ObjectStatsVisitBase(
1586 MarkCompactMarkingVisitor::VisitorId id, Map* map, HeapObject* obj) { 1584 MarkCompactMarkingVisitor::VisitorId id, Map* map, HeapObject* obj) {
1587 Heap* heap = map->GetHeap(); 1585 Heap* heap = map->GetHeap();
1588 int object_size = obj->Size(); 1586 int object_size = obj->Size();
1589 heap->RecordObjectStats(map->instance_type(), -1, object_size); 1587 heap->RecordObjectStats(map->instance_type(), object_size);
1590 non_count_table_.GetVisitorById(id)(map, obj); 1588 non_count_table_.GetVisitorById(id)(map, obj);
1591 if (obj->IsJSObject()) { 1589 if (obj->IsJSObject()) {
1592 JSObject* object = JSObject::cast(obj); 1590 JSObject* object = JSObject::cast(obj);
1593 ObjectStatsCountFixedArray(object->elements(), 1591 ObjectStatsCountFixedArray(object->elements(),
1594 DICTIONARY_ELEMENTS_SUB_TYPE, 1592 DICTIONARY_ELEMENTS_SUB_TYPE,
1595 FAST_ELEMENTS_SUB_TYPE); 1593 FAST_ELEMENTS_SUB_TYPE);
1596 ObjectStatsCountFixedArray(object->properties(), 1594 ObjectStatsCountFixedArray(object->properties(),
1597 DICTIONARY_PROPERTIES_SUB_TYPE, 1595 DICTIONARY_PROPERTIES_SUB_TYPE,
1598 FAST_PROPERTIES_SUB_TYPE); 1596 FAST_PROPERTIES_SUB_TYPE);
1599 } 1597 }
(...skipping 12 matching lines...) Expand all
1612 MarkCompactMarkingVisitor::kVisitMap> { 1610 MarkCompactMarkingVisitor::kVisitMap> {
1613 public: 1611 public:
1614 static inline void Visit(Map* map, HeapObject* obj) { 1612 static inline void Visit(Map* map, HeapObject* obj) {
1615 Heap* heap = map->GetHeap(); 1613 Heap* heap = map->GetHeap();
1616 Map* map_obj = Map::cast(obj); 1614 Map* map_obj = Map::cast(obj);
1617 ASSERT(map->instance_type() == MAP_TYPE); 1615 ASSERT(map->instance_type() == MAP_TYPE);
1618 DescriptorArray* array = map_obj->instance_descriptors(); 1616 DescriptorArray* array = map_obj->instance_descriptors();
1619 if (map_obj->owns_descriptors() && 1617 if (map_obj->owns_descriptors() &&
1620 array != heap->empty_descriptor_array()) { 1618 array != heap->empty_descriptor_array()) {
1621 int fixed_array_size = array->Size(); 1619 int fixed_array_size = array->Size();
1622 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1620 heap->RecordFixedArraySubTypeStats(DESCRIPTOR_ARRAY_SUB_TYPE,
1623 DESCRIPTOR_ARRAY_SUB_TYPE, 1621 fixed_array_size);
1624 fixed_array_size);
1625 } 1622 }
1626 if (map_obj->HasTransitionArray()) { 1623 if (map_obj->HasTransitionArray()) {
1627 int fixed_array_size = map_obj->transitions()->Size(); 1624 int fixed_array_size = map_obj->transitions()->Size();
1628 heap->RecordObjectStats(FIXED_ARRAY_TYPE, 1625 heap->RecordFixedArraySubTypeStats(TRANSITION_ARRAY_SUB_TYPE,
1629 TRANSITION_ARRAY_SUB_TYPE, 1626 fixed_array_size);
1630 fixed_array_size);
1631 } 1627 }
1632 if (map_obj->has_code_cache()) { 1628 if (map_obj->has_code_cache()) {
1633 CodeCache* cache = CodeCache::cast(map_obj->code_cache()); 1629 CodeCache* cache = CodeCache::cast(map_obj->code_cache());
1634 heap->RecordObjectStats( 1630 heap->RecordFixedArraySubTypeStats(MAP_CODE_CACHE_SUB_TYPE,
1635 FIXED_ARRAY_TYPE, 1631 cache->default_cache()->Size());
1636 MAP_CODE_CACHE_SUB_TYPE,
1637 cache->default_cache()->Size());
1638 if (!cache->normal_type_cache()->IsUndefined()) { 1632 if (!cache->normal_type_cache()->IsUndefined()) {
1639 heap->RecordObjectStats( 1633 heap->RecordFixedArraySubTypeStats(
1640 FIXED_ARRAY_TYPE,
1641 MAP_CODE_CACHE_SUB_TYPE, 1634 MAP_CODE_CACHE_SUB_TYPE,
1642 FixedArray::cast(cache->normal_type_cache())->Size()); 1635 FixedArray::cast(cache->normal_type_cache())->Size());
1643 } 1636 }
1644 } 1637 }
1645 ObjectStatsVisitBase(kVisitMap, map, obj); 1638 ObjectStatsVisitBase(kVisitMap, map, obj);
1646 } 1639 }
1647 }; 1640 };
1648 1641
1649 1642
1650 template<> 1643 template<>
1651 class MarkCompactMarkingVisitor::ObjectStatsTracker< 1644 class MarkCompactMarkingVisitor::ObjectStatsTracker<
1652 MarkCompactMarkingVisitor::kVisitCode> { 1645 MarkCompactMarkingVisitor::kVisitCode> {
1653 public: 1646 public:
1654 static inline void Visit(Map* map, HeapObject* obj) { 1647 static inline void Visit(Map* map, HeapObject* obj) {
1655 Heap* heap = map->GetHeap(); 1648 Heap* heap = map->GetHeap();
1656 int object_size = obj->Size(); 1649 int object_size = obj->Size();
1657 ASSERT(map->instance_type() == CODE_TYPE); 1650 ASSERT(map->instance_type() == CODE_TYPE);
1658 heap->RecordObjectStats(CODE_TYPE, Code::cast(obj)->kind(), object_size); 1651 Code* code_obj = Code::cast(obj);
1652 heap->RecordCodeSubTypeStats(code_obj->kind(), code_obj->GetAge(),
1653 object_size);
1659 ObjectStatsVisitBase(kVisitCode, map, obj); 1654 ObjectStatsVisitBase(kVisitCode, map, obj);
1660 } 1655 }
1661 }; 1656 };
1662 1657
1663 1658
1664 template<> 1659 template<>
1665 class MarkCompactMarkingVisitor::ObjectStatsTracker< 1660 class MarkCompactMarkingVisitor::ObjectStatsTracker<
1666 MarkCompactMarkingVisitor::kVisitSharedFunctionInfo> { 1661 MarkCompactMarkingVisitor::kVisitSharedFunctionInfo> {
1667 public: 1662 public:
1668 static inline void Visit(Map* map, HeapObject* obj) { 1663 static inline void Visit(Map* map, HeapObject* obj) {
1669 Heap* heap = map->GetHeap(); 1664 Heap* heap = map->GetHeap();
1670 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj); 1665 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
1671 if (sfi->scope_info() != heap->empty_fixed_array()) { 1666 if (sfi->scope_info() != heap->empty_fixed_array()) {
1672 heap->RecordObjectStats( 1667 heap->RecordFixedArraySubTypeStats(
1673 FIXED_ARRAY_TYPE,
1674 SCOPE_INFO_SUB_TYPE, 1668 SCOPE_INFO_SUB_TYPE,
1675 FixedArray::cast(sfi->scope_info())->Size()); 1669 FixedArray::cast(sfi->scope_info())->Size());
1676 } 1670 }
1677 ObjectStatsVisitBase(kVisitSharedFunctionInfo, map, obj); 1671 ObjectStatsVisitBase(kVisitSharedFunctionInfo, map, obj);
1678 } 1672 }
1679 }; 1673 };
1680 1674
1681 1675
1682 template<> 1676 template<>
1683 class MarkCompactMarkingVisitor::ObjectStatsTracker< 1677 class MarkCompactMarkingVisitor::ObjectStatsTracker<
1684 MarkCompactMarkingVisitor::kVisitFixedArray> { 1678 MarkCompactMarkingVisitor::kVisitFixedArray> {
1685 public: 1679 public:
1686 static inline void Visit(Map* map, HeapObject* obj) { 1680 static inline void Visit(Map* map, HeapObject* obj) {
1687 Heap* heap = map->GetHeap(); 1681 Heap* heap = map->GetHeap();
1688 FixedArray* fixed_array = FixedArray::cast(obj); 1682 FixedArray* fixed_array = FixedArray::cast(obj);
1689 if (fixed_array == heap->string_table()) { 1683 if (fixed_array == heap->string_table()) {
1690 heap->RecordObjectStats( 1684 heap->RecordFixedArraySubTypeStats(
1691 FIXED_ARRAY_TYPE,
1692 STRING_TABLE_SUB_TYPE, 1685 STRING_TABLE_SUB_TYPE,
1693 fixed_array->Size()); 1686 fixed_array->Size());
1694 } 1687 }
1695 ObjectStatsVisitBase(kVisitFixedArray, map, obj); 1688 ObjectStatsVisitBase(kVisitFixedArray, map, obj);
1696 } 1689 }
1697 }; 1690 };
1698 1691
1699 1692
1700 void MarkCompactMarkingVisitor::Initialize() { 1693 void MarkCompactMarkingVisitor::Initialize() {
1701 StaticMarkingVisitor<MarkCompactMarkingVisitor>::Initialize(); 1694 StaticMarkingVisitor<MarkCompactMarkingVisitor>::Initialize();
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 // The second pass updates pointers to new space in all spaces. It is possible 2745 // The second pass updates pointers to new space in all spaces. It is possible
2753 // to encounter pointers to dead new space objects during traversal of pointers 2746 // to encounter pointers to dead new space objects during traversal of pointers
2754 // to new space. We should clear them to avoid encountering them during next 2747 // to new space. We should clear them to avoid encountering them during next
2755 // pointer iteration. This is an issue if the store buffer overflows and we 2748 // pointer iteration. This is an issue if the store buffer overflows and we
2756 // have to scan the entire old space, including dead objects, looking for 2749 // have to scan the entire old space, including dead objects, looking for
2757 // pointers to new space. 2750 // pointers to new space.
2758 void MarkCompactCollector::MigrateObject(Address dst, 2751 void MarkCompactCollector::MigrateObject(Address dst,
2759 Address src, 2752 Address src,
2760 int size, 2753 int size,
2761 AllocationSpace dest) { 2754 AllocationSpace dest) {
2762 HEAP_PROFILE(heap(), ObjectMoveEvent(src, dst)); 2755 HeapProfiler* heap_profiler = heap()->isolate()->heap_profiler();
2756 if (heap_profiler->is_profiling()) {
2757 heap_profiler->ObjectMoveEvent(src, dst, size);
2758 }
2763 ASSERT(heap()->AllowedToBeMigrated(HeapObject::FromAddress(src), dest)); 2759 ASSERT(heap()->AllowedToBeMigrated(HeapObject::FromAddress(src), dest));
2764 ASSERT(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize); 2760 ASSERT(dest != LO_SPACE && size <= Page::kMaxNonCodeHeapObjectSize);
2765 if (dest == OLD_POINTER_SPACE) { 2761 if (dest == OLD_POINTER_SPACE) {
2766 Address src_slot = src; 2762 Address src_slot = src;
2767 Address dst_slot = dst; 2763 Address dst_slot = dst;
2768 ASSERT(IsAligned(size, kPointerSize)); 2764 ASSERT(IsAligned(size, kPointerSize));
2769 2765
2770 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { 2766 for (int remaining = size / kPointerSize; remaining > 0; remaining--) {
2771 Object* value = Memory::Object_at(src_slot); 2767 Object* value = Memory::Object_at(src_slot);
2772 2768
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 bool MarkCompactCollector::TryPromoteObject(HeapObject* object, 2931 bool MarkCompactCollector::TryPromoteObject(HeapObject* object,
2936 int object_size) { 2932 int object_size) {
2937 // TODO(hpayer): Replace that check with an assert. 2933 // TODO(hpayer): Replace that check with an assert.
2938 CHECK(object_size <= Page::kMaxNonCodeHeapObjectSize); 2934 CHECK(object_size <= Page::kMaxNonCodeHeapObjectSize);
2939 2935
2940 OldSpace* target_space = heap()->TargetSpace(object); 2936 OldSpace* target_space = heap()->TargetSpace(object);
2941 2937
2942 ASSERT(target_space == heap()->old_pointer_space() || 2938 ASSERT(target_space == heap()->old_pointer_space() ||
2943 target_space == heap()->old_data_space()); 2939 target_space == heap()->old_data_space());
2944 Object* result; 2940 Object* result;
2945 MaybeObject* maybe_result = target_space->AllocateRaw(object_size); 2941 MaybeObject* maybe_result = target_space->AllocateRaw(
2942 object_size,
2943 PagedSpace::MOVE_OBJECT);
2946 if (maybe_result->ToObject(&result)) { 2944 if (maybe_result->ToObject(&result)) {
2947 HeapObject* target = HeapObject::cast(result); 2945 HeapObject* target = HeapObject::cast(result);
2948 MigrateObject(target->address(), 2946 MigrateObject(target->address(),
2949 object->address(), 2947 object->address(),
2950 object_size, 2948 object_size,
2951 target_space->identity()); 2949 target_space->identity());
2952 heap()->mark_compact_collector()->tracer()-> 2950 heap()->mark_compact_collector()->tracer()->
2953 increment_promoted_objects_size(object_size); 2951 increment_promoted_objects_size(object_size);
2954 return true; 2952 return true;
2955 } 2953 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3008 if (*cell == 0) continue; 3006 if (*cell == 0) continue;
3009 3007
3010 int live_objects = MarkWordToObjectStarts(*cell, offsets); 3008 int live_objects = MarkWordToObjectStarts(*cell, offsets);
3011 for (int i = 0; i < live_objects; i++) { 3009 for (int i = 0; i < live_objects; i++) {
3012 Address object_addr = cell_base + offsets[i] * kPointerSize; 3010 Address object_addr = cell_base + offsets[i] * kPointerSize;
3013 HeapObject* object = HeapObject::FromAddress(object_addr); 3011 HeapObject* object = HeapObject::FromAddress(object_addr);
3014 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object))); 3012 ASSERT(Marking::IsBlack(Marking::MarkBitFrom(object)));
3015 3013
3016 int size = object->Size(); 3014 int size = object->Size();
3017 3015
3018 MaybeObject* target = space->AllocateRaw(size); 3016 MaybeObject* target = space->AllocateRaw(size, PagedSpace::MOVE_OBJECT);
3019 if (target->IsFailure()) { 3017 if (target->IsFailure()) {
3020 // OS refused to give us memory. 3018 // OS refused to give us memory.
3021 V8::FatalProcessOutOfMemory("Evacuation"); 3019 V8::FatalProcessOutOfMemory("Evacuation");
3022 return; 3020 return;
3023 } 3021 }
3024 3022
3025 Object* target_object = target->ToObjectUnchecked(); 3023 Object* target_object = target->ToObjectUnchecked();
3026 3024
3027 MigrateObject(HeapObject::cast(target_object)->address(), 3025 MigrateObject(HeapObject::cast(target_object)->address(),
3028 object_addr, 3026 object_addr,
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 while (buffer != NULL) { 4352 while (buffer != NULL) {
4355 SlotsBuffer* next_buffer = buffer->next(); 4353 SlotsBuffer* next_buffer = buffer->next();
4356 DeallocateBuffer(buffer); 4354 DeallocateBuffer(buffer);
4357 buffer = next_buffer; 4355 buffer = next_buffer;
4358 } 4356 }
4359 *buffer_address = NULL; 4357 *buffer_address = NULL;
4360 } 4358 }
4361 4359
4362 4360
4363 } } // namespace v8::internal 4361 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/macros.py ('k') | src/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698