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 2061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2072 } | 2072 } |
2073 } | 2073 } |
2074 | 2074 |
2075 | 2075 |
2076 bool JSObject::HasFastProperties() { | 2076 bool JSObject::HasFastProperties() { |
2077 ASSERT(properties()->IsDictionary() == map()->is_dictionary_map()); | 2077 ASSERT(properties()->IsDictionary() == map()->is_dictionary_map()); |
2078 return !properties()->IsDictionary(); | 2078 return !properties()->IsDictionary(); |
2079 } | 2079 } |
2080 | 2080 |
2081 | 2081 |
2082 bool JSObject::TooManyFastProperties(StoreFromKeyed store_mode) { | 2082 bool Map::TooManyFastProperties(StoreFromKeyed store_mode) { |
2083 // Allow extra fast properties if the object has more than | 2083 if (unused_property_fields() != 0) return false; |
2084 // kFastPropertiesSoftLimit in-object properties. When this is the case, it is | 2084 int minimum = store_mode == CERTAINLY_NOT_STORE_FROM_KEYED ? 128 : 12; |
2085 // very unlikely that the object is being used as a dictionary and there is a | 2085 int limit = Max(minimum, inobject_properties()); |
2086 // good chance that allowing more map transitions will be worth it. | 2086 int external = NumberOfFields() - inobject_properties(); |
2087 Map* map = this->map(); | 2087 return external > limit; |
2088 if (map->unused_property_fields() != 0) return false; | |
2089 | |
2090 int inobject = map->inobject_properties(); | |
2091 | |
2092 int limit; | |
2093 if (store_mode == CERTAINLY_NOT_STORE_FROM_KEYED) { | |
2094 limit = Max(inobject, kMaxFastProperties); | |
2095 } else { | |
2096 limit = Max(inobject, kFastPropertiesSoftLimit); | |
2097 } | |
2098 return properties()->length() > limit; | |
2099 } | 2088 } |
2100 | 2089 |
2101 | 2090 |
2102 void Struct::InitializeBody(int object_size) { | 2091 void Struct::InitializeBody(int object_size) { |
2103 Object* value = GetHeap()->undefined_value(); | 2092 Object* value = GetHeap()->undefined_value(); |
2104 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 2093 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
2105 WRITE_FIELD(this, offset, value); | 2094 WRITE_FIELD(this, offset, value); |
2106 } | 2095 } |
2107 } | 2096 } |
2108 | 2097 |
(...skipping 5099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7208 #undef READ_SHORT_FIELD | 7197 #undef READ_SHORT_FIELD |
7209 #undef WRITE_SHORT_FIELD | 7198 #undef WRITE_SHORT_FIELD |
7210 #undef READ_BYTE_FIELD | 7199 #undef READ_BYTE_FIELD |
7211 #undef WRITE_BYTE_FIELD | 7200 #undef WRITE_BYTE_FIELD |
7212 #undef NOBARRIER_READ_BYTE_FIELD | 7201 #undef NOBARRIER_READ_BYTE_FIELD |
7213 #undef NOBARRIER_WRITE_BYTE_FIELD | 7202 #undef NOBARRIER_WRITE_BYTE_FIELD |
7214 | 7203 |
7215 } } // namespace v8::internal | 7204 } } // namespace v8::internal |
7216 | 7205 |
7217 #endif // V8_OBJECTS_INL_H_ | 7206 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |