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

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

Issue 2314783002: [heap] Removes spaces.h include from heap.h (Closed)
Patch Set: Move data structures used in debug mode Created 4 years, 3 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 | « no previous file | src/heap/heap.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 #ifndef V8_HEAP_HEAP_H_ 5 #ifndef V8_HEAP_HEAP_H_
6 #define V8_HEAP_HEAP_H_ 6 #define V8_HEAP_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
11 // Clients of this interface shouldn't depend on lots of heap internals. 11 // Clients of this interface shouldn't depend on lots of heap internals.
12 // Do not include anything from src/heap here! 12 // Do not include anything from src/heap here!
13 #include "include/v8.h" 13 #include "include/v8.h"
14 #include "src/allocation.h" 14 #include "src/allocation.h"
15 #include "src/assert-scope.h" 15 #include "src/assert-scope.h"
16 #include "src/base/atomic-utils.h" 16 #include "src/base/atomic-utils.h"
17 #include "src/globals.h" 17 #include "src/globals.h"
18 #include "src/heap-symbols.h" 18 #include "src/heap-symbols.h"
19 // TODO(mstarzinger): One more include to kill!
20 #include "src/heap/spaces.h"
21 #include "src/list.h" 19 #include "src/list.h"
20 #include "src/objects.h"
22 21
23 namespace v8 { 22 namespace v8 {
24 namespace internal { 23 namespace internal {
25 24
26 using v8::MemoryPressureLevel; 25 using v8::MemoryPressureLevel;
27 26
28 // Defines all the roots in Heap. 27 // Defines all the roots in Heap.
29 #define STRONG_ROOT_LIST(V) \ 28 #define STRONG_ROOT_LIST(V) \
30 /* Cluster the most popular ones in a few cache lines here at the top. */ \ 29 /* Cluster the most popular ones in a few cache lines here at the top. */ \
31 /* The first 32 entries are most often used in the startup snapshot and */ \ 30 /* The first 32 entries are most often used in the startup snapshot and */ \
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 class GCIdleTimeAction; 318 class GCIdleTimeAction;
320 class GCIdleTimeHandler; 319 class GCIdleTimeHandler;
321 class GCIdleTimeHeapState; 320 class GCIdleTimeHeapState;
322 class GCTracer; 321 class GCTracer;
323 class HeapObjectsFilter; 322 class HeapObjectsFilter;
324 class HeapStats; 323 class HeapStats;
325 class HistogramTimer; 324 class HistogramTimer;
326 class Isolate; 325 class Isolate;
327 class MemoryAllocator; 326 class MemoryAllocator;
328 class MemoryReducer; 327 class MemoryReducer;
328 class ObjectIterator;
329 class ObjectStats; 329 class ObjectStats;
330 class Page;
330 class PagedSpace; 331 class PagedSpace;
331 class Scavenger; 332 class Scavenger;
332 class ScavengeJob; 333 class ScavengeJob;
333 class Space; 334 class Space;
334 class StoreBuffer; 335 class StoreBuffer;
335 class WeakObjectRetainer; 336 class WeakObjectRetainer;
336 337
337 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); 338 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to);
338 339
339 enum PromotionMode { PROMOTE_MARKED, DEFAULT_PROMOTION }; 340 enum PromotionMode { PROMOTE_MARKED, DEFAULT_PROMOTION };
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 struct Entry* front_; 395 struct Entry* front_;
395 struct Entry* rear_; 396 struct Entry* rear_;
396 struct Entry* limit_; 397 struct Entry* limit_;
397 398
398 List<Entry>* emergency_stack_; 399 List<Entry>* emergency_stack_;
399 Heap* heap_; 400 Heap* heap_;
400 401
401 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); 402 DISALLOW_COPY_AND_ASSIGN(PromotionQueue);
402 }; 403 };
403 404
405 class AllocationResult {
406 public:
407 // Implicit constructor from Object*.
408 AllocationResult(Object* object) // NOLINT
409 : object_(object) {
410 // AllocationResults can't return Smis, which are used to represent
411 // failure and the space to retry in.
412 CHECK(!object->IsSmi());
413 }
414
415 AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {}
416
417 static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
418 return AllocationResult(space);
419 }
420
421 inline bool IsRetry() { return object_->IsSmi(); }
422
423 template <typename T>
424 bool To(T** obj) {
425 if (IsRetry()) return false;
426 *obj = T::cast(object_);
427 return true;
428 }
429
430 Object* ToObjectChecked() {
431 CHECK(!IsRetry());
432 return object_;
433 }
434
435 inline AllocationSpace RetrySpace();
436
437 private:
438 explicit AllocationResult(AllocationSpace space)
439 : object_(Smi::FromInt(static_cast<int>(space))) {}
440
441 Object* object_;
442 };
443
444 STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
445
446 #ifdef DEBUG
447 struct CommentStatistic {
448 const char* comment;
449 int size;
450 int count;
451 void Clear() {
452 comment = NULL;
453 size = 0;
454 count = 0;
455 }
456 // Must be small, since an iteration is used for lookup.
457 static const int kMaxComments = 64;
458 };
459 #endif
460
461 class NumberAndSizeInfo BASE_EMBEDDED {
462 public:
463 NumberAndSizeInfo() : number_(0), bytes_(0) {}
464
465 int number() const { return number_; }
466 void increment_number(int num) { number_ += num; }
467
468 int bytes() const { return bytes_; }
469 void increment_bytes(int size) { bytes_ += size; }
470
471 void clear() {
472 number_ = 0;
473 bytes_ = 0;
474 }
475
476 private:
477 int number_;
478 int bytes_;
479 };
480
481 // HistogramInfo class for recording a single "bar" of a histogram. This
482 // class is used for collecting statistics to print to the log file.
483 class HistogramInfo : public NumberAndSizeInfo {
484 public:
485 HistogramInfo() : NumberAndSizeInfo(), name_(nullptr) {}
486
487 const char* name() { return name_; }
488 void set_name(const char* name) { name_ = name; }
489
490 private:
491 const char* name_;
492 };
493
404 class Heap { 494 class Heap {
405 public: 495 public:
406 // Declare all the root indices. This defines the root list order. 496 // Declare all the root indices. This defines the root list order.
407 enum RootListIndex { 497 enum RootListIndex {
408 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, 498 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
409 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) 499 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
410 #undef ROOT_INDEX_DECLARATION 500 #undef ROOT_INDEX_DECLARATION
411 501
412 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex, 502 #define STRING_INDEX_DECLARATION(name, str) k##name##RootIndex,
413 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION) 503 INTERNALIZED_STRING_LIST(STRING_INDEX_DECLARATION)
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 external_memory_concurrently_freed_.Increment(freed); 868 external_memory_concurrently_freed_.Increment(freed);
779 } 869 }
780 870
781 void account_external_memory_concurrently_freed() { 871 void account_external_memory_concurrently_freed() {
782 external_memory_ -= external_memory_concurrently_freed_.Value(); 872 external_memory_ -= external_memory_concurrently_freed_.Value();
783 external_memory_concurrently_freed_.SetValue(0); 873 external_memory_concurrently_freed_.SetValue(0);
784 } 874 }
785 875
786 void DeoptMarkedAllocationSites(); 876 void DeoptMarkedAllocationSites();
787 877
788 bool DeoptMaybeTenuredAllocationSites() { 878 inline bool DeoptMaybeTenuredAllocationSites();
789 return new_space_.IsAtMaximumCapacity() && maximum_size_scavenges_ == 0;
790 }
791 879
792 void AddWeakNewSpaceObjectToCodeDependency(Handle<HeapObject> obj, 880 void AddWeakNewSpaceObjectToCodeDependency(Handle<HeapObject> obj,
793 Handle<WeakCell> code); 881 Handle<WeakCell> code);
794 882
795 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj, 883 void AddWeakObjectToCodeDependency(Handle<HeapObject> obj,
796 Handle<DependentCode> dep); 884 Handle<DependentCode> dep);
797 885
798 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj); 886 DependentCode* LookupWeakObjectToCodeDependency(Handle<HeapObject> obj);
799 887
800 void CompactWeakFixedArrays(); 888 void CompactWeakFixedArrays();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // Destroys all memory allocated by the heap. 942 // Destroys all memory allocated by the heap.
855 void TearDown(); 943 void TearDown();
856 944
857 // Returns whether SetUp has been called. 945 // Returns whether SetUp has been called.
858 bool HasBeenSetUp(); 946 bool HasBeenSetUp();
859 947
860 // =========================================================================== 948 // ===========================================================================
861 // Getters for spaces. ======================================================= 949 // Getters for spaces. =======================================================
862 // =========================================================================== 950 // ===========================================================================
863 951
864 Address NewSpaceTop() { return new_space_.top(); } 952 inline Address NewSpaceTop();
865 953
866 NewSpace* new_space() { return &new_space_; } 954 NewSpace* new_space() { return new_space_; }
867 OldSpace* old_space() { return old_space_; } 955 OldSpace* old_space() { return old_space_; }
868 OldSpace* code_space() { return code_space_; } 956 OldSpace* code_space() { return code_space_; }
869 MapSpace* map_space() { return map_space_; } 957 MapSpace* map_space() { return map_space_; }
870 LargeObjectSpace* lo_space() { return lo_space_; } 958 LargeObjectSpace* lo_space() { return lo_space_; }
871 959
872 inline PagedSpace* paged_space(int idx); 960 inline PagedSpace* paged_space(int idx);
873 inline Space* space(int idx); 961 inline Space* space(int idx);
874 962
875 // Returns name of the space. 963 // Returns name of the space.
876 const char* GetSpaceName(int idx); 964 const char* GetSpaceName(int idx);
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 // For keeping track of context disposals. 2082 // For keeping track of context disposals.
1995 int contexts_disposed_; 2083 int contexts_disposed_;
1996 2084
1997 // The length of the retained_maps array at the time of context disposal. 2085 // The length of the retained_maps array at the time of context disposal.
1998 // This separates maps in the retained_maps array that were created before 2086 // This separates maps in the retained_maps array that were created before
1999 // and after context disposal. 2087 // and after context disposal.
2000 int number_of_disposed_maps_; 2088 int number_of_disposed_maps_;
2001 2089
2002 int global_ic_age_; 2090 int global_ic_age_;
2003 2091
2004 NewSpace new_space_; 2092 NewSpace* new_space_;
2005 OldSpace* old_space_; 2093 OldSpace* old_space_;
2006 OldSpace* code_space_; 2094 OldSpace* code_space_;
2007 MapSpace* map_space_; 2095 MapSpace* map_space_;
2008 LargeObjectSpace* lo_space_; 2096 LargeObjectSpace* lo_space_;
2009 HeapState gc_state_; 2097 HeapState gc_state_;
2010 int gc_post_processing_depth_; 2098 int gc_post_processing_depth_;
2011 Address new_space_top_after_last_gc_; 2099 Address new_space_top_after_last_gc_;
2012 2100
2013 // Returns the amount of external memory registered since last global gc. 2101 // Returns the amount of external memory registered since last global gc.
2014 int64_t PromotedExternalMemorySize(); 2102 int64_t PromotedExternalMemorySize();
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2519 friend class LargeObjectSpace; 2607 friend class LargeObjectSpace;
2520 friend class NewSpace; 2608 friend class NewSpace;
2521 friend class PagedSpace; 2609 friend class PagedSpace;
2522 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); 2610 DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
2523 }; 2611 };
2524 2612
2525 } // namespace internal 2613 } // namespace internal
2526 } // namespace v8 2614 } // namespace v8
2527 2615
2528 #endif // V8_HEAP_HEAP_H_ 2616 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698