OLD | NEW |
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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 Object** end = start + external_string_table_.old_space_strings_.length(); | 1657 Object** end = start + external_string_table_.old_space_strings_.length(); |
1658 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); | 1658 for (Object** p = start; p < end; ++p) *p = updater_func(this, p); |
1659 } | 1659 } |
1660 | 1660 |
1661 UpdateNewSpaceReferencesInExternalStringTable(updater_func); | 1661 UpdateNewSpaceReferencesInExternalStringTable(updater_func); |
1662 } | 1662 } |
1663 | 1663 |
1664 | 1664 |
1665 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) { | 1665 void Heap::ProcessAllWeakReferences(WeakObjectRetainer* retainer) { |
1666 ProcessArrayBuffers(retainer, false); | 1666 ProcessArrayBuffers(retainer, false); |
1667 ProcessNewArrayBufferViews(retainer); | |
1668 ProcessNativeContexts(retainer); | 1667 ProcessNativeContexts(retainer); |
1669 ProcessAllocationSites(retainer); | 1668 ProcessAllocationSites(retainer); |
1670 } | 1669 } |
1671 | 1670 |
1672 | 1671 |
1673 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { | 1672 void Heap::ProcessYoungWeakReferences(WeakObjectRetainer* retainer) { |
1674 ProcessArrayBuffers(retainer, true); | 1673 ProcessArrayBuffers(retainer, true); |
1675 ProcessNewArrayBufferViews(retainer); | |
1676 ProcessNativeContexts(retainer); | 1674 ProcessNativeContexts(retainer); |
1677 } | 1675 } |
1678 | 1676 |
1679 | 1677 |
1680 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { | 1678 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer) { |
1681 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer, | 1679 Object* head = VisitWeakList<Context>(this, native_contexts_list(), retainer, |
1682 false, NULL); | 1680 false, NULL); |
1683 // Update the head of the list of contexts. | 1681 // Update the head of the list of contexts. |
1684 set_native_contexts_list(head); | 1682 set_native_contexts_list(head); |
1685 } | 1683 } |
(...skipping 17 matching lines...) Expand all Loading... |
1703 while (next != undefined) { | 1701 while (next != undefined) { |
1704 if (!old_objects_recorded) { | 1702 if (!old_objects_recorded) { |
1705 old_objects_recorded = !InNewSpace(next); | 1703 old_objects_recorded = !InNewSpace(next); |
1706 } | 1704 } |
1707 CHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next)); | 1705 CHECK((InNewSpace(next) && !old_objects_recorded) || !InNewSpace(next)); |
1708 next = JSArrayBuffer::cast(next)->weak_next(); | 1706 next = JSArrayBuffer::cast(next)->weak_next(); |
1709 } | 1707 } |
1710 } | 1708 } |
1711 | 1709 |
1712 | 1710 |
1713 void Heap::ProcessNewArrayBufferViews(WeakObjectRetainer* retainer) { | |
1714 // Retain the list of new space views. | |
1715 Object* typed_array_obj = VisitWeakList<JSArrayBufferView>( | |
1716 this, new_array_buffer_views_list_, retainer, false, NULL); | |
1717 set_new_array_buffer_views_list(typed_array_obj); | |
1718 | |
1719 // Some objects in the list may be in old space now. Find them | |
1720 // and move them to the corresponding array buffer. | |
1721 Object* view = VisitNewArrayBufferViewsWeakList( | |
1722 this, new_array_buffer_views_list_, retainer); | |
1723 set_new_array_buffer_views_list(view); | |
1724 } | |
1725 | |
1726 | |
1727 void Heap::TearDownArrayBuffers() { | 1711 void Heap::TearDownArrayBuffers() { |
1728 Object* undefined = undefined_value(); | 1712 Object* undefined = undefined_value(); |
1729 for (Object* o = array_buffers_list(); o != undefined;) { | 1713 for (Object* o = array_buffers_list(); o != undefined;) { |
1730 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); | 1714 JSArrayBuffer* buffer = JSArrayBuffer::cast(o); |
1731 Runtime::FreeArrayBuffer(isolate(), buffer); | 1715 Runtime::FreeArrayBuffer(isolate(), buffer); |
1732 o = buffer->weak_next(); | 1716 o = buffer->weak_next(); |
1733 } | 1717 } |
1734 set_array_buffers_list(undefined); | 1718 set_array_buffers_list(undefined); |
1735 } | 1719 } |
1736 | 1720 |
(...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5375 if (!CreateInitialMaps()) return false; | 5359 if (!CreateInitialMaps()) return false; |
5376 CreateApiObjects(); | 5360 CreateApiObjects(); |
5377 | 5361 |
5378 // Create initial objects | 5362 // Create initial objects |
5379 CreateInitialObjects(); | 5363 CreateInitialObjects(); |
5380 CHECK_EQ(0u, gc_count_); | 5364 CHECK_EQ(0u, gc_count_); |
5381 | 5365 |
5382 set_native_contexts_list(undefined_value()); | 5366 set_native_contexts_list(undefined_value()); |
5383 set_array_buffers_list(undefined_value()); | 5367 set_array_buffers_list(undefined_value()); |
5384 set_last_array_buffer_in_list(undefined_value()); | 5368 set_last_array_buffer_in_list(undefined_value()); |
5385 set_new_array_buffer_views_list(undefined_value()); | |
5386 set_allocation_sites_list(undefined_value()); | 5369 set_allocation_sites_list(undefined_value()); |
5387 return true; | 5370 return true; |
5388 } | 5371 } |
5389 | 5372 |
5390 | 5373 |
5391 void Heap::SetStackLimits() { | 5374 void Heap::SetStackLimits() { |
5392 DCHECK(isolate_ != NULL); | 5375 DCHECK(isolate_ != NULL); |
5393 DCHECK(isolate_ == isolate()); | 5376 DCHECK(isolate_ == isolate()); |
5394 // On 64 bit machines, pointers are generally out of range of Smis. We write | 5377 // On 64 bit machines, pointers are generally out of range of Smis. We write |
5395 // something that looks like an out of range Smi to the GC. | 5378 // something that looks like an out of range Smi to the GC. |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6389 static_cast<int>(object_sizes_last_time_[index])); | 6372 static_cast<int>(object_sizes_last_time_[index])); |
6390 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6373 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6391 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6374 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6392 | 6375 |
6393 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6376 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6394 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6377 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6395 ClearObjectStats(); | 6378 ClearObjectStats(); |
6396 } | 6379 } |
6397 } | 6380 } |
6398 } // namespace v8::internal | 6381 } // namespace v8::internal |
OLD | NEW |