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