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

Unified Diff: src/spaces.h

Issue 7058009: Make InToSpace/InFromSpace use the page header. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 7 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/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index bf6938cee441591721a71ca1d79eac8401b05697..6ea0ebedfa49a152e673429c295c3b8c763b1959 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -376,6 +376,7 @@ class MemoryChunk {
POINTERS_FROM_HERE_ARE_INTERESTING,
SCAN_ON_SCAVENGE,
IN_NEW_SPACE,
+ SEMI_SPACE_TAG,
NUM_MEMORY_CHUNK_FLAGS
};
@@ -391,10 +392,6 @@ class MemoryChunk {
return (flags_ & (1 << flag)) != 0;
}
- void CopyFlagsFrom(MemoryChunk* chunk) {
- flags_ = chunk->flags_;
- }
-
static const intptr_t kAlignment = (1 << kPageSizeBits);
static const intptr_t kAlignmentMask = kAlignment - 1;
@@ -1444,6 +1441,13 @@ class HistogramInfo: public NumberAndSizeInfo {
};
#endif
+// Give numbers to semispaces, so we can see which semispace a newspace
+// page belongs to.
+enum SemiSpaceId {
+ kFirstSemiSpace,
+ kSecondSemiSpace
+};
+
class NewSpacePage : public MemoryChunk {
public:
@@ -1454,6 +1458,23 @@ class NewSpacePage : public MemoryChunk {
inline void set_next_page(NewSpacePage* page) {
set_next_chunk(page);
}
+
+ static NewSpacePage* cast(MemoryChunk* page) {
+ ASSERT(page->IsFlagSet(MemoryChunk::IN_NEW_SPACE));
+ return reinterpret_cast<NewSpacePage*>(page);
+ }
+
+ SemiSpaceId GetSemiSpaceId() {
+ return IsFlagSet(MemoryChunk::SEMI_SPACE_TAG) ? kSecondSemiSpace
+ : kFirstSemiSpace;
+ }
+
+ void CopyFlagsFrom(NewSpacePage* chunk) {
Erik Corry 2011/05/23 12:58:56 This is called CopyFlagsFrom, but it only copies o
+ intptr_t semi_space_mask = 1 << MemoryChunk::SEMI_SPACE_TAG;
+ flags_ = (flags_ & semi_space_mask) | (chunk->flags_ & ~(semi_space_mask));
+ }
+
+
private:
// Finds the NewSpacePage containg the given address.
static NewSpacePage* FromAddress(Address address_in_page) {
@@ -1463,7 +1484,7 @@ class NewSpacePage : public MemoryChunk {
return reinterpret_cast<NewSpacePage*>(page_start);
}
- static NewSpacePage* Initialize(Heap* heap, Address start);
+ static NewSpacePage* Initialize(Heap* heap, Address start, SemiSpaceId id);
friend class SemiSpace;
friend class SemiSpaceIterator;
@@ -1480,10 +1501,11 @@ class NewSpacePage : public MemoryChunk {
class SemiSpace : public Space {
public:
// Constructor.
- explicit SemiSpace(Heap* heap) : Space(heap, NEW_SPACE, NOT_EXECUTABLE) {
- start_ = NULL;
- age_mark_ = NULL;
- }
+ SemiSpace(Heap* heap, SemiSpaceId id)
+ : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
+ start_(NULL),
+ age_mark_(NULL),
+ id_(id) { }
// Sets up the semispace using the given chunk.
bool Setup(Address start, int initial_capacity, int maximum_capacity);
@@ -1535,7 +1557,17 @@ class SemiSpace : public Space {
// True if the object is a heap object in the address range of this
// semispace (not necessarily below the allocation pointer).
bool Contains(Object* o) {
- return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
+ if (o->IsSmi()) {
Erik Corry 2011/05/23 12:58:56 this is SemiSpace::Contains(), but I think what we
Lasse Reichstein 2011/05/24 10:53:42 Will do. That also means that the CopyFlagsFrom f
+ return false;
+ }
+ if ((reinterpret_cast<uintptr_t>(o) & ~kHeapObjectTagMask) == 0u) {
+ // A heap-object tagged NULL pointer.
+ return false;
+ }
+ MemoryChunk* page =
+ MemoryChunk::FromAddress(HeapObject::cast(o)->address());
+ return (page->InNewSpace() &&
+ NewSpacePage::cast(page)->GetSemiSpaceId() == id_);
}
// The offset of an address from the beginning of the space.
@@ -1600,6 +1632,7 @@ class SemiSpace : public Space {
bool committed_;
+ SemiSpaceId id_;
NewSpacePage* current_page_;
public:
@@ -1667,8 +1700,8 @@ class NewSpace : public Space {
// Constructor.
explicit NewSpace(Heap* heap)
: Space(heap, NEW_SPACE, NOT_EXECUTABLE),
- to_space_(heap),
- from_space_(heap) {}
+ to_space_(heap, kFirstSemiSpace),
+ from_space_(heap, kSecondSemiSpace) {}
// Sets up the new space using the given chunk.
bool Setup(int max_semispace_size);
« no previous file with comments | « no previous file | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698