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::ShouldPretenure() { | |
1397 ASSERT(FLAG_allocation_site_pretenuring); | |
1398 int create_count = memento_create_count()->value(); | |
1399 int found_count = memento_found_count()->value(); | |
1400 double ratio = create_count > 0 | |
Hannes Payer (out of office)
2013/11/21 20:52:24
We have to guard against the case where we just st
mvstanton
2013/11/22 11:18:51
Good advice. Done.
| |
1401 ? static_cast<double>(found_count) / create_count | |
1402 : 0.0; | |
1403 if (FLAG_trace_track_allocation_sites) { | |
1404 PrintF("(%d, %d) ratio = %f\n", create_count, found_count, ratio); | |
1405 } | |
1406 return ratio >= 0.60; | |
Hannes Payer (out of office)
2013/11/21 20:52:24
This should be a constant in allocation site calle
mvstanton
2013/11/22 11:18:51
Done. Awkwardly, it must be initialized in objects
| |
1407 } | |
1408 | |
1409 | |
1370 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { | 1410 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { |
1371 object->ValidateElements(); | 1411 object->ValidateElements(); |
1372 ElementsKind elements_kind = object->map()->elements_kind(); | 1412 ElementsKind elements_kind = object->map()->elements_kind(); |
1373 if (!IsFastObjectElementsKind(elements_kind)) { | 1413 if (!IsFastObjectElementsKind(elements_kind)) { |
1374 if (IsFastHoleyElementsKind(elements_kind)) { | 1414 if (IsFastHoleyElementsKind(elements_kind)) { |
1375 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); | 1415 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); |
1376 } else { | 1416 } else { |
1377 TransitionElementsKind(object, FAST_ELEMENTS); | 1417 TransitionElementsKind(object, FAST_ELEMENTS); |
1378 } | 1418 } |
1379 } | 1419 } |
(...skipping 5038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6418 #undef WRITE_UINT32_FIELD | 6458 #undef WRITE_UINT32_FIELD |
6419 #undef READ_SHORT_FIELD | 6459 #undef READ_SHORT_FIELD |
6420 #undef WRITE_SHORT_FIELD | 6460 #undef WRITE_SHORT_FIELD |
6421 #undef READ_BYTE_FIELD | 6461 #undef READ_BYTE_FIELD |
6422 #undef WRITE_BYTE_FIELD | 6462 #undef WRITE_BYTE_FIELD |
6423 | 6463 |
6424 | 6464 |
6425 } } // namespace v8::internal | 6465 } } // namespace v8::internal |
6426 | 6466 |
6427 #endif // V8_OBJECTS_INL_H_ | 6467 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |