| 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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1543 inline void AllocationSite::IncrementMementoCreateCount() { | 1543 inline void AllocationSite::IncrementMementoCreateCount() { |
| 1544 ASSERT(FLAG_allocation_site_pretenuring); | 1544 ASSERT(FLAG_allocation_site_pretenuring); |
| 1545 int value = memento_create_count(); | 1545 int value = memento_create_count(); |
| 1546 set_memento_create_count(value + 1); | 1546 set_memento_create_count(value + 1); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 | 1549 |
| 1550 inline bool AllocationSite::DigestPretenuringFeedback() { | 1550 inline bool AllocationSite::DigestPretenuringFeedback() { |
| 1551 bool decision_changed = false; | 1551 bool decision_changed = false; |
| 1552 int create_count = memento_create_count(); | 1552 int create_count = memento_create_count(); |
| 1553 if (create_count >= kPretenureMinimumCreated) { | 1553 int found_count = memento_found_count(); |
| 1554 int found_count = memento_found_count(); | 1554 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated; |
| 1555 double ratio = static_cast<double>(found_count) / create_count; | 1555 double ratio = |
| 1556 if (FLAG_trace_track_allocation_sites) { | 1556 minimum_mementos_created || FLAG_trace_pretenuring_statistics ? |
| 1557 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n", | 1557 static_cast<double>(found_count) / create_count : 0.0; |
| 1558 static_cast<void*>(this), create_count, found_count, ratio); | 1558 PretenureFlag current_mode = GetPretenureMode(); |
| 1559 } | 1559 |
| 1560 int current_mode = GetPretenureMode(); | 1560 if (minimum_mementos_created) { |
| 1561 PretenureDecision result = ratio >= kPretenureRatio | 1561 PretenureDecision result = ratio >= kPretenureRatio |
| 1562 ? kTenure | 1562 ? kTenure |
| 1563 : kDontTenure; | 1563 : kDontTenure; |
| 1564 set_pretenure_decision(result); | 1564 set_pretenure_decision(result); |
| 1565 if (current_mode != GetPretenureMode()) { | 1565 if (current_mode != GetPretenureMode()) { |
| 1566 decision_changed = true; | 1566 decision_changed = true; |
| 1567 dependent_code()->MarkCodeForDeoptimization( | 1567 dependent_code()->MarkCodeForDeoptimization( |
| 1568 GetIsolate(), | 1568 GetIsolate(), |
| 1569 DependentCode::kAllocationSiteTenuringChangedGroup); | 1569 DependentCode::kAllocationSiteTenuringChangedGroup); |
| 1570 } | 1570 } |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 if (FLAG_trace_pretenuring_statistics) { |
| 1574 PrintF( |
| 1575 "AllocationSite(%p): (created, found, ratio) (%d, %d, %f) %s => %s\n", |
| 1576 static_cast<void*>(this), create_count, found_count, ratio, |
| 1577 current_mode == TENURED ? "tenured" : "not tenured", |
| 1578 GetPretenureMode() == TENURED ? "tenured" : "not tenured"); |
| 1579 } |
| 1580 |
| 1573 // Clear feedback calculation fields until the next gc. | 1581 // Clear feedback calculation fields until the next gc. |
| 1574 set_memento_found_count(0); | 1582 set_memento_found_count(0); |
| 1575 set_memento_create_count(0); | 1583 set_memento_create_count(0); |
| 1576 return decision_changed; | 1584 return decision_changed; |
| 1577 } | 1585 } |
| 1578 | 1586 |
| 1579 | 1587 |
| 1580 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { | 1588 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { |
| 1581 object->ValidateElements(); | 1589 object->ValidateElements(); |
| 1582 ElementsKind elements_kind = object->map()->elements_kind(); | 1590 ElementsKind elements_kind = object->map()->elements_kind(); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 WRITE_FIELD(this, offset, value); | 1969 WRITE_FIELD(this, offset, value); |
| 1962 WRITE_BARRIER(GetHeap(), this, offset, value); | 1970 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 1963 } else { | 1971 } else { |
| 1964 ASSERT(index < properties()->length()); | 1972 ASSERT(index < properties()->length()); |
| 1965 properties()->set(index, value); | 1973 properties()->set(index, value); |
| 1966 } | 1974 } |
| 1967 } | 1975 } |
| 1968 | 1976 |
| 1969 | 1977 |
| 1970 int JSObject::GetInObjectPropertyOffset(int index) { | 1978 int JSObject::GetInObjectPropertyOffset(int index) { |
| 1971 // Adjust for the number of properties stored in the object. | 1979 return map()->GetInObjectPropertyOffset(index); |
| 1972 index -= map()->inobject_properties(); | |
| 1973 ASSERT(index < 0); | |
| 1974 return map()->instance_size() + (index * kPointerSize); | |
| 1975 } | 1980 } |
| 1976 | 1981 |
| 1977 | 1982 |
| 1978 Object* JSObject::InObjectPropertyAt(int index) { | 1983 Object* JSObject::InObjectPropertyAt(int index) { |
| 1979 // Adjust for the number of properties stored in the object. | 1984 int offset = GetInObjectPropertyOffset(index); |
| 1980 index -= map()->inobject_properties(); | |
| 1981 ASSERT(index < 0); | |
| 1982 int offset = map()->instance_size() + (index * kPointerSize); | |
| 1983 return READ_FIELD(this, offset); | 1985 return READ_FIELD(this, offset); |
| 1984 } | 1986 } |
| 1985 | 1987 |
| 1986 | 1988 |
| 1987 Object* JSObject::InObjectPropertyAtPut(int index, | 1989 Object* JSObject::InObjectPropertyAtPut(int index, |
| 1988 Object* value, | 1990 Object* value, |
| 1989 WriteBarrierMode mode) { | 1991 WriteBarrierMode mode) { |
| 1990 // Adjust for the number of properties stored in the object. | 1992 // Adjust for the number of properties stored in the object. |
| 1991 index -= map()->inobject_properties(); | 1993 int offset = GetInObjectPropertyOffset(index); |
| 1992 ASSERT(index < 0); | |
| 1993 int offset = map()->instance_size() + (index * kPointerSize); | |
| 1994 WRITE_FIELD(this, offset, value); | 1994 WRITE_FIELD(this, offset, value); |
| 1995 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); | 1995 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); |
| 1996 return value; | 1996 return value; |
| 1997 } | 1997 } |
| 1998 | 1998 |
| 1999 | 1999 |
| 2000 | 2000 |
| 2001 void JSObject::InitializeBody(Map* map, | 2001 void JSObject::InitializeBody(Map* map, |
| 2002 Object* pre_allocated_value, | 2002 Object* pre_allocated_value, |
| 2003 Object* filler_value) { | 2003 Object* filler_value) { |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3194 void ExternalAsciiString::update_data_cache() { | 3194 void ExternalAsciiString::update_data_cache() { |
| 3195 if (is_short()) return; | 3195 if (is_short()) return; |
| 3196 const char** data_field = | 3196 const char** data_field = |
| 3197 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); | 3197 reinterpret_cast<const char**>(FIELD_ADDR(this, kResourceDataOffset)); |
| 3198 *data_field = resource()->data(); | 3198 *data_field = resource()->data(); |
| 3199 } | 3199 } |
| 3200 | 3200 |
| 3201 | 3201 |
| 3202 void ExternalAsciiString::set_resource( | 3202 void ExternalAsciiString::set_resource( |
| 3203 const ExternalAsciiString::Resource* resource) { | 3203 const ExternalAsciiString::Resource* resource) { |
| 3204 ASSERT(IsAligned(reinterpret_cast<intptr_t>(resource), kPointerSize)); |
| 3204 *reinterpret_cast<const Resource**>( | 3205 *reinterpret_cast<const Resource**>( |
| 3205 FIELD_ADDR(this, kResourceOffset)) = resource; | 3206 FIELD_ADDR(this, kResourceOffset)) = resource; |
| 3206 if (resource != NULL) update_data_cache(); | 3207 if (resource != NULL) update_data_cache(); |
| 3207 } | 3208 } |
| 3208 | 3209 |
| 3209 | 3210 |
| 3210 const uint8_t* ExternalAsciiString::GetChars() { | 3211 const uint8_t* ExternalAsciiString::GetChars() { |
| 3211 return reinterpret_cast<const uint8_t*>(resource()->data()); | 3212 return reinterpret_cast<const uint8_t*>(resource()->data()); |
| 3212 } | 3213 } |
| 3213 | 3214 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3801 int Map::inobject_properties() { | 3802 int Map::inobject_properties() { |
| 3802 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); | 3803 return READ_BYTE_FIELD(this, kInObjectPropertiesOffset); |
| 3803 } | 3804 } |
| 3804 | 3805 |
| 3805 | 3806 |
| 3806 int Map::pre_allocated_property_fields() { | 3807 int Map::pre_allocated_property_fields() { |
| 3807 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); | 3808 return READ_BYTE_FIELD(this, kPreAllocatedPropertyFieldsOffset); |
| 3808 } | 3809 } |
| 3809 | 3810 |
| 3810 | 3811 |
| 3812 int Map::GetInObjectPropertyOffset(int index) { |
| 3813 // Adjust for the number of properties stored in the object. |
| 3814 index -= inobject_properties(); |
| 3815 ASSERT(index < 0); |
| 3816 return instance_size() + (index * kPointerSize); |
| 3817 } |
| 3818 |
| 3819 |
| 3811 int HeapObject::SizeFromMap(Map* map) { | 3820 int HeapObject::SizeFromMap(Map* map) { |
| 3812 int instance_size = map->instance_size(); | 3821 int instance_size = map->instance_size(); |
| 3813 if (instance_size != kVariableSizeSentinel) return instance_size; | 3822 if (instance_size != kVariableSizeSentinel) return instance_size; |
| 3814 // Only inline the most frequent cases. | 3823 // Only inline the most frequent cases. |
| 3815 int instance_type = static_cast<int>(map->instance_type()); | 3824 int instance_type = static_cast<int>(map->instance_type()); |
| 3816 if (instance_type == FIXED_ARRAY_TYPE) { | 3825 if (instance_type == FIXED_ARRAY_TYPE) { |
| 3817 return FixedArray::BodyDescriptor::SizeOf(map, this); | 3826 return FixedArray::BodyDescriptor::SizeOf(map, this); |
| 3818 } | 3827 } |
| 3819 if (instance_type == ASCII_STRING_TYPE || | 3828 if (instance_type == ASCII_STRING_TYPE || |
| 3820 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { | 3829 instance_type == ASCII_INTERNALIZED_STRING_TYPE) { |
| (...skipping 2960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6781 #undef READ_UINT32_FIELD | 6790 #undef READ_UINT32_FIELD |
| 6782 #undef WRITE_UINT32_FIELD | 6791 #undef WRITE_UINT32_FIELD |
| 6783 #undef READ_SHORT_FIELD | 6792 #undef READ_SHORT_FIELD |
| 6784 #undef WRITE_SHORT_FIELD | 6793 #undef WRITE_SHORT_FIELD |
| 6785 #undef READ_BYTE_FIELD | 6794 #undef READ_BYTE_FIELD |
| 6786 #undef WRITE_BYTE_FIELD | 6795 #undef WRITE_BYTE_FIELD |
| 6787 | 6796 |
| 6788 } } // namespace v8::internal | 6797 } } // namespace v8::internal |
| 6789 | 6798 |
| 6790 #endif // V8_OBJECTS_INL_H_ | 6799 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |