Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 // caching. | 1338 // caching. |
| 1339 class JSObject: public HeapObject { | 1339 class JSObject: public HeapObject { |
| 1340 public: | 1340 public: |
| 1341 enum DeleteMode { | 1341 enum DeleteMode { |
| 1342 NORMAL_DELETION, | 1342 NORMAL_DELETION, |
| 1343 STRICT_DELETION, | 1343 STRICT_DELETION, |
| 1344 FORCE_DELETION | 1344 FORCE_DELETION |
| 1345 }; | 1345 }; |
| 1346 | 1346 |
| 1347 enum ElementsKind { | 1347 enum ElementsKind { |
| 1348 // The only "fast" kind. | 1348 // The "fast" kind for tagged values. Must be first to make it possible |
| 1349 // to efficiently check maps if they have fast elements. | |
| 1349 FAST_ELEMENTS, | 1350 FAST_ELEMENTS, |
| 1350 // All the kinds below are "slow". | 1351 // The "slow" kind. |
| 1351 DICTIONARY_ELEMENTS, | 1352 DICTIONARY_ELEMENTS, |
| 1353 // The "fast" kind for external arrays | |
| 1352 EXTERNAL_BYTE_ELEMENTS, | 1354 EXTERNAL_BYTE_ELEMENTS, |
| 1353 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, | 1355 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, |
| 1354 EXTERNAL_SHORT_ELEMENTS, | 1356 EXTERNAL_SHORT_ELEMENTS, |
| 1355 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, | 1357 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, |
| 1356 EXTERNAL_INT_ELEMENTS, | 1358 EXTERNAL_INT_ELEMENTS, |
| 1357 EXTERNAL_UNSIGNED_INT_ELEMENTS, | 1359 EXTERNAL_UNSIGNED_INT_ELEMENTS, |
| 1358 EXTERNAL_FLOAT_ELEMENTS, | 1360 EXTERNAL_FLOAT_ELEMENTS, |
| 1359 EXTERNAL_DOUBLE_ELEMENTS, | 1361 EXTERNAL_DOUBLE_ELEMENTS, |
| 1360 EXTERNAL_PIXEL_ELEMENTS | 1362 EXTERNAL_PIXEL_ELEMENTS, |
| 1363 | |
| 1364 // Derived constants from ElementsKind | |
| 1365 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS, | |
| 1366 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS, | |
| 1367 FIRST_ELEMENTS_KIND = FAST_ELEMENTS, | |
| 1368 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS | |
| 1361 }; | 1369 }; |
| 1362 | 1370 |
| 1371 static const int kElementsKindCount = | |
| 1372 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1; | |
| 1373 | |
| 1363 // [properties]: Backing storage for properties. | 1374 // [properties]: Backing storage for properties. |
| 1364 // properties is a FixedArray in the fast case and a Dictionary in the | 1375 // properties is a FixedArray in the fast case and a Dictionary in the |
| 1365 // slow case. | 1376 // slow case. |
| 1366 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. | 1377 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. |
| 1367 inline void initialize_properties(); | 1378 inline void initialize_properties(); |
| 1368 inline bool HasFastProperties(); | 1379 inline bool HasFastProperties(); |
| 1369 inline StringDictionary* property_dictionary(); // Gets slow properties. | 1380 inline StringDictionary* property_dictionary(); // Gets slow properties. |
| 1370 | 1381 |
| 1371 // [elements]: The elements (properties with names that are integers). | 1382 // [elements]: The elements (properties with names that are integers). |
| 1372 // | 1383 // |
| (...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3738 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); | 3749 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); |
| 3739 } | 3750 } |
| 3740 | 3751 |
| 3741 inline bool has_instance_call_handler() { | 3752 inline bool has_instance_call_handler() { |
| 3742 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; | 3753 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; |
| 3743 } | 3754 } |
| 3744 | 3755 |
| 3745 inline void set_is_extensible(bool value); | 3756 inline void set_is_extensible(bool value); |
| 3746 inline bool is_extensible(); | 3757 inline bool is_extensible(); |
| 3747 | 3758 |
| 3748 // Tells whether the instance has fast elements. | 3759 inline void set_elements_kind(JSObject::ElementsKind elements_kind) { |
| 3749 // Equivalent to instance->GetElementsKind() == FAST_ELEMENTS. | 3760 ASSERT(elements_kind < JSObject::kElementsKindCount); |
| 3750 inline void set_has_fast_elements(bool value) { | 3761 ASSERT(JSObject::kElementsKindCount <= (1 << kElementsKindBitCount)); |
| 3751 if (value) { | 3762 set_bit_field2((bit_field2() & ~kElementsKindMask) | |
| 3752 set_bit_field2(bit_field2() | (1 << kHasFastElements)); | 3763 (elements_kind << kElementsKindFirstBit)); |
|
Mads Ager (chromium)
2011/05/30 11:14:24
Rename kElementsKindFirstBit to kElementsKindShift
danno
2011/06/01 22:29:54
Done.
| |
| 3753 } else { | 3764 ASSERT(this->elements_kind() == elements_kind); |
| 3754 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); | 3765 } |
| 3755 } | 3766 |
| 3767 inline JSObject::ElementsKind elements_kind() { | |
| 3768 return static_cast<JSObject::ElementsKind>( | |
| 3769 (bit_field2() & kElementsKindMask) >> kElementsKindFirstBit); | |
| 3756 } | 3770 } |
| 3757 | 3771 |
| 3758 inline bool has_fast_elements() { | 3772 inline bool has_fast_elements() { |
| 3759 return ((1 << kHasFastElements) & bit_field2()) != 0; | 3773 return elements_kind() == JSObject::FAST_ELEMENTS; |
| 3760 } | |
| 3761 | |
| 3762 // Tells whether an instance has pixel array elements. | |
| 3763 inline void set_has_external_array_elements(bool value) { | |
| 3764 if (value) { | |
| 3765 set_bit_field2(bit_field2() | (1 << kHasExternalArrayElements)); | |
| 3766 } else { | |
| 3767 set_bit_field2(bit_field2() & ~(1 << kHasExternalArrayElements)); | |
| 3768 } | |
| 3769 } | 3774 } |
| 3770 | 3775 |
| 3771 inline bool has_external_array_elements() { | 3776 inline bool has_external_array_elements() { |
| 3772 return ((1 << kHasExternalArrayElements) & bit_field2()) != 0; | 3777 JSObject::ElementsKind kind(elements_kind()); |
| 3778 return kind >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && | |
| 3779 kind <= JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND; | |
| 3773 } | 3780 } |
| 3774 | 3781 |
| 3775 // Tells whether the map is attached to SharedFunctionInfo | 3782 // Tells whether the map is attached to SharedFunctionInfo |
| 3776 // (for inobject slack tracking). | 3783 // (for inobject slack tracking). |
| 3777 inline void set_attached_to_shared_function_info(bool value); | 3784 inline void set_attached_to_shared_function_info(bool value); |
| 3778 | 3785 |
| 3779 inline bool attached_to_shared_function_info(); | 3786 inline bool attached_to_shared_function_info(); |
| 3780 | 3787 |
| 3781 // Tells whether the map is shared between objects that may have different | 3788 // Tells whether the map is shared between objects that may have different |
| 3782 // behavior. If true, the map should never be modified, instead a clone | 3789 // behavior. If true, the map should never be modified, instead a clone |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3983 static const int kIsHiddenPrototype = 2; | 3990 static const int kIsHiddenPrototype = 2; |
| 3984 static const int kHasNamedInterceptor = 3; | 3991 static const int kHasNamedInterceptor = 3; |
| 3985 static const int kHasIndexedInterceptor = 4; | 3992 static const int kHasIndexedInterceptor = 4; |
| 3986 static const int kIsUndetectable = 5; | 3993 static const int kIsUndetectable = 5; |
| 3987 static const int kHasInstanceCallHandler = 6; | 3994 static const int kHasInstanceCallHandler = 6; |
| 3988 static const int kIsAccessCheckNeeded = 7; | 3995 static const int kIsAccessCheckNeeded = 7; |
| 3989 | 3996 |
| 3990 // Bit positions for bit field 2 | 3997 // Bit positions for bit field 2 |
| 3991 static const int kIsExtensible = 0; | 3998 static const int kIsExtensible = 0; |
| 3992 static const int kFunctionWithPrototype = 1; | 3999 static const int kFunctionWithPrototype = 1; |
| 3993 static const int kHasFastElements = 2; | 4000 static const int kStringWrapperSafeForDefaultValueOf = 2; |
| 3994 static const int kStringWrapperSafeForDefaultValueOf = 3; | 4001 static const int kAttachedToSharedFunctionInfo = 3; |
| 3995 static const int kAttachedToSharedFunctionInfo = 4; | 4002 // No bits can be used between kElementsKindFirstBit and kElementsKindLastBit |
|
Mads Ager (chromium)
2011/05/30 11:14:24
Since the elements kind is using the remaining bit
danno
2011/06/01 22:29:54
Done.
| |
| 3996 static const int kHasExternalArrayElements = 5; | 4003 // for anything other than storing the ElementKind. |
| 4004 static const int kElementsKindFirstBit = 4; | |
| 4005 static const int kElementsKindLastBit = 7; | |
| 4006 | |
| 4007 // Derived values from bit field 2 | |
| 4008 static const int kElementsKindBitCount = | |
| 4009 kElementsKindLastBit - kElementsKindFirstBit + 1; | |
| 4010 static const int kElementsKindMask = | |
| 4011 (-1 << kElementsKindFirstBit) & ((1 << (kElementsKindLastBit + 1)) - 1); | |
| 4012 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>( | |
| 4013 (JSObject::FAST_ELEMENTS + 1) << Map::kElementsKindFirstBit) - 1; | |
| 3997 | 4014 |
| 3998 // Bit positions for bit field 3 | 4015 // Bit positions for bit field 3 |
| 3999 static const int kIsShared = 1; | 4016 static const int kIsShared = 0; |
| 4000 | 4017 |
| 4001 // Layout of the default cache. It holds alternating name and code objects. | 4018 // Layout of the default cache. It holds alternating name and code objects. |
| 4002 static const int kCodeCacheEntrySize = 2; | 4019 static const int kCodeCacheEntrySize = 2; |
| 4003 static const int kCodeCacheEntryNameOffset = 0; | 4020 static const int kCodeCacheEntryNameOffset = 0; |
| 4004 static const int kCodeCacheEntryCodeOffset = 1; | 4021 static const int kCodeCacheEntryCodeOffset = 1; |
| 4005 | 4022 |
| 4006 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, | 4023 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, |
| 4007 kPointerFieldsEndOffset, | 4024 kPointerFieldsEndOffset, |
| 4008 kSize> BodyDescriptor; | 4025 kSize> BodyDescriptor; |
| 4009 | 4026 |
| (...skipping 2823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6833 } else { | 6850 } else { |
| 6834 value &= ~(1 << bit_position); | 6851 value &= ~(1 << bit_position); |
| 6835 } | 6852 } |
| 6836 return value; | 6853 return value; |
| 6837 } | 6854 } |
| 6838 }; | 6855 }; |
| 6839 | 6856 |
| 6840 } } // namespace v8::internal | 6857 } } // namespace v8::internal |
| 6841 | 6858 |
| 6842 #endif // V8_OBJECTS_H_ | 6859 #endif // V8_OBJECTS_H_ |
| OLD | NEW |