Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: src/objects-inl.h

Issue 132063004: More efficient use of space in AllocationSite. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 accessor->Validate(this); 1297 accessor->Validate(this);
1298 } 1298 }
1299 #endif 1299 #endif
1300 } 1300 }
1301 1301
1302 1302
1303 void AllocationSite::Initialize() { 1303 void AllocationSite::Initialize() {
1304 set_transition_info(Smi::FromInt(0)); 1304 set_transition_info(Smi::FromInt(0));
1305 SetElementsKind(GetInitialFastElementsKind()); 1305 SetElementsKind(GetInitialFastElementsKind());
1306 set_nested_site(Smi::FromInt(0)); 1306 set_nested_site(Smi::FromInt(0));
1307 set_memento_create_count(Smi::FromInt(0)); 1307 set_pretenure_data(Smi::FromInt(0));
1308 set_memento_found_count(Smi::FromInt(0));
1309 set_pretenure_decision(Smi::FromInt(0));
1310 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()), 1308 set_dependent_code(DependentCode::cast(GetHeap()->empty_fixed_array()),
1311 SKIP_WRITE_BARRIER); 1309 SKIP_WRITE_BARRIER);
1312 } 1310 }
1313 1311
1314 1312
1315 void AllocationSite::MarkZombie() { 1313 void AllocationSite::MarkZombie() {
1316 ASSERT(!IsZombie()); 1314 ASSERT(!IsZombie());
1317 Initialize(); 1315 Initialize();
1318 set_pretenure_decision(Smi::FromInt(kZombie)); 1316 set_pretenure_decision(kZombie);
1319 } 1317 }
1320 1318
1321 1319
1322 // Heuristic: We only need to create allocation site info if the boilerplate 1320 // Heuristic: We only need to create allocation site info if the boilerplate
1323 // elements kind is the initial elements kind. 1321 // elements kind is the initial elements kind.
1324 AllocationSiteMode AllocationSite::GetMode( 1322 AllocationSiteMode AllocationSite::GetMode(
1325 ElementsKind boilerplate_elements_kind) { 1323 ElementsKind boilerplate_elements_kind) {
1326 if (IsFastSmiElementsKind(boilerplate_elements_kind)) { 1324 if (IsFastSmiElementsKind(boilerplate_elements_kind)) {
1327 return TRACK_ALLOCATION_SITE; 1325 return TRACK_ALLOCATION_SITE;
1328 } 1326 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 break; 1361 break;
1364 } 1362 }
1365 UNREACHABLE(); 1363 UNREACHABLE();
1366 return DependentCode::kAllocationSiteTransitionChangedGroup; 1364 return DependentCode::kAllocationSiteTransitionChangedGroup;
1367 } 1365 }
1368 1366
1369 1367
1370 inline bool AllocationSite::IncrementMementoFoundCount() { 1368 inline bool AllocationSite::IncrementMementoFoundCount() {
1371 if (IsZombie()) return false; 1369 if (IsZombie()) return false;
1372 1370
1373 int value = memento_found_count()->value(); 1371 int value = memento_found_count();
1374 set_memento_found_count(Smi::FromInt(value + 1)); 1372 set_memento_found_count(value + 1);
1375 return value == 0; 1373 return value == 0;
1376 } 1374 }
1377 1375
1378 1376
1379 inline void AllocationSite::IncrementMementoCreateCount() { 1377 inline void AllocationSite::IncrementMementoCreateCount() {
1380 ASSERT(FLAG_allocation_site_pretenuring); 1378 ASSERT(FLAG_allocation_site_pretenuring);
1381 int value = memento_create_count()->value(); 1379 int value = memento_create_count();
1382 set_memento_create_count(Smi::FromInt(value + 1)); 1380 set_memento_create_count(value + 1);
1383 } 1381 }
1384 1382
1385 1383
1386 inline bool AllocationSite::DigestPretenuringFeedback() { 1384 inline bool AllocationSite::DigestPretenuringFeedback() {
1387 bool decision_made = false; 1385 bool decision_made = false;
1388 if (!PretenuringDecisionMade()) { 1386 if (!PretenuringDecisionMade()) {
1389 int create_count = memento_create_count()->value(); 1387 int create_count = memento_create_count();
1390 if (create_count >= kPretenureMinimumCreated) { 1388 if (create_count >= kPretenureMinimumCreated) {
1391 int found_count = memento_found_count()->value(); 1389 int found_count = memento_found_count();
1392 double ratio = static_cast<double>(found_count) / create_count; 1390 double ratio = static_cast<double>(found_count) / create_count;
1393 if (FLAG_trace_track_allocation_sites) { 1391 if (FLAG_trace_track_allocation_sites) {
1394 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n", 1392 PrintF("AllocationSite: %p (created, found, ratio) (%d, %d, %f)\n",
1395 static_cast<void*>(this), create_count, found_count, ratio); 1393 static_cast<void*>(this), create_count, found_count, ratio);
1396 } 1394 }
1397 int result = ratio >= kPretenureRatio ? kTenure : kDontTenure; 1395 int result = ratio >= kPretenureRatio ? kTenure : kDontTenure;
1398 set_pretenure_decision(Smi::FromInt(result)); 1396 set_pretenure_decision(result);
1399 decision_made = true; 1397 decision_made = true;
1400 // TODO(mvstanton): if the decision represents a change, any dependent 1398 // TODO(mvstanton): if the decision represents a change, any dependent
1401 // code registered for pretenuring changes should be deopted. 1399 // code registered for pretenuring changes should be deopted.
1402 } 1400 }
1403 } 1401 }
1404 1402
1405 // Clear feedback calculation fields until the next gc. 1403 // Clear feedback calculation fields until the next gc.
1406 set_memento_found_count(Smi::FromInt(0)); 1404 set_memento_found_count(0);
1407 set_memento_create_count(Smi::FromInt(0)); 1405 set_memento_create_count(0);
1408 return decision_made; 1406 return decision_made;
1409 } 1407 }
1410 1408
1411 1409
1412 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) { 1410 void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
1413 object->ValidateElements(); 1411 object->ValidateElements();
1414 ElementsKind elements_kind = object->map()->elements_kind(); 1412 ElementsKind elements_kind = object->map()->elements_kind();
1415 if (!IsFastObjectElementsKind(elements_kind)) { 1413 if (!IsFastObjectElementsKind(elements_kind)) {
1416 if (IsFastHoleyElementsKind(elements_kind)) { 1414 if (IsFastHoleyElementsKind(elements_kind)) {
1417 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS); 1415 TransitionElementsKind(object, FAST_HOLEY_ELEMENTS);
(...skipping 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after
4591 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object, 4589 ACCESSORS(ObjectTemplateInfo, internal_field_count, Object,
4592 kInternalFieldCountOffset) 4590 kInternalFieldCountOffset)
4593 4591
4594 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset) 4592 ACCESSORS(SignatureInfo, receiver, Object, kReceiverOffset)
4595 ACCESSORS(SignatureInfo, args, Object, kArgsOffset) 4593 ACCESSORS(SignatureInfo, args, Object, kArgsOffset)
4596 4594
4597 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset) 4595 ACCESSORS(TypeSwitchInfo, types, Object, kTypesOffset)
4598 4596
4599 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset) 4597 ACCESSORS(AllocationSite, transition_info, Object, kTransitionInfoOffset)
4600 ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset) 4598 ACCESSORS(AllocationSite, nested_site, Object, kNestedSiteOffset)
4601 ACCESSORS_TO_SMI(AllocationSite, memento_found_count, kMementoFoundCountOffset) 4599 ACCESSORS_TO_SMI(AllocationSite, pretenure_data, kPretenureDataOffset)
4602 ACCESSORS_TO_SMI(AllocationSite, memento_create_count,
4603 kMementoCreateCountOffset)
4604 ACCESSORS_TO_SMI(AllocationSite, pretenure_decision, kPretenureDecisionOffset)
4605 ACCESSORS(AllocationSite, dependent_code, DependentCode, 4600 ACCESSORS(AllocationSite, dependent_code, DependentCode,
4606 kDependentCodeOffset) 4601 kDependentCodeOffset)
4607 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) 4602 ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
4608 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) 4603 ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset)
4609 4604
4610 ACCESSORS(Script, source, Object, kSourceOffset) 4605 ACCESSORS(Script, source, Object, kSourceOffset)
4611 ACCESSORS(Script, name, Object, kNameOffset) 4606 ACCESSORS(Script, name, Object, kNameOffset)
4612 ACCESSORS(Script, id, Smi, kIdOffset) 4607 ACCESSORS(Script, id, Smi, kIdOffset)
4613 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset) 4608 ACCESSORS_TO_SMI(Script, line_offset, kLineOffsetOffset)
4614 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset) 4609 ACCESSORS_TO_SMI(Script, column_offset, kColumnOffsetOffset)
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
6475 #undef WRITE_UINT32_FIELD 6470 #undef WRITE_UINT32_FIELD
6476 #undef READ_SHORT_FIELD 6471 #undef READ_SHORT_FIELD
6477 #undef WRITE_SHORT_FIELD 6472 #undef WRITE_SHORT_FIELD
6478 #undef READ_BYTE_FIELD 6473 #undef READ_BYTE_FIELD
6479 #undef WRITE_BYTE_FIELD 6474 #undef WRITE_BYTE_FIELD
6480 6475
6481 6476
6482 } } // namespace v8::internal 6477 } } // namespace v8::internal
6483 6478
6484 #endif // V8_OBJECTS_INL_H_ 6479 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/flag-definitions.h ('K') | « src/objects.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698