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

Side by Side Diff: src/heap/heap.cc

Issue 1176263004: Introduce a base pointer field in FixedTypedArrayBase and teach GC about it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/elements-kind.cc ('k') | src/heap/mark-compact.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); 2414 int length = reinterpret_cast<FixedDoubleArray*>(object)->length();
2415 int object_size = FixedDoubleArray::SizeFor(length); 2415 int object_size = FixedDoubleArray::SizeFor(length);
2416 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size); 2416 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
2417 } 2417 }
2418 2418
2419 2419
2420 static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot, 2420 static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot,
2421 HeapObject* object) { 2421 HeapObject* object) {
2422 int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size(); 2422 int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size();
2423 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); 2423 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size);
2424
2425 MapWord map_word = object->map_word();
2426 DCHECK(map_word.IsForwardingAddress());
2427 FixedTypedArrayBase* target =
2428 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress());
2429 target->set_base_pointer(target, SKIP_WRITE_BARRIER);
2424 } 2430 }
2425 2431
2426 2432
2427 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, 2433 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot,
2428 HeapObject* object) { 2434 HeapObject* object) {
2429 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); 2435 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size();
2430 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size); 2436 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size);
2437
2438 MapWord map_word = object->map_word();
2439 DCHECK(map_word.IsForwardingAddress());
2440 FixedTypedArrayBase* target =
2441 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress());
2442 target->set_base_pointer(target, SKIP_WRITE_BARRIER);
2431 } 2443 }
2432 2444
2433 2445
2434 static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot, 2446 static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot,
2435 HeapObject* object) { 2447 HeapObject* object) {
2436 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object); 2448 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object);
2437 2449
2438 Heap* heap = map->GetHeap(); 2450 Heap* heap = map->GetHeap();
2439 MapWord map_word = object->map_word(); 2451 MapWord map_word = object->map_word();
2440 DCHECK(map_word.IsForwardingAddress()); 2452 DCHECK(map_word.IsForwardingAddress());
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 AllocationSpace space = SelectSpace(size, pretenure); 3913 AllocationSpace space = SelectSpace(size, pretenure);
3902 3914
3903 HeapObject* object; 3915 HeapObject* object;
3904 AllocationResult allocation = AllocateRaw( 3916 AllocationResult allocation = AllocateRaw(
3905 size, space, OLD_SPACE, 3917 size, space, OLD_SPACE,
3906 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned); 3918 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned);
3907 if (!allocation.To(&object)) return allocation; 3919 if (!allocation.To(&object)) return allocation;
3908 3920
3909 object->set_map(MapForFixedTypedArray(array_type)); 3921 object->set_map(MapForFixedTypedArray(array_type));
3910 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); 3922 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object);
3923 elements->set_base_pointer(elements, SKIP_WRITE_BARRIER);
3911 elements->set_length(length); 3924 elements->set_length(length);
3912 if (initialize) memset(elements->DataPtr(), 0, elements->DataSize()); 3925 if (initialize) memset(elements->DataPtr(), 0, elements->DataSize());
3913 return elements; 3926 return elements;
3914 } 3927 }
3915 3928
3916 3929
3917 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { 3930 AllocationResult Heap::AllocateCode(int object_size, bool immovable) {
3918 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); 3931 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment));
3919 AllocationResult allocation = 3932 AllocationResult allocation =
3920 AllocateRaw(object_size, CODE_SPACE, CODE_SPACE); 3933 AllocateRaw(object_size, CODE_SPACE, CODE_SPACE);
(...skipping 2840 matching lines...) Expand 10 before | Expand all | Expand 10 after
6761 *object_type = "CODE_TYPE"; \ 6774 *object_type = "CODE_TYPE"; \
6762 *object_sub_type = "CODE_AGE/" #name; \ 6775 *object_sub_type = "CODE_AGE/" #name; \
6763 return true; 6776 return true;
6764 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6777 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6765 #undef COMPARE_AND_RETURN_NAME 6778 #undef COMPARE_AND_RETURN_NAME
6766 } 6779 }
6767 return false; 6780 return false;
6768 } 6781 }
6769 } // namespace internal 6782 } // namespace internal
6770 } // namespace v8 6783 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements-kind.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698