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