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 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 SetElementsKind(GetInitialFastElementsKind()); | 1315 SetElementsKind(GetInitialFastElementsKind()); |
1316 set_nested_site(Smi::FromInt(0)); | 1316 set_nested_site(Smi::FromInt(0)); |
1317 set_memento_create_count(Smi::FromInt(0)); | 1317 set_memento_create_count(Smi::FromInt(0)); |
1318 set_memento_found_count(Smi::FromInt(0)); | 1318 set_memento_found_count(Smi::FromInt(0)); |
1319 set_pretenure_decision(Smi::FromInt(0)); | 1319 set_pretenure_decision(Smi::FromInt(0)); |
1320 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), | 1320 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
1321 SKIP_WRITE_BARRIER); | 1321 SKIP_WRITE_BARRIER); |
1322 } | 1322 } |
1323 | 1323 |
1324 | 1324 |
| 1325 void AllocationSite::MarkZombie() { |
| 1326 ASSERT(!IsZombie()); |
| 1327 set_pretenure_decision(Smi::FromInt(kZombie)); |
| 1328 // Clear all non-smi fields |
| 1329 set_transition_info(Smi::FromInt(0)); |
| 1330 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), |
| 1331 SKIP_WRITE_BARRIER); |
| 1332 } |
| 1333 |
| 1334 |
1325 // Heuristic: We only need to create allocation site info if the boilerplate | 1335 // Heuristic: We only need to create allocation site info if the boilerplate |
1326 // elements kind is the initial elements kind. | 1336 // elements kind is the initial elements kind. |
1327 AllocationSiteMode AllocationSite::GetMode( | 1337 AllocationSiteMode AllocationSite::GetMode( |
1328 ElementsKind boilerplate_elements_kind) { | 1338 ElementsKind boilerplate_elements_kind) { |
1329 if (FLAG_track_allocation_sites && | 1339 if (FLAG_track_allocation_sites && |
1330 IsFastSmiElementsKind(boilerplate_elements_kind)) { | 1340 IsFastSmiElementsKind(boilerplate_elements_kind)) { |
1331 return TRACK_ALLOCATION_SITE; | 1341 return TRACK_ALLOCATION_SITE; |
1332 } | 1342 } |
1333 | 1343 |
1334 return DONT_TRACK_ALLOCATION_SITE; | 1344 return DONT_TRACK_ALLOCATION_SITE; |
1335 } | 1345 } |
1336 | 1346 |
1337 | 1347 |
1338 AllocationSiteMode AllocationSite::GetMode(ElementsKind from, | 1348 AllocationSiteMode AllocationSite::GetMode(ElementsKind from, |
1339 ElementsKind to) { | 1349 ElementsKind to) { |
1340 if (FLAG_track_allocation_sites && | 1350 if (FLAG_track_allocation_sites && |
1341 IsFastSmiElementsKind(from) && | 1351 IsFastSmiElementsKind(from) && |
1342 IsMoreGeneralElementsKindTransition(from, to)) { | 1352 IsMoreGeneralElementsKindTransition(from, to)) { |
1343 return TRACK_ALLOCATION_SITE; | 1353 return TRACK_ALLOCATION_SITE; |
1344 } | 1354 } |
1345 | 1355 |
1346 return DONT_TRACK_ALLOCATION_SITE; | 1356 return DONT_TRACK_ALLOCATION_SITE; |
1347 } | 1357 } |
1348 | 1358 |
1349 | 1359 |
1350 inline bool AllocationSite::CanTrack(InstanceType type) { | 1360 inline bool AllocationSite::CanTrack(InstanceType type) { |
| 1361 if (FLAG_allocation_site_pretenuring) { |
| 1362 return type == JS_ARRAY_TYPE || type == JS_OBJECT_TYPE; |
| 1363 } |
1351 return type == JS_ARRAY_TYPE; | 1364 return type == JS_ARRAY_TYPE; |
1352 } | 1365 } |
1353 | 1366 |
1354 | 1367 |
1355 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup( | 1368 inline DependentCode::DependencyGroup AllocationSite::ToDependencyGroup( |
1356 Reason reason) { | 1369 Reason reason) { |
1357 switch (reason) { | 1370 switch (reason) { |
1358 case TENURING: | 1371 case TENURING: |
1359 return DependentCode::kAllocationSiteTenuringChangedGroup; | 1372 return DependentCode::kAllocationSiteTenuringChangedGroup; |
1360 break; | 1373 break; |
1361 case TRANSITIONS: | 1374 case TRANSITIONS: |
1362 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1375 return DependentCode::kAllocationSiteTransitionChangedGroup; |
1363 break; | 1376 break; |
1364 } | 1377 } |
1365 UNREACHABLE(); | 1378 UNREACHABLE(); |
1366 return DependentCode::kAllocationSiteTransitionChangedGroup; | 1379 return DependentCode::kAllocationSiteTransitionChangedGroup; |
1367 } | 1380 } |
1368 | 1381 |
1369 | 1382 |
| 1383 inline void AllocationSite::IncrementMementoFoundCount() { |
| 1384 int value = memento_found_count()->value(); |
| 1385 set_memento_found_count(Smi::FromInt(value + 1)); |
| 1386 } |
| 1387 |
| 1388 |
| 1389 inline void AllocationSite::IncrementMementoCreateCount() { |
| 1390 ASSERT(FLAG_allocation_site_pretenuring); |
| 1391 int value = memento_create_count()->value(); |
| 1392 set_memento_create_count(Smi::FromInt(value + 1)); |
| 1393 } |
| 1394 |
| 1395 |
| 1396 inline bool AllocationSite::DigestPretenuringFeedback() { |
| 1397 bool decision_made = false; |
| 1398 if (!PretenuringDecisionMade()) { |
| 1399 int create_count = memento_create_count()->value(); |
| 1400 if (create_count >= kPretenureMinimumCreated) { |
| 1401 int found_count = memento_found_count()->value(); |
| 1402 double ratio = static_cast<double>(found_count) / create_count; |
| 1403 if (FLAG_trace_track_allocation_sites) { |
| 1404 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n", |
| 1405 static_cast<void*>(this), create_count, found_count, ratio); |
| 1406 } |
| 1407 int result = ratio >= kPretenureRatio ? kTenure : kDontTenure; |
| 1408 set_pretenure_decision(Smi::FromInt(result)); |
| 1409 decision_made = true; |
| 1410 // TODO(mvstanton): if the decision represents a change, any dependent |
| 1411 // code registered for pretenuring changes should be deopted. |
| 1412 } |
| 1413 } |
| 1414 |
| 1415 // Clear feedback calculation fields until the next gc. |
| 1416 set_memento_found_count(Smi::FromInt(0)); |
| 1417 set_memento_create_count(Smi::FromInt(0)); |
| 1418 return decision_made; |
| 1419 } |
| 1420 |
| 1421 |
1370 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { | 1422 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { |
1371 object->ValidateElements(); | 1423 object->ValidateElements(); |
1372 ElementsKind elements_kind = object->map()->elements_kind(); | 1424 ElementsKind elements_kind = object->map()->elements_kind(); |
1373 if (!IsFastObjectElementsKind(elements_kind)) { | 1425 if (!IsFastObjectElementsKind(elements_kind)) { |
1374 if (IsFastHoleyElementsKind(elements_kind)) { | 1426 if (IsFastHoleyElementsKind(elements_kind)) { |
1375 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); | 1427 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); |
1376 } else { | 1428 } else { |
1377 TransitionElementsKind(object, FAST_ELEMENTS); | 1429 TransitionElementsKind(object, FAST_ELEMENTS); |
1378 } | 1430 } |
1379 } | 1431 } |
(...skipping 5034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6414 #undef WRITE_UINT32_FIELD | 6466 #undef WRITE_UINT32_FIELD |
6415 #undef READ_SHORT_FIELD | 6467 #undef READ_SHORT_FIELD |
6416 #undef WRITE_SHORT_FIELD | 6468 #undef WRITE_SHORT_FIELD |
6417 #undef READ_BYTE_FIELD | 6469 #undef READ_BYTE_FIELD |
6418 #undef WRITE_BYTE_FIELD | 6470 #undef WRITE_BYTE_FIELD |
6419 | 6471 |
6420 | 6472 |
6421 } } // namespace v8::internal | 6473 } } // namespace v8::internal |
6422 | 6474 |
6423 #endif // V8_OBJECTS_INL_H_ | 6475 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |