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

Unified Diff: src/heap/heap.h

Issue 2314783002: [heap] Removes spaces.h include from heap.h (Closed)
Patch Set: No more spaces.h 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | src/heap/heap.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 4c2b57dc60f28d6b8cdb8c6ebc4fdd5eedfb080b..9d84b05a3e961cace4b542d48742a33c77187d60 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -16,9 +16,8 @@
#include "src/base/atomic-utils.h"
#include "src/globals.h"
#include "src/heap-symbols.h"
-// TODO(mstarzinger): One more include to kill!
-#include "src/heap/spaces.h"
#include "src/list.h"
+#include "src/objects.h"
namespace v8 {
namespace internal {
@@ -326,7 +325,9 @@ class HistogramTimer;
class Isolate;
class MemoryAllocator;
class MemoryReducer;
+class ObjectIterator;
class ObjectStats;
+class Page;
class PagedSpace;
class Scavenger;
class ScavengeJob;
@@ -401,6 +402,47 @@ class PromotionQueue {
DISALLOW_COPY_AND_ASSIGN(PromotionQueue);
};
+class AllocationResult {
+ public:
+ // Implicit constructor from Object*.
+ AllocationResult(Object* object) // NOLINT
+ : object_(object) {
+ // AllocationResults can't return Smis, which are used to represent
+ // failure and the space to retry in.
+ CHECK(!object->IsSmi());
+ }
+
+ AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {}
+
+ static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) {
+ return AllocationResult(space);
+ }
+
+ inline bool IsRetry() { return object_->IsSmi(); }
+
+ template <typename T>
+ bool To(T** obj) {
+ if (IsRetry()) return false;
+ *obj = T::cast(object_);
+ return true;
+ }
+
+ Object* ToObjectChecked() {
+ CHECK(!IsRetry());
+ return object_;
+ }
+
+ inline AllocationSpace RetrySpace();
+
+ private:
+ explicit AllocationResult(AllocationSpace space)
+ : object_(Smi::FromInt(static_cast<int>(space))) {}
+
+ Object* object_;
+};
+
+STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize);
+
class Heap {
public:
// Declare all the root indices. This defines the root list order.
@@ -785,9 +827,7 @@ class Heap {
void DeoptMarkedAllocationSites();
- bool DeoptMaybeTenuredAllocationSites() {
- return new_space_.IsAtMaximumCapacity() && maximum_size_scavenges_ == 0;
- }
+ inline bool DeoptMaybeTenuredAllocationSites();
void AddWeakNewSpaceObjectToCodeDependency(Handle<HeapObject> obj,
Handle<WeakCell> code);
@@ -861,9 +901,9 @@ class Heap {
// Getters for spaces. =======================================================
// ===========================================================================
- Address NewSpaceTop() { return new_space_.top(); }
+ inline Address NewSpaceTop();
- NewSpace* new_space() { return &new_space_; }
+ NewSpace* new_space() { return new_space_; }
OldSpace* old_space() { return old_space_; }
OldSpace* code_space() { return code_space_; }
MapSpace* map_space() { return map_space_; }
@@ -2001,7 +2041,7 @@ class Heap {
int global_ic_age_;
- NewSpace new_space_;
+ NewSpace* new_space_;
OldSpace* old_space_;
OldSpace* code_space_;
MapSpace* map_space_;
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | src/heap/heap.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698