| 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 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3830 // Only allow uninitialized or debugger states for non-IC code | 3882 // Only allow uninitialized or debugger states for non-IC code |
| 3831 // objects. This is used in the debugger to determine whether or not | 3883 // objects. This is used in the debugger to determine whether or not |
| 3832 // a call to code object has been replaced with a debug break call. | 3884 // a call to code object has been replaced with a debug break call. |
| 3833 ASSERT(is_inline_cache_stub() || | 3885 ASSERT(is_inline_cache_stub() || |
| 3834 result == UNINITIALIZED || | 3886 result == UNINITIALIZED || |
| 3835 result == DEBUG_STUB); | 3887 result == DEBUG_STUB); |
| 3836 return result; | 3888 return result; |
| 3837 } | 3889 } |
| 3838 | 3890 |
| 3839 | 3891 |
| 3840 Code::ExtraICState Code::extra_ic_state() { | 3892 ExtraICState Code::extra_ic_state() { |
| 3841 ASSERT((is_inline_cache_stub() && !needs_extended_extra_ic_state(kind())) | 3893 ASSERT((is_inline_cache_stub() && !needs_extended_extra_ic_state(kind())) |
| 3842 || ic_state() == DEBUG_STUB); | 3894 || ic_state() == DEBUG_STUB); |
| 3843 return ExtractExtraICStateFromFlags(flags()); | 3895 return ExtractExtraICStateFromFlags(flags()); |
| 3844 } | 3896 } |
| 3845 | 3897 |
| 3846 | 3898 |
| 3847 Code::ExtraICState Code::extended_extra_ic_state() { | 3899 ExtraICState Code::extended_extra_ic_state() { |
| 3848 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); | 3900 ASSERT(is_inline_cache_stub() || ic_state() == DEBUG_STUB); |
| 3849 ASSERT(needs_extended_extra_ic_state(kind())); | 3901 ASSERT(needs_extended_extra_ic_state(kind())); |
| 3850 return ExtractExtendedExtraICStateFromFlags(flags()); | 3902 return ExtractExtendedExtraICStateFromFlags(flags()); |
| 3851 } | 3903 } |
| 3852 | 3904 |
| 3853 | 3905 |
| 3854 Code::StubType Code::type() { | 3906 Code::StubType Code::type() { |
| 3855 return ExtractTypeFromFlags(flags()); | 3907 return ExtractTypeFromFlags(flags()); |
| 3856 } | 3908 } |
| 3857 | 3909 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4174 Code::Kind Code::ExtractKindFromFlags(Flags flags) { | 4226 Code::Kind Code::ExtractKindFromFlags(Flags flags) { |
| 4175 return KindField::decode(flags); | 4227 return KindField::decode(flags); |
| 4176 } | 4228 } |
| 4177 | 4229 |
| 4178 | 4230 |
| 4179 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { | 4231 InlineCacheState Code::ExtractICStateFromFlags(Flags flags) { |
| 4180 return ICStateField::decode(flags); | 4232 return ICStateField::decode(flags); |
| 4181 } | 4233 } |
| 4182 | 4234 |
| 4183 | 4235 |
| 4184 Code::ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { | 4236 ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { |
| 4185 return ExtraICStateField::decode(flags); | 4237 return ExtraICStateField::decode(flags); |
| 4186 } | 4238 } |
| 4187 | 4239 |
| 4188 | 4240 |
| 4189 Code::ExtraICState Code::ExtractExtendedExtraICStateFromFlags( | 4241 ExtraICState Code::ExtractExtendedExtraICStateFromFlags( |
| 4190 Flags flags) { | 4242 Flags flags) { |
| 4191 return ExtendedExtraICStateField::decode(flags); | 4243 return ExtendedExtraICStateField::decode(flags); |
| 4192 } | 4244 } |
| 4193 | 4245 |
| 4194 | 4246 |
| 4195 Code::StubType Code::ExtractTypeFromFlags(Flags flags) { | 4247 Code::StubType Code::ExtractTypeFromFlags(Flags flags) { |
| 4196 return TypeField::decode(flags); | 4248 return TypeField::decode(flags); |
| 4197 } | 4249 } |
| 4198 | 4250 |
| 4199 | 4251 |
| (...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6424 #undef WRITE_UINT32_FIELD | 6476 #undef WRITE_UINT32_FIELD |
| 6425 #undef READ_SHORT_FIELD | 6477 #undef READ_SHORT_FIELD |
| 6426 #undef WRITE_SHORT_FIELD | 6478 #undef WRITE_SHORT_FIELD |
| 6427 #undef READ_BYTE_FIELD | 6479 #undef READ_BYTE_FIELD |
| 6428 #undef WRITE_BYTE_FIELD | 6480 #undef WRITE_BYTE_FIELD |
| 6429 | 6481 |
| 6430 | 6482 |
| 6431 } } // namespace v8::internal | 6483 } } // namespace v8::internal |
| 6432 | 6484 |
| 6433 #endif // V8_OBJECTS_INL_H_ | 6485 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |