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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 V(FreeSpace) \ | 847 V(FreeSpace) \ |
848 V(JSReceiver) \ | 848 V(JSReceiver) \ |
849 V(JSObject) \ | 849 V(JSObject) \ |
850 V(JSContextExtensionObject) \ | 850 V(JSContextExtensionObject) \ |
851 V(JSModule) \ | 851 V(JSModule) \ |
852 V(Map) \ | 852 V(Map) \ |
853 V(DescriptorArray) \ | 853 V(DescriptorArray) \ |
854 V(TransitionArray) \ | 854 V(TransitionArray) \ |
855 V(DeoptimizationInputData) \ | 855 V(DeoptimizationInputData) \ |
856 V(DeoptimizationOutputData) \ | 856 V(DeoptimizationOutputData) \ |
857 V(DependentCodes) \ | |
857 V(TypeFeedbackCells) \ | 858 V(TypeFeedbackCells) \ |
858 V(FixedArray) \ | 859 V(FixedArray) \ |
859 V(FixedDoubleArray) \ | 860 V(FixedDoubleArray) \ |
860 V(Context) \ | 861 V(Context) \ |
861 V(NativeContext) \ | 862 V(NativeContext) \ |
862 V(ScopeInfo) \ | 863 V(ScopeInfo) \ |
863 V(JSFunction) \ | 864 V(JSFunction) \ |
864 V(Code) \ | 865 V(Code) \ |
865 V(Oddball) \ | 866 V(Oddball) \ |
866 V(SharedFunctionInfo) \ | 867 V(SharedFunctionInfo) \ |
(...skipping 3565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4432 | 4433 |
4433 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. | 4434 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. |
4434 inline byte to_boolean_state(); | 4435 inline byte to_boolean_state(); |
4435 inline void set_to_boolean_state(byte value); | 4436 inline void set_to_boolean_state(byte value); |
4436 | 4437 |
4437 // [has_function_cache]: For kind STUB tells whether there is a function | 4438 // [has_function_cache]: For kind STUB tells whether there is a function |
4438 // cache is passed to the stub. | 4439 // cache is passed to the stub. |
4439 inline bool has_function_cache(); | 4440 inline bool has_function_cache(); |
4440 inline void set_has_function_cache(bool flag); | 4441 inline void set_has_function_cache(bool flag); |
4441 | 4442 |
4443 | |
4444 // [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether | |
4445 // the code is going to be deoptimized because of dead embedded maps. | |
4446 inline bool marked_for_deoptimization(); | |
4447 inline void set_marked_for_deoptimization(bool flag); | |
4448 | |
4442 bool allowed_in_shared_map_code_cache(); | 4449 bool allowed_in_shared_map_code_cache(); |
4443 | 4450 |
4444 // Get the safepoint entry for the given pc. | 4451 // Get the safepoint entry for the given pc. |
4445 SafepointEntry GetSafepointEntry(Address pc); | 4452 SafepointEntry GetSafepointEntry(Address pc); |
4446 | 4453 |
4447 // Mark this code object as not having a stack check table. Assumes kind | 4454 // Mark this code object as not having a stack check table. Assumes kind |
4448 // is FUNCTION. | 4455 // is FUNCTION. |
4449 void SetNoStackCheckTable(); | 4456 void SetNoStackCheckTable(); |
4450 | 4457 |
4451 // Find the first map in an IC stub. | 4458 // Find the first map in an IC stub. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4548 int SourcePosition(Address pc); | 4555 int SourcePosition(Address pc); |
4549 int SourceStatementPosition(Address pc); | 4556 int SourceStatementPosition(Address pc); |
4550 | 4557 |
4551 // Casting. | 4558 // Casting. |
4552 static inline Code* cast(Object* obj); | 4559 static inline Code* cast(Object* obj); |
4553 | 4560 |
4554 // Dispatched behavior. | 4561 // Dispatched behavior. |
4555 int CodeSize() { return SizeFor(body_size()); } | 4562 int CodeSize() { return SizeFor(body_size()); } |
4556 inline void CodeIterateBody(ObjectVisitor* v); | 4563 inline void CodeIterateBody(ObjectVisitor* v); |
4557 | 4564 |
4558 template<typename StaticVisitor> | 4565 enum EmbeddedMapVisitMode { VISIT_EMBEDDED_MAPS, SKIP_EMBEDDED_MAPS }; |
4566 | |
4567 template<typename StaticVisitor, EmbeddedMapVisitMode map_visit_mode> | |
4559 inline void CodeIterateBody(Heap* heap); | 4568 inline void CodeIterateBody(Heap* heap); |
4560 #ifdef OBJECT_PRINT | 4569 #ifdef OBJECT_PRINT |
4561 inline void CodePrint() { | 4570 inline void CodePrint() { |
4562 CodePrint(stdout); | 4571 CodePrint(stdout); |
4563 } | 4572 } |
4564 void CodePrint(FILE* out); | 4573 void CodePrint(FILE* out); |
4565 #endif | 4574 #endif |
4566 DECLARE_VERIFIER(Code) | 4575 DECLARE_VERIFIER(Code) |
4567 | 4576 |
4568 void ClearInlineCaches(); | 4577 void ClearInlineCaches(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4639 static const int kStackSlotsBitCount = 24; | 4648 static const int kStackSlotsBitCount = 24; |
4640 static const int kUnaryOpTypeFirstBit = | 4649 static const int kUnaryOpTypeFirstBit = |
4641 kStackSlotsFirstBit + kStackSlotsBitCount; | 4650 kStackSlotsFirstBit + kStackSlotsBitCount; |
4642 static const int kUnaryOpTypeBitCount = 3; | 4651 static const int kUnaryOpTypeBitCount = 3; |
4643 static const int kToBooleanStateFirstBit = | 4652 static const int kToBooleanStateFirstBit = |
4644 kStackSlotsFirstBit + kStackSlotsBitCount; | 4653 kStackSlotsFirstBit + kStackSlotsBitCount; |
4645 static const int kToBooleanStateBitCount = 8; | 4654 static const int kToBooleanStateBitCount = 8; |
4646 static const int kHasFunctionCacheFirstBit = | 4655 static const int kHasFunctionCacheFirstBit = |
4647 kStackSlotsFirstBit + kStackSlotsBitCount; | 4656 kStackSlotsFirstBit + kStackSlotsBitCount; |
4648 static const int kHasFunctionCacheBitCount = 1; | 4657 static const int kHasFunctionCacheBitCount = 1; |
4658 static const int kMarkedForDeoptimizationFirstBit = | |
4659 kStackSlotsFirstBit + kStackSlotsBitCount + 1; | |
4660 static const int kMarkedForDeoptimizationBitCount = 1; | |
4649 | 4661 |
4650 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); | 4662 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); |
4651 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); | 4663 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); |
4652 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); | 4664 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); |
4653 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); | 4665 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); |
4666 STATIC_ASSERT(kMarkedForDeoptimizationBitCount + | |
4667 kMarkedForDeoptimizationBitCount <= 32); | |
4654 | 4668 |
4655 class StackSlotsField: public BitField<int, | 4669 class StackSlotsField: public BitField<int, |
4656 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT | 4670 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT |
4657 class UnaryOpTypeField: public BitField<int, | 4671 class UnaryOpTypeField: public BitField<int, |
4658 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT | 4672 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT |
4659 class ToBooleanStateField: public BitField<int, | 4673 class ToBooleanStateField: public BitField<int, |
4660 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT | 4674 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT |
4661 class HasFunctionCacheField: public BitField<bool, | 4675 class HasFunctionCacheField: public BitField<bool, |
4662 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT | 4676 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT |
4677 class MarkedForDeoptimizationField: public BitField<bool, | |
4678 kMarkedForDeoptimizationFirstBit, | |
4679 kMarkedForDeoptimizationBitCount> {}; // NOLINT | |
4663 | 4680 |
4664 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) | 4681 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) |
4665 static const int kStubMajorKeyFirstBit = 0; | 4682 static const int kStubMajorKeyFirstBit = 0; |
4666 static const int kSafepointTableOffsetFirstBit = | 4683 static const int kSafepointTableOffsetFirstBit = |
4667 kStubMajorKeyFirstBit + kStubMajorKeyBits; | 4684 kStubMajorKeyFirstBit + kStubMajorKeyBits; |
4668 static const int kSafepointTableOffsetBitCount = 26; | 4685 static const int kSafepointTableOffsetBitCount = 26; |
4669 | 4686 |
4670 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); | 4687 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); |
4671 STATIC_ASSERT(kSafepointTableOffsetFirstBit + | 4688 STATIC_ASSERT(kSafepointTableOffsetFirstBit + |
4672 kSafepointTableOffsetBitCount <= 32); | 4689 kSafepointTableOffsetBitCount <= 32); |
(...skipping 27 matching lines...) Expand all Loading... | |
4700 static Code* GetCodeAgeStub(Age age, MarkingParity parity); | 4717 static Code* GetCodeAgeStub(Age age, MarkingParity parity); |
4701 | 4718 |
4702 // Code aging -- platform-specific | 4719 // Code aging -- platform-specific |
4703 static void PatchPlatformCodeAge(byte* sequence, Age age, | 4720 static void PatchPlatformCodeAge(byte* sequence, Age age, |
4704 MarkingParity parity); | 4721 MarkingParity parity); |
4705 | 4722 |
4706 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4723 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
4707 }; | 4724 }; |
4708 | 4725 |
4709 | 4726 |
4727 // This class describes the layout of dependent codes array of a map. The | |
4728 // first element contains the number of codes as a Smi. The subsequent | |
4729 // elements contain code objects. The suffix of the array can be filled with | |
4730 // Smi(0) if the number of codes is less than the length of the array. | |
4731 class DependentCodes: public FixedArray { | |
4732 public: | |
4733 inline int number_of_codes(); | |
4734 inline void set_number_of_codes(int value); | |
4735 inline Code* code_at(int i); | |
4736 inline void set_code_at(int i, Code* value); | |
4737 inline Object** code_slot_at(int i); | |
4738 inline void clear_code_at(int i); | |
4739 static Handle<DependentCodes> Append(Handle<DependentCodes> codes, | |
4740 Handle<Code> value); | |
4741 static inline DependentCodes* cast(Object* object); | |
4742 private: | |
4743 static const int kNumberOfCodesOffset = 0; | |
Michael Starzinger
2013/01/21 10:31:48
This should actually be called kNumberOfCodesIndex
ulan
2013/01/21 13:11:57
Done.
| |
4744 static const int kCodesOffset = 1; | |
Michael Starzinger
2013/01/21 10:31:48
Likewise.
ulan
2013/01/21 13:11:57
Done.
| |
4745 }; | |
4746 | |
4747 | |
4710 // All heap objects have a Map that describes their structure. | 4748 // All heap objects have a Map that describes their structure. |
4711 // A Map contains information about: | 4749 // A Map contains information about: |
4712 // - Size information about the object | 4750 // - Size information about the object |
4713 // - How to iterate over an object (for garbage collection) | 4751 // - How to iterate over an object (for garbage collection) |
4714 class Map: public HeapObject { | 4752 class Map: public HeapObject { |
4715 public: | 4753 public: |
4716 // Instance size. | 4754 // Instance size. |
4717 // Size in bytes or kVariableSizeSentinel if instances do not have | 4755 // Size in bytes or kVariableSizeSentinel if instances do not have |
4718 // a fixed size. | 4756 // a fixed size. |
4719 inline int instance_size(); | 4757 inline int instance_size(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4921 | 4959 |
4922 inline JSFunction* unchecked_constructor(); | 4960 inline JSFunction* unchecked_constructor(); |
4923 | 4961 |
4924 // [instance descriptors]: describes the object. | 4962 // [instance descriptors]: describes the object. |
4925 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4963 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
4926 inline void InitializeDescriptors(DescriptorArray* descriptors); | 4964 inline void InitializeDescriptors(DescriptorArray* descriptors); |
4927 | 4965 |
4928 // [stub cache]: contains stubs compiled for this map. | 4966 // [stub cache]: contains stubs compiled for this map. |
4929 DECL_ACCESSORS(code_cache, Object) | 4967 DECL_ACCESSORS(code_cache, Object) |
4930 | 4968 |
4969 // [dependent codes]: list of optimized codes that have this map embedded. | |
4970 DECL_ACCESSORS(dependent_codes, DependentCodes) | |
4971 | |
4931 // [back pointer]: points back to the parent map from which a transition | 4972 // [back pointer]: points back to the parent map from which a transition |
4932 // leads to this map. The field overlaps with prototype transitions and the | 4973 // leads to this map. The field overlaps with prototype transitions and the |
4933 // back pointer will be moved into the prototype transitions array if | 4974 // back pointer will be moved into the prototype transitions array if |
4934 // required. | 4975 // required. |
4935 inline Object* GetBackPointer(); | 4976 inline Object* GetBackPointer(); |
4936 inline void SetBackPointer(Object* value, | 4977 inline void SetBackPointer(Object* value, |
4937 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4978 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
4938 inline void init_back_pointer(Object* undefined); | 4979 inline void init_back_pointer(Object* undefined); |
4939 | 4980 |
4940 // [prototype transitions]: cache of prototype transitions. | 4981 // [prototype transitions]: cache of prototype transitions. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5130 | 5171 |
5131 // Zaps the contents of backing data structures. Note that the | 5172 // Zaps the contents of backing data structures. Note that the |
5132 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects | 5173 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects |
5133 // holding weak references when incremental marking is used, because it also | 5174 // holding weak references when incremental marking is used, because it also |
5134 // iterates over objects that are otherwise unreachable. | 5175 // iterates over objects that are otherwise unreachable. |
5135 // In general we only want to call these functions in release mode when | 5176 // In general we only want to call these functions in release mode when |
5136 // heap verification is turned on. | 5177 // heap verification is turned on. |
5137 void ZapPrototypeTransitions(); | 5178 void ZapPrototypeTransitions(); |
5138 void ZapTransitions(); | 5179 void ZapTransitions(); |
5139 | 5180 |
5181 bool CanTransition() { | |
Michael Starzinger
2013/01/21 10:31:48
I like this!
| |
5182 // Only JSObject and subtypes have map transitions and back pointers. | |
5183 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | |
5184 return instance_type() >= FIRST_JS_OBJECT_TYPE; | |
5185 } | |
5186 | |
5187 inline void AddDependentCode(Handle<Code> code); | |
5188 | |
5140 // Dispatched behavior. | 5189 // Dispatched behavior. |
5141 #ifdef OBJECT_PRINT | 5190 #ifdef OBJECT_PRINT |
5142 inline void MapPrint() { | 5191 inline void MapPrint() { |
5143 MapPrint(stdout); | 5192 MapPrint(stdout); |
5144 } | 5193 } |
5145 void MapPrint(FILE* out); | 5194 void MapPrint(FILE* out); |
5146 #endif | 5195 #endif |
5147 DECLARE_VERIFIER(Map) | 5196 DECLARE_VERIFIER(Map) |
5148 | 5197 |
5149 #ifdef VERIFY_HEAP | 5198 #ifdef VERIFY_HEAP |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5183 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 5232 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
5184 // Storage for the transition array is overloaded to directly contain a back | 5233 // Storage for the transition array is overloaded to directly contain a back |
5185 // pointer if unused. When the map has transitions, the back pointer is | 5234 // pointer if unused. When the map has transitions, the back pointer is |
5186 // transferred to the transition array and accessed through an extra | 5235 // transferred to the transition array and accessed through an extra |
5187 // indirection. | 5236 // indirection. |
5188 static const int kTransitionsOrBackPointerOffset = | 5237 static const int kTransitionsOrBackPointerOffset = |
5189 kConstructorOffset + kPointerSize; | 5238 kConstructorOffset + kPointerSize; |
5190 static const int kDescriptorsOffset = | 5239 static const int kDescriptorsOffset = |
5191 kTransitionsOrBackPointerOffset + kPointerSize; | 5240 kTransitionsOrBackPointerOffset + kPointerSize; |
5192 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; | 5241 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
5193 static const int kBitField3Offset = kCodeCacheOffset + kPointerSize; | 5242 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; |
5243 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; | |
5194 static const int kSize = kBitField3Offset + kPointerSize; | 5244 static const int kSize = kBitField3Offset + kPointerSize; |
5195 | 5245 |
5196 // Layout of pointer fields. Heap iteration code relies on them | 5246 // Layout of pointer fields. Heap iteration code relies on them |
5197 // being continuously allocated. | 5247 // being continuously allocated. |
5198 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5248 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
5199 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; | 5249 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
5200 | 5250 |
5201 // Byte offsets within kInstanceSizesOffset. | 5251 // Byte offsets within kInstanceSizesOffset. |
5202 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5252 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
5203 static const int kInObjectPropertiesByte = 1; | 5253 static const int kInObjectPropertiesByte = 1; |
(...skipping 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9099 } else { | 9149 } else { |
9100 value &= ~(1 << bit_position); | 9150 value &= ~(1 << bit_position); |
9101 } | 9151 } |
9102 return value; | 9152 return value; |
9103 } | 9153 } |
9104 }; | 9154 }; |
9105 | 9155 |
9106 } } // namespace v8::internal | 9156 } } // namespace v8::internal |
9107 | 9157 |
9108 #endif // V8_OBJECTS_H_ | 9158 #endif // V8_OBJECTS_H_ |
OLD | NEW |