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

Unified Diff: src/spaces.h

Issue 7029030: Use page header information to test for InNewSpace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Addressed review comments. 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 | « src/runtime.cc ('k') | 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 95bb40a0637ff1f6e74ec623c57f4bc131512499..9cf8547898e98d8d2ca60d24daf2fc3e0a64d4e7 100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -375,6 +375,7 @@ class MemoryChunk {
POINTERS_TO_HERE_ARE_INTERESTING,
POINTERS_FROM_HERE_ARE_INTERESTING,
SCAN_ON_SCAVENGE,
+ IN_NEW_SPACE,
NUM_MEMORY_CHUNK_FLAGS
};
@@ -421,6 +422,10 @@ class MemoryChunk {
return IsFlagSet(CONTAINS_ONLY_DATA);
}
+ bool InNewSpace() {
+ return IsFlagSet(IN_NEW_SPACE);
+ }
+
// ---------------------------------------------------------------------
// Markbits support
@@ -1693,10 +1698,40 @@ class NewSpace : public Space {
return (reinterpret_cast<uintptr_t>(a) & address_mask_)
== reinterpret_cast<uintptr_t>(start_);
}
+
+ // True if the address or object lies on a NewSpacePage.
+ // Must be a pointer into a heap page, and if it's a large object
+ // page, it must be a pointer into the beginning of it.
+ // TODO(gc): When every call to Contains is converted to PageContains,
+ // remove Contains and rename PageContains to Contains.
+ bool PageContains(Address a) {
+ if ((reinterpret_cast<intptr_t>(a) & ~kHeapObjectTagMask) ==
+ static_cast<intptr_t>(0)) {
+ // Tagged zero-page pointers are not real heap pointers.
+ // TODO(gc): Remove when we no longer have tagged zero-page
+ // pointers intermingled with real heap object pointers.
+ return false;
+ }
+ return MemoryChunk::FromAddress(a)->InNewSpace();
+ }
+
bool Contains(Object* o) {
return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
}
+ bool PageContains(Object* o) {
+ if (o->IsSmi()) return false;
+ if ((reinterpret_cast<uintptr_t>(o) & ~kHeapObjectTagMask) ==
+ static_cast<uintptr_t>(0)) {
+ // Tagged zero-page pointers are not real heap pointers.
+ // TODO(gc): Remove when we no longer have tagged zero-page
+ // pointers intermingled with real heap object pointers.
+ return false;
+ }
+ Address a = HeapObject::cast(o)->address();
+ return MemoryChunk::FromAddress(a)->InNewSpace();
+ }
+
// Return the allocated bytes in the active semispace.
virtual intptr_t Size() { return static_cast<int>(top() - bottom()); }
// The same, but returning an int. We have to have the one that returns
« no previous file with comments | « src/runtime.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698