| 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 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 } | 2114 } |
| 2115 UNREACHABLE(); | 2115 UNREACHABLE(); |
| 2116 return 0; | 2116 return 0; |
| 2117 } | 2117 } |
| 2118 } | 2118 } |
| 2119 | 2119 |
| 2120 inline bool IsSpecialReceiverInstanceType(InstanceType instance_type) { | 2120 inline bool IsSpecialReceiverInstanceType(InstanceType instance_type) { |
| 2121 return instance_type <= LAST_SPECIAL_RECEIVER_TYPE; | 2121 return instance_type <= LAST_SPECIAL_RECEIVER_TYPE; |
| 2122 } | 2122 } |
| 2123 | 2123 |
| 2124 int JSObject::GetInternalFieldCount(Map* map) { | 2124 int JSObject::GetEmbedderFieldCount(Map* map) { |
| 2125 int instance_size = map->instance_size(); | 2125 int instance_size = map->instance_size(); |
| 2126 if (instance_size == kVariableSizeSentinel) return 0; | 2126 if (instance_size == kVariableSizeSentinel) return 0; |
| 2127 InstanceType instance_type = map->instance_type(); | 2127 InstanceType instance_type = map->instance_type(); |
| 2128 return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) - | 2128 return ((instance_size - GetHeaderSize(instance_type)) >> kPointerSizeLog2) - |
| 2129 map->GetInObjectProperties(); | 2129 map->GetInObjectProperties(); |
| 2130 } | 2130 } |
| 2131 | 2131 |
| 2132 int JSObject::GetEmbedderFieldCount() { return GetEmbedderFieldCount(map()); } |
| 2132 | 2133 |
| 2133 int JSObject::GetInternalFieldCount() { return GetInternalFieldCount(map()); } | 2134 int JSObject::GetEmbedderFieldOffset(int index) { |
| 2134 | 2135 DCHECK(index < GetEmbedderFieldCount() && index >= 0); |
| 2135 | |
| 2136 int JSObject::GetInternalFieldOffset(int index) { | |
| 2137 DCHECK(index < GetInternalFieldCount() && index >= 0); | |
| 2138 return GetHeaderSize() + (kPointerSize * index); | 2136 return GetHeaderSize() + (kPointerSize * index); |
| 2139 } | 2137 } |
| 2140 | 2138 |
| 2141 | 2139 Object* JSObject::GetEmbedderField(int index) { |
| 2142 Object* JSObject::GetInternalField(int index) { | 2140 DCHECK(index < GetEmbedderFieldCount() && index >= 0); |
| 2143 DCHECK(index < GetInternalFieldCount() && index >= 0); | |
| 2144 // Internal objects do follow immediately after the header, whereas in-object | 2141 // Internal objects do follow immediately after the header, whereas in-object |
| 2145 // properties are at the end of the object. Therefore there is no need | 2142 // properties are at the end of the object. Therefore there is no need |
| 2146 // to adjust the index here. | 2143 // to adjust the index here. |
| 2147 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); | 2144 return READ_FIELD(this, GetHeaderSize() + (kPointerSize * index)); |
| 2148 } | 2145 } |
| 2149 | 2146 |
| 2150 | 2147 void JSObject::SetEmbedderField(int index, Object* value) { |
| 2151 void JSObject::SetInternalField(int index, Object* value) { | 2148 DCHECK(index < GetEmbedderFieldCount() && index >= 0); |
| 2152 DCHECK(index < GetInternalFieldCount() && index >= 0); | |
| 2153 // Internal objects do follow immediately after the header, whereas in-object | 2149 // Internal objects do follow immediately after the header, whereas in-object |
| 2154 // properties are at the end of the object. Therefore there is no need | 2150 // properties are at the end of the object. Therefore there is no need |
| 2155 // to adjust the index here. | 2151 // to adjust the index here. |
| 2156 int offset = GetHeaderSize() + (kPointerSize * index); | 2152 int offset = GetHeaderSize() + (kPointerSize * index); |
| 2157 WRITE_FIELD(this, offset, value); | 2153 WRITE_FIELD(this, offset, value); |
| 2158 WRITE_BARRIER(GetHeap(), this, offset, value); | 2154 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2159 } | 2155 } |
| 2160 | 2156 |
| 2161 | 2157 void JSObject::SetEmbedderField(int index, Smi* value) { |
| 2162 void JSObject::SetInternalField(int index, Smi* value) { | 2158 DCHECK(index < GetEmbedderFieldCount() && index >= 0); |
| 2163 DCHECK(index < GetInternalFieldCount() && index >= 0); | |
| 2164 // Internal objects do follow immediately after the header, whereas in-object | 2159 // Internal objects do follow immediately after the header, whereas in-object |
| 2165 // properties are at the end of the object. Therefore there is no need | 2160 // properties are at the end of the object. Therefore there is no need |
| 2166 // to adjust the index here. | 2161 // to adjust the index here. |
| 2167 int offset = GetHeaderSize() + (kPointerSize * index); | 2162 int offset = GetHeaderSize() + (kPointerSize * index); |
| 2168 WRITE_FIELD(this, offset, value); | 2163 WRITE_FIELD(this, offset, value); |
| 2169 } | 2164 } |
| 2170 | 2165 |
| 2171 | 2166 |
| 2172 bool JSObject::IsUnboxedDoubleField(FieldIndex index) { | 2167 bool JSObject::IsUnboxedDoubleField(FieldIndex index) { |
| 2173 if (!FLAG_unbox_double_fields) return false; | 2168 if (!FLAG_unbox_double_fields) return false; |
| (...skipping 3527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5701 ACCESSORS(FunctionTemplateInfo, shared_function_info, Object, | 5696 ACCESSORS(FunctionTemplateInfo, shared_function_info, Object, |
| 5702 kSharedFunctionInfoOffset) | 5697 kSharedFunctionInfoOffset) |
| 5703 ACCESSORS(FunctionTemplateInfo, cached_property_name, Object, | 5698 ACCESSORS(FunctionTemplateInfo, cached_property_name, Object, |
| 5704 kCachedPropertyNameOffset) | 5699 kCachedPropertyNameOffset) |
| 5705 | 5700 |
| 5706 SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset) | 5701 SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset) |
| 5707 | 5702 |
| 5708 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) | 5703 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) |
| 5709 ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset) | 5704 ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset) |
| 5710 | 5705 |
| 5711 int ObjectTemplateInfo::internal_field_count() const { | 5706 int ObjectTemplateInfo::embedder_field_count() const { |
| 5712 Object* value = data(); | 5707 Object* value = data(); |
| 5713 DCHECK(value->IsSmi()); | 5708 DCHECK(value->IsSmi()); |
| 5714 return InternalFieldCount::decode(Smi::cast(value)->value()); | 5709 return EmbedderFieldCount::decode(Smi::cast(value)->value()); |
| 5715 } | 5710 } |
| 5716 | 5711 |
| 5717 void ObjectTemplateInfo::set_internal_field_count(int count) { | 5712 void ObjectTemplateInfo::set_embedder_field_count(int count) { |
| 5718 return set_data(Smi::FromInt( | 5713 return set_data(Smi::FromInt( |
| 5719 InternalFieldCount::update(Smi::cast(data())->value(), count))); | 5714 EmbedderFieldCount::update(Smi::cast(data())->value(), count))); |
| 5720 } | 5715 } |
| 5721 | 5716 |
| 5722 bool ObjectTemplateInfo::immutable_proto() const { | 5717 bool ObjectTemplateInfo::immutable_proto() const { |
| 5723 Object* value = data(); | 5718 Object* value = data(); |
| 5724 DCHECK(value->IsSmi()); | 5719 DCHECK(value->IsSmi()); |
| 5725 return IsImmutablePrototype::decode(Smi::cast(value)->value()); | 5720 return IsImmutablePrototype::decode(Smi::cast(value)->value()); |
| 5726 } | 5721 } |
| 5727 | 5722 |
| 5728 void ObjectTemplateInfo::set_immutable_proto(bool immutable) { | 5723 void ObjectTemplateInfo::set_immutable_proto(bool immutable) { |
| 5729 return set_data(Smi::FromInt( | 5724 return set_data(Smi::FromInt( |
| (...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7570 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); | 7565 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); |
| 7571 } | 7566 } |
| 7572 | 7567 |
| 7573 | 7568 |
| 7574 bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const { | 7569 bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const { |
| 7575 const PrototypeIterator iter(this->GetIsolate(), | 7570 const PrototypeIterator iter(this->GetIsolate(), |
| 7576 const_cast<JSGlobalProxy*>(this)); | 7571 const_cast<JSGlobalProxy*>(this)); |
| 7577 return iter.GetCurrent() != global; | 7572 return iter.GetCurrent() != global; |
| 7578 } | 7573 } |
| 7579 | 7574 |
| 7580 inline int JSGlobalProxy::SizeWithInternalFields(int internal_field_count) { | 7575 inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) { |
| 7581 DCHECK_GE(internal_field_count, 0); | 7576 DCHECK_GE(embedder_field_count, 0); |
| 7582 return kSize + internal_field_count * kPointerSize; | 7577 return kSize + embedder_field_count * kPointerSize; |
| 7583 } | 7578 } |
| 7584 | 7579 |
| 7585 Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate, | 7580 Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate, |
| 7586 Handle<JSReceiver> object) { | 7581 Handle<JSReceiver> object) { |
| 7587 return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash( | 7582 return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash( |
| 7588 isolate, Handle<JSProxy>::cast(object)) | 7583 isolate, Handle<JSProxy>::cast(object)) |
| 7589 : JSObject::GetOrCreateIdentityHash( | 7584 : JSObject::GetOrCreateIdentityHash( |
| 7590 isolate, Handle<JSObject>::cast(object)); | 7585 isolate, Handle<JSObject>::cast(object)); |
| 7591 } | 7586 } |
| 7592 | 7587 |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8277 #undef WRITE_INT64_FIELD | 8272 #undef WRITE_INT64_FIELD |
| 8278 #undef READ_BYTE_FIELD | 8273 #undef READ_BYTE_FIELD |
| 8279 #undef WRITE_BYTE_FIELD | 8274 #undef WRITE_BYTE_FIELD |
| 8280 #undef NOBARRIER_READ_BYTE_FIELD | 8275 #undef NOBARRIER_READ_BYTE_FIELD |
| 8281 #undef NOBARRIER_WRITE_BYTE_FIELD | 8276 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8282 | 8277 |
| 8283 } // namespace internal | 8278 } // namespace internal |
| 8284 } // namespace v8 | 8279 } // namespace v8 |
| 8285 | 8280 |
| 8286 #endif // V8_OBJECTS_INL_H_ | 8281 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |