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 5296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5307 inline bool is_load_stub() { return kind() == LOAD_IC; } | 5307 inline bool is_load_stub() { return kind() == LOAD_IC; } |
5308 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } | 5308 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } |
5309 inline bool is_store_stub() { return kind() == STORE_IC; } | 5309 inline bool is_store_stub() { return kind() == STORE_IC; } |
5310 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } | 5310 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } |
5311 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } | 5311 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } |
5312 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } | 5312 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } |
5313 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } | 5313 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } |
5314 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } | 5314 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } |
5315 inline bool is_keyed_stub(); | 5315 inline bool is_keyed_stub(); |
5316 inline bool is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; } | 5316 inline bool is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; } |
5317 inline bool can_be_weak_stub() { | |
Michael Starzinger
2014/04/11 09:01:56
nit: This is not really a primitive predicate, gro
ulan
2014/04/11 09:28:01
Done.
| |
5318 Kind k = kind(); | |
5319 return (k == LOAD_IC || k == STORE_IC || k == KEYED_LOAD_IC || | |
5320 k == KEYED_STORE_IC || k == COMPARE_NIL_IC) && | |
5321 ic_state() == MONOMORPHIC; | |
5322 } | |
5323 inline bool is_weak_stub(); | |
5324 inline void mark_as_weak_stub(); | |
5325 inline bool is_invalidated_weak_stub(); | |
5326 inline void mark_as_invalidated_weak_stub(); | |
5317 | 5327 |
5318 inline void set_raw_kind_specific_flags1(int value); | 5328 inline void set_raw_kind_specific_flags1(int value); |
5319 inline void set_raw_kind_specific_flags2(int value); | 5329 inline void set_raw_kind_specific_flags2(int value); |
5320 | 5330 |
5321 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. | 5331 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. |
5322 inline int major_key(); | 5332 inline int major_key(); |
5323 inline void set_major_key(int value); | 5333 inline void set_major_key(int value); |
5324 inline bool has_major_key(); | 5334 inline bool has_major_key(); |
5325 | 5335 |
5326 // For kind STUB or ICs, tells whether or not a code object was generated by | 5336 // For kind STUB or ICs, tells whether or not a code object was generated by |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5564 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY); | 5574 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY); |
5565 } | 5575 } |
5566 | 5576 |
5567 void PrintDeoptLocation(FILE* out, int bailout_id); | 5577 void PrintDeoptLocation(FILE* out, int bailout_id); |
5568 bool CanDeoptAt(Address pc); | 5578 bool CanDeoptAt(Address pc); |
5569 | 5579 |
5570 #ifdef VERIFY_HEAP | 5580 #ifdef VERIFY_HEAP |
5571 void VerifyEmbeddedObjectsDependency(); | 5581 void VerifyEmbeddedObjectsDependency(); |
5572 #endif | 5582 #endif |
5573 | 5583 |
5584 inline bool CanContainWeakObjects() { | |
5585 return is_optimized_code() || is_weak_stub(); | |
5586 } | |
5587 | |
5574 inline bool IsWeakObject(Object* object) { | 5588 inline bool IsWeakObject(Object* object) { |
5575 return is_optimized_code() && IsWeakObjectInOptimizedCode(object); | 5589 return (is_optimized_code() && IsWeakObjectInOptimizedCode(object)) || |
5590 (is_weak_stub() && IsWeakObjectInIC(object)); | |
5576 } | 5591 } |
5577 | 5592 |
5578 inline bool IsWeakObjectInOptimizedCode(Object* object); | 5593 inline bool IsWeakObjectInOptimizedCode(Object* object); |
5594 inline bool IsWeakObjectInIC(Object* object); | |
5579 | 5595 |
5580 // Max loop nesting marker used to postpose OSR. We don't take loop | 5596 // Max loop nesting marker used to postpose OSR. We don't take loop |
5581 // nesting that is deeper than 5 levels into account. | 5597 // nesting that is deeper than 5 levels into account. |
5582 static const int kMaxLoopNestingMarker = 6; | 5598 static const int kMaxLoopNestingMarker = 6; |
5583 | 5599 |
5584 // Layout description. | 5600 // Layout description. |
5585 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; | 5601 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
5586 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; | 5602 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; |
5587 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; | 5603 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; |
5588 static const int kDeoptimizationDataOffset = | 5604 static const int kDeoptimizationDataOffset = |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5631 | 5647 |
5632 // KindSpecificFlags1 layout (STUB and OPTIMIZED_FUNCTION) | 5648 // KindSpecificFlags1 layout (STUB and OPTIMIZED_FUNCTION) |
5633 static const int kStackSlotsFirstBit = 0; | 5649 static const int kStackSlotsFirstBit = 0; |
5634 static const int kStackSlotsBitCount = 24; | 5650 static const int kStackSlotsBitCount = 24; |
5635 static const int kHasFunctionCacheFirstBit = | 5651 static const int kHasFunctionCacheFirstBit = |
5636 kStackSlotsFirstBit + kStackSlotsBitCount; | 5652 kStackSlotsFirstBit + kStackSlotsBitCount; |
5637 static const int kHasFunctionCacheBitCount = 1; | 5653 static const int kHasFunctionCacheBitCount = 1; |
5638 static const int kMarkedForDeoptimizationFirstBit = | 5654 static const int kMarkedForDeoptimizationFirstBit = |
5639 kStackSlotsFirstBit + kStackSlotsBitCount + 1; | 5655 kStackSlotsFirstBit + kStackSlotsBitCount + 1; |
5640 static const int kMarkedForDeoptimizationBitCount = 1; | 5656 static const int kMarkedForDeoptimizationBitCount = 1; |
5657 static const int kWeakStubFirstBit = | |
5658 kMarkedForDeoptimizationFirstBit + kMarkedForDeoptimizationBitCount; | |
5659 static const int kWeakStubBitCount = 1; | |
5660 static const int kInvalidatedWeakStubFirstBit = | |
5661 kWeakStubFirstBit + kWeakStubBitCount; | |
5662 static const int kInvalidatedWeakStubBitCount = 1; | |
5641 | 5663 |
5642 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); | 5664 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); |
5643 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); | 5665 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); |
5644 STATIC_ASSERT(kMarkedForDeoptimizationFirstBit + | 5666 STATIC_ASSERT(kInvalidatedWeakStubFirstBit + |
5645 kMarkedForDeoptimizationBitCount <= 32); | 5667 kInvalidatedWeakStubBitCount <= 32); |
5646 | 5668 |
5647 class StackSlotsField: public BitField<int, | 5669 class StackSlotsField: public BitField<int, |
5648 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT | 5670 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT |
5649 class HasFunctionCacheField: public BitField<bool, | 5671 class HasFunctionCacheField: public BitField<bool, |
5650 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT | 5672 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT |
5651 class MarkedForDeoptimizationField: public BitField<bool, | 5673 class MarkedForDeoptimizationField: public BitField<bool, |
5652 kMarkedForDeoptimizationFirstBit, | 5674 kMarkedForDeoptimizationFirstBit, |
5653 kMarkedForDeoptimizationBitCount> {}; // NOLINT | 5675 kMarkedForDeoptimizationBitCount> {}; // NOLINT |
5676 class WeakStubField: public BitField<bool, | |
5677 kWeakStubFirstBit, | |
5678 kWeakStubBitCount> {}; // NOLINT | |
5679 class InvalidatedWeakStubField: public BitField<bool, | |
5680 kInvalidatedWeakStubFirstBit, | |
5681 kInvalidatedWeakStubBitCount> {}; // NOLINT | |
5654 | 5682 |
5655 // KindSpecificFlags2 layout (ALL) | 5683 // KindSpecificFlags2 layout (ALL) |
5656 static const int kIsCrankshaftedBit = 0; | 5684 static const int kIsCrankshaftedBit = 0; |
5657 class IsCrankshaftedField: public BitField<bool, | 5685 class IsCrankshaftedField: public BitField<bool, |
5658 kIsCrankshaftedBit, 1> {}; // NOLINT | 5686 kIsCrankshaftedBit, 1> {}; // NOLINT |
5659 | 5687 |
5660 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) | 5688 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) |
5661 static const int kStubMajorKeyFirstBit = kIsCrankshaftedBit + 1; | 5689 static const int kStubMajorKeyFirstBit = kIsCrankshaftedBit + 1; |
5662 static const int kSafepointTableOffsetFirstBit = | 5690 static const int kSafepointTableOffsetFirstBit = |
5663 kStubMajorKeyFirstBit + kStubMajorKeyBits; | 5691 kStubMajorKeyFirstBit + kStubMajorKeyBits; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5728 // the number of codes is less than the length of the array. The order of the | 5756 // the number of codes is less than the length of the array. The order of the |
5729 // code objects within a group is not preserved. | 5757 // code objects within a group is not preserved. |
5730 // | 5758 // |
5731 // All code indexes used in the class are counted starting from the first | 5759 // All code indexes used in the class are counted starting from the first |
5732 // code object of the first group. In other words, code index 0 corresponds | 5760 // code object of the first group. In other words, code index 0 corresponds |
5733 // to array index n = kCodesStartIndex. | 5761 // to array index n = kCodesStartIndex. |
5734 | 5762 |
5735 class DependentCode: public FixedArray { | 5763 class DependentCode: public FixedArray { |
5736 public: | 5764 public: |
5737 enum DependencyGroup { | 5765 enum DependencyGroup { |
5766 // Group of IC stubs that weakly embed this map and depend on being | |
5767 // invalidated when the map is garbage collected. Dependent IC stubs form | |
5768 // a linked list. This group stores only the head of the list. This means | |
5769 // that the number_of_entries(kWeakICGroup) is 0 or 1. | |
5770 kWeakICGroup, | |
5738 // Group of code that weakly embed this map and depend on being | 5771 // Group of code that weakly embed this map and depend on being |
5739 // deoptimized when the map is garbage collected. | 5772 // deoptimized when the map is garbage collected. |
5740 kWeaklyEmbeddedGroup, | 5773 kWeakCodeGroup, |
5741 // Group of code that embed a transition to this map, and depend on being | 5774 // Group of code that embed a transition to this map, and depend on being |
5742 // deoptimized when the transition is replaced by a new version. | 5775 // deoptimized when the transition is replaced by a new version. |
5743 kTransitionGroup, | 5776 kTransitionGroup, |
5744 // Group of code that omit run-time prototype checks for prototypes | 5777 // Group of code that omit run-time prototype checks for prototypes |
5745 // described by this map. The group is deoptimized whenever an object | 5778 // described by this map. The group is deoptimized whenever an object |
5746 // described by this map changes shape (and transitions to a new map), | 5779 // described by this map changes shape (and transitions to a new map), |
5747 // possibly invalidating the assumptions embedded in the code. | 5780 // possibly invalidating the assumptions embedded in the code. |
5748 kPrototypeCheckGroup, | 5781 kPrototypeCheckGroup, |
5749 // Group of code that depends on elements not being added to objects with | 5782 // Group of code that depends on elements not being added to objects with |
5750 // this map. | 5783 // this map. |
(...skipping 30 matching lines...) Expand all Loading... | |
5781 CompilationInfo* info, | 5814 CompilationInfo* info, |
5782 Code* code); | 5815 Code* code); |
5783 void RemoveCompilationInfo(DependentCode::DependencyGroup group, | 5816 void RemoveCompilationInfo(DependentCode::DependencyGroup group, |
5784 CompilationInfo* info); | 5817 CompilationInfo* info); |
5785 | 5818 |
5786 void DeoptimizeDependentCodeGroup(Isolate* isolate, | 5819 void DeoptimizeDependentCodeGroup(Isolate* isolate, |
5787 DependentCode::DependencyGroup group); | 5820 DependentCode::DependencyGroup group); |
5788 | 5821 |
5789 bool MarkCodeForDeoptimization(Isolate* isolate, | 5822 bool MarkCodeForDeoptimization(Isolate* isolate, |
5790 DependentCode::DependencyGroup group); | 5823 DependentCode::DependencyGroup group); |
5824 void AddToDependentICList(Handle<Code> stub); | |
5791 | 5825 |
5792 // The following low-level accessors should only be used by this class | 5826 // The following low-level accessors should only be used by this class |
5793 // and the mark compact collector. | 5827 // and the mark compact collector. |
5794 inline int number_of_entries(DependencyGroup group); | 5828 inline int number_of_entries(DependencyGroup group); |
5795 inline void set_number_of_entries(DependencyGroup group, int value); | 5829 inline void set_number_of_entries(DependencyGroup group, int value); |
5796 inline bool is_code_at(int i); | 5830 inline bool is_code_at(int i); |
5797 inline Code* code_at(int i); | 5831 inline Code* code_at(int i); |
5798 inline CompilationInfo* compilation_info_at(int i); | 5832 inline CompilationInfo* compilation_info_at(int i); |
5799 inline void set_object_at(int i, Object* object); | 5833 inline void set_object_at(int i, Object* object); |
5800 inline Object** slot_at(int i); | 5834 inline Object** slot_at(int i); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6097 // [constructor]: points back to the function responsible for this map. | 6131 // [constructor]: points back to the function responsible for this map. |
6098 DECL_ACCESSORS(constructor, Object) | 6132 DECL_ACCESSORS(constructor, Object) |
6099 | 6133 |
6100 // [instance descriptors]: describes the object. | 6134 // [instance descriptors]: describes the object. |
6101 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 6135 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
6102 inline void InitializeDescriptors(DescriptorArray* descriptors); | 6136 inline void InitializeDescriptors(DescriptorArray* descriptors); |
6103 | 6137 |
6104 // [stub cache]: contains stubs compiled for this map. | 6138 // [stub cache]: contains stubs compiled for this map. |
6105 DECL_ACCESSORS(code_cache, Object) | 6139 DECL_ACCESSORS(code_cache, Object) |
6106 | 6140 |
6107 // [dependent code]: list of optimized codes that have this map embedded. | 6141 // [dependent code]: list of optimized codes that weakly embed this map. |
6108 DECL_ACCESSORS(dependent_code, DependentCode) | 6142 DECL_ACCESSORS(dependent_code, DependentCode) |
6109 | 6143 |
6110 // [back pointer]: points back to the parent map from which a transition | 6144 // [back pointer]: points back to the parent map from which a transition |
6111 // leads to this map. The field overlaps with prototype transitions and the | 6145 // leads to this map. The field overlaps with prototype transitions and the |
6112 // back pointer will be moved into the prototype transitions array if | 6146 // back pointer will be moved into the prototype transitions array if |
6113 // required. | 6147 // required. |
6114 inline Object* GetBackPointer(); | 6148 inline Object* GetBackPointer(); |
6115 inline void SetBackPointer(Object* value, | 6149 inline void SetBackPointer(Object* value, |
6116 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 6150 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
6117 inline void init_back_pointer(Object* undefined); | 6151 inline void init_back_pointer(Object* undefined); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6383 // the descriptor array. | 6417 // the descriptor array. |
6384 inline void NotifyLeafMapLayoutChange(); | 6418 inline void NotifyLeafMapLayoutChange(); |
6385 | 6419 |
6386 inline bool CanOmitMapChecks(); | 6420 inline bool CanOmitMapChecks(); |
6387 | 6421 |
6388 void AddDependentCompilationInfo(DependentCode::DependencyGroup group, | 6422 void AddDependentCompilationInfo(DependentCode::DependencyGroup group, |
6389 CompilationInfo* info); | 6423 CompilationInfo* info); |
6390 | 6424 |
6391 void AddDependentCode(DependentCode::DependencyGroup group, | 6425 void AddDependentCode(DependentCode::DependencyGroup group, |
6392 Handle<Code> code); | 6426 Handle<Code> code); |
6427 void AddDependentIC(Handle<Code> stub); | |
6393 | 6428 |
6394 bool IsMapInArrayPrototypeChain(); | 6429 bool IsMapInArrayPrototypeChain(); |
6395 | 6430 |
6396 // Dispatched behavior. | 6431 // Dispatched behavior. |
6397 DECLARE_PRINTER(Map) | 6432 DECLARE_PRINTER(Map) |
6398 DECLARE_VERIFIER(Map) | 6433 DECLARE_VERIFIER(Map) |
6399 | 6434 |
6400 #ifdef VERIFY_HEAP | 6435 #ifdef VERIFY_HEAP |
6401 void SharedMapVerify(); | 6436 void SharedMapVerify(); |
6402 void VerifyOmittedMapChecks(); | 6437 void VerifyOmittedMapChecks(); |
(...skipping 4424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10827 } else { | 10862 } else { |
10828 value &= ~(1 << bit_position); | 10863 value &= ~(1 << bit_position); |
10829 } | 10864 } |
10830 return value; | 10865 return value; |
10831 } | 10866 } |
10832 }; | 10867 }; |
10833 | 10868 |
10834 } } // namespace v8::internal | 10869 } } // namespace v8::internal |
10835 | 10870 |
10836 #endif // V8_OBJECTS_H_ | 10871 #endif // V8_OBJECTS_H_ |
OLD | NEW |