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 30 matching lines...) Expand all Loading... |
41 #include "conversions-inl.h" | 41 #include "conversions-inl.h" |
42 #include "heap.h" | 42 #include "heap.h" |
43 #include "isolate.h" | 43 #include "isolate.h" |
44 #include "property.h" | 44 #include "property.h" |
45 #include "spaces.h" | 45 #include "spaces.h" |
46 #include "store-buffer.h" | 46 #include "store-buffer.h" |
47 #include "v8memory.h" | 47 #include "v8memory.h" |
48 #include "factory.h" | 48 #include "factory.h" |
49 #include "incremental-marking.h" | 49 #include "incremental-marking.h" |
50 #include "transitions-inl.h" | 50 #include "transitions-inl.h" |
| 51 #include "objects-visiting.h" |
51 | 52 |
52 namespace v8 { | 53 namespace v8 { |
53 namespace internal { | 54 namespace internal { |
54 | 55 |
55 PropertyDetails::PropertyDetails(Smi* smi) { | 56 PropertyDetails::PropertyDetails(Smi* smi) { |
56 value_ = smi->value(); | 57 value_ = smi->value(); |
57 } | 58 } |
58 | 59 |
59 | 60 |
60 Smi* PropertyDetails::AsSmi() { | 61 Smi* PropertyDetails::AsSmi() { |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 accessor->Validate(this); | 1298 accessor->Validate(this); |
1298 } | 1299 } |
1299 #endif | 1300 #endif |
1300 } | 1301 } |
1301 | 1302 |
1302 | 1303 |
1303 void AllocationSite::Initialize() { | 1304 void AllocationSite::Initialize() { |
1304 set_transition_info(Smi::FromInt(0)); | 1305 set_transition_info(Smi::FromInt(0)); |
1305 SetElementsKind(GetInitialFastElementsKind()); | 1306 SetElementsKind(GetInitialFastElementsKind()); |
1306 set_nested_site(Smi::FromInt(0)); | 1307 set_nested_site(Smi::FromInt(0)); |
1307 set_memento_create_count(Smi::FromInt(0)); | 1308 set_pretenure_data(Smi::FromInt(0)); |
1308 set_memento_found_count(Smi::FromInt(0)); | 1309 set_pretenure_create_count(Smi::FromInt(0)); |
1309 set_pretenure_decision(Smi::FromInt(0)); | |
1310 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1310 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
1311 SKIP_WRITE_BARRIER); | 1311 SKIP_WRITE_BARRIER); |
1312 } | 1312 } |
1313 | 1313 |
1314 | 1314 |
1315 void AllocationSite::MarkZombie() { | 1315 void AllocationSite::MarkZombie() { |
1316 ASSERT(!IsZombie()); | 1316 ASSERT(!IsZombie()); |
1317 Initialize(); | 1317 Initialize(); |
1318 set_pretenure_decision(Smi::FromInt(kZombie)); | 1318 set_pretenure_decision(kZombie); |
1319 } | 1319 } |
1320 | 1320 |
1321 | 1321 |
1322 // Heuristic: We only need to create allocation site info if the boilerplate | 1322 // Heuristic: We only need to create allocation site info if the boilerplate |
1323 // elements kind is the initial elements kind. | 1323 // elements kind is the initial elements kind. |
1324 AllocationSiteMode AllocationSite::GetMode( | 1324 AllocationSiteMode AllocationSite::GetMode( |
1325 ElementsKind boilerplate_elements_kind) { | 1325 ElementsKind boilerplate_elements_kind) { |
1326 if (IsFastSmiElementsKind(boilerplate_elements_kind)) { | 1326 if (IsFastSmiElementsKind(boilerplate_elements_kind)) { |
1327 return TRACK_ALLOCATION_SITE; | 1327 return TRACK_ALLOCATION_SITE; |
1328 } | 1328 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 break; | 1360 break; |
1361 case TRANSITIONS: | 1361 case TRANSITIONS: |
1362 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1362 return DependentCode::kAllocationSiteTransitionChangedGroup; |
1363 break; | 1363 break; |
1364 } | 1364 } |
1365 UNREACHABLE(); | 1365 UNREACHABLE(); |
1366 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1366 return DependentCode::kAllocationSiteTransitionChangedGroup; |
1367 } | 1367 } |
1368 | 1368 |
1369 | 1369 |
| 1370 inline void AllocationSite::set_memento_found_count(int count) { |
| 1371 int value = pretenure_data()->value(); |
| 1372 // Verify that we can count more mementos than we can possibly find in one |
| 1373 // new space collection. |
| 1374 ASSERT((GetHeap()->MaxSemiSpaceSize() / |
| 1375 (StaticVisitorBase::kMinObjectSizeInWords * kPointerSize + |
| 1376 AllocationMemento::kSize)) < MementoFoundCountBits::kMax); |
| 1377 ASSERT(count < MementoFoundCountBits::kMax); |
| 1378 set_pretenure_data( |
| 1379 Smi::FromInt(MementoFoundCountBits::update(value, count)), |
| 1380 SKIP_WRITE_BARRIER); |
| 1381 } |
| 1382 |
1370 inline bool AllocationSite::IncrementMementoFoundCount() { | 1383 inline bool AllocationSite::IncrementMementoFoundCount() { |
1371 if (IsZombie()) return false; | 1384 if (IsZombie()) return false; |
1372 | 1385 |
1373 int value = memento_found_count()->value(); | 1386 int value = memento_found_count(); |
1374 set_memento_found_count(Smi::FromInt(value + 1)); | 1387 set_memento_found_count(value + 1); |
1375 return value == 0; | 1388 return value == 0; |
1376 } | 1389 } |
1377 | 1390 |
1378 | 1391 |
1379 inline void AllocationSite::IncrementMementoCreateCount() { | 1392 inline void AllocationSite::IncrementMementoCreateCount() { |
1380 ASSERT(FLAG_allocation_site_pretenuring); | 1393 ASSERT(FLAG_allocation_site_pretenuring); |
1381 int value = memento_create_count()->value(); | 1394 int value = memento_create_count(); |
1382 set_memento_create_count(Smi::FromInt(value + 1)); | 1395 set_memento_create_count(value + 1); |
1383 } | 1396 } |
1384 | 1397 |
1385 | 1398 |
1386 inline bool AllocationSite::DigestPretenuringFeedback() { | 1399 inline bool AllocationSite::DigestPretenuringFeedback() { |
1387 bool decision_made = false; | 1400 bool decision_made = false; |
1388 int create_count = memento_create_count()->value(); | 1401 int create_count = memento_create_count(); |
1389 if (create_count >= kPretenureMinimumCreated) { | 1402 if (create_count >= kPretenureMinimumCreated) { |
1390 int found_count = memento_found_count()->value(); | 1403 int found_count = memento_found_count(); |
1391 double ratio = static_cast<double>(found_count) / create_count; | 1404 double ratio = static_cast<double>(found_count) / create_count; |
1392 if (FLAG_trace_track_allocation_sites) { | 1405 if (FLAG_trace_track_allocation_sites) { |
1393 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n", | 1406 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n", |
1394 static_cast<void*>(this), create_count, found_count, ratio); | 1407 static_cast<void*>(this), create_count, found_count, ratio); |
1395 } | 1408 } |
1396 int current_mode = GetPretenureMode(); | 1409 int current_mode = GetPretenureMode(); |
1397 int result = ratio >= kPretenureRatio ? kTenure : kDontTenure; | 1410 PretenureDecision result = ratio >= kPretenureRatio |
1398 set_pretenure_decision(Smi::FromInt(result)); | 1411 ? kTenure |
| 1412 : kDontTenure; |
| 1413 set_pretenure_decision(result); |
1399 decision_made = true; | 1414 decision_made = true; |
1400 if (current_mode != GetPretenureMode()) { | 1415 if (current_mode != GetPretenureMode()) { |
1401 dependent_code()->DeoptimizeDependentCodeGroup( | 1416 dependent_code()->DeoptimizeDependentCodeGroup( |
1402 GetIsolate(), | 1417 GetIsolate(), |
1403 DependentCode::kAllocationSiteTenuringChangedGroup); | 1418 DependentCode::kAllocationSiteTenuringChangedGroup); |
1404 } | 1419 } |
1405 } | 1420 } |
1406 | 1421 |
1407 // Clear feedback calculation fields until the next gc. | 1422 // Clear feedback calculation fields until the next gc. |
1408 set_memento_found_count(Smi::FromInt(0)); | 1423 set_memento_found_count(0); |
1409 set_memento_create_count(Smi::FromInt(0)); | 1424 set_memento_create_count(0); |
1410 return decision_made; | 1425 return decision_made; |
1411 } | 1426 } |
1412 | 1427 |
1413 | 1428 |
1414 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { | 1429 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { |
1415 object->ValidateElements(); | 1430 object->ValidateElements(); |
1416 ElementsKind elements_kind = object->map()->elements_kind(); | 1431 ElementsKind elements_kind = object->map()->elements_kind(); |
1417 if (!IsFastObjectElementsKind(elements_kind)) { | 1432 if (!IsFastObjectElementsKind(elements_kind)) { |
1418 if (IsFastHoleyElementsKind(elements_kind)) { | 1433 if (IsFastHoleyElementsKind(elements_kind)) { |
1419 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); | 1434 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); |
(...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4593 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, | 4608 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, |
4594 kInternalFieldCountOffset) | 4609 kInternalFieldCountOffset) |
4595 | 4610 |
4596 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) | 4611 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) |
4597 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) | 4612 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) |
4598 | 4613 |
4599 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) | 4614 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) |
4600 | 4615 |
4601 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) | 4616 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) |
4602 ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset) | 4617 ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset) |
4603 ACCESSORS_TO_SMI(AllocationSite, memento_found_count, kMementoFoundCountOffset) | 4618 ACCESSORS_TO_SMI(AllocationSite, pretenure_data, kPretenureDataOffset) |
4604 ACCESSORS_TO_SMI(AllocationSite, memento_create_count, | 4619 ACCESSORS_TO_SMI(AllocationSite, pretenure_create_count, |
4605 kMementoCreateCountOffset) | 4620 kPretenureCreateCountOffset) |
4606 ACCESSORS_TO_SMI(AllocationSite, pretenure_decision, kPretenureDecisionOffset) | |
4607 ACCESSORS(AllocationSite, dependent_code, DependentCode, | 4621 ACCESSORS(AllocationSite, dependent_code, DependentCode, |
4608 kDependentCodeOffset) | 4622 kDependentCodeOffset) |
4609 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) | 4623 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) |
4610 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) | 4624 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) |
4611 | 4625 |
4612 ACCESSORS(Script, source, Object, kSourceOffset) | 4626 ACCESSORS(Script, source, Object, kSourceOffset) |
4613 ACCESSORS(Script, name, Object, kNameOffset) | 4627 ACCESSORS(Script, name, Object, kNameOffset) |
4614 ACCESSORS(Script, id, Smi, kIdOffset) | 4628 ACCESSORS(Script, id, Smi, kIdOffset) |
4615 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) | 4629 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) |
4616 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) | 4630 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) |
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6477 #undef WRITE_UINT32_FIELD | 6491 #undef WRITE_UINT32_FIELD |
6478 #undef READ_SHORT_FIELD | 6492 #undef READ_SHORT_FIELD |
6479 #undef WRITE_SHORT_FIELD | 6493 #undef WRITE_SHORT_FIELD |
6480 #undef READ_BYTE_FIELD | 6494 #undef READ_BYTE_FIELD |
6481 #undef WRITE_BYTE_FIELD | 6495 #undef WRITE_BYTE_FIELD |
6482 | 6496 |
6483 | 6497 |
6484 } } // namespace v8::internal | 6498 } } // namespace v8::internal |
6485 | 6499 |
6486 #endif // V8_OBJECTS_INL_H_ | 6500 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |