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 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2127 | 2127 |
2128 | 2128 |
2129 void WeakCell::clear_next(Heap* heap) { | 2129 void WeakCell::clear_next(Heap* heap) { |
2130 set_next(heap->the_hole_value(), SKIP_WRITE_BARRIER); | 2130 set_next(heap->the_hole_value(), SKIP_WRITE_BARRIER); |
2131 } | 2131 } |
2132 | 2132 |
2133 | 2133 |
2134 bool WeakCell::next_cleared() { return next()->IsTheHole(); } | 2134 bool WeakCell::next_cleared() { return next()->IsTheHole(); } |
2135 | 2135 |
2136 | 2136 |
2137 int JSObject::GetHeaderSize() { | 2137 int JSObject::GetHeaderSize() { return GetHeaderSize(map()->instance_type()); } |
2138 InstanceType type = map()->instance_type(); | 2138 |
| 2139 |
| 2140 int JSObject::GetHeaderSize(InstanceType type) { |
2139 // Check for the most common kind of JavaScript object before | 2141 // Check for the most common kind of JavaScript object before |
2140 // falling into the generic switch. This speeds up the internal | 2142 // falling into the generic switch. This speeds up the internal |
2141 // field operations considerably on average. | 2143 // field operations considerably on average. |
2142 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; | 2144 if (type == JS_OBJECT_TYPE) return JSObject::kHeaderSize; |
2143 switch (type) { | 2145 switch (type) { |
2144 case JS_GENERATOR_OBJECT_TYPE: | 2146 case JS_GENERATOR_OBJECT_TYPE: |
2145 return JSGeneratorObject::kSize; | 2147 return JSGeneratorObject::kSize; |
2146 case JS_MODULE_TYPE: | 2148 case JS_MODULE_TYPE: |
2147 return JSModule::kSize; | 2149 return JSModule::kSize; |
2148 case JS_GLOBAL_PROXY_TYPE: | 2150 case JS_GLOBAL_PROXY_TYPE: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 return JSObject::kHeaderSize; | 2187 return JSObject::kHeaderSize; |
2186 case JS_MESSAGE_OBJECT_TYPE: | 2188 case JS_MESSAGE_OBJECT_TYPE: |
2187 return JSMessageObject::kSize; | 2189 return JSMessageObject::kSize; |
2188 default: | 2190 default: |
2189 UNREACHABLE(); | 2191 UNREACHABLE(); |
2190 return 0; | 2192 return 0; |
2191 } | 2193 } |
2192 } | 2194 } |
2193 | 2195 |
2194 | 2196 |
2195 int JSObject::GetInternalFieldCount() { | 2197 int JSObject::GetInternalFieldCount(Map* map) { |
2196 DCHECK(1 << kPointerSizeLog2 == kPointerSize); | 2198 int instance_size = map->instance_size(); |
2197 // Make sure to adjust for the number of in-object properties. These | 2199 if (instance_size == kVariableSizeSentinel) return 0; |
2198 // properties do contribute to the size, but are not internal fields. | 2200 InstanceType instance_type = map->instance_type(); |
2199 return ((Size() - GetHeaderSize()) >> kPointerSizeLog2) - | 2201 return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) - |
2200 map()->GetInObjectProperties(); | 2202 map->GetInObjectProperties(); |
2201 } | 2203 } |
2202 | 2204 |
2203 | 2205 |
| 2206 int JSObject::GetInternalFieldCount() { return GetInternalFieldCount(map()); } |
| 2207 |
| 2208 |
2204 int JSObject::GetInternalFieldOffset(int index) { | 2209 int JSObject::GetInternalFieldOffset(int index) { |
2205 DCHECK(index < GetInternalFieldCount() && index >= 0); | 2210 DCHECK(index < GetInternalFieldCount() && index >= 0); |
2206 return GetHeaderSize() + (kPointerSize * index); | 2211 return GetHeaderSize() + (kPointerSize * index); |
2207 } | 2212 } |
2208 | 2213 |
2209 | 2214 |
2210 Object* JSObject::GetInternalField(int index) { | 2215 Object* JSObject::GetInternalField(int index) { |
2211 DCHECK(index < GetInternalFieldCount() && index >= 0); | 2216 DCHECK(index < GetInternalFieldCount() && index >= 0); |
2212 // Internal objects do follow immediately after the header, whereas in-object | 2217 // Internal objects do follow immediately after the header, whereas in-object |
2213 // properties are at the end of the object. Therefore there is no need | 2218 // properties are at the end of the object. Therefore there is no need |
(...skipping 3403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5617 } | 5622 } |
5618 | 5623 |
5619 | 5624 |
5620 void Map::SetConstructor(Object* constructor, WriteBarrierMode mode) { | 5625 void Map::SetConstructor(Object* constructor, WriteBarrierMode mode) { |
5621 // Never overwrite a back pointer with a constructor. | 5626 // Never overwrite a back pointer with a constructor. |
5622 DCHECK(!constructor_or_backpointer()->IsMap()); | 5627 DCHECK(!constructor_or_backpointer()->IsMap()); |
5623 set_constructor_or_backpointer(constructor, mode); | 5628 set_constructor_or_backpointer(constructor, mode); |
5624 } | 5629 } |
5625 | 5630 |
5626 | 5631 |
| 5632 Handle<Map> Map::CopyInitialMap(Handle<Map> map) { |
| 5633 return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(), |
| 5634 map->unused_property_fields()); |
| 5635 } |
| 5636 |
| 5637 |
5627 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 5638 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
5628 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) | 5639 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) |
5629 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) | 5640 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) |
5630 | 5641 |
5631 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) | 5642 ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) |
5632 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) | 5643 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) |
5633 ACCESSORS(GlobalObject, global_proxy, JSObject, kGlobalProxyOffset) | 5644 ACCESSORS(GlobalObject, global_proxy, JSObject, kGlobalProxyOffset) |
5634 | 5645 |
5635 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) | 5646 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) |
5636 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) | 5647 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) |
(...skipping 2497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8134 #undef WRITE_INT64_FIELD | 8145 #undef WRITE_INT64_FIELD |
8135 #undef READ_BYTE_FIELD | 8146 #undef READ_BYTE_FIELD |
8136 #undef WRITE_BYTE_FIELD | 8147 #undef WRITE_BYTE_FIELD |
8137 #undef NOBARRIER_READ_BYTE_FIELD | 8148 #undef NOBARRIER_READ_BYTE_FIELD |
8138 #undef NOBARRIER_WRITE_BYTE_FIELD | 8149 #undef NOBARRIER_WRITE_BYTE_FIELD |
8139 | 8150 |
8140 } // namespace internal | 8151 } // namespace internal |
8141 } // namespace v8 | 8152 } // namespace v8 |
8142 | 8153 |
8143 #endif // V8_OBJECTS_INL_H_ | 8154 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |