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}
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);
}
+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) \
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);