Break a circular include dependency.

1. heap-inl.h has a function Heap::_inline_get_heap_ that calls
Isolate::Current() defined in isolate.h, so heap-inl.h requires
isolate.h.

2. Isolate has an embedded Heap member, so isolate.h requires heap.h.

3. heap.h has inline functions functions defined that call
Heap::_inline_get_heap_, so heap.h requires heap-inl.h (!).

The upshot is that all three need to be included wherever one is.  A
simpler way is to break the cycle by moving the inlined functions in
heap.h to heap-inl.h.

R=vegorov@chromium.org
BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/9121033

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10539 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 900a0012
// Copyright 2011 the V8 project authors. All rights reserved. // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
...@@ -700,11 +700,94 @@ MaybeObject* TranscendentalCache::SubCache::Get(double input) { ...@@ -700,11 +700,94 @@ MaybeObject* TranscendentalCache::SubCache::Get(double input) {
} }
Heap* _inline_get_heap_() { AlwaysAllocateScope::AlwaysAllocateScope() {
return HEAP; // We shouldn't hit any nested scopes, because that requires
// non-handle code to call handle code. The code still works but
// performance will degrade, so we want to catch this situation
// in debug mode.
ASSERT(HEAP->always_allocate_scope_depth_ == 0);
HEAP->always_allocate_scope_depth_++;
} }
AlwaysAllocateScope::~AlwaysAllocateScope() {
HEAP->always_allocate_scope_depth_--;
ASSERT(HEAP->always_allocate_scope_depth_ == 0);
}
LinearAllocationScope::LinearAllocationScope() {
HEAP->linear_allocation_scope_depth_++;
}
LinearAllocationScope::~LinearAllocationScope() {
HEAP->linear_allocation_scope_depth_--;
ASSERT(HEAP->linear_allocation_scope_depth_ >= 0);
}
#ifdef DEBUG
void VerifyPointersVisitor::VisitPointers(Object** start, Object** end) {
for (Object** current = start; current < end; current++) {
if ((*current)->IsHeapObject()) {
HeapObject* object = HeapObject::cast(*current);
ASSERT(HEAP->Contains(object));
ASSERT(object->map()->IsMap());
}
}
}
#endif
double GCTracer::SizeOfHeapObjects() {
return (static_cast<double>(HEAP->SizeOfObjects())) / MB;
}
#ifdef DEBUG
DisallowAllocationFailure::DisallowAllocationFailure() {
old_state_ = HEAP->disallow_allocation_failure_;
HEAP->disallow_allocation_failure_ = true;
}
DisallowAllocationFailure::~DisallowAllocationFailure() {
HEAP->disallow_allocation_failure_ = old_state_;
}
#endif
#ifdef DEBUG
AssertNoAllocation::AssertNoAllocation() {
old_state_ = HEAP->allow_allocation(false);
}
AssertNoAllocation::~AssertNoAllocation() {
HEAP->allow_allocation(old_state_);
}
DisableAssertNoAllocation::DisableAssertNoAllocation() {
old_state_ = HEAP->allow_allocation(true);
}
DisableAssertNoAllocation::~DisableAssertNoAllocation() {
HEAP->allow_allocation(old_state_);
}
#else
AssertNoAllocation::AssertNoAllocation() { }
AssertNoAllocation::~AssertNoAllocation() { }
DisableAssertNoAllocation::DisableAssertNoAllocation() { }
DisableAssertNoAllocation::~DisableAssertNoAllocation() { }
#endif
} } // namespace v8::internal } } // namespace v8::internal
#endif // V8_HEAP_INL_H_ #endif // V8_HEAP_INL_H_
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
// TODO(isolates): remove HEAP here
#define HEAP (_inline_get_heap_())
class Heap;
inline Heap* _inline_get_heap_();
// Defines all the roots in Heap. // Defines all the roots in Heap.
#define STRONG_ROOT_LIST(V) \ #define STRONG_ROOT_LIST(V) \
V(Map, byte_array_map, ByteArrayMap) \ V(Map, byte_array_map, ByteArrayMap) \
...@@ -2042,32 +2036,15 @@ class HeapStats { ...@@ -2042,32 +2036,15 @@ class HeapStats {
class AlwaysAllocateScope { class AlwaysAllocateScope {
public: public:
AlwaysAllocateScope() { inline AlwaysAllocateScope();
// We shouldn't hit any nested scopes, because that requires inline ~AlwaysAllocateScope();
// non-handle code to call handle code. The code still works but
// performance will degrade, so we want to catch this situation
// in debug mode.
ASSERT(HEAP->always_allocate_scope_depth_ == 0);
HEAP->always_allocate_scope_depth_++;
}
~AlwaysAllocateScope() {
HEAP->always_allocate_scope_depth_--;
ASSERT(HEAP->always_allocate_scope_depth_ == 0);
}
}; };
class LinearAllocationScope { class LinearAllocationScope {
public: public:
LinearAllocationScope() { inline LinearAllocationScope();
HEAP->linear_allocation_scope_depth_++; inline ~LinearAllocationScope();
}
~LinearAllocationScope() {
HEAP->linear_allocation_scope_depth_--;
ASSERT(HEAP->linear_allocation_scope_depth_ >= 0);
}
}; };
...@@ -2079,15 +2056,7 @@ class LinearAllocationScope { ...@@ -2079,15 +2056,7 @@ class LinearAllocationScope {
// objects in a heap space but above the allocation pointer. // objects in a heap space but above the allocation pointer.
class VerifyPointersVisitor: public ObjectVisitor { class VerifyPointersVisitor: public ObjectVisitor {
public: public:
void VisitPointers(Object** start, Object** end) { inline void VisitPointers(Object** start, Object** end);
for (Object** current = start; current < end; current++) {
if ((*current)->IsHeapObject()) {
HeapObject* object = HeapObject::cast(*current);
ASSERT(HEAP->Contains(object));
ASSERT(object->map()->IsMap());
}
}
}
}; };
#endif #endif
...@@ -2313,72 +2282,47 @@ class DescriptorLookupCache { ...@@ -2313,72 +2282,47 @@ class DescriptorLookupCache {
}; };
// A helper class to document/test C++ scopes where we do not
// expect a GC. Usage:
//
// /* Allocation not allowed: we cannot handle a GC in this scope. */
// { AssertNoAllocation nogc;
// ...
// }
#ifdef DEBUG #ifdef DEBUG
class DisallowAllocationFailure { class DisallowAllocationFailure {
public: public:
DisallowAllocationFailure() { inline DisallowAllocationFailure();
old_state_ = HEAP->disallow_allocation_failure_; inline ~DisallowAllocationFailure();
HEAP->disallow_allocation_failure_ = true;
}
~DisallowAllocationFailure() {
HEAP->disallow_allocation_failure_ = old_state_;
}
private: private:
bool old_state_; bool old_state_;
}; };
#endif
// A helper class to document/test C++ scopes where we do not
// expect a GC. Usage:
//
// /* Allocation not allowed: we cannot handle a GC in this scope. */
// { AssertNoAllocation nogc;
// ...
// }
class AssertNoAllocation { class AssertNoAllocation {
public: public:
AssertNoAllocation() { inline AssertNoAllocation();
old_state_ = HEAP->allow_allocation(false); inline ~AssertNoAllocation();
}
~AssertNoAllocation() {
HEAP->allow_allocation(old_state_);
}
#ifdef DEBUG
private: private:
bool old_state_; bool old_state_;
#endif
}; };
class DisableAssertNoAllocation { class DisableAssertNoAllocation {
public: public:
DisableAssertNoAllocation() { inline DisableAssertNoAllocation();
old_state_ = HEAP->allow_allocation(true); inline ~DisableAssertNoAllocation();
}
~DisableAssertNoAllocation() {
HEAP->allow_allocation(old_state_);
}
#ifdef DEBUG
private: private:
bool old_state_; bool old_state_;
};
#else // ndef DEBUG
class AssertNoAllocation {
public:
AssertNoAllocation() { }
~AssertNoAllocation() { }
};
class DisableAssertNoAllocation {
public:
DisableAssertNoAllocation() { }
~DisableAssertNoAllocation() { }
};
#endif #endif
};
// GCTracer collects and prints ONE line after each garbage collector // GCTracer collects and prints ONE line after each garbage collector
// invocation IFF --trace_gc is used. // invocation IFF --trace_gc is used.
...@@ -2441,9 +2385,7 @@ class GCTracer BASE_EMBEDDED { ...@@ -2441,9 +2385,7 @@ class GCTracer BASE_EMBEDDED {
const char* CollectorString(); const char* CollectorString();
// Returns size of object in heap (in MB). // Returns size of object in heap (in MB).
double SizeOfHeapObjects() { inline double SizeOfHeapObjects();
return (static_cast<double>(HEAP->SizeOfObjects())) / MB;
}
double start_time_; // Timestamp set in the constructor. double start_time_; // Timestamp set in the constructor.
intptr_t start_size_; // Size of objects in heap set in constructor. intptr_t start_size_; // Size of objects in heap set in constructor.
...@@ -2693,6 +2635,4 @@ class PathTracer : public ObjectVisitor { ...@@ -2693,6 +2635,4 @@ class PathTracer : public ObjectVisitor {
} } // namespace v8::internal } } // namespace v8::internal
#undef HEAP
#endif // V8_HEAP_H_ #endif // V8_HEAP_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment