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

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: 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
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index 95bb40a0637ff1f6e74ec623c57f4bc131512499..039e62d02db01e22678429837f696c6f2d8bd706 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
@@ -1689,14 +1694,36 @@ class NewSpace : public Space {
// True if the address or object lies in the address range of either
// semispace (not necessarily below the allocation pointer).
+ // 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.
Erik Corry 2011/05/19 07:22:32 Comment should be moved down to the function to wh
Lasse Reichstein 2011/05/19 08:40:40 Moved.
bool Contains(Address a) {
return (reinterpret_cast<uintptr_t>(a) & address_mask_)
== reinterpret_cast<uintptr_t>(start_);
}
+
+ 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.
+ return false;
Erik Corry 2011/05/19 07:22:32 Can we add a TODO to remove this?
Lasse Reichstein 2011/05/19 08:40:40 Done.
+ }
+ 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) ==
Erik Corry 2011/05/19 07:22:32 And this
Lasse Reichstein 2011/05/19 08:40:40 And done.
+ static_cast<uintptr_t>(0)) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698