Commit ed1ca7bd authored by Chris Toshok's avatar Chris Toshok

keep track of min_nonheap_root as well

parent f69d1a99
...@@ -150,6 +150,7 @@ static std::unordered_set<void*> nonheap_roots; ...@@ -150,6 +150,7 @@ static std::unordered_set<void*> nonheap_roots;
// typically all have lower addresses than the heap roots, so this can serve as a cheap // typically all have lower addresses than the heap roots, so this can serve as a cheap
// way to verify it's not a nonheap root (the full check requires a hashtable lookup). // way to verify it's not a nonheap root (the full check requires a hashtable lookup).
static void* max_nonheap_root = 0; static void* max_nonheap_root = 0;
static void* min_nonheap_root = (void*)~0;
void registerNonheapRootObject(void* obj) { void registerNonheapRootObject(void* obj) {
// I suppose that things could work fine even if this were true, but why would it happen? // I suppose that things could work fine even if this were true, but why would it happen?
assert(global_heap.getAllocationFromInteriorPointer(obj) == NULL); assert(global_heap.getAllocationFromInteriorPointer(obj) == NULL);
...@@ -158,10 +159,13 @@ void registerNonheapRootObject(void* obj) { ...@@ -158,10 +159,13 @@ void registerNonheapRootObject(void* obj) {
nonheap_roots.insert(obj); nonheap_roots.insert(obj);
max_nonheap_root = std::max(obj, max_nonheap_root); max_nonheap_root = std::max(obj, max_nonheap_root);
min_nonheap_root = std::min(obj, min_nonheap_root);
} }
bool isNonheapRoot(void* p) { bool isNonheapRoot(void* p) {
return p <= max_nonheap_root && nonheap_roots.count(p) != 0; if (p > max_nonheap_root || p < min_nonheap_root)
return false;
return nonheap_roots.count(p) != 0;
} }
bool isValidGCObject(void* p) { bool isValidGCObject(void* p) {
......
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