Index: src/heap/heap.h |
diff --git a/src/heap/heap.h b/src/heap/heap.h |
index cce467ff4f24deebbd53f8ef7f3652b3d8f44447..6225d582691ee6e7dec7938033096225992aeffa 100644 |
--- a/src/heap/heap.h |
+++ b/src/heap/heap.h |
@@ -1023,6 +1023,14 @@ class Heap { |
Handle<Object> root_handle(RootListIndex index) { |
return Handle<Object>(&roots_[index]); |
} |
+ template <typename T> |
+ bool IsRootHandle(Handle<T> handle, RootListIndex* index) const { |
+ Object** const handle_location = bit_cast<Object**>(handle.address()); |
+ if (handle_location >= &roots_[kRootListLength]) return false; |
+ if (handle_location < &roots_[0]) return false; |
+ *index = static_cast<RootListIndex>(handle_location - &roots_[0]); |
+ return true; |
+ } |
// Generated code can embed this address to get access to the roots. |
Object** roots_array_start() { return roots_; } |