| 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 3523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5697 ACCESSORS(FunctionTemplateInfo, shared_function_info, Object, | 5692 ACCESSORS(FunctionTemplateInfo, shared_function_info, Object, |
| 5698 kSharedFunctionInfoOffset) | 5693 kSharedFunctionInfoOffset) |
| 5699 ACCESSORS(FunctionTemplateInfo, cached_property_name, Object, | 5694 ACCESSORS(FunctionTemplateInfo, cached_property_name, Object, |
| 5700 kCachedPropertyNameOffset) | 5695 kCachedPropertyNameOffset) |
| 5701 | 5696 |
| 5702 SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset) | 5697 SMI_ACCESSORS(FunctionTemplateInfo, flag, kFlagOffset) |
| 5703 | 5698 |
| 5704 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) | 5699 ACCESSORS(ObjectTemplateInfo, constructor, Object, kConstructorOffset) |
| 5705 ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset) | 5700 ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset) |
| 5706 | 5701 |
| 5707 int ObjectTemplateInfo::internal_field_count() const { | 5702 int ObjectTemplateInfo::embedder_field_count() const { |
| 5708 Object* value = data(); | 5703 Object* value = data(); |
| 5709 DCHECK(value->IsSmi()); | 5704 DCHECK(value->IsSmi()); |
| 5710 return InternalFieldCount::decode(Smi::cast(value)->value()); | 5705 return EmbedderFieldCount::decode(Smi::cast(value)->value()); |
| 5711 } | 5706 } |
| 5712 | 5707 |
| 5713 void ObjectTemplateInfo::set_internal_field_count(int count) { | 5708 void ObjectTemplateInfo::set_embedder_field_count(int count) { |
| 5714 return set_data(Smi::FromInt( | 5709 return set_data(Smi::FromInt( |
| 5715 InternalFieldCount::update(Smi::cast(data())->value(), count))); | 5710 EmbedderFieldCount::update(Smi::cast(data())->value(), count))); |
| 5716 } | 5711 } |
| 5717 | 5712 |
| 5718 bool ObjectTemplateInfo::immutable_proto() const { | 5713 bool ObjectTemplateInfo::immutable_proto() const { |
| 5719 Object* value = data(); | 5714 Object* value = data(); |
| 5720 DCHECK(value->IsSmi()); | 5715 DCHECK(value->IsSmi()); |
| 5721 return IsImmutablePrototype::decode(Smi::cast(value)->value()); | 5716 return IsImmutablePrototype::decode(Smi::cast(value)->value()); |
| 5722 } | 5717 } |
| 5723 | 5718 |
| 5724 void ObjectTemplateInfo::set_immutable_proto(bool immutable) { | 5719 void ObjectTemplateInfo::set_immutable_proto(bool immutable) { |
| 5725 return set_data(Smi::FromInt( | 5720 return set_data(Smi::FromInt( |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7563 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); | 7558 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); |
| 7564 } | 7559 } |
| 7565 | 7560 |
| 7566 | 7561 |
| 7567 bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const { | 7562 bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const { |
| 7568 const PrototypeIterator iter(this->GetIsolate(), | 7563 const PrototypeIterator iter(this->GetIsolate(), |
| 7569 const_cast<JSGlobalProxy*>(this)); | 7564 const_cast<JSGlobalProxy*>(this)); |
| 7570 return iter.GetCurrent() != global; | 7565 return iter.GetCurrent() != global; |
| 7571 } | 7566 } |
| 7572 | 7567 |
| 7573 inline int JSGlobalProxy::SizeWithInternalFields(int internal_field_count) { | 7568 inline int JSGlobalProxy::SizeWithEmbedderFields(int embedder_field_count) { |
| 7574 DCHECK_GE(internal_field_count, 0); | 7569 DCHECK_GE(embedder_field_count, 0); |
| 7575 return kSize + internal_field_count * kPointerSize; | 7570 return kSize + embedder_field_count * kPointerSize; |
| 7576 } | 7571 } |
| 7577 | 7572 |
| 7578 Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate, | 7573 Smi* JSReceiver::GetOrCreateIdentityHash(Isolate* isolate, |
| 7579 Handle<JSReceiver> object) { | 7574 Handle<JSReceiver> object) { |
| 7580 return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash( | 7575 return object->IsJSProxy() ? JSProxy::GetOrCreateIdentityHash( |
| 7581 isolate, Handle<JSProxy>::cast(object)) | 7576 isolate, Handle<JSProxy>::cast(object)) |
| 7582 : JSObject::GetOrCreateIdentityHash( | 7577 : JSObject::GetOrCreateIdentityHash( |
| 7583 isolate, Handle<JSObject>::cast(object)); | 7578 isolate, Handle<JSObject>::cast(object)); |
| 7584 } | 7579 } |
| 7585 | 7580 |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8270 #undef WRITE_INT64_FIELD | 8265 #undef WRITE_INT64_FIELD |
| 8271 #undef READ_BYTE_FIELD | 8266 #undef READ_BYTE_FIELD |
| 8272 #undef WRITE_BYTE_FIELD | 8267 #undef WRITE_BYTE_FIELD |
| 8273 #undef NOBARRIER_READ_BYTE_FIELD | 8268 #undef NOBARRIER_READ_BYTE_FIELD |
| 8274 #undef NOBARRIER_WRITE_BYTE_FIELD | 8269 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8275 | 8270 |
| 8276 } // namespace internal | 8271 } // namespace internal |
| 8277 } // namespace v8 | 8272 } // namespace v8 |
| 8278 | 8273 |
| 8279 #endif // V8_OBJECTS_INL_H_ | 8274 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |