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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 bool Object::IsJSGlobalProxy() const { | 1003 bool Object::IsJSGlobalProxy() const { |
1004 bool result = IsHeapObject() && | 1004 bool result = IsHeapObject() && |
1005 (HeapObject::cast(this)->map()->instance_type() == | 1005 (HeapObject::cast(this)->map()->instance_type() == |
1006 JS_GLOBAL_PROXY_TYPE); | 1006 JS_GLOBAL_PROXY_TYPE); |
1007 DCHECK(!result || | 1007 DCHECK(!result || |
1008 HeapObject::cast(this)->map()->is_access_check_needed()); | 1008 HeapObject::cast(this)->map()->is_access_check_needed()); |
1009 return result; | 1009 return result; |
1010 } | 1010 } |
1011 | 1011 |
1012 | 1012 |
1013 bool Object::IsGlobalObject() const { | |
1014 if (!IsHeapObject()) return false; | |
1015 return HeapObject::cast(this)->map()->IsGlobalObjectMap(); | |
1016 } | |
1017 | |
1018 | |
1019 TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE) | 1013 TYPE_CHECKER(JSGlobalObject, JS_GLOBAL_OBJECT_TYPE) |
1020 | 1014 |
1021 | 1015 |
1022 bool Object::IsUndetectableObject() const { | 1016 bool Object::IsUndetectableObject() const { |
1023 return IsHeapObject() | 1017 return IsHeapObject() |
1024 && HeapObject::cast(this)->map()->is_undetectable(); | 1018 && HeapObject::cast(this)->map()->is_undetectable(); |
1025 } | 1019 } |
1026 | 1020 |
1027 | 1021 |
1028 bool Object::IsAccessCheckNeeded() const { | 1022 bool Object::IsAccessCheckNeeded() const { |
1029 if (!IsHeapObject()) return false; | 1023 if (!IsHeapObject()) return false; |
1030 if (IsJSGlobalProxy()) { | 1024 if (IsJSGlobalProxy()) { |
1031 const JSGlobalProxy* proxy = JSGlobalProxy::cast(this); | 1025 const JSGlobalProxy* proxy = JSGlobalProxy::cast(this); |
1032 GlobalObject* global = proxy->GetIsolate()->context()->global_object(); | 1026 JSGlobalObject* global = proxy->GetIsolate()->context()->global_object(); |
1033 return proxy->IsDetachedFrom(global); | 1027 return proxy->IsDetachedFrom(global); |
1034 } | 1028 } |
1035 return HeapObject::cast(this)->map()->is_access_check_needed(); | 1029 return HeapObject::cast(this)->map()->is_access_check_needed(); |
1036 } | 1030 } |
1037 | 1031 |
1038 | 1032 |
1039 bool Object::IsStruct() const { | 1033 bool Object::IsStruct() const { |
1040 if (!IsHeapObject()) return false; | 1034 if (!IsHeapObject()) return false; |
1041 switch (HeapObject::cast(this)->map()->instance_type()) { | 1035 switch (HeapObject::cast(this)->map()->instance_type()) { |
1042 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return true; | 1036 #define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: return true; |
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 CAST_ACCESSOR(ExternalOneByteString) | 3296 CAST_ACCESSOR(ExternalOneByteString) |
3303 CAST_ACCESSOR(ExternalString) | 3297 CAST_ACCESSOR(ExternalString) |
3304 CAST_ACCESSOR(ExternalTwoByteString) | 3298 CAST_ACCESSOR(ExternalTwoByteString) |
3305 CAST_ACCESSOR(FixedArray) | 3299 CAST_ACCESSOR(FixedArray) |
3306 CAST_ACCESSOR(FixedArrayBase) | 3300 CAST_ACCESSOR(FixedArrayBase) |
3307 CAST_ACCESSOR(FixedDoubleArray) | 3301 CAST_ACCESSOR(FixedDoubleArray) |
3308 CAST_ACCESSOR(FixedTypedArrayBase) | 3302 CAST_ACCESSOR(FixedTypedArrayBase) |
3309 CAST_ACCESSOR(Float32x4) | 3303 CAST_ACCESSOR(Float32x4) |
3310 CAST_ACCESSOR(Foreign) | 3304 CAST_ACCESSOR(Foreign) |
3311 CAST_ACCESSOR(GlobalDictionary) | 3305 CAST_ACCESSOR(GlobalDictionary) |
3312 CAST_ACCESSOR(GlobalObject) | |
3313 CAST_ACCESSOR(HandlerTable) | 3306 CAST_ACCESSOR(HandlerTable) |
3314 CAST_ACCESSOR(HeapObject) | 3307 CAST_ACCESSOR(HeapObject) |
3315 CAST_ACCESSOR(Int16x8) | 3308 CAST_ACCESSOR(Int16x8) |
3316 CAST_ACCESSOR(Int32x4) | 3309 CAST_ACCESSOR(Int32x4) |
3317 CAST_ACCESSOR(Int8x16) | 3310 CAST_ACCESSOR(Int8x16) |
3318 CAST_ACCESSOR(JSArray) | 3311 CAST_ACCESSOR(JSArray) |
3319 CAST_ACCESSOR(JSArrayBuffer) | 3312 CAST_ACCESSOR(JSArrayBuffer) |
3320 CAST_ACCESSOR(JSArrayBufferView) | 3313 CAST_ACCESSOR(JSArrayBufferView) |
3321 CAST_ACCESSOR(JSDataView) | 3314 CAST_ACCESSOR(JSDataView) |
3322 CAST_ACCESSOR(JSDate) | 3315 CAST_ACCESSOR(JSDate) |
(...skipping 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4919 InstanceType type = instance_type(); | 4912 InstanceType type = instance_type(); |
4920 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; | 4913 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; |
4921 } | 4914 } |
4922 bool Map::IsJSGlobalProxyMap() { | 4915 bool Map::IsJSGlobalProxyMap() { |
4923 return instance_type() == JS_GLOBAL_PROXY_TYPE; | 4916 return instance_type() == JS_GLOBAL_PROXY_TYPE; |
4924 } | 4917 } |
4925 bool Map::IsJSGlobalObjectMap() { | 4918 bool Map::IsJSGlobalObjectMap() { |
4926 return instance_type() == JS_GLOBAL_OBJECT_TYPE; | 4919 return instance_type() == JS_GLOBAL_OBJECT_TYPE; |
4927 } | 4920 } |
4928 bool Map::IsJSTypedArrayMap() { return instance_type() == JS_TYPED_ARRAY_TYPE; } | 4921 bool Map::IsJSTypedArrayMap() { return instance_type() == JS_TYPED_ARRAY_TYPE; } |
4929 bool Map::IsGlobalObjectMap() { | |
4930 const InstanceType type = instance_type(); | |
4931 return type == JS_GLOBAL_OBJECT_TYPE; | |
4932 } | |
4933 | 4922 |
4934 | 4923 |
4935 bool Map::CanOmitMapChecks() { | 4924 bool Map::CanOmitMapChecks() { |
4936 return is_stable() && FLAG_omit_map_checks_for_leaf_maps; | 4925 return is_stable() && FLAG_omit_map_checks_for_leaf_maps; |
4937 } | 4926 } |
4938 | 4927 |
4939 | 4928 |
4940 int DependentCode::number_of_entries(DependencyGroup group) { | 4929 int DependentCode::number_of_entries(DependencyGroup group) { |
4941 if (length() == 0) return 0; | 4930 if (length() == 0) return 0; |
4942 return Smi::cast(get(group))->value(); | 4931 return Smi::cast(get(group))->value(); |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5628 Handle<Map> Map::CopyInitialMap(Handle<Map> map) { | 5617 Handle<Map> Map::CopyInitialMap(Handle<Map> map) { |
5629 return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(), | 5618 return CopyInitialMap(map, map->instance_size(), map->GetInObjectProperties(), |
5630 map->unused_property_fields()); | 5619 map->unused_property_fields()); |
5631 } | 5620 } |
5632 | 5621 |
5633 | 5622 |
5634 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) | 5623 ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset) |
5635 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) | 5624 ACCESSORS(JSFunction, literals_or_bindings, FixedArray, kLiteralsOffset) |
5636 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) | 5625 ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) |
5637 | 5626 |
5638 ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) | 5627 ACCESSORS(JSGlobalObject, native_context, Context, kNativeContextOffset) |
5639 ACCESSORS(GlobalObject, global_proxy, JSObject, kGlobalProxyOffset) | 5628 ACCESSORS(JSGlobalObject, global_proxy, JSObject, kGlobalProxyOffset) |
5640 | 5629 |
5641 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) | 5630 ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) |
5642 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) | 5631 ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) |
5643 | 5632 |
5644 ACCESSORS(AccessorInfo, name, Object, kNameOffset) | 5633 ACCESSORS(AccessorInfo, name, Object, kNameOffset) |
5645 SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset) | 5634 SMI_ACCESSORS(AccessorInfo, flag, kFlagOffset) |
5646 ACCESSORS(AccessorInfo, expected_receiver_type, Object, | 5635 ACCESSORS(AccessorInfo, expected_receiver_type, Object, |
5647 kExpectedReceiverTypeOffset) | 5636 kExpectedReceiverTypeOffset) |
5648 | 5637 |
5649 ACCESSORS(ExecutableAccessorInfo, getter, Object, kGetterOffset) | 5638 ACCESSORS(ExecutableAccessorInfo, getter, Object, kGetterOffset) |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6957 } | 6946 } |
6958 | 6947 |
6959 | 6948 |
6960 bool JSObject::HasIndexedInterceptor() { | 6949 bool JSObject::HasIndexedInterceptor() { |
6961 return map()->has_indexed_interceptor(); | 6950 return map()->has_indexed_interceptor(); |
6962 } | 6951 } |
6963 | 6952 |
6964 | 6953 |
6965 NameDictionary* JSObject::property_dictionary() { | 6954 NameDictionary* JSObject::property_dictionary() { |
6966 DCHECK(!HasFastProperties()); | 6955 DCHECK(!HasFastProperties()); |
6967 DCHECK(!IsGlobalObject()); | 6956 DCHECK(!IsJSGlobalObject()); |
6968 return NameDictionary::cast(properties()); | 6957 return NameDictionary::cast(properties()); |
6969 } | 6958 } |
6970 | 6959 |
6971 | 6960 |
6972 GlobalDictionary* JSObject::global_dictionary() { | 6961 GlobalDictionary* JSObject::global_dictionary() { |
6973 DCHECK(!HasFastProperties()); | 6962 DCHECK(!HasFastProperties()); |
6974 DCHECK(IsGlobalObject()); | 6963 DCHECK(IsJSGlobalObject()); |
6975 return GlobalDictionary::cast(properties()); | 6964 return GlobalDictionary::cast(properties()); |
6976 } | 6965 } |
6977 | 6966 |
6978 | 6967 |
6979 SeededNumberDictionary* JSObject::element_dictionary() { | 6968 SeededNumberDictionary* JSObject::element_dictionary() { |
6980 DCHECK(HasDictionaryElements()); | 6969 DCHECK(HasDictionaryElements()); |
6981 return SeededNumberDictionary::cast(elements()); | 6970 return SeededNumberDictionary::cast(elements()); |
6982 } | 6971 } |
6983 | 6972 |
6984 | 6973 |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7367 LookupIterator it(isolate, object, index, LookupIterator::HIDDEN); | 7356 LookupIterator it(isolate, object, index, LookupIterator::HIDDEN); |
7368 return GetPropertyAttributes(&it); | 7357 return GetPropertyAttributes(&it); |
7369 } | 7358 } |
7370 | 7359 |
7371 | 7360 |
7372 bool JSGlobalObject::IsDetached() { | 7361 bool JSGlobalObject::IsDetached() { |
7373 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); | 7362 return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); |
7374 } | 7363 } |
7375 | 7364 |
7376 | 7365 |
7377 bool JSGlobalProxy::IsDetachedFrom(GlobalObject* global) const { | 7366 bool JSGlobalProxy::IsDetachedFrom(JSGlobalObject* global) const { |
7378 const PrototypeIterator iter(this->GetIsolate(), | 7367 const PrototypeIterator iter(this->GetIsolate(), |
7379 const_cast<JSGlobalProxy*>(this)); | 7368 const_cast<JSGlobalProxy*>(this)); |
7380 return iter.GetCurrent() != global; | 7369 return iter.GetCurrent() != global; |
7381 } | 7370 } |
7382 | 7371 |
7383 | 7372 |
7384 Handle<Smi> JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver> object) { | 7373 Handle<Smi> JSReceiver::GetOrCreateIdentityHash(Handle<JSReceiver> object) { |
7385 return object->IsJSProxy() | 7374 return object->IsJSProxy() |
7386 ? JSProxy::GetOrCreateIdentityHash(Handle<JSProxy>::cast(object)) | 7375 ? JSProxy::GetOrCreateIdentityHash(Handle<JSProxy>::cast(object)) |
7387 : JSObject::GetOrCreateIdentityHash(Handle<JSObject>::cast(object)); | 7376 : JSObject::GetOrCreateIdentityHash(Handle<JSObject>::cast(object)); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8140 #undef WRITE_INT64_FIELD | 8129 #undef WRITE_INT64_FIELD |
8141 #undef READ_BYTE_FIELD | 8130 #undef READ_BYTE_FIELD |
8142 #undef WRITE_BYTE_FIELD | 8131 #undef WRITE_BYTE_FIELD |
8143 #undef NOBARRIER_READ_BYTE_FIELD | 8132 #undef NOBARRIER_READ_BYTE_FIELD |
8144 #undef NOBARRIER_WRITE_BYTE_FIELD | 8133 #undef NOBARRIER_WRITE_BYTE_FIELD |
8145 | 8134 |
8146 } // namespace internal | 8135 } // namespace internal |
8147 } // namespace v8 | 8136 } // namespace v8 |
8148 | 8137 |
8149 #endif // V8_OBJECTS_INL_H_ | 8138 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |