OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 844 matching lines...) Loading... |
855 V(FreeSpace) \ | 855 V(FreeSpace) \ |
856 V(JSReceiver) \ | 856 V(JSReceiver) \ |
857 V(JSObject) \ | 857 V(JSObject) \ |
858 V(JSContextExtensionObject) \ | 858 V(JSContextExtensionObject) \ |
859 V(JSModule) \ | 859 V(JSModule) \ |
860 V(Map) \ | 860 V(Map) \ |
861 V(DescriptorArray) \ | 861 V(DescriptorArray) \ |
862 V(TransitionArray) \ | 862 V(TransitionArray) \ |
863 V(DeoptimizationInputData) \ | 863 V(DeoptimizationInputData) \ |
864 V(DeoptimizationOutputData) \ | 864 V(DeoptimizationOutputData) \ |
| 865 V(DependentCodes) \ |
865 V(TypeFeedbackCells) \ | 866 V(TypeFeedbackCells) \ |
866 V(FixedArray) \ | 867 V(FixedArray) \ |
867 V(FixedDoubleArray) \ | 868 V(FixedDoubleArray) \ |
868 V(Context) \ | 869 V(Context) \ |
869 V(NativeContext) \ | 870 V(NativeContext) \ |
870 V(ScopeInfo) \ | 871 V(ScopeInfo) \ |
871 V(JSFunction) \ | 872 V(JSFunction) \ |
872 V(Code) \ | 873 V(Code) \ |
873 V(Oddball) \ | 874 V(Oddball) \ |
874 V(SharedFunctionInfo) \ | 875 V(SharedFunctionInfo) \ |
(...skipping 3513 matching lines...) Loading... |
4388 | 4389 |
4389 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. | 4390 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. |
4390 inline byte to_boolean_state(); | 4391 inline byte to_boolean_state(); |
4391 inline void set_to_boolean_state(byte value); | 4392 inline void set_to_boolean_state(byte value); |
4392 | 4393 |
4393 // [has_function_cache]: For kind STUB tells whether there is a function | 4394 // [has_function_cache]: For kind STUB tells whether there is a function |
4394 // cache is passed to the stub. | 4395 // cache is passed to the stub. |
4395 inline bool has_function_cache(); | 4396 inline bool has_function_cache(); |
4396 inline void set_has_function_cache(bool flag); | 4397 inline void set_has_function_cache(bool flag); |
4397 | 4398 |
| 4399 |
| 4400 // [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether |
| 4401 // the code is going to be deoptimized because of dead embedded maps. |
| 4402 inline bool marked_for_deoptimization(); |
| 4403 inline void set_marked_for_deoptimization(bool flag); |
| 4404 |
4398 bool allowed_in_shared_map_code_cache(); | 4405 bool allowed_in_shared_map_code_cache(); |
4399 | 4406 |
4400 // Get the safepoint entry for the given pc. | 4407 // Get the safepoint entry for the given pc. |
4401 SafepointEntry GetSafepointEntry(Address pc); | 4408 SafepointEntry GetSafepointEntry(Address pc); |
4402 | 4409 |
4403 // Mark this code object as not having a stack check table. Assumes kind | 4410 // Mark this code object as not having a stack check table. Assumes kind |
4404 // is FUNCTION. | 4411 // is FUNCTION. |
4405 void SetNoStackCheckTable(); | 4412 void SetNoStackCheckTable(); |
4406 | 4413 |
4407 // Find the first map in an IC stub. | 4414 // Find the first map in an IC stub. |
(...skipping 185 matching lines...) Loading... |
4593 static const int kStackSlotsBitCount = 24; | 4600 static const int kStackSlotsBitCount = 24; |
4594 static const int kUnaryOpTypeFirstBit = | 4601 static const int kUnaryOpTypeFirstBit = |
4595 kStackSlotsFirstBit + kStackSlotsBitCount; | 4602 kStackSlotsFirstBit + kStackSlotsBitCount; |
4596 static const int kUnaryOpTypeBitCount = 3; | 4603 static const int kUnaryOpTypeBitCount = 3; |
4597 static const int kToBooleanStateFirstBit = | 4604 static const int kToBooleanStateFirstBit = |
4598 kStackSlotsFirstBit + kStackSlotsBitCount; | 4605 kStackSlotsFirstBit + kStackSlotsBitCount; |
4599 static const int kToBooleanStateBitCount = 8; | 4606 static const int kToBooleanStateBitCount = 8; |
4600 static const int kHasFunctionCacheFirstBit = | 4607 static const int kHasFunctionCacheFirstBit = |
4601 kStackSlotsFirstBit + kStackSlotsBitCount; | 4608 kStackSlotsFirstBit + kStackSlotsBitCount; |
4602 static const int kHasFunctionCacheBitCount = 1; | 4609 static const int kHasFunctionCacheBitCount = 1; |
| 4610 static const int kMarkedForDeoptimizationFirstBit = |
| 4611 kStackSlotsFirstBit + kStackSlotsBitCount + 1; |
| 4612 static const int kMarkedForDeoptimizationBitCount = 1; |
4603 | 4613 |
4604 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); | 4614 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); |
4605 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); | 4615 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); |
4606 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); | 4616 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); |
4607 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); | 4617 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); |
| 4618 STATIC_ASSERT(kMarkedForDeoptimizationFirstBit + |
| 4619 kMarkedForDeoptimizationBitCount <= 32); |
4608 | 4620 |
4609 class StackSlotsField: public BitField<int, | 4621 class StackSlotsField: public BitField<int, |
4610 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT | 4622 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT |
4611 class UnaryOpTypeField: public BitField<int, | 4623 class UnaryOpTypeField: public BitField<int, |
4612 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT | 4624 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT |
4613 class ToBooleanStateField: public BitField<int, | 4625 class ToBooleanStateField: public BitField<int, |
4614 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT | 4626 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT |
4615 class HasFunctionCacheField: public BitField<bool, | 4627 class HasFunctionCacheField: public BitField<bool, |
4616 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT | 4628 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT |
| 4629 class MarkedForDeoptimizationField: public BitField<bool, |
| 4630 kMarkedForDeoptimizationFirstBit, |
| 4631 kMarkedForDeoptimizationBitCount> {}; // NOLINT |
4617 | 4632 |
4618 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) | 4633 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) |
4619 static const int kStubMajorKeyFirstBit = 0; | 4634 static const int kStubMajorKeyFirstBit = 0; |
4620 static const int kSafepointTableOffsetFirstBit = | 4635 static const int kSafepointTableOffsetFirstBit = |
4621 kStubMajorKeyFirstBit + kStubMajorKeyBits; | 4636 kStubMajorKeyFirstBit + kStubMajorKeyBits; |
4622 static const int kSafepointTableOffsetBitCount = 26; | 4637 static const int kSafepointTableOffsetBitCount = 26; |
4623 | 4638 |
4624 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); | 4639 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); |
4625 STATIC_ASSERT(kSafepointTableOffsetFirstBit + | 4640 STATIC_ASSERT(kSafepointTableOffsetFirstBit + |
4626 kSafepointTableOffsetBitCount <= 32); | 4641 kSafepointTableOffsetBitCount <= 32); |
(...skipping 27 matching lines...) Loading... |
4654 static Code* GetCodeAgeStub(Age age, MarkingParity parity); | 4669 static Code* GetCodeAgeStub(Age age, MarkingParity parity); |
4655 | 4670 |
4656 // Code aging -- platform-specific | 4671 // Code aging -- platform-specific |
4657 static void PatchPlatformCodeAge(byte* sequence, Age age, | 4672 static void PatchPlatformCodeAge(byte* sequence, Age age, |
4658 MarkingParity parity); | 4673 MarkingParity parity); |
4659 | 4674 |
4660 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4675 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
4661 }; | 4676 }; |
4662 | 4677 |
4663 | 4678 |
| 4679 // This class describes the layout of dependent codes array of a map. The |
| 4680 // first element contains the number of codes as a Smi. The subsequent |
| 4681 // elements contain code objects. The suffix of the array can be filled with the |
| 4682 // undefined value if the number of codes is less than the length of the array. |
| 4683 class DependentCodes: public FixedArray { |
| 4684 public: |
| 4685 inline int number_of_codes(); |
| 4686 inline void set_number_of_codes(int value); |
| 4687 inline Code* code_at(int i); |
| 4688 inline void set_code_at(int i, Code* value); |
| 4689 inline Object** code_slot_at(int i); |
| 4690 inline void clear_code_at(int i); |
| 4691 static Handle<DependentCodes> Append(Handle<DependentCodes> codes, |
| 4692 Handle<Code> value); |
| 4693 static inline DependentCodes* cast(Object* object); |
| 4694 private: |
| 4695 static const int kNumberOfCodesIndex = 0; |
| 4696 static const int kCodesIndex = 1; |
| 4697 }; |
| 4698 |
| 4699 |
4664 // All heap objects have a Map that describes their structure. | 4700 // All heap objects have a Map that describes their structure. |
4665 // A Map contains information about: | 4701 // A Map contains information about: |
4666 // - Size information about the object | 4702 // - Size information about the object |
4667 // - How to iterate over an object (for garbage collection) | 4703 // - How to iterate over an object (for garbage collection) |
4668 class Map: public HeapObject { | 4704 class Map: public HeapObject { |
4669 public: | 4705 public: |
4670 // Instance size. | 4706 // Instance size. |
4671 // Size in bytes or kVariableSizeSentinel if instances do not have | 4707 // Size in bytes or kVariableSizeSentinel if instances do not have |
4672 // a fixed size. | 4708 // a fixed size. |
4673 inline int instance_size(); | 4709 inline int instance_size(); |
(...skipping 209 matching lines...) Loading... |
4883 | 4919 |
4884 inline JSFunction* unchecked_constructor(); | 4920 inline JSFunction* unchecked_constructor(); |
4885 | 4921 |
4886 // [instance descriptors]: describes the object. | 4922 // [instance descriptors]: describes the object. |
4887 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4923 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
4888 inline void InitializeDescriptors(DescriptorArray* descriptors); | 4924 inline void InitializeDescriptors(DescriptorArray* descriptors); |
4889 | 4925 |
4890 // [stub cache]: contains stubs compiled for this map. | 4926 // [stub cache]: contains stubs compiled for this map. |
4891 DECL_ACCESSORS(code_cache, Object) | 4927 DECL_ACCESSORS(code_cache, Object) |
4892 | 4928 |
| 4929 // [dependent codes]: list of optimized codes that have this map embedded. |
| 4930 DECL_ACCESSORS(dependent_codes, DependentCodes) |
| 4931 |
4893 // [back pointer]: points back to the parent map from which a transition | 4932 // [back pointer]: points back to the parent map from which a transition |
4894 // leads to this map. The field overlaps with prototype transitions and the | 4933 // leads to this map. The field overlaps with prototype transitions and the |
4895 // back pointer will be moved into the prototype transitions array if | 4934 // back pointer will be moved into the prototype transitions array if |
4896 // required. | 4935 // required. |
4897 inline Object* GetBackPointer(); | 4936 inline Object* GetBackPointer(); |
4898 inline void SetBackPointer(Object* value, | 4937 inline void SetBackPointer(Object* value, |
4899 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4938 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
4900 inline void init_back_pointer(Object* undefined); | 4939 inline void init_back_pointer(Object* undefined); |
4901 | 4940 |
4902 // [prototype transitions]: cache of prototype transitions. | 4941 // [prototype transitions]: cache of prototype transitions. |
(...skipping 189 matching lines...) Loading... |
5092 | 5131 |
5093 // Zaps the contents of backing data structures. Note that the | 5132 // Zaps the contents of backing data structures. Note that the |
5094 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects | 5133 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects |
5095 // holding weak references when incremental marking is used, because it also | 5134 // holding weak references when incremental marking is used, because it also |
5096 // iterates over objects that are otherwise unreachable. | 5135 // iterates over objects that are otherwise unreachable. |
5097 // In general we only want to call these functions in release mode when | 5136 // In general we only want to call these functions in release mode when |
5098 // heap verification is turned on. | 5137 // heap verification is turned on. |
5099 void ZapPrototypeTransitions(); | 5138 void ZapPrototypeTransitions(); |
5100 void ZapTransitions(); | 5139 void ZapTransitions(); |
5101 | 5140 |
| 5141 bool CanTransition() { |
| 5142 // Only JSObject and subtypes have map transitions and back pointers. |
| 5143 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
| 5144 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
| 5145 } |
| 5146 |
| 5147 inline void AddDependentCode(Handle<Code> code); |
| 5148 |
5102 // Dispatched behavior. | 5149 // Dispatched behavior. |
5103 DECLARE_PRINTER(Map) | 5150 DECLARE_PRINTER(Map) |
5104 DECLARE_VERIFIER(Map) | 5151 DECLARE_VERIFIER(Map) |
5105 | 5152 |
5106 #ifdef VERIFY_HEAP | 5153 #ifdef VERIFY_HEAP |
5107 void SharedMapVerify(); | 5154 void SharedMapVerify(); |
5108 #endif | 5155 #endif |
5109 | 5156 |
5110 inline int visitor_id(); | 5157 inline int visitor_id(); |
5111 inline void set_visitor_id(int visitor_id); | 5158 inline void set_visitor_id(int visitor_id); |
(...skipping 28 matching lines...) Loading... |
5140 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 5187 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
5141 // Storage for the transition array is overloaded to directly contain a back | 5188 // Storage for the transition array is overloaded to directly contain a back |
5142 // pointer if unused. When the map has transitions, the back pointer is | 5189 // pointer if unused. When the map has transitions, the back pointer is |
5143 // transferred to the transition array and accessed through an extra | 5190 // transferred to the transition array and accessed through an extra |
5144 // indirection. | 5191 // indirection. |
5145 static const int kTransitionsOrBackPointerOffset = | 5192 static const int kTransitionsOrBackPointerOffset = |
5146 kConstructorOffset + kPointerSize; | 5193 kConstructorOffset + kPointerSize; |
5147 static const int kDescriptorsOffset = | 5194 static const int kDescriptorsOffset = |
5148 kTransitionsOrBackPointerOffset + kPointerSize; | 5195 kTransitionsOrBackPointerOffset + kPointerSize; |
5149 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; | 5196 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
5150 static const int kBitField3Offset = kCodeCacheOffset + kPointerSize; | 5197 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; |
| 5198 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; |
5151 static const int kSize = kBitField3Offset + kPointerSize; | 5199 static const int kSize = kBitField3Offset + kPointerSize; |
5152 | 5200 |
5153 // Layout of pointer fields. Heap iteration code relies on them | 5201 // Layout of pointer fields. Heap iteration code relies on them |
5154 // being continuously allocated. | 5202 // being continuously allocated. |
5155 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5203 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
5156 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; | 5204 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
5157 | 5205 |
5158 // Byte offsets within kInstanceSizesOffset. | 5206 // Byte offsets within kInstanceSizesOffset. |
5159 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5207 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
5160 static const int kInObjectPropertiesByte = 1; | 5208 static const int kInObjectPropertiesByte = 1; |
(...skipping 3670 matching lines...) Loading... |
8831 } else { | 8879 } else { |
8832 value &= ~(1 << bit_position); | 8880 value &= ~(1 << bit_position); |
8833 } | 8881 } |
8834 return value; | 8882 return value; |
8835 } | 8883 } |
8836 }; | 8884 }; |
8837 | 8885 |
8838 } } // namespace v8::internal | 8886 } } // namespace v8::internal |
8839 | 8887 |
8840 #endif // V8_OBJECTS_H_ | 8888 #endif // V8_OBJECTS_H_ |
OLD | NEW |