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

Side by Side Diff: src/heap.h

Issue 6639024: Get rid of distinction between below- and above-watermark in page allocation.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 9 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/frames.cc ('k') | src/heap.cc » ('j') | src/spaces-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 23 matching lines...) Expand all
35 #include "spaces.h" 35 #include "spaces.h"
36 #include "splay-tree-inl.h" 36 #include "splay-tree-inl.h"
37 #include "v8-counters.h" 37 #include "v8-counters.h"
38 38
39 namespace v8 { 39 namespace v8 {
40 namespace internal { 40 namespace internal {
41 41
42 42
43 // Defines all the roots in Heap. 43 // Defines all the roots in Heap.
44 #define STRONG_ROOT_LIST(V) \ 44 #define STRONG_ROOT_LIST(V) \
45 /* Put the byte array map early. We need it to be in place by the time */ \
46 /* the deserializer hits the next page, since it wants to put a byte */ \
47 /* array in the unused space at the end of the page. */ \
48 V(Map, byte_array_map, ByteArrayMap) \ 45 V(Map, byte_array_map, ByteArrayMap) \
46 V(Map, free_space_map, FreeSpaceMap) \
49 V(Map, one_pointer_filler_map, OnePointerFillerMap) \ 47 V(Map, one_pointer_filler_map, OnePointerFillerMap) \
50 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \ 48 V(Map, two_pointer_filler_map, TwoPointerFillerMap) \
51 /* Cluster the most popular ones in a few cache lines here at the top. */ \ 49 /* Cluster the most popular ones in a few cache lines here at the top. */ \
52 V(Smi, store_buffer_top, StoreBufferTop) \ 50 V(Smi, store_buffer_top, StoreBufferTop) \
53 V(Object, undefined_value, UndefinedValue) \ 51 V(Object, undefined_value, UndefinedValue) \
54 V(Object, the_hole_value, TheHoleValue) \ 52 V(Object, the_hole_value, TheHoleValue) \
55 V(Object, null_value, NullValue) \ 53 V(Object, null_value, NullValue) \
56 V(Object, true_value, TrueValue) \ 54 V(Object, true_value, TrueValue) \
57 V(Object, false_value, FalseValue) \ 55 V(Object, false_value, FalseValue) \
58 V(Object, arguments_marker, ArgumentsMarker) \ 56 V(Object, arguments_marker, ArgumentsMarker) \
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // A cache is used for ascii codes. 482 // A cache is used for ascii codes.
485 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 483 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
486 // failed. Please note this does not perform a garbage collection. 484 // failed. Please note this does not perform a garbage collection.
487 MUST_USE_RESULT static MaybeObject* LookupSingleCharacterStringFromCode( 485 MUST_USE_RESULT static MaybeObject* LookupSingleCharacterStringFromCode(
488 uint16_t code); 486 uint16_t code);
489 487
490 // Allocate a byte array of the specified length 488 // Allocate a byte array of the specified length
491 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 489 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
492 // failed. 490 // failed.
493 // Please note this does not perform a garbage collection. 491 // Please note this does not perform a garbage collection.
494 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length, 492 MUST_USE_RESULT static MaybeObject* AllocateByteArray(
495 PretenureFlag pretenure); 493 int length,
494 PretenureFlag pretenure);
496 495
497 // Allocate a non-tenured byte array of the specified length 496 // Allocate a non-tenured byte array of the specified length
498 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 497 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
499 // failed. 498 // failed.
500 // Please note this does not perform a garbage collection. 499 // Please note this does not perform a garbage collection.
501 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length); 500 MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length);
502 501
503 // Allocates an external array of the specified length and type. 502 // Allocates an external array of the specified length and type.
504 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation 503 // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
505 // failed. 504 // failed.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 // Performs garbage collection operation. 754 // Performs garbage collection operation.
756 // Returns whether there is a chance that another major GC could 755 // Returns whether there is a chance that another major GC could
757 // collect more garbage. 756 // collect more garbage.
758 static bool CollectGarbage(AllocationSpace space, GarbageCollector collector); 757 static bool CollectGarbage(AllocationSpace space, GarbageCollector collector);
759 758
760 // Performs garbage collection operation. 759 // Performs garbage collection operation.
761 // Returns whether there is a chance that another major GC could 760 // Returns whether there is a chance that another major GC could
762 // collect more garbage. 761 // collect more garbage.
763 inline static bool CollectGarbage(AllocationSpace space); 762 inline static bool CollectGarbage(AllocationSpace space);
764 763
765 // Performs a full garbage collection. Force compaction if the 764 static const int kNoGCFlags = 0;
766 // parameter is true. 765 static const int kForceCompactionMask = 1;
767 static void CollectAllGarbage(bool force_compaction); 766 static const int kMakeHeapIterableMask = 2;
767
768 // Performs a full garbage collection. If (flags & kForceCompactionMask) is
769 // non-zero then force compaction. If (flags & kMakeHeapIterableMask) is non-
770 // zero, then the slower precise sweeper is used, which leaves the heap in a
771 // state where we can iterate over the heap visiting all objects.
772 static void CollectAllGarbage(int flags);
773
774 // Ensure that we have swept all spaces in such a way that we can iterate
775 // over all objects. May cause a GC.
776 static void EnsureHeapIsIterable();
768 777
769 // Last hope GC, should try to squeeze as much as possible. 778 // Last hope GC, should try to squeeze as much as possible.
770 static void CollectAllAvailableGarbage(); 779 static void CollectAllAvailableGarbage();
771 780
772 // Notify the heap that a context has been disposed. 781 // Notify the heap that a context has been disposed.
773 static int NotifyContextDisposed() { return ++contexts_disposed_; } 782 static int NotifyContextDisposed() { return ++contexts_disposed_; }
774 783
775 // Utility to invoke the scavenger. This is needed in test code to 784 // Utility to invoke the scavenger. This is needed in test code to
776 // ensure correct callback for weak global handles. 785 // ensure correct callback for weak global handles.
777 static void PerformScavenge(); 786 static void PerformScavenge();
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 ObjectIterator* CreateIterator(); 1616 ObjectIterator* CreateIterator();
1608 1617
1609 int current_space_; // from enum AllocationSpace. 1618 int current_space_; // from enum AllocationSpace.
1610 ObjectIterator* iterator_; // object iterator for the current space. 1619 ObjectIterator* iterator_; // object iterator for the current space.
1611 HeapObjectCallback size_func_; 1620 HeapObjectCallback size_func_;
1612 }; 1621 };
1613 1622
1614 1623
1615 // A HeapIterator provides iteration over the whole heap. It 1624 // A HeapIterator provides iteration over the whole heap. It
1616 // aggregates the specific iterators for the different spaces as 1625 // aggregates the specific iterators for the different spaces as
1617 // these can only iterate over one space only. 1626 // these can only iterate over one space only. It can only be guaranteed
1627 // to iterate over live objects.
1618 // 1628 //
1619 // HeapIterator can skip free list nodes (that is, de-allocated heap 1629 // HeapIterator can skip free list nodes (that is, de-allocated heap
1620 // objects that still remain in the heap). As implementation of free 1630 // objects that still remain in the heap). As implementation of free
1621 // nodes filtering uses GC marks, it can't be used during MS/MC GC 1631 // nodes filtering uses GC marks, it can't be used during MS/MC GC
1622 // phases. Also, it is forbidden to interrupt iteration in this mode, 1632 // phases. Also, it is forbidden to interrupt iteration in this mode,
1623 // as this will leave heap objects marked (and thus, unusable). 1633 // as this will leave heap objects marked (and thus, unusable).
1624 class HeapObjectsFilter; 1634 class HeapObjectsFilter;
1625 1635
1626 class HeapIterator BASE_EMBEDDED { 1636 class HeapIterator BASE_EMBEDDED {
1627 public: 1637 public:
1628 enum HeapObjectsFiltering {
1629 kNoFiltering,
1630 kFilterFreeListNodes,
1631 kFilterUnreachable
1632 };
1633
1634 HeapIterator(); 1638 HeapIterator();
1635 explicit HeapIterator(HeapObjectsFiltering filtering);
1636 ~HeapIterator(); 1639 ~HeapIterator();
1637 1640
1638 HeapObject* next(); 1641 HeapObject* Next();
1639 void reset(); 1642 void Reset();
1640 1643
1641 private: 1644 private:
1642 // Perform the initialization. 1645 // Perform the initialization.
1643 void Init(); 1646 void Init();
1644 // Perform all necessary shutdown (destruction) work. 1647 // Perform all necessary shutdown (destruction) work.
1645 void Shutdown(); 1648 void Shutdown();
1646 HeapObject* NextObject();
1647 1649
1648 HeapObjectsFiltering filtering_;
1649 HeapObjectsFilter* filter_;
1650 // Space iterator for iterating all the spaces. 1650 // Space iterator for iterating all the spaces.
1651 SpaceIterator* space_iterator_; 1651 SpaceIterator* space_iterator_;
1652 // Object iterator for the space currently being iterated. 1652 // Object iterator for the space currently being iterated.
1653 ObjectIterator* object_iterator_; 1653 ObjectIterator* object_iterator_;
1654 }; 1654 };
1655 1655
1656 1656
1657 // Cache for mapping (map, property name) into field offset. 1657 // Cache for mapping (map, property name) into field offset.
1658 // Cleared at startup and prior to mark sweep collection. 1658 // Cleared at startup and prior to mark sweep collection.
1659 class KeyedLookupCache { 1659 class KeyedLookupCache {
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 2235
2236 AssertNoAllocation no_alloc; // i.e. no gc allowed. 2236 AssertNoAllocation no_alloc; // i.e. no gc allowed.
2237 2237
2238 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 2238 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
2239 }; 2239 };
2240 #endif // DEBUG || LIVE_OBJECT_LIST 2240 #endif // DEBUG || LIVE_OBJECT_LIST
2241 2241
2242 } } // namespace v8::internal 2242 } } // namespace v8::internal
2243 2243
2244 #endif // V8_HEAP_H_ 2244 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « src/frames.cc ('k') | src/heap.cc » ('j') | src/spaces-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698