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...) Expand 10 before | Expand all | Expand 10 after 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...) Expand 10 before | Expand all | Expand 10 after 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4504 int SourcePosition(Address pc); | 4511 int SourcePosition(Address pc); |
4505 int SourceStatementPosition(Address pc); | 4512 int SourceStatementPosition(Address pc); |
4506 | 4513 |
4507 // Casting. | 4514 // Casting. |
4508 static inline Code* cast(Object* obj); | 4515 static inline Code* cast(Object* obj); |
4509 | 4516 |
4510 // Dispatched behavior. | 4517 // Dispatched behavior. |
4511 int CodeSize() { return SizeFor(body_size()); } | 4518 int CodeSize() { return SizeFor(body_size()); } |
4512 inline void CodeIterateBody(ObjectVisitor* v); | 4519 inline void CodeIterateBody(ObjectVisitor* v); |
4513 | 4520 |
4514 template<typename StaticVisitor> | 4521 enum EmbeddedMapVisitMode { VISIT_EMBEDDED_MAPS, SKIP_EMBEDDED_MAPS }; |
Michael Starzinger
2013/01/21 14:36:44
We should no longer need this enum or the template
ulan
2013/01/21 15:56:02
Done.
| |
4522 | |
4523 template<typename StaticVisitor, EmbeddedMapVisitMode map_visit_mode> | |
4515 inline void CodeIterateBody(Heap* heap); | 4524 inline void CodeIterateBody(Heap* heap); |
4516 | 4525 |
4517 DECLARE_PRINTER(Code) | 4526 DECLARE_PRINTER(Code) |
4518 DECLARE_VERIFIER(Code) | 4527 DECLARE_VERIFIER(Code) |
4519 | 4528 |
4520 void ClearInlineCaches(); | 4529 void ClearInlineCaches(); |
4521 void ClearTypeFeedbackCells(Heap* heap); | 4530 void ClearTypeFeedbackCells(Heap* heap); |
4522 | 4531 |
4523 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, | 4532 #define DECLARE_CODE_AGE_ENUM(X) k##X##CodeAge, |
4524 enum Age { | 4533 enum Age { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4593 static const int kStackSlotsBitCount = 24; | 4602 static const int kStackSlotsBitCount = 24; |
4594 static const int kUnaryOpTypeFirstBit = | 4603 static const int kUnaryOpTypeFirstBit = |
4595 kStackSlotsFirstBit + kStackSlotsBitCount; | 4604 kStackSlotsFirstBit + kStackSlotsBitCount; |
4596 static const int kUnaryOpTypeBitCount = 3; | 4605 static const int kUnaryOpTypeBitCount = 3; |
4597 static const int kToBooleanStateFirstBit = | 4606 static const int kToBooleanStateFirstBit = |
4598 kStackSlotsFirstBit + kStackSlotsBitCount; | 4607 kStackSlotsFirstBit + kStackSlotsBitCount; |
4599 static const int kToBooleanStateBitCount = 8; | 4608 static const int kToBooleanStateBitCount = 8; |
4600 static const int kHasFunctionCacheFirstBit = | 4609 static const int kHasFunctionCacheFirstBit = |
4601 kStackSlotsFirstBit + kStackSlotsBitCount; | 4610 kStackSlotsFirstBit + kStackSlotsBitCount; |
4602 static const int kHasFunctionCacheBitCount = 1; | 4611 static const int kHasFunctionCacheBitCount = 1; |
4612 static const int kMarkedForDeoptimizationFirstBit = | |
4613 kStackSlotsFirstBit + kStackSlotsBitCount + 1; | |
4614 static const int kMarkedForDeoptimizationBitCount = 1; | |
4603 | 4615 |
4604 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); | 4616 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); |
4605 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); | 4617 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); |
4606 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); | 4618 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); |
4607 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); | 4619 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); |
4620 STATIC_ASSERT(kMarkedForDeoptimizationBitCount + | |
Michael Starzinger
2013/01/21 14:36:44
This should be "kMarkedForDeoptimizationFirstBit"
ulan
2013/01/21 15:56:02
Done.
| |
4621 kMarkedForDeoptimizationBitCount <= 32); | |
4608 | 4622 |
4609 class StackSlotsField: public BitField<int, | 4623 class StackSlotsField: public BitField<int, |
4610 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT | 4624 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT |
4611 class UnaryOpTypeField: public BitField<int, | 4625 class UnaryOpTypeField: public BitField<int, |
4612 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT | 4626 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT |
4613 class ToBooleanStateField: public BitField<int, | 4627 class ToBooleanStateField: public BitField<int, |
4614 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT | 4628 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT |
4615 class HasFunctionCacheField: public BitField<bool, | 4629 class HasFunctionCacheField: public BitField<bool, |
4616 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT | 4630 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT |
4631 class MarkedForDeoptimizationField: public BitField<bool, | |
4632 kMarkedForDeoptimizationFirstBit, | |
4633 kMarkedForDeoptimizationBitCount> {}; // NOLINT | |
4617 | 4634 |
4618 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) | 4635 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) |
4619 static const int kStubMajorKeyFirstBit = 0; | 4636 static const int kStubMajorKeyFirstBit = 0; |
4620 static const int kSafepointTableOffsetFirstBit = | 4637 static const int kSafepointTableOffsetFirstBit = |
4621 kStubMajorKeyFirstBit + kStubMajorKeyBits; | 4638 kStubMajorKeyFirstBit + kStubMajorKeyBits; |
4622 static const int kSafepointTableOffsetBitCount = 26; | 4639 static const int kSafepointTableOffsetBitCount = 26; |
4623 | 4640 |
4624 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); | 4641 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); |
4625 STATIC_ASSERT(kSafepointTableOffsetFirstBit + | 4642 STATIC_ASSERT(kSafepointTableOffsetFirstBit + |
4626 kSafepointTableOffsetBitCount <= 32); | 4643 kSafepointTableOffsetBitCount <= 32); |
(...skipping 27 matching lines...) Expand all Loading... | |
4654 static Code* GetCodeAgeStub(Age age, MarkingParity parity); | 4671 static Code* GetCodeAgeStub(Age age, MarkingParity parity); |
4655 | 4672 |
4656 // Code aging -- platform-specific | 4673 // Code aging -- platform-specific |
4657 static void PatchPlatformCodeAge(byte* sequence, Age age, | 4674 static void PatchPlatformCodeAge(byte* sequence, Age age, |
4658 MarkingParity parity); | 4675 MarkingParity parity); |
4659 | 4676 |
4660 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 4677 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
4661 }; | 4678 }; |
4662 | 4679 |
4663 | 4680 |
4681 // This class describes the layout of dependent codes array of a map. The | |
4682 // first element contains the number of codes as a Smi. The subsequent | |
4683 // elements contain code objects. The suffix of the array can be filled with | |
4684 // Smi(0) if the number of codes is less than the length of the array. | |
Michael Starzinger
2013/01/21 14:36:44
Comment no longer applies, it's undefined instead
ulan
2013/01/21 15:56:02
Done.
| |
4685 class DependentCodes: public FixedArray { | |
4686 public: | |
4687 inline int number_of_codes(); | |
4688 inline void set_number_of_codes(int value); | |
4689 inline Code* code_at(int i); | |
4690 inline void set_code_at(int i, Code* value); | |
4691 inline Object** code_slot_at(int i); | |
4692 inline void clear_code_at(int i); | |
4693 static Handle<DependentCodes> Append(Handle<DependentCodes> codes, | |
4694 Handle<Code> value); | |
4695 static inline DependentCodes* cast(Object* object); | |
4696 private: | |
4697 static const int kNumberOfCodesIndex = 0; | |
4698 static const int kCodesIndex = 1; | |
4699 }; | |
4700 | |
4701 | |
4664 // All heap objects have a Map that describes their structure. | 4702 // All heap objects have a Map that describes their structure. |
4665 // A Map contains information about: | 4703 // A Map contains information about: |
4666 // - Size information about the object | 4704 // - Size information about the object |
4667 // - How to iterate over an object (for garbage collection) | 4705 // - How to iterate over an object (for garbage collection) |
4668 class Map: public HeapObject { | 4706 class Map: public HeapObject { |
4669 public: | 4707 public: |
4670 // Instance size. | 4708 // Instance size. |
4671 // Size in bytes or kVariableSizeSentinel if instances do not have | 4709 // Size in bytes or kVariableSizeSentinel if instances do not have |
4672 // a fixed size. | 4710 // a fixed size. |
4673 inline int instance_size(); | 4711 inline int instance_size(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4883 | 4921 |
4884 inline JSFunction* unchecked_constructor(); | 4922 inline JSFunction* unchecked_constructor(); |
4885 | 4923 |
4886 // [instance descriptors]: describes the object. | 4924 // [instance descriptors]: describes the object. |
4887 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 4925 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
4888 inline void InitializeDescriptors(DescriptorArray* descriptors); | 4926 inline void InitializeDescriptors(DescriptorArray* descriptors); |
4889 | 4927 |
4890 // [stub cache]: contains stubs compiled for this map. | 4928 // [stub cache]: contains stubs compiled for this map. |
4891 DECL_ACCESSORS(code_cache, Object) | 4929 DECL_ACCESSORS(code_cache, Object) |
4892 | 4930 |
4931 // [dependent codes]: list of optimized codes that have this map embedded. | |
4932 DECL_ACCESSORS(dependent_codes, DependentCodes) | |
4933 | |
4893 // [back pointer]: points back to the parent map from which a transition | 4934 // [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 | 4935 // leads to this map. The field overlaps with prototype transitions and the |
4895 // back pointer will be moved into the prototype transitions array if | 4936 // back pointer will be moved into the prototype transitions array if |
4896 // required. | 4937 // required. |
4897 inline Object* GetBackPointer(); | 4938 inline Object* GetBackPointer(); |
4898 inline void SetBackPointer(Object* value, | 4939 inline void SetBackPointer(Object* value, |
4899 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 4940 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
4900 inline void init_back_pointer(Object* undefined); | 4941 inline void init_back_pointer(Object* undefined); |
4901 | 4942 |
4902 // [prototype transitions]: cache of prototype transitions. | 4943 // [prototype transitions]: cache of prototype transitions. |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5092 | 5133 |
5093 // Zaps the contents of backing data structures. Note that the | 5134 // Zaps the contents of backing data structures. Note that the |
5094 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects | 5135 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects |
5095 // holding weak references when incremental marking is used, because it also | 5136 // holding weak references when incremental marking is used, because it also |
5096 // iterates over objects that are otherwise unreachable. | 5137 // iterates over objects that are otherwise unreachable. |
5097 // In general we only want to call these functions in release mode when | 5138 // In general we only want to call these functions in release mode when |
5098 // heap verification is turned on. | 5139 // heap verification is turned on. |
5099 void ZapPrototypeTransitions(); | 5140 void ZapPrototypeTransitions(); |
5100 void ZapTransitions(); | 5141 void ZapTransitions(); |
5101 | 5142 |
5143 bool CanTransition() { | |
5144 // Only JSObject and subtypes have map transitions and back pointers. | |
5145 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | |
5146 return instance_type() >= FIRST_JS_OBJECT_TYPE; | |
5147 } | |
5148 | |
5149 inline void AddDependentCode(Handle<Code> code); | |
5150 | |
5102 // Dispatched behavior. | 5151 // Dispatched behavior. |
5103 DECLARE_PRINTER(Map) | 5152 DECLARE_PRINTER(Map) |
5104 DECLARE_VERIFIER(Map) | 5153 DECLARE_VERIFIER(Map) |
5105 | 5154 |
5106 #ifdef VERIFY_HEAP | 5155 #ifdef VERIFY_HEAP |
5107 void SharedMapVerify(); | 5156 void SharedMapVerify(); |
5108 #endif | 5157 #endif |
5109 | 5158 |
5110 inline int visitor_id(); | 5159 inline int visitor_id(); |
5111 inline void set_visitor_id(int visitor_id); | 5160 inline void set_visitor_id(int visitor_id); |
(...skipping 28 matching lines...) Expand all Loading... | |
5140 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 5189 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
5141 // Storage for the transition array is overloaded to directly contain a back | 5190 // 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 | 5191 // pointer if unused. When the map has transitions, the back pointer is |
5143 // transferred to the transition array and accessed through an extra | 5192 // transferred to the transition array and accessed through an extra |
5144 // indirection. | 5193 // indirection. |
5145 static const int kTransitionsOrBackPointerOffset = | 5194 static const int kTransitionsOrBackPointerOffset = |
5146 kConstructorOffset + kPointerSize; | 5195 kConstructorOffset + kPointerSize; |
5147 static const int kDescriptorsOffset = | 5196 static const int kDescriptorsOffset = |
5148 kTransitionsOrBackPointerOffset + kPointerSize; | 5197 kTransitionsOrBackPointerOffset + kPointerSize; |
5149 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; | 5198 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; |
5150 static const int kBitField3Offset = kCodeCacheOffset + kPointerSize; | 5199 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize; |
5200 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize; | |
5151 static const int kSize = kBitField3Offset + kPointerSize; | 5201 static const int kSize = kBitField3Offset + kPointerSize; |
5152 | 5202 |
5153 // Layout of pointer fields. Heap iteration code relies on them | 5203 // Layout of pointer fields. Heap iteration code relies on them |
5154 // being continuously allocated. | 5204 // being continuously allocated. |
5155 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; | 5205 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; |
5156 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; | 5206 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; |
5157 | 5207 |
5158 // Byte offsets within kInstanceSizesOffset. | 5208 // Byte offsets within kInstanceSizesOffset. |
5159 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 5209 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
5160 static const int kInObjectPropertiesByte = 1; | 5210 static const int kInObjectPropertiesByte = 1; |
(...skipping 3670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8831 } else { | 8881 } else { |
8832 value &= ~(1 << bit_position); | 8882 value &= ~(1 << bit_position); |
8833 } | 8883 } |
8834 return value; | 8884 return value; |
8835 } | 8885 } |
8836 }; | 8886 }; |
8837 | 8887 |
8838 } } // namespace v8::internal | 8888 } } // namespace v8::internal |
8839 | 8889 |
8840 #endif // V8_OBJECTS_H_ | 8890 #endif // V8_OBJECTS_H_ |
OLD | NEW |