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

Side by Side Diff: src/objects.h

Issue 1276533003: [runtime] Store constructor function index on primitive maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm failures Created 5 years, 4 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
« no previous file with comments | « src/mips64/builtins-mips64.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 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 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 kStringRepresentationMask; 605 kStringRepresentationMask;
606 const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag; 606 const uint32_t kShortcutTypeTag = kConsStringTag | kNotInternalizedTag;
607 607
608 static inline bool IsShortcutCandidate(int type) { 608 static inline bool IsShortcutCandidate(int type) {
609 return ((type & kShortcutTypeMask) == kShortcutTypeTag); 609 return ((type & kShortcutTypeMask) == kShortcutTypeTag);
610 } 610 }
611 611
612 612
613 enum InstanceType { 613 enum InstanceType {
614 // String types. 614 // String types.
615 INTERNALIZED_STRING_TYPE = 615 INTERNALIZED_STRING_TYPE = kTwoByteStringTag | kSeqStringTag |
616 kTwoByteStringTag | kSeqStringTag | kInternalizedTag, 616 kInternalizedTag, // FIRST_PRIMITIVE_TYPE
617 ONE_BYTE_INTERNALIZED_STRING_TYPE = 617 ONE_BYTE_INTERNALIZED_STRING_TYPE =
618 kOneByteStringTag | kSeqStringTag | kInternalizedTag, 618 kOneByteStringTag | kSeqStringTag | kInternalizedTag,
619 EXTERNAL_INTERNALIZED_STRING_TYPE = 619 EXTERNAL_INTERNALIZED_STRING_TYPE =
620 kTwoByteStringTag | kExternalStringTag | kInternalizedTag, 620 kTwoByteStringTag | kExternalStringTag | kInternalizedTag,
621 EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE = 621 EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE =
622 kOneByteStringTag | kExternalStringTag | kInternalizedTag, 622 kOneByteStringTag | kExternalStringTag | kInternalizedTag,
623 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = 623 EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE =
624 EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag | 624 EXTERNAL_INTERNALIZED_STRING_TYPE | kOneByteDataHintTag |
625 kInternalizedTag, 625 kInternalizedTag,
626 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = EXTERNAL_INTERNALIZED_STRING_TYPE | 626 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE = EXTERNAL_INTERNALIZED_STRING_TYPE |
(...skipping 26 matching lines...) Expand all
653 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, 653 SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
654 SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE = 654 SHORT_EXTERNAL_ONE_BYTE_STRING_TYPE =
655 SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag, 655 SHORT_EXTERNAL_ONE_BYTE_INTERNALIZED_STRING_TYPE | kNotInternalizedTag,
656 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE = 656 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE =
657 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE | 657 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE |
658 kNotInternalizedTag, 658 kNotInternalizedTag,
659 659
660 // Non-string names 660 // Non-string names
661 SYMBOL_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE, LAST_NAME_TYPE 661 SYMBOL_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE, LAST_NAME_TYPE
662 662
663 // Other primitives (cannot contain non-map-word pointers to heap objects).
664 HEAP_NUMBER_TYPE,
665 SIMD128_VALUE_TYPE,
666 ODDBALL_TYPE, // LAST_PRIMITIVE_TYPE
667
663 // Objects allocated in their own spaces (never in new space). 668 // Objects allocated in their own spaces (never in new space).
664 MAP_TYPE, 669 MAP_TYPE,
665 CODE_TYPE, 670 CODE_TYPE,
666 ODDBALL_TYPE,
667 671
668 // "Data", objects that cannot contain non-map-word pointers to heap 672 // "Data", objects that cannot contain non-map-word pointers to heap
669 // objects. 673 // objects.
670 HEAP_NUMBER_TYPE,
671 MUTABLE_HEAP_NUMBER_TYPE, 674 MUTABLE_HEAP_NUMBER_TYPE,
672 SIMD128_VALUE_TYPE,
673 FOREIGN_TYPE, 675 FOREIGN_TYPE,
674 BYTE_ARRAY_TYPE, 676 BYTE_ARRAY_TYPE,
675 BYTECODE_ARRAY_TYPE, 677 BYTECODE_ARRAY_TYPE,
676 FREE_SPACE_TYPE, 678 FREE_SPACE_TYPE,
677 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE 679 FIXED_INT8_ARRAY_TYPE, // FIRST_FIXED_TYPED_ARRAY_TYPE
678 FIXED_UINT8_ARRAY_TYPE, 680 FIXED_UINT8_ARRAY_TYPE,
679 FIXED_INT16_ARRAY_TYPE, 681 FIXED_INT16_ARRAY_TYPE,
680 FIXED_UINT16_ARRAY_TYPE, 682 FIXED_UINT16_ARRAY_TYPE,
681 FIXED_INT32_ARRAY_TYPE, 683 FIXED_INT32_ARRAY_TYPE,
682 FIXED_UINT32_ARRAY_TYPE, 684 FIXED_UINT32_ARRAY_TYPE,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE 748 JS_FUNCTION_TYPE, // LAST_JS_OBJECT_TYPE, LAST_JS_RECEIVER_TYPE
747 749
748 // Pseudo-types 750 // Pseudo-types
749 FIRST_TYPE = 0x0, 751 FIRST_TYPE = 0x0,
750 LAST_TYPE = JS_FUNCTION_TYPE, 752 LAST_TYPE = JS_FUNCTION_TYPE,
751 FIRST_NAME_TYPE = FIRST_TYPE, 753 FIRST_NAME_TYPE = FIRST_TYPE,
752 LAST_NAME_TYPE = SYMBOL_TYPE, 754 LAST_NAME_TYPE = SYMBOL_TYPE,
753 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE, 755 FIRST_UNIQUE_NAME_TYPE = INTERNALIZED_STRING_TYPE,
754 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE, 756 LAST_UNIQUE_NAME_TYPE = SYMBOL_TYPE,
755 FIRST_NONSTRING_TYPE = SYMBOL_TYPE, 757 FIRST_NONSTRING_TYPE = SYMBOL_TYPE,
758 FIRST_PRIMITIVE_TYPE = FIRST_NAME_TYPE,
759 LAST_PRIMITIVE_TYPE = ODDBALL_TYPE,
756 // Boundaries for testing for a fixed typed array. 760 // Boundaries for testing for a fixed typed array.
757 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE, 761 FIRST_FIXED_TYPED_ARRAY_TYPE = FIXED_INT8_ARRAY_TYPE,
758 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE, 762 LAST_FIXED_TYPED_ARRAY_TYPE = FIXED_UINT8_CLAMPED_ARRAY_TYPE,
759 // Boundary for promotion to old space. 763 // Boundary for promotion to old space.
760 LAST_DATA_TYPE = FILLER_TYPE, 764 LAST_DATA_TYPE = FILLER_TYPE,
761 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy). 765 // Boundary for objects represented as JSReceiver (i.e. JSObject or JSProxy).
762 // Note that there is no range for JSObject or JSProxy, since their subtypes 766 // Note that there is no range for JSObject or JSProxy, since their subtypes
763 // are not continuous in this enum! The enum ranges instead reflect the 767 // are not continuous in this enum! The enum ranges instead reflect the
764 // external class names, where proxies are treated as either ordinary objects, 768 // external class names, where proxies are treated as either ordinary objects,
765 // or functions. 769 // or functions.
(...skipping 4500 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 public: 5270 public:
5267 // Instance size. 5271 // Instance size.
5268 // Size in bytes or kVariableSizeSentinel if instances do not have 5272 // Size in bytes or kVariableSizeSentinel if instances do not have
5269 // a fixed size. 5273 // a fixed size.
5270 inline int instance_size(); 5274 inline int instance_size();
5271 inline void set_instance_size(int value); 5275 inline void set_instance_size(int value);
5272 5276
5273 // Only to clear an unused byte, remove once byte is used. 5277 // Only to clear an unused byte, remove once byte is used.
5274 inline void clear_unused(); 5278 inline void clear_unused();
5275 5279
5276 // Count of properties allocated in the object. 5280 // [inobject_properties_or_constructor_function_index]: Provides access
5277 inline int inobject_properties(); 5281 // to the inobject properties in case of JSObject maps, or the constructor
5278 inline void set_inobject_properties(int value); 5282 // function index in case of primitive maps.
5283 inline int inobject_properties_or_constructor_function_index();
5284 inline void set_inobject_properties_or_constructor_function_index(int value);
5285 // Count of properties allocated in the object (JSObject only).
5286 inline int GetInObjectProperties();
5287 inline void SetInObjectProperties(int value);
5288 // Index of the constructor function in the native context (primitives only),
5289 // or the special sentinel value to indicate that there is no object wrapper
5290 // for the primitive (i.e. in case of null or undefined).
5291 static const int kNoConstructorFunctionIndex = 0;
5292 inline int GetConstructorFunctionIndex();
5293 inline void SetConstructorFunctionIndex(int value);
5279 5294
5280 // Instance type. 5295 // Instance type.
5281 inline InstanceType instance_type(); 5296 inline InstanceType instance_type();
5282 inline void set_instance_type(InstanceType value); 5297 inline void set_instance_type(InstanceType value);
5283 5298
5284 // Tells how many unused property fields are available in the 5299 // Tells how many unused property fields are available in the
5285 // instance (only used for JSObject in fast mode). 5300 // instance (only used for JSObject in fast mode).
5286 inline int unused_property_fields(); 5301 inline int unused_property_fields();
5287 inline void set_unused_property_fields(int value); 5302 inline void set_unused_property_fields(int value);
5288 5303
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
5759 // found at all. 5774 // found at all.
5760 static Handle<Map> FindTransitionedMap(Handle<Map> map, 5775 static Handle<Map> FindTransitionedMap(Handle<Map> map,
5761 MapHandleList* candidates); 5776 MapHandleList* candidates);
5762 5777
5763 bool CanTransition() { 5778 bool CanTransition() {
5764 // Only JSObject and subtypes have map transitions and back pointers. 5779 // Only JSObject and subtypes have map transitions and back pointers.
5765 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); 5780 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
5766 return instance_type() >= FIRST_JS_OBJECT_TYPE; 5781 return instance_type() >= FIRST_JS_OBJECT_TYPE;
5767 } 5782 }
5768 5783
5784 bool IsPrimitiveMap() {
5785 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE);
5786 return instance_type() <= LAST_PRIMITIVE_TYPE;
5787 }
5769 bool IsJSObjectMap() { 5788 bool IsJSObjectMap() {
5789 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE);
5770 return instance_type() >= FIRST_JS_OBJECT_TYPE; 5790 return instance_type() >= FIRST_JS_OBJECT_TYPE;
5771 } 5791 }
5772 bool IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; } 5792 bool IsJSArrayMap() { return instance_type() == JS_ARRAY_TYPE; }
5773 bool IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; } 5793 bool IsStringMap() { return instance_type() < FIRST_NONSTRING_TYPE; }
5774 bool IsJSProxyMap() { 5794 bool IsJSProxyMap() {
5775 InstanceType type = instance_type(); 5795 InstanceType type = instance_type();
5776 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE; 5796 return FIRST_JS_PROXY_TYPE <= type && type <= LAST_JS_PROXY_TYPE;
5777 } 5797 }
5778 bool IsJSGlobalProxyMap() { 5798 bool IsJSGlobalProxyMap() {
5779 return instance_type() == JS_GLOBAL_PROXY_TYPE; 5799 return instance_type() == JS_GLOBAL_PROXY_TYPE;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
5840 static const int kWeakCellCacheOffset = kDependentCodeOffset + kPointerSize; 5860 static const int kWeakCellCacheOffset = kDependentCodeOffset + kPointerSize;
5841 static const int kSize = kWeakCellCacheOffset + kPointerSize; 5861 static const int kSize = kWeakCellCacheOffset + kPointerSize;
5842 5862
5843 // Layout of pointer fields. Heap iteration code relies on them 5863 // Layout of pointer fields. Heap iteration code relies on them
5844 // being continuously allocated. 5864 // being continuously allocated.
5845 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; 5865 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset;
5846 static const int kPointerFieldsEndOffset = kSize; 5866 static const int kPointerFieldsEndOffset = kSize;
5847 5867
5848 // Byte offsets within kInstanceSizesOffset. 5868 // Byte offsets within kInstanceSizesOffset.
5849 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 5869 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
5850 static const int kInObjectPropertiesByte = 1; 5870 static const int kInObjectPropertiesOrConstructorFunctionIndexByte = 1;
5851 static const int kInObjectPropertiesOffset = 5871 static const int kInObjectPropertiesOrConstructorFunctionIndexOffset =
5852 kInstanceSizesOffset + kInObjectPropertiesByte; 5872 kInstanceSizesOffset + kInObjectPropertiesOrConstructorFunctionIndexByte;
5853 // Note there is one byte available for use here. 5873 // Note there is one byte available for use here.
5854 static const int kUnusedByte = 2; 5874 static const int kUnusedByte = 2;
5855 static const int kUnusedOffset = kInstanceSizesOffset + kUnusedByte; 5875 static const int kUnusedOffset = kInstanceSizesOffset + kUnusedByte;
5856 static const int kVisitorIdByte = 3; 5876 static const int kVisitorIdByte = 3;
5857 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte; 5877 static const int kVisitorIdOffset = kInstanceSizesOffset + kVisitorIdByte;
5858 5878
5859 // Byte offsets within kInstanceAttributesOffset attributes. 5879 // Byte offsets within kInstanceAttributesOffset attributes.
5860 #if V8_TARGET_LITTLE_ENDIAN 5880 #if V8_TARGET_LITTLE_ENDIAN
5861 // Order instance type and bit field together such that they can be loaded 5881 // Order instance type and bit field together such that they can be loaded
5862 // together as a 16-bit word with instance type in the lower 8 bits regardless 5882 // together as a 16-bit word with instance type in the lower 8 bits regardless
(...skipping 4686 matching lines...) Expand 10 before | Expand all | Expand 10 after
10549 } else { 10569 } else {
10550 value &= ~(1 << bit_position); 10570 value &= ~(1 << bit_position);
10551 } 10571 }
10552 return value; 10572 return value;
10553 } 10573 }
10554 }; 10574 };
10555 10575
10556 } } // namespace v8::internal 10576 } } // namespace v8::internal
10557 10577
10558 #endif // V8_OBJECTS_H_ 10578 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/builtins-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698