Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 #undef SIMD128_TYPE_CHECKER | 155 #undef SIMD128_TYPE_CHECKER |
| 156 | 156 |
| 157 #define IS_TYPE_FUNCTION_DEF(type_) \ | 157 #define IS_TYPE_FUNCTION_DEF(type_) \ |
| 158 bool Object::Is##type_() const { \ | 158 bool Object::Is##type_() const { \ |
| 159 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ | 159 return IsHeapObject() && HeapObject::cast(this)->Is##type_(); \ |
| 160 } | 160 } |
| 161 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) | 161 HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DEF) |
| 162 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF) | 162 ODDBALL_LIST(IS_TYPE_FUNCTION_DEF) |
| 163 #undef IS_TYPE_FUNCTION_DEF | 163 #undef IS_TYPE_FUNCTION_DEF |
| 164 | 164 |
| 165 bool HeapObject::IsTheHole(Isolate* isolate) const { | |
| 166 return this == isolate->heap()->the_hole_value(); | |
| 167 } | |
| 168 | |
| 169 bool HeapObject::IsUndefined(Isolate* isolate) const { | |
| 170 return this == isolate->heap()->undefined_value(); | |
| 171 } | |
| 172 | |
| 173 bool Object::IsTheHole(Isolate* isolate) const { | |
| 174 return this == isolate->heap()->the_hole_value(); | |
| 175 } | |
| 176 | |
| 177 bool Object::IsUndefined(Isolate* isolate) const { | |
| 178 return this == isolate->heap()->undefined_value(); | |
| 179 } | |
|
Toon Verwaest
2016/06/01 12:36:17
We should replace the versions above with these ve
| |
| 180 | |
| 165 bool HeapObject::IsString() const { | 181 bool HeapObject::IsString() const { |
| 166 return map()->instance_type() < FIRST_NONSTRING_TYPE; | 182 return map()->instance_type() < FIRST_NONSTRING_TYPE; |
| 167 } | 183 } |
| 168 | 184 |
| 169 bool HeapObject::IsName() const { | 185 bool HeapObject::IsName() const { |
| 170 return map()->instance_type() <= LAST_NAME_TYPE; | 186 return map()->instance_type() <= LAST_NAME_TYPE; |
| 171 } | 187 } |
| 172 | 188 |
| 173 bool HeapObject::IsUniqueName() const { | 189 bool HeapObject::IsUniqueName() const { |
| 174 return IsInternalizedString() || IsSymbol(); | 190 return IsInternalizedString() || IsSymbol(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 return StringShape(String::cast(this)).IsExternal() && | 253 return StringShape(String::cast(this)).IsExternal() && |
| 238 String::cast(this)->IsOneByteRepresentation(); | 254 String::cast(this)->IsOneByteRepresentation(); |
| 239 } | 255 } |
| 240 | 256 |
| 241 bool HeapObject::IsExternalTwoByteString() const { | 257 bool HeapObject::IsExternalTwoByteString() const { |
| 242 if (!IsString()) return false; | 258 if (!IsString()) return false; |
| 243 return StringShape(String::cast(this)).IsExternal() && | 259 return StringShape(String::cast(this)).IsExternal() && |
| 244 String::cast(this)->IsTwoByteRepresentation(); | 260 String::cast(this)->IsTwoByteRepresentation(); |
| 245 } | 261 } |
| 246 | 262 |
| 247 | |
| 248 bool Object::HasValidElements() { | 263 bool Object::HasValidElements() { |
| 249 // Dictionary is covered under FixedArray. | 264 // Dictionary is covered under FixedArray. |
| 250 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); | 265 return IsFixedArray() || IsFixedDoubleArray() || IsFixedTypedArrayBase(); |
| 251 } | 266 } |
| 252 | 267 |
| 253 | 268 |
| 254 bool Object::KeyEquals(Object* second) { | 269 bool Object::KeyEquals(Object* second) { |
| 255 Object* first = this; | 270 Object* first = this; |
| 256 if (second->IsNumber()) { | 271 if (second->IsNumber()) { |
| 257 if (first->IsNumber()) return first->Number() == second->Number(); | 272 if (first->IsNumber()) return first->Number() == second->Number(); |
| (...skipping 2756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3014 const int kMinCapacity = 4; | 3029 const int kMinCapacity = 4; |
| 3015 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); | 3030 int capacity = base::bits::RoundUpToPowerOfTwo32(at_least_space_for * 2); |
| 3016 return Max(capacity, kMinCapacity); | 3031 return Max(capacity, kMinCapacity); |
| 3017 } | 3032 } |
| 3018 | 3033 |
| 3019 bool HashTableBase::IsKey(Heap* heap, Object* k) { | 3034 bool HashTableBase::IsKey(Heap* heap, Object* k) { |
| 3020 return k != heap->the_hole_value() && k != heap->undefined_value(); | 3035 return k != heap->the_hole_value() && k != heap->undefined_value(); |
| 3021 } | 3036 } |
| 3022 | 3037 |
| 3023 bool HashTableBase::IsKey(Object* k) { | 3038 bool HashTableBase::IsKey(Object* k) { |
| 3024 return !k->IsTheHole() && !k->IsUndefined(); | 3039 Isolate* isolate = this->GetIsolate(); |
| 3040 return !k->IsTheHole(isolate) && !k->IsUndefined(isolate); | |
| 3025 } | 3041 } |
| 3026 | 3042 |
| 3027 | 3043 |
| 3028 void HashTableBase::SetNumberOfElements(int nof) { | 3044 void HashTableBase::SetNumberOfElements(int nof) { |
| 3029 set(kNumberOfElementsIndex, Smi::FromInt(nof)); | 3045 set(kNumberOfElementsIndex, Smi::FromInt(nof)); |
| 3030 } | 3046 } |
| 3031 | 3047 |
| 3032 | 3048 |
| 3033 void HashTableBase::SetNumberOfDeletedElements(int nod) { | 3049 void HashTableBase::SetNumberOfDeletedElements(int nod) { |
| 3034 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); | 3050 set(kNumberOfDeletedElementsIndex, Smi::FromInt(nod)); |
| (...skipping 4852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7887 #undef WRITE_INT64_FIELD | 7903 #undef WRITE_INT64_FIELD |
| 7888 #undef READ_BYTE_FIELD | 7904 #undef READ_BYTE_FIELD |
| 7889 #undef WRITE_BYTE_FIELD | 7905 #undef WRITE_BYTE_FIELD |
| 7890 #undef NOBARRIER_READ_BYTE_FIELD | 7906 #undef NOBARRIER_READ_BYTE_FIELD |
| 7891 #undef NOBARRIER_WRITE_BYTE_FIELD | 7907 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7892 | 7908 |
| 7893 } // namespace internal | 7909 } // namespace internal |
| 7894 } // namespace v8 | 7910 } // namespace v8 |
| 7895 | 7911 |
| 7896 #endif // V8_OBJECTS_INL_H_ | 7912 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |