OLD | NEW |
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 5538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5549 // array is partitioned into several groups of dependent codes. Each group | 5549 // array is partitioned into several groups of dependent codes. Each group |
5550 // contains codes with the same dependency on the map. The array has the | 5550 // contains codes with the same dependency on the map. The array has the |
5551 // following layout for n dependency groups: | 5551 // following layout for n dependency groups: |
5552 // | 5552 // |
5553 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 5553 // +----+----+-----+----+---------+----------+-----+---------+-----------+ |
5554 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | | 5554 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | |
5555 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 5555 // +----+----+-----+----+---------+----------+-----+---------+-----------+ |
5556 // | 5556 // |
5557 // The first n elements are Smis, each of them specifies the number of codes | 5557 // The first n elements are Smis, each of them specifies the number of codes |
5558 // in the corresponding group. The subsequent elements contain grouped code | 5558 // in the corresponding group. The subsequent elements contain grouped code |
5559 // objects. The suffix of the array can be filled with the undefined value if | 5559 // objects in weak cells. The suffix of the array can be filled with the |
5560 // the number of codes is less than the length of the array. The order of the | 5560 // undefined value if the number of codes is less than the length of the |
5561 // code objects within a group is not preserved. | 5561 // array. The order of the code objects within a group is not preserved. |
5562 // | 5562 // |
5563 // All code indexes used in the class are counted starting from the first | 5563 // All code indexes used in the class are counted starting from the first |
5564 // code object of the first group. In other words, code index 0 corresponds | 5564 // code object of the first group. In other words, code index 0 corresponds |
5565 // to array index n = kCodesStartIndex. | 5565 // to array index n = kCodesStartIndex. |
5566 | 5566 |
5567 class DependentCode: public FixedArray { | 5567 class DependentCode: public FixedArray { |
5568 public: | 5568 public: |
5569 enum DependencyGroup { | 5569 enum DependencyGroup { |
5570 // Group of code that weakly embed this map and depend on being | 5570 // Group of code that weakly embed this map and depend on being |
5571 // deoptimized when the map is garbage collected. | 5571 // deoptimized when the map is garbage collected. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5605 class GroupStartIndexes { | 5605 class GroupStartIndexes { |
5606 public: | 5606 public: |
5607 explicit GroupStartIndexes(DependentCode* entries); | 5607 explicit GroupStartIndexes(DependentCode* entries); |
5608 void Recompute(DependentCode* entries); | 5608 void Recompute(DependentCode* entries); |
5609 int at(int i) { return start_indexes_[i]; } | 5609 int at(int i) { return start_indexes_[i]; } |
5610 int number_of_entries() { return start_indexes_[kGroupCount]; } | 5610 int number_of_entries() { return start_indexes_[kGroupCount]; } |
5611 private: | 5611 private: |
5612 int start_indexes_[kGroupCount + 1]; | 5612 int start_indexes_[kGroupCount + 1]; |
5613 }; | 5613 }; |
5614 | 5614 |
5615 bool Contains(DependencyGroup group, Code* code); | 5615 bool Contains(DependencyGroup group, WeakCell* code_cell); |
5616 static Handle<DependentCode> Insert(Handle<DependentCode> entries, | 5616 |
5617 DependencyGroup group, | 5617 static Handle<DependentCode> InsertCompilationInfo( |
5618 Handle<Object> object); | 5618 Handle<DependentCode> entries, DependencyGroup group, |
5619 void UpdateToFinishedCode(DependencyGroup group, | 5619 Handle<Foreign> info); |
5620 CompilationInfo* info, | 5620 |
5621 Code* code); | 5621 static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries, |
| 5622 DependencyGroup group, |
| 5623 Handle<WeakCell> code_cell); |
| 5624 |
| 5625 void UpdateToFinishedCode(DependencyGroup group, Foreign* info, |
| 5626 WeakCell* code_cell); |
| 5627 |
5622 void RemoveCompilationInfo(DependentCode::DependencyGroup group, | 5628 void RemoveCompilationInfo(DependentCode::DependencyGroup group, |
5623 CompilationInfo* info); | 5629 Foreign* info); |
5624 | 5630 |
5625 void DeoptimizeDependentCodeGroup(Isolate* isolate, | 5631 void DeoptimizeDependentCodeGroup(Isolate* isolate, |
5626 DependentCode::DependencyGroup group); | 5632 DependentCode::DependencyGroup group); |
5627 | 5633 |
5628 bool MarkCodeForDeoptimization(Isolate* isolate, | 5634 bool MarkCodeForDeoptimization(Isolate* isolate, |
5629 DependentCode::DependencyGroup group); | 5635 DependentCode::DependencyGroup group); |
5630 | 5636 |
5631 // The following low-level accessors should only be used by this class | 5637 // The following low-level accessors should only be used by this class |
5632 // and the mark compact collector. | 5638 // and the mark compact collector. |
5633 inline int number_of_entries(DependencyGroup group); | 5639 inline int number_of_entries(DependencyGroup group); |
5634 inline void set_number_of_entries(DependencyGroup group, int value); | 5640 inline void set_number_of_entries(DependencyGroup group, int value); |
5635 inline bool is_code_at(int i); | 5641 inline Object* object_at(int i); |
5636 inline Code* code_at(int i); | |
5637 inline CompilationInfo* compilation_info_at(int i); | |
5638 inline void set_object_at(int i, Object* object); | 5642 inline void set_object_at(int i, Object* object); |
5639 inline Object** slot_at(int i); | |
5640 inline Object* object_at(int i); | |
5641 inline void clear_at(int i); | 5643 inline void clear_at(int i); |
5642 inline void copy(int from, int to); | 5644 inline void copy(int from, int to); |
5643 DECLARE_CAST(DependentCode) | 5645 DECLARE_CAST(DependentCode) |
5644 | 5646 |
5645 static DependentCode* ForObject(Handle<HeapObject> object, | 5647 static DependentCode* ForObject(Handle<HeapObject> object, |
5646 DependencyGroup group); | 5648 DependencyGroup group); |
5647 | 5649 |
5648 static const char* DependencyGroupName(DependencyGroup group); | 5650 static const char* DependencyGroupName(DependencyGroup group); |
5649 static void SetMarkedForDeoptimization(Code* code, DependencyGroup group); | 5651 static void SetMarkedForDeoptimization(Code* code, DependencyGroup group); |
5650 | 5652 |
5651 private: | 5653 private: |
| 5654 static Handle<DependentCode> Insert(Handle<DependentCode> entries, |
| 5655 DependencyGroup group, |
| 5656 Handle<Object> object); |
| 5657 static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries); |
5652 // Make a room at the end of the given group by moving out the first | 5658 // Make a room at the end of the given group by moving out the first |
5653 // code objects of the subsequent groups. | 5659 // code objects of the subsequent groups. |
5654 inline void ExtendGroup(DependencyGroup group); | 5660 inline void ExtendGroup(DependencyGroup group); |
| 5661 // Compact by removing cleared weak cells and return true if there was |
| 5662 // any cleared weak cell. |
| 5663 bool Compact(); |
| 5664 static int Grow(int number_of_entries) { |
| 5665 if (number_of_entries < 5) return number_of_entries + 1; |
| 5666 return number_of_entries * 5 / 4; |
| 5667 } |
5655 static const int kCodesStartIndex = kGroupCount; | 5668 static const int kCodesStartIndex = kGroupCount; |
5656 }; | 5669 }; |
5657 | 5670 |
5658 | 5671 |
5659 // All heap objects have a Map that describes their structure. | 5672 // All heap objects have a Map that describes their structure. |
5660 // A Map contains information about: | 5673 // A Map contains information about: |
5661 // - Size information about the object | 5674 // - Size information about the object |
5662 // - How to iterate over an object (for garbage collection) | 5675 // - How to iterate over an object (for garbage collection) |
5663 class Map: public HeapObject { | 5676 class Map: public HeapObject { |
5664 public: | 5677 public: |
(...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8447 static const int kPretenureCreateCountOffset = | 8460 static const int kPretenureCreateCountOffset = |
8448 kPretenureDataOffset + kPointerSize; | 8461 kPretenureDataOffset + kPointerSize; |
8449 static const int kDependentCodeOffset = | 8462 static const int kDependentCodeOffset = |
8450 kPretenureCreateCountOffset + kPointerSize; | 8463 kPretenureCreateCountOffset + kPointerSize; |
8451 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; | 8464 static const int kWeakNextOffset = kDependentCodeOffset + kPointerSize; |
8452 static const int kSize = kWeakNextOffset + kPointerSize; | 8465 static const int kSize = kWeakNextOffset + kPointerSize; |
8453 | 8466 |
8454 // During mark compact we need to take special care for the dependent code | 8467 // During mark compact we need to take special care for the dependent code |
8455 // field. | 8468 // field. |
8456 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; | 8469 static const int kPointerFieldsBeginOffset = kTransitionInfoOffset; |
8457 static const int kPointerFieldsEndOffset = kDependentCodeOffset; | 8470 static const int kPointerFieldsEndOffset = kWeakNextOffset; |
8458 | 8471 |
8459 // For other visitors, use the fixed body descriptor below. | 8472 // For other visitors, use the fixed body descriptor below. |
8460 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, | 8473 typedef FixedBodyDescriptor<HeapObject::kHeaderSize, |
8461 kDependentCodeOffset + kPointerSize, | 8474 kDependentCodeOffset + kPointerSize, |
8462 kSize> BodyDescriptor; | 8475 kSize> BodyDescriptor; |
8463 | 8476 |
8464 private: | 8477 private: |
8465 static void AddDependentCompilationInfo(Handle<AllocationSite> site, | 8478 static void AddDependentCompilationInfo(Handle<AllocationSite> site, |
8466 DependentCode::DependencyGroup group, | 8479 DependentCode::DependencyGroup group, |
8467 CompilationInfo* info); | 8480 CompilationInfo* info); |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9698 // Dispatched behavior. | 9711 // Dispatched behavior. |
9699 DECLARE_PRINTER(PropertyCell) | 9712 DECLARE_PRINTER(PropertyCell) |
9700 DECLARE_VERIFIER(PropertyCell) | 9713 DECLARE_VERIFIER(PropertyCell) |
9701 | 9714 |
9702 // Layout description. | 9715 // Layout description. |
9703 static const int kTypeOffset = kValueOffset + kPointerSize; | 9716 static const int kTypeOffset = kValueOffset + kPointerSize; |
9704 static const int kDependentCodeOffset = kTypeOffset + kPointerSize; | 9717 static const int kDependentCodeOffset = kTypeOffset + kPointerSize; |
9705 static const int kSize = kDependentCodeOffset + kPointerSize; | 9718 static const int kSize = kDependentCodeOffset + kPointerSize; |
9706 | 9719 |
9707 static const int kPointerFieldsBeginOffset = kValueOffset; | 9720 static const int kPointerFieldsBeginOffset = kValueOffset; |
9708 static const int kPointerFieldsEndOffset = kDependentCodeOffset; | 9721 static const int kPointerFieldsEndOffset = kSize; |
9709 | 9722 |
9710 typedef FixedBodyDescriptor<kValueOffset, | 9723 typedef FixedBodyDescriptor<kValueOffset, |
9711 kSize, | 9724 kSize, |
9712 kSize> BodyDescriptor; | 9725 kSize> BodyDescriptor; |
9713 | 9726 |
9714 private: | 9727 private: |
9715 DECL_ACCESSORS(type_raw, Object) | 9728 DECL_ACCESSORS(type_raw, Object) |
9716 DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell); | 9729 DISALLOW_IMPLICIT_CONSTRUCTORS(PropertyCell); |
9717 }; | 9730 }; |
9718 | 9731 |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10933 } else { | 10946 } else { |
10934 value &= ~(1 << bit_position); | 10947 value &= ~(1 << bit_position); |
10935 } | 10948 } |
10936 return value; | 10949 return value; |
10937 } | 10950 } |
10938 }; | 10951 }; |
10939 | 10952 |
10940 } } // namespace v8::internal | 10953 } } // namespace v8::internal |
10941 | 10954 |
10942 #endif // V8_OBJECTS_H_ | 10955 #endif // V8_OBJECTS_H_ |
OLD | NEW |