Commit cb08656b authored by titzer's avatar titzer Committed by Commit bot

Move GetRootListIndex into Heap.

R=hpayer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/1095513003

Cr-Commit-Position: refs/heads/master@{#27891}
parent a0e2dd23
......@@ -202,13 +202,7 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle<HeapObject> object,
bool CodeGenerator::IsMaterializableFromRoot(
Handle<HeapObject> object, Heap::RootListIndex* index_return) {
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
#define IMMORTAL_IMMOVABLE_ROOT(Name) \
if (*object == isolate()->heap()->root(Heap::k##Name##RootIndex)) { \
*index_return = Heap::k##Name##RootIndex; \
return true; \
}
IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT)
#undef IMMORTAL_IMMOVABLE_ROOT
return isolate()->heap()->GetRootListIndex(object, index_return);
}
return false;
}
......
......@@ -4808,6 +4808,20 @@ bool Heap::RootIsImmortalImmovable(int root_index) {
}
bool Heap::GetRootListIndex(Handle<HeapObject> object,
Heap::RootListIndex* index_return) {
Object* ptr = *object;
#define IMMORTAL_IMMOVABLE_ROOT(Name) \
if (ptr == roots_[Heap::k##Name##RootIndex]) { \
*index_return = k##Name##RootIndex; \
return true; \
}
IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT)
#undef IMMORTAL_IMMOVABLE_ROOT
return false;
}
#ifdef VERIFY_HEAP
void Heap::Verify() {
CHECK(HasBeenSetUp());
......
......@@ -1166,6 +1166,10 @@ class Heap {
kSmiRootsStart = kStringTableRootIndex + 1
};
// Get the root list index for {object} if such a root list index exists.
bool GetRootListIndex(Handle<HeapObject> object,
Heap::RootListIndex* index_return);
Object* root(RootListIndex index) { return roots_[index]; }
STATIC_ASSERT(kUndefinedValueRootIndex ==
......
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