Commit e23d8bc7 authored by sejunho's avatar sejunho Committed by Commit bot

Fix compile warning [-Wtype-limits]

This fixes warning on android_arm build.
Previously the compiler complained about a check that can never be true.
See second check below(index is size_t type, FIRST_SPACE=0):
if (index > i::LAST_SPACE || index < i::FIRST_SPACE)
And make the code easy to understand.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#29042}
parent a1a7cfd6
......@@ -7273,9 +7273,8 @@ size_t Isolate::NumberOfHeapSpaces() {
bool Isolate::GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics,
size_t index) {
if (!space_statistics)
return false;
if (index > i::LAST_SPACE || index < i::FIRST_SPACE)
if (!space_statistics) return false;
if (!i::Heap::IsValidAllocationSpace(static_cast<i::AllocationSpace>(index)))
return false;
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......
......@@ -5019,6 +5019,20 @@ bool Heap::InSpace(Address addr, AllocationSpace space) {
}
bool Heap::IsValidAllocationSpace(AllocationSpace space) {
switch (space) {
case NEW_SPACE:
case OLD_SPACE:
case CODE_SPACE:
case MAP_SPACE:
case LO_SPACE:
return true;
default:
return false;
}
}
bool Heap::RootIsImmortalImmovable(int root_index) {
switch (root_index) {
#define CASE(name) \
......
......@@ -955,6 +955,9 @@ class Heap {
bool InSpace(Address addr, AllocationSpace space);
bool InSpace(HeapObject* value, AllocationSpace space);
// Checks whether the space is valid.
static bool IsValidAllocationSpace(AllocationSpace space);
// Checks whether the given object is allowed to be migrated from it's
// current space into the given destination space. Used for debugging.
inline bool AllowedToBeMigrated(HeapObject* object, AllocationSpace dest);
......
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