Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: src/objects.h

Issue 6993057: Version 3.4.2 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 // caching. 1413 // caching.
1414 class JSObject: public JSReceiver { 1414 class JSObject: public JSReceiver {
1415 public: 1415 public:
1416 enum DeleteMode { 1416 enum DeleteMode {
1417 NORMAL_DELETION, 1417 NORMAL_DELETION,
1418 STRICT_DELETION, 1418 STRICT_DELETION,
1419 FORCE_DELETION 1419 FORCE_DELETION
1420 }; 1420 };
1421 1421
1422 enum ElementsKind { 1422 enum ElementsKind {
1423 // The only "fast" kind. 1423 // The "fast" kind for tagged values. Must be first to make it possible
1424 // to efficiently check maps if they have fast elements.
1424 FAST_ELEMENTS, 1425 FAST_ELEMENTS,
1425 // All the kinds below are "slow". 1426 // The "slow" kind.
1426 DICTIONARY_ELEMENTS, 1427 DICTIONARY_ELEMENTS,
1428 // The "fast" kind for external arrays
1427 EXTERNAL_BYTE_ELEMENTS, 1429 EXTERNAL_BYTE_ELEMENTS,
1428 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, 1430 EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
1429 EXTERNAL_SHORT_ELEMENTS, 1431 EXTERNAL_SHORT_ELEMENTS,
1430 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, 1432 EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
1431 EXTERNAL_INT_ELEMENTS, 1433 EXTERNAL_INT_ELEMENTS,
1432 EXTERNAL_UNSIGNED_INT_ELEMENTS, 1434 EXTERNAL_UNSIGNED_INT_ELEMENTS,
1433 EXTERNAL_FLOAT_ELEMENTS, 1435 EXTERNAL_FLOAT_ELEMENTS,
1434 EXTERNAL_DOUBLE_ELEMENTS, 1436 EXTERNAL_DOUBLE_ELEMENTS,
1435 EXTERNAL_PIXEL_ELEMENTS 1437 EXTERNAL_PIXEL_ELEMENTS,
1438
1439 // Derived constants from ElementsKind
1440 FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_BYTE_ELEMENTS,
1441 LAST_EXTERNAL_ARRAY_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS,
1442 FIRST_ELEMENTS_KIND = FAST_ELEMENTS,
1443 LAST_ELEMENTS_KIND = EXTERNAL_PIXEL_ELEMENTS
1436 }; 1444 };
1437 1445
1446 static const int kElementsKindCount =
1447 LAST_ELEMENTS_KIND - FIRST_ELEMENTS_KIND + 1;
1448
1438 // [properties]: Backing storage for properties. 1449 // [properties]: Backing storage for properties.
1439 // properties is a FixedArray in the fast case and a Dictionary in the 1450 // properties is a FixedArray in the fast case and a Dictionary in the
1440 // slow case. 1451 // slow case.
1441 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. 1452 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
1442 inline void initialize_properties(); 1453 inline void initialize_properties();
1443 inline bool HasFastProperties(); 1454 inline bool HasFastProperties();
1444 inline StringDictionary* property_dictionary(); // Gets slow properties. 1455 inline StringDictionary* property_dictionary(); // Gets slow properties.
1445 1456
1446 // [elements]: The elements (properties with names that are integers). 1457 // [elements]: The elements (properties with names that are integers).
1447 // 1458 //
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3777 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler)); 3788 set_bit_field(bit_field() | (1 << kHasInstanceCallHandler));
3778 } 3789 }
3779 3790
3780 inline bool has_instance_call_handler() { 3791 inline bool has_instance_call_handler() {
3781 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0; 3792 return ((1 << kHasInstanceCallHandler) & bit_field()) != 0;
3782 } 3793 }
3783 3794
3784 inline void set_is_extensible(bool value); 3795 inline void set_is_extensible(bool value);
3785 inline bool is_extensible(); 3796 inline bool is_extensible();
3786 3797
3787 // Tells whether the instance has fast elements. 3798 inline void set_elements_kind(JSObject::ElementsKind elements_kind) {
3788 // Equivalent to instance->GetElementsKind() == FAST_ELEMENTS. 3799 ASSERT(elements_kind < JSObject::kElementsKindCount);
3789 inline void set_has_fast_elements(bool value) { 3800 ASSERT(JSObject::kElementsKindCount <= (1 << kElementsKindBitCount));
3790 if (value) { 3801 set_bit_field2((bit_field2() & ~kElementsKindMask) |
3791 set_bit_field2(bit_field2() | (1 << kHasFastElements)); 3802 (elements_kind << kElementsKindShift));
3792 } else { 3803 ASSERT(this->elements_kind() == elements_kind);
3793 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); 3804 }
3794 } 3805
3806 inline JSObject::ElementsKind elements_kind() {
3807 return static_cast<JSObject::ElementsKind>(
3808 (bit_field2() & kElementsKindMask) >> kElementsKindShift);
3795 } 3809 }
3796 3810
3797 inline bool has_fast_elements() { 3811 inline bool has_fast_elements() {
3798 return ((1 << kHasFastElements) & bit_field2()) != 0; 3812 return elements_kind() == JSObject::FAST_ELEMENTS;
3799 }
3800
3801 // Tells whether an instance has pixel array elements.
3802 inline void set_has_external_array_elements(bool value) {
3803 if (value) {
3804 set_bit_field2(bit_field2() | (1 << kHasExternalArrayElements));
3805 } else {
3806 set_bit_field2(bit_field2() & ~(1 << kHasExternalArrayElements));
3807 }
3808 } 3813 }
3809 3814
3810 inline bool has_external_array_elements() { 3815 inline bool has_external_array_elements() {
3811 return ((1 << kHasExternalArrayElements) & bit_field2()) != 0; 3816 JSObject::ElementsKind kind(elements_kind());
3817 return kind >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND &&
3818 kind <= JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND;
3812 } 3819 }
3813 3820
3814 // Tells whether the map is attached to SharedFunctionInfo 3821 // Tells whether the map is attached to SharedFunctionInfo
3815 // (for inobject slack tracking). 3822 // (for inobject slack tracking).
3816 inline void set_attached_to_shared_function_info(bool value); 3823 inline void set_attached_to_shared_function_info(bool value);
3817 3824
3818 inline bool attached_to_shared_function_info(); 3825 inline bool attached_to_shared_function_info();
3819 3826
3820 // Tells whether the map is shared between objects that may have different 3827 // Tells whether the map is shared between objects that may have different
3821 // behavior. If true, the map should never be modified, instead a clone 3828 // behavior. If true, the map should never be modified, instead a clone
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3854 // [prototype transitions]: cache of prototype transitions. 3861 // [prototype transitions]: cache of prototype transitions.
3855 // Prototype transition is a transition that happens 3862 // Prototype transition is a transition that happens
3856 // when we change object's prototype to a new one. 3863 // when we change object's prototype to a new one.
3857 // Cache format: 3864 // Cache format:
3858 // 0: finger - index of the first free cell in the cache 3865 // 0: finger - index of the first free cell in the cache
3859 // 1 + 2 * i: prototype 3866 // 1 + 2 * i: prototype
3860 // 2 + 2 * i: target map 3867 // 2 + 2 * i: target map
3861 DECL_ACCESSORS(prototype_transitions, FixedArray) 3868 DECL_ACCESSORS(prototype_transitions, FixedArray)
3862 inline FixedArray* unchecked_prototype_transitions(); 3869 inline FixedArray* unchecked_prototype_transitions();
3863 3870
3871 static const int kProtoTransitionHeaderSize = 1;
3872 static const int kProtoTransitionNumberOfEntriesOffset = 0;
3873 static const int kProtoTransitionElementsPerEntry = 2;
3874 static const int kProtoTransitionPrototypeOffset = 0;
3875 static const int kProtoTransitionMapOffset = 1;
3876
3877 inline int NumberOfProtoTransitions() {
3878 FixedArray* cache = unchecked_prototype_transitions();
3879 if (cache->length() == 0) return 0;
3880 return
3881 Smi::cast(cache->get(kProtoTransitionNumberOfEntriesOffset))->value();
3882 }
3883
3884 inline void SetNumberOfProtoTransitions(int value) {
3885 FixedArray* cache = unchecked_prototype_transitions();
3886 ASSERT(cache->length() != 0);
3887 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset,
3888 Smi::FromInt(value));
3889 }
3890
3864 // Lookup in the map's instance descriptors and fill out the result 3891 // Lookup in the map's instance descriptors and fill out the result
3865 // with the given holder if the name is found. The holder may be 3892 // with the given holder if the name is found. The holder may be
3866 // NULL when this function is used from the compiler. 3893 // NULL when this function is used from the compiler.
3867 void LookupInDescriptors(JSObject* holder, 3894 void LookupInDescriptors(JSObject* holder,
3868 String* name, 3895 String* name,
3869 LookupResult* result); 3896 LookupResult* result);
3870 3897
3871 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 3898 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
3872 3899
3873 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, 3900 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
4022 static const int kIsHiddenPrototype = 2; 4049 static const int kIsHiddenPrototype = 2;
4023 static const int kHasNamedInterceptor = 3; 4050 static const int kHasNamedInterceptor = 3;
4024 static const int kHasIndexedInterceptor = 4; 4051 static const int kHasIndexedInterceptor = 4;
4025 static const int kIsUndetectable = 5; 4052 static const int kIsUndetectable = 5;
4026 static const int kHasInstanceCallHandler = 6; 4053 static const int kHasInstanceCallHandler = 6;
4027 static const int kIsAccessCheckNeeded = 7; 4054 static const int kIsAccessCheckNeeded = 7;
4028 4055
4029 // Bit positions for bit field 2 4056 // Bit positions for bit field 2
4030 static const int kIsExtensible = 0; 4057 static const int kIsExtensible = 0;
4031 static const int kFunctionWithPrototype = 1; 4058 static const int kFunctionWithPrototype = 1;
4032 static const int kHasFastElements = 2; 4059 static const int kStringWrapperSafeForDefaultValueOf = 2;
4033 static const int kStringWrapperSafeForDefaultValueOf = 3; 4060 static const int kAttachedToSharedFunctionInfo = 3;
4034 static const int kAttachedToSharedFunctionInfo = 4; 4061 // No bits can be used after kElementsKindFirstBit, they are all reserved for
4035 static const int kHasExternalArrayElements = 5; 4062 // storing ElementKind. for anything other than storing the ElementKind.
4063 static const int kElementsKindShift = 4;
4064 static const int kElementsKindBitCount = 4;
4065
4066 // Derived values from bit field 2
4067 static const int kElementsKindMask = (-1 << kElementsKindShift) &
4068 ((1 << (kElementsKindShift + kElementsKindBitCount)) - 1);
4069 static const int8_t kMaximumBitField2FastElementValue = static_cast<int8_t>(
4070 (JSObject::FAST_ELEMENTS + 1) << Map::kElementsKindShift) - 1;
4036 4071
4037 // Bit positions for bit field 3 4072 // Bit positions for bit field 3
4038 static const int kIsShared = 1; 4073 static const int kIsShared = 0;
4039 4074
4040 // Layout of the default cache. It holds alternating name and code objects. 4075 // Layout of the default cache. It holds alternating name and code objects.
4041 static const int kCodeCacheEntrySize = 2; 4076 static const int kCodeCacheEntrySize = 2;
4042 static const int kCodeCacheEntryNameOffset = 0; 4077 static const int kCodeCacheEntryNameOffset = 0;
4043 static const int kCodeCacheEntryCodeOffset = 1; 4078 static const int kCodeCacheEntryCodeOffset = 1;
4044 4079
4045 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, 4080 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
4046 kPointerFieldsEndOffset, 4081 kPointerFieldsEndOffset,
4047 kSize> BodyDescriptor; 4082 kSize> BodyDescriptor;
4048 4083
(...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after
6893 } else { 6928 } else {
6894 value &= ~(1 << bit_position); 6929 value &= ~(1 << bit_position);
6895 } 6930 }
6896 return value; 6931 return value;
6897 } 6932 }
6898 }; 6933 };
6899 6934
6900 } } // namespace v8::internal 6935 } } // namespace v8::internal
6901 6936
6902 #endif // V8_OBJECTS_H_ 6937 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698