| 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 5371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5382 | 5382 |
| 5383 // Code aging -- platform-specific | 5383 // Code aging -- platform-specific |
| 5384 static void PatchPlatformCodeAge(Isolate* isolate, | 5384 static void PatchPlatformCodeAge(Isolate* isolate, |
| 5385 byte* sequence, Age age, | 5385 byte* sequence, Age age, |
| 5386 MarkingParity parity); | 5386 MarkingParity parity); |
| 5387 | 5387 |
| 5388 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 5388 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
| 5389 }; | 5389 }; |
| 5390 | 5390 |
| 5391 | 5391 |
| 5392 // This class describes the layout of dependent codes array of a map. The | 5392 // Dependent code is a singly linked list of fixed arrays. Each array contains |
| 5393 // array is partitioned into several groups of dependent codes. Each group | 5393 // code objects in weak cells for one dependent group. The suffix of the array |
| 5394 // contains codes with the same dependency on the map. The array has the | 5394 // can be filled with the undefined value if the number of codes is less than |
| 5395 // following layout for n dependency groups: | 5395 // the length of the array. |
| 5396 // | 5396 // |
| 5397 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 5397 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
| 5398 // | C1 | C2 | ... | Cn | group 1 | group 2 | ... | group n | undefined | | 5398 // | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... | |
| 5399 // +----+----+-----+----+---------+----------+-----+---------+-----------+ | 5399 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
| 5400 // | |
| 5401 // V |
| 5402 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
| 5403 // | next | count & group 2 | code 1 | code 2 | ... | code m | undefined | ... | |
| 5404 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
| 5405 // | |
| 5406 // V |
| 5407 // empty_fixed_array() |
| 5400 // | 5408 // |
| 5401 // The first n elements are Smis, each of them specifies the number of codes | 5409 // The list of fixed arrays is ordered by dependency groups. |
| 5402 // in the corresponding group. The subsequent elements contain grouped code | |
| 5403 // objects in weak cells. The suffix of the array can be filled with the | |
| 5404 // undefined value if the number of codes is less than the length of the | |
| 5405 // array. The order of the code objects within a group is not preserved. | |
| 5406 // | |
| 5407 // All code indexes used in the class are counted starting from the first | |
| 5408 // code object of the first group. In other words, code index 0 corresponds | |
| 5409 // to array index n = kCodesStartIndex. | |
| 5410 | 5410 |
| 5411 class DependentCode: public FixedArray { | 5411 class DependentCode: public FixedArray { |
| 5412 public: | 5412 public: |
| 5413 enum DependencyGroup { | 5413 enum DependencyGroup { |
| 5414 // Group of code that weakly embed this map and depend on being | 5414 // Group of code that weakly embed this map and depend on being |
| 5415 // deoptimized when the map is garbage collected. | 5415 // deoptimized when the map is garbage collected. |
| 5416 kWeakCodeGroup, | 5416 kWeakCodeGroup, |
| 5417 // Group of code that embed a transition to this map, and depend on being | 5417 // Group of code that embed a transition to this map, and depend on being |
| 5418 // deoptimized when the transition is replaced by a new version. | 5418 // deoptimized when the transition is replaced by a new version. |
| 5419 kTransitionGroup, | 5419 kTransitionGroup, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5434 // Group of code that depends on tenuring information in AllocationSites | 5434 // Group of code that depends on tenuring information in AllocationSites |
| 5435 // not being changed. | 5435 // not being changed. |
| 5436 kAllocationSiteTenuringChangedGroup, | 5436 kAllocationSiteTenuringChangedGroup, |
| 5437 // Group of code that depends on element transition information in | 5437 // Group of code that depends on element transition information in |
| 5438 // AllocationSites not being changed. | 5438 // AllocationSites not being changed. |
| 5439 kAllocationSiteTransitionChangedGroup | 5439 kAllocationSiteTransitionChangedGroup |
| 5440 }; | 5440 }; |
| 5441 | 5441 |
| 5442 static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1; | 5442 static const int kGroupCount = kAllocationSiteTransitionChangedGroup + 1; |
| 5443 | 5443 |
| 5444 // Array for holding the index of the first code object of each group. | |
| 5445 // The last element stores the total number of code objects. | |
| 5446 class GroupStartIndexes { | |
| 5447 public: | |
| 5448 explicit GroupStartIndexes(DependentCode* entries); | |
| 5449 void Recompute(DependentCode* entries); | |
| 5450 int at(int i) { return start_indexes_[i]; } | |
| 5451 int number_of_entries() { return start_indexes_[kGroupCount]; } | |
| 5452 private: | |
| 5453 int start_indexes_[kGroupCount + 1]; | |
| 5454 }; | |
| 5455 | |
| 5456 bool Contains(DependencyGroup group, WeakCell* code_cell); | 5444 bool Contains(DependencyGroup group, WeakCell* code_cell); |
| 5445 bool IsEmpty(DependencyGroup group); |
| 5457 | 5446 |
| 5458 static Handle<DependentCode> InsertCompilationDependencies( | 5447 static Handle<DependentCode> InsertCompilationDependencies( |
| 5459 Handle<DependentCode> entries, DependencyGroup group, | 5448 Handle<DependentCode> entries, DependencyGroup group, |
| 5460 Handle<Foreign> info); | 5449 Handle<Foreign> info); |
| 5461 | 5450 |
| 5462 static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries, | 5451 static Handle<DependentCode> InsertWeakCode(Handle<DependentCode> entries, |
| 5463 DependencyGroup group, | 5452 DependencyGroup group, |
| 5464 Handle<WeakCell> code_cell); | 5453 Handle<WeakCell> code_cell); |
| 5465 | 5454 |
| 5466 void UpdateToFinishedCode(DependencyGroup group, Foreign* info, | 5455 void UpdateToFinishedCode(DependencyGroup group, Foreign* info, |
| 5467 WeakCell* code_cell); | 5456 WeakCell* code_cell); |
| 5468 | 5457 |
| 5469 void RemoveCompilationDependencies(DependentCode::DependencyGroup group, | 5458 void RemoveCompilationDependencies(DependentCode::DependencyGroup group, |
| 5470 Foreign* info); | 5459 Foreign* info); |
| 5471 | 5460 |
| 5472 void DeoptimizeDependentCodeGroup(Isolate* isolate, | 5461 void DeoptimizeDependentCodeGroup(Isolate* isolate, |
| 5473 DependentCode::DependencyGroup group); | 5462 DependentCode::DependencyGroup group); |
| 5474 | 5463 |
| 5475 bool MarkCodeForDeoptimization(Isolate* isolate, | 5464 bool MarkCodeForDeoptimization(Isolate* isolate, |
| 5476 DependentCode::DependencyGroup group); | 5465 DependentCode::DependencyGroup group); |
| 5477 | 5466 |
| 5478 // The following low-level accessors should only be used by this class | 5467 // The following low-level accessors should only be used by this class |
| 5479 // and the mark compact collector. | 5468 // and the mark compact collector. |
| 5480 inline int number_of_entries(DependencyGroup group); | 5469 inline DependentCode* next_link(); |
| 5481 inline void set_number_of_entries(DependencyGroup group, int value); | 5470 inline void set_next_link(DependentCode* next); |
| 5471 inline int count(); |
| 5472 inline void set_count(int value); |
| 5473 inline DependencyGroup group(); |
| 5474 inline void set_group(DependencyGroup group); |
| 5482 inline Object* object_at(int i); | 5475 inline Object* object_at(int i); |
| 5483 inline void set_object_at(int i, Object* object); | 5476 inline void set_object_at(int i, Object* object); |
| 5484 inline void clear_at(int i); | 5477 inline void clear_at(int i); |
| 5485 inline void copy(int from, int to); | 5478 inline void copy(int from, int to); |
| 5486 DECLARE_CAST(DependentCode) | 5479 DECLARE_CAST(DependentCode) |
| 5487 | 5480 |
| 5488 static const char* DependencyGroupName(DependencyGroup group); | 5481 static const char* DependencyGroupName(DependencyGroup group); |
| 5489 static void SetMarkedForDeoptimization(Code* code, DependencyGroup group); | 5482 static void SetMarkedForDeoptimization(Code* code, DependencyGroup group); |
| 5490 | 5483 |
| 5491 private: | 5484 private: |
| 5492 static Handle<DependentCode> Insert(Handle<DependentCode> entries, | 5485 static Handle<DependentCode> Insert(Handle<DependentCode> entries, |
| 5493 DependencyGroup group, | 5486 DependencyGroup group, |
| 5494 Handle<Object> object); | 5487 Handle<Object> object); |
| 5488 static Handle<DependentCode> New(DependencyGroup group, Handle<Object> object, |
| 5489 Handle<DependentCode> next); |
| 5495 static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries); | 5490 static Handle<DependentCode> EnsureSpace(Handle<DependentCode> entries); |
| 5496 // Make a room at the end of the given group by moving out the first | |
| 5497 // code objects of the subsequent groups. | |
| 5498 inline void ExtendGroup(DependencyGroup group); | |
| 5499 // Compact by removing cleared weak cells and return true if there was | 5491 // Compact by removing cleared weak cells and return true if there was |
| 5500 // any cleared weak cell. | 5492 // any cleared weak cell. |
| 5501 bool Compact(); | 5493 bool Compact(); |
| 5502 static int Grow(int number_of_entries) { | 5494 static int Grow(int number_of_entries) { |
| 5503 if (number_of_entries < 5) return number_of_entries + 1; | 5495 if (number_of_entries < 5) return number_of_entries + 1; |
| 5504 return number_of_entries * 5 / 4; | 5496 return number_of_entries * 5 / 4; |
| 5505 } | 5497 } |
| 5506 static const int kCodesStartIndex = kGroupCount; | 5498 inline int flags(); |
| 5499 inline void set_flags(int flags); |
| 5500 class GroupField : public BitField<int, 0, 3> {}; |
| 5501 class CountField : public BitField<int, 3, 27> {}; |
| 5502 STATIC_ASSERT(kGroupCount <= GroupField::kMax + 1); |
| 5503 static const int kNextLinkIndex = 0; |
| 5504 static const int kFlagsIndex = 1; |
| 5505 static const int kCodesStartIndex = 2; |
| 5507 }; | 5506 }; |
| 5508 | 5507 |
| 5509 | 5508 |
| 5510 class PrototypeInfo; | 5509 class PrototypeInfo; |
| 5511 | 5510 |
| 5512 | 5511 |
| 5513 // All heap objects have a Map that describes their structure. | 5512 // All heap objects have a Map that describes their structure. |
| 5514 // A Map contains information about: | 5513 // A Map contains information about: |
| 5515 // - Size information about the object | 5514 // - Size information about the object |
| 5516 // - How to iterate over an object (for garbage collection) | 5515 // - How to iterate over an object (for garbage collection) |
| (...skipping 5271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10788 } | 10787 } |
| 10789 return value; | 10788 return value; |
| 10790 } | 10789 } |
| 10791 }; | 10790 }; |
| 10792 | 10791 |
| 10793 | 10792 |
| 10794 } // NOLINT, false-positive due to second-order macros. | 10793 } // NOLINT, false-positive due to second-order macros. |
| 10795 } // NOLINT, false-positive due to second-order macros. | 10794 } // NOLINT, false-positive due to second-order macros. |
| 10796 | 10795 |
| 10797 #endif // V8_OBJECTS_H_ | 10796 #endif // V8_OBJECTS_H_ |
| OLD | NEW |