OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Review notes: | 5 // Review notes: |
6 // | 6 // |
7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
10 // | 10 // |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 } | 1244 } |
1245 | 1245 |
1246 | 1246 |
1247 inline void AllocationSite::IncrementMementoCreateCount() { | 1247 inline void AllocationSite::IncrementMementoCreateCount() { |
1248 DCHECK(FLAG_allocation_site_pretenuring); | 1248 DCHECK(FLAG_allocation_site_pretenuring); |
1249 int value = memento_create_count(); | 1249 int value = memento_create_count(); |
1250 set_memento_create_count(value + 1); | 1250 set_memento_create_count(value + 1); |
1251 } | 1251 } |
1252 | 1252 |
1253 | 1253 |
1254 inline bool AllocationSite::MakePretenureDecision( | |
1255 PretenureDecision current_decision, | |
1256 double ratio, | |
1257 bool maximum_size_scavenge) { | |
1258 // Here we just allow state transitions from undecided or maybe tenure | |
1259 // to don't tenure, maybe tenure, or tenure. | |
1260 if ((current_decision == kUndecided || current_decision == kMaybeTenure)) { | |
1261 if (ratio >= kPretenureRatio) { | |
1262 // We just transition into tenure state when the semi-space was at | |
1263 // maximum capacity. | |
1264 if (maximum_size_scavenge) { | |
1265 set_deopt_dependent_code(true); | |
1266 set_pretenure_decision(kTenure); | |
1267 // Currently we just need to deopt when we make a state transition to | |
1268 // tenure. | |
1269 return true; | |
1270 } | |
1271 set_pretenure_decision(kMaybeTenure); | |
1272 } else { | |
1273 set_pretenure_decision(kDontTenure); | |
1274 } | |
1275 } | |
1276 return false; | |
1277 } | |
1278 | |
1279 | |
1280 inline bool AllocationSite::DigestPretenuringFeedback( | |
1281 bool maximum_size_scavenge) { | |
1282 bool deopt = false; | |
1283 int create_count = memento_create_count(); | |
1284 int found_count = memento_found_count(); | |
1285 bool minimum_mementos_created = create_count >= kPretenureMinimumCreated; | |
1286 double ratio = | |
1287 minimum_mementos_created || FLAG_trace_pretenuring_statistics ? | |
1288 static_cast<double>(found_count) / create_count : 0.0; | |
1289 PretenureDecision current_decision = pretenure_decision(); | |
1290 | |
1291 if (minimum_mementos_created) { | |
1292 deopt = MakePretenureDecision( | |
1293 current_decision, ratio, maximum_size_scavenge); | |
1294 } | |
1295 | |
1296 if (FLAG_trace_pretenuring_statistics) { | |
1297 PrintIsolate(GetIsolate(), | |
1298 "pretenuring: AllocationSite(%p): (created, found, ratio) " | |
1299 "(%d, %d, %f) %s => %s\n", | |
1300 static_cast<void*>(this), create_count, found_count, ratio, | |
1301 PretenureDecisionName(current_decision), | |
1302 PretenureDecisionName(pretenure_decision())); | |
1303 } | |
1304 | |
1305 // Clear feedback calculation fields until the next gc. | |
1306 set_memento_found_count(0); | |
1307 set_memento_create_count(0); | |
1308 return deopt; | |
1309 } | |
1310 | |
1311 | |
1312 bool AllocationMemento::IsValid() { | 1254 bool AllocationMemento::IsValid() { |
1313 return allocation_site()->IsAllocationSite() && | 1255 return allocation_site()->IsAllocationSite() && |
1314 !AllocationSite::cast(allocation_site())->IsZombie(); | 1256 !AllocationSite::cast(allocation_site())->IsZombie(); |
1315 } | 1257 } |
1316 | 1258 |
1317 | 1259 |
1318 AllocationSite* AllocationMemento::GetAllocationSite() { | 1260 AllocationSite* AllocationMemento::GetAllocationSite() { |
1319 DCHECK(IsValid()); | 1261 DCHECK(IsValid()); |
1320 return AllocationSite::cast(allocation_site()); | 1262 return AllocationSite::cast(allocation_site()); |
1321 } | 1263 } |
(...skipping 5151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6473 | 6415 |
6474 ACCESSORS(JSStringIterator, string, String, kStringOffset) | 6416 ACCESSORS(JSStringIterator, string, String, kStringOffset) |
6475 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) | 6417 SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset) |
6476 | 6418 |
6477 } // namespace internal | 6419 } // namespace internal |
6478 } // namespace v8 | 6420 } // namespace v8 |
6479 | 6421 |
6480 #include "src/objects/object-macros-undef.h" | 6422 #include "src/objects/object-macros-undef.h" |
6481 | 6423 |
6482 #endif // V8_OBJECTS_INL_H_ | 6424 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |