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