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 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 } | 1570 } |
1571 | 1571 |
1572 | 1572 |
1573 inline void AllocationSite::IncrementMementoCreateCount() { | 1573 inline void AllocationSite::IncrementMementoCreateCount() { |
1574 ASSERT(FLAG_allocation_site_pretenuring); | 1574 ASSERT(FLAG_allocation_site_pretenuring); |
1575 int value = memento_create_count(); | 1575 int value = memento_create_count(); |
1576 set_memento_create_count(value + 1); | 1576 set_memento_create_count(value + 1); |
1577 } | 1577 } |
1578 | 1578 |
1579 | 1579 |
1580 inline bool AllocationSite::MakePretenuringDecision(double ratio) { | |
1581 // Currently we just need to deopt when we make a state transition to tenure. | |
1582 if (ratio >= kPretenureRatio) { | |
1583 // We just transition into tenure state when the semi-space was at | |
1584 // maximum capacity. | |
1585 Heap* heap = GetHeap(); | |
1586 if (heap->changed_to_max_semi_space_size() && | |
mvstanton
2014/06/02 13:31:25
Since the allocation sites are processed in bulk,
Hannes Payer (out of office)
2014/06/02 14:56:52
Done.
| |
1587 heap->new_space()->IsAtMaximumCapacity()) { | |
1588 set_deopt_dependent_code(true); | |
1589 set_pretenure_decision(kTenure); | |
1590 return true; | |
1591 } | |
1592 set_pretenure_decision(kMaybeTenure); | |
1593 } else { | |
1594 set_pretenure_decision(kDontTenure); | |
1595 } | |
1596 return false; | |
1597 } | |
1598 | |
1599 | |
1580 inline bool AllocationSite::DigestPretenuringFeedback() { | 1600 inline bool AllocationSite::DigestPretenuringFeedback() { |
1581 bool decision_changed = false; | 1601 bool deopt = false; |
1582 int create_count = memento_create_count(); | 1602 int create_count = memento_create_count(); |
1583 int found_count = memento_found_count(); | 1603 int found_count = memento_found_count(); |
1584 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated; | 1604 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated; |
1585 double ratio = | 1605 double ratio = |
1586 minimum_mementos_created || FLAG_trace_pretenuring_statistics ? | 1606 minimum_mementos_created || FLAG_trace_pretenuring_statistics ? |
1587 static_cast<double>(found_count) / create_count : 0.0; | 1607 static_cast<double>(found_count) / create_count : 0.0; |
1588 PretenureFlag current_mode = GetPretenureMode(); | 1608 PretenureDecision current_decision = pretenure_decision(); |
1589 | 1609 |
1590 // TODO(hpayer): Add an intermediate state MAYBE_TENURE which collects | 1610 // Here we just allow state transitions from undecided or maybe tenure |
1591 // more lifetime feedback for tenuring candidates. In the meantime, we | 1611 // to don't tenure, maybe tenure, or tenure. |
1592 // just allow transitions from undecided to tenured or not tenured. | 1612 if (minimum_mementos_created) { |
1593 if (minimum_mementos_created && pretenure_decision() == kUndecided) { | 1613 if ((current_decision == kUndecided || current_decision == kMaybeTenure)) { |
1594 PretenureDecision result = ratio >= kPretenureRatio | 1614 deopt = MakePretenuringDecision(ratio); |
1595 ? kTenure | |
1596 : kDontTenure; | |
1597 set_pretenure_decision(result); | |
1598 if (current_mode != GetPretenureMode()) { | |
1599 decision_changed = true; | |
1600 set_deopt_dependent_code(true); | |
1601 } | 1615 } |
1602 } | 1616 } |
1603 | 1617 |
1604 if (FLAG_trace_pretenuring_statistics) { | 1618 if (FLAG_trace_pretenuring_statistics) { |
1605 PrintF( | 1619 PrintF( |
1606 "AllocationSite(%p): (created, found, ratio) (%d, %d, %f) %s => %s\n", | 1620 "AllocationSite(%p): (created, found, ratio) (%d, %d, %f) %s => %s\n", |
1607 static_cast<void*>(this), create_count, found_count, ratio, | 1621 static_cast<void*>(this), create_count, found_count, ratio, |
1608 current_mode == TENURED ? "tenured" : "not tenured", | 1622 PretenureDecisionName(current_decision), |
1609 GetPretenureMode() == TENURED ? "tenured" : "not tenured"); | 1623 PretenureDecisionName(pretenure_decision())); |
1610 } | 1624 } |
1611 | 1625 |
1612 // Clear feedback calculation fields until the next gc. | 1626 // Clear feedback calculation fields until the next gc. |
1613 set_memento_found_count(0); | 1627 set_memento_found_count(0); |
1614 set_memento_create_count(0); | 1628 set_memento_create_count(0); |
1615 return decision_changed; | 1629 return deopt; |
1616 } | 1630 } |
1617 | 1631 |
1618 | 1632 |
1619 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { | 1633 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { |
1620 JSObject::ValidateElements(object); | 1634 JSObject::ValidateElements(object); |
1621 ElementsKind elements_kind = object->map()->elements_kind(); | 1635 ElementsKind elements_kind = object->map()->elements_kind(); |
1622 if (!IsFastObjectElementsKind(elements_kind)) { | 1636 if (!IsFastObjectElementsKind(elements_kind)) { |
1623 if (IsFastHoleyElementsKind(elements_kind)) { | 1637 if (IsFastHoleyElementsKind(elements_kind)) { |
1624 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); | 1638 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); |
1625 } else { | 1639 } else { |
(...skipping 5243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6869 #undef READ_SHORT_FIELD | 6883 #undef READ_SHORT_FIELD |
6870 #undef WRITE_SHORT_FIELD | 6884 #undef WRITE_SHORT_FIELD |
6871 #undef READ_BYTE_FIELD | 6885 #undef READ_BYTE_FIELD |
6872 #undef WRITE_BYTE_FIELD | 6886 #undef WRITE_BYTE_FIELD |
6873 #undef NOBARRIER_READ_BYTE_FIELD | 6887 #undef NOBARRIER_READ_BYTE_FIELD |
6874 #undef NOBARRIER_WRITE_BYTE_FIELD | 6888 #undef NOBARRIER_WRITE_BYTE_FIELD |
6875 | 6889 |
6876 } } // namespace v8::internal | 6890 } } // namespace v8::internal |
6877 | 6891 |
6878 #endif // V8_OBJECTS_INL_H_ | 6892 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |