Move GetRootListIndex into Heap.

R=hpayer@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#27891}
This commit is contained in:
titzer 2015-04-16 08:08:17 -07:00 committed by Commit bot
parent a0e2dd23ce
commit cb08656b6d
3 changed files with 19 additions and 7 deletions

View File

@ -202,13 +202,7 @@ bool CodeGenerator::IsMaterializableFromFrame(Handle<HeapObject> object,
bool CodeGenerator::IsMaterializableFromRoot( bool CodeGenerator::IsMaterializableFromRoot(
Handle<HeapObject> object, Heap::RootListIndex* index_return) { Handle<HeapObject> object, Heap::RootListIndex* index_return) {
if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) { if (linkage()->GetIncomingDescriptor()->IsJSFunctionCall()) {
#define IMMORTAL_IMMOVABLE_ROOT(Name) \ return isolate()->heap()->GetRootListIndex(object, index_return);
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 false; return false;
} }

View File

@ -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 #ifdef VERIFY_HEAP
void Heap::Verify() { void Heap::Verify() {
CHECK(HasBeenSetUp()); CHECK(HasBeenSetUp());

View File

@ -1166,6 +1166,10 @@ class Heap {
kSmiRootsStart = kStringTableRootIndex + 1 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]; } Object* root(RootListIndex index) { return roots_[index]; }
STATIC_ASSERT(kUndefinedValueRootIndex == STATIC_ASSERT(kUndefinedValueRootIndex ==