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

Side by Side Diff: src/heap.cc

Issue 148343005: A64: Synchronize with r18147. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 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
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Will be 4 * reserved_semispace_size_ to ensure that young 80 // Will be 4 * reserved_semispace_size_ to ensure that young
81 // generation can be aligned to its size. 81 // generation can be aligned to its size.
82 maximum_committed_(0), 82 maximum_committed_(0),
83 survived_since_last_expansion_(0), 83 survived_since_last_expansion_(0),
84 sweep_generation_(0), 84 sweep_generation_(0),
85 always_allocate_scope_depth_(0), 85 always_allocate_scope_depth_(0),
86 linear_allocation_scope_depth_(0), 86 linear_allocation_scope_depth_(0),
87 contexts_disposed_(0), 87 contexts_disposed_(0),
88 global_ic_age_(0), 88 global_ic_age_(0),
89 flush_monomorphic_ics_(false), 89 flush_monomorphic_ics_(false),
90 allocation_mementos_found_(0),
91 scan_on_scavenge_pages_(0), 90 scan_on_scavenge_pages_(0),
92 new_space_(this), 91 new_space_(this),
93 old_pointer_space_(NULL), 92 old_pointer_space_(NULL),
94 old_data_space_(NULL), 93 old_data_space_(NULL),
95 code_space_(NULL), 94 code_space_(NULL),
96 map_space_(NULL), 95 map_space_(NULL),
97 cell_space_(NULL), 96 cell_space_(NULL),
98 property_cell_space_(NULL), 97 property_cell_space_(NULL),
99 lo_space_(NULL), 98 lo_space_(NULL),
100 gc_state_(NOT_IN_GC), 99 gc_state_(NOT_IN_GC),
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 PagedSpaces spaces(this); 498 PagedSpaces spaces(this);
500 for (PagedSpace* space = spaces.next(); 499 for (PagedSpace* space = spaces.next();
501 space != NULL; 500 space != NULL;
502 space = spaces.next()) { 501 space = spaces.next()) {
503 space->RepairFreeListsAfterBoot(); 502 space->RepairFreeListsAfterBoot();
504 } 503 }
505 } 504 }
506 505
507 506
508 void Heap::GarbageCollectionEpilogue() { 507 void Heap::GarbageCollectionEpilogue() {
508 if (FLAG_allocation_site_pretenuring) {
509 int tenure_decisions = 0;
510 int dont_tenure_decisions = 0;
511 int allocation_mementos_found = 0;
512
513 Object* cur = allocation_sites_list();
514 while (cur->IsAllocationSite()) {
515 AllocationSite* casted = AllocationSite::cast(cur);
516 allocation_mementos_found += casted->memento_found_count()->value();
517 if (casted->DigestPretenuringFeedback()) {
518 if (casted->GetPretenureMode() == TENURED) {
519 tenure_decisions++;
520 } else {
521 dont_tenure_decisions++;
522 }
523 }
524 cur = casted->weak_next();
525 }
526
527 // TODO(mvstanton): Pretenure decisions are only made once for an allocation
528 // site. Find a sane way to decide about revisiting the decision later.
529
530 if (FLAG_trace_track_allocation_sites &&
531 (allocation_mementos_found > 0 ||
532 tenure_decisions > 0 ||
533 dont_tenure_decisions > 0)) {
534 PrintF("GC: (#mementos, #tenure decisions, #donttenure decisions) "
535 "(%d, %d, %d)\n",
536 allocation_mementos_found,
537 tenure_decisions,
538 dont_tenure_decisions);
539 }
540 }
541
509 store_buffer()->GCEpilogue(); 542 store_buffer()->GCEpilogue();
510 543
511 // In release mode, we only zap the from space under heap verification. 544 // In release mode, we only zap the from space under heap verification.
512 if (Heap::ShouldZapGarbage()) { 545 if (Heap::ShouldZapGarbage()) {
513 ZapFromSpace(); 546 ZapFromSpace();
514 } 547 }
515 548
516 #ifdef VERIFY_HEAP 549 #ifdef VERIFY_HEAP
517 if (FLAG_verify_heap) { 550 if (FLAG_verify_heap) {
518 Verify(); 551 Verify();
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 } 1419 }
1387 1420
1388 private: 1421 private:
1389 Heap* heap_; 1422 Heap* heap_;
1390 }; 1423 };
1391 1424
1392 1425
1393 void Heap::Scavenge() { 1426 void Heap::Scavenge() {
1394 RelocationLock relocation_lock(this); 1427 RelocationLock relocation_lock(this);
1395 1428
1396 allocation_mementos_found_ = 0;
1397
1398 #ifdef VERIFY_HEAP 1429 #ifdef VERIFY_HEAP
1399 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this); 1430 if (FLAG_verify_heap) VerifyNonPointerSpacePointers(this);
1400 #endif 1431 #endif
1401 1432
1402 gc_state_ = SCAVENGE; 1433 gc_state_ = SCAVENGE;
1403 1434
1404 // Implements Cheney's copying algorithm 1435 // Implements Cheney's copying algorithm
1405 LOG(isolate_, ResourceEvent("scavenge", "begin")); 1436 LOG(isolate_, ResourceEvent("scavenge", "begin"));
1406 1437
1407 // Clear descriptor cache. 1438 // Clear descriptor cache.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 1566
1536 // Update how much has survived scavenge. 1567 // Update how much has survived scavenge.
1537 IncrementYoungSurvivorsCounter(static_cast<int>( 1568 IncrementYoungSurvivorsCounter(static_cast<int>(
1538 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size())); 1569 (PromotedSpaceSizeOfObjects() - survived_watermark) + new_space_.Size()));
1539 1570
1540 LOG(isolate_, ResourceEvent("scavenge", "end")); 1571 LOG(isolate_, ResourceEvent("scavenge", "end"));
1541 1572
1542 gc_state_ = NOT_IN_GC; 1573 gc_state_ = NOT_IN_GC;
1543 1574
1544 scavenges_since_last_idle_round_++; 1575 scavenges_since_last_idle_round_++;
1545
1546 if (FLAG_trace_track_allocation_sites && allocation_mementos_found_ > 0) {
1547 PrintF("AllocationMementos found during scavenge = %d\n",
1548 allocation_mementos_found_);
1549 }
1550 } 1576 }
1551 1577
1552 1578
1553 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, 1579 String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap,
1554 Object** p) { 1580 Object** p) {
1555 MapWord first_word = HeapObject::cast(*p)->map_word(); 1581 MapWord first_word = HeapObject::cast(*p)->map_word();
1556 1582
1557 if (!first_word.IsForwardingAddress()) { 1583 if (!first_word.IsForwardingAddress()) {
1558 // Unreachable external string can be finalized. 1584 // Unreachable external string can be finalized.
1559 heap->FinalizeExternalString(String::cast(*p)); 1585 heap->FinalizeExternalString(String::cast(*p));
(...skipping 2797 matching lines...) Expand 10 before | Expand all | Expand 10 after
4357 4383
4358 #ifdef VERIFY_HEAP 4384 #ifdef VERIFY_HEAP
4359 if (FLAG_verify_heap) { 4385 if (FLAG_verify_heap) {
4360 code->Verify(); 4386 code->Verify();
4361 } 4387 }
4362 #endif 4388 #endif
4363 return new_code; 4389 return new_code;
4364 } 4390 }
4365 4391
4366 4392
4393 void Heap::InitializeAllocationMemento(AllocationMemento* memento,
4394 AllocationSite* allocation_site) {
4395 memento->set_map_no_write_barrier(allocation_memento_map());
4396 ASSERT(allocation_site->map() == allocation_site_map());
4397 memento->set_allocation_site(allocation_site, SKIP_WRITE_BARRIER);
4398 if (FLAG_allocation_site_pretenuring) {
4399 allocation_site->IncrementMementoCreateCount();
4400 }
4401 }
4402
4403
4367 MaybeObject* Heap::AllocateWithAllocationSite(Map* map, AllocationSpace space, 4404 MaybeObject* Heap::AllocateWithAllocationSite(Map* map, AllocationSpace space,
4368 Handle<AllocationSite> allocation_site) { 4405 Handle<AllocationSite> allocation_site) {
4369 ASSERT(gc_state_ == NOT_IN_GC); 4406 ASSERT(gc_state_ == NOT_IN_GC);
4370 ASSERT(map->instance_type() != MAP_TYPE); 4407 ASSERT(map->instance_type() != MAP_TYPE);
4371 // If allocation failures are disallowed, we may allocate in a different 4408 // If allocation failures are disallowed, we may allocate in a different
4372 // space when new space is full and the object is not a large object. 4409 // space when new space is full and the object is not a large object.
4373 AllocationSpace retry_space = 4410 AllocationSpace retry_space =
4374 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); 4411 (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type());
4375 int size = map->instance_size() + AllocationMemento::kSize; 4412 int size = map->instance_size() + AllocationMemento::kSize;
4376 Object* result; 4413 Object* result;
4377 MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); 4414 MaybeObject* maybe_result = AllocateRaw(size, space, retry_space);
4378 if (!maybe_result->ToObject(&result)) return maybe_result; 4415 if (!maybe_result->ToObject(&result)) return maybe_result;
4379 // No need for write barrier since object is white and map is in old space. 4416 // No need for write barrier since object is white and map is in old space.
4380 HeapObject::cast(result)->set_map_no_write_barrier(map); 4417 HeapObject::cast(result)->set_map_no_write_barrier(map);
4381 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>( 4418 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>(
4382 reinterpret_cast<Address>(result) + map->instance_size()); 4419 reinterpret_cast<Address>(result) + map->instance_size());
4383 alloc_memento->set_map_no_write_barrier(allocation_memento_map()); 4420 InitializeAllocationMemento(alloc_memento, *allocation_site);
4384 ASSERT(allocation_site->map() == allocation_site_map());
4385 alloc_memento->set_allocation_site(*allocation_site, SKIP_WRITE_BARRIER);
4386 return result; 4421 return result;
4387 } 4422 }
4388 4423
4389 4424
4390 MaybeObject* Heap::Allocate(Map* map, AllocationSpace space) { 4425 MaybeObject* Heap::Allocate(Map* map, AllocationSpace space) {
4391 ASSERT(gc_state_ == NOT_IN_GC); 4426 ASSERT(gc_state_ == NOT_IN_GC);
4392 ASSERT(map->instance_type() != MAP_TYPE); 4427 ASSERT(map->instance_type() != MAP_TYPE);
4393 // If allocation failures are disallowed, we may allocate in a different 4428 // If allocation failures are disallowed, we may allocate in a different
4394 // space when new space is full and the object is not a large object. 4429 // space when new space is full and the object is not a large object.
4395 AllocationSpace retry_space = 4430 AllocationSpace retry_space =
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
4808 MaybeObject* Heap::CopyJSObject(JSObject* source, AllocationSite* site) { 4843 MaybeObject* Heap::CopyJSObject(JSObject* source, AllocationSite* site) {
4809 // Never used to copy functions. If functions need to be copied we 4844 // Never used to copy functions. If functions need to be copied we
4810 // have to be careful to clear the literals array. 4845 // have to be careful to clear the literals array.
4811 SLOW_ASSERT(!source->IsJSFunction()); 4846 SLOW_ASSERT(!source->IsJSFunction());
4812 4847
4813 // Make the clone. 4848 // Make the clone.
4814 Map* map = source->map(); 4849 Map* map = source->map();
4815 int object_size = map->instance_size(); 4850 int object_size = map->instance_size();
4816 Object* clone; 4851 Object* clone;
4817 4852
4818 ASSERT(site == NULL || (AllocationSite::CanTrack(map->instance_type()) && 4853 ASSERT(site == NULL || AllocationSite::CanTrack(map->instance_type()));
4819 map->instance_type() == JS_ARRAY_TYPE));
4820 4854
4821 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; 4855 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER;
4822 4856
4823 // If we're forced to always allocate, we use the general allocation 4857 // If we're forced to always allocate, we use the general allocation
4824 // functions which may leave us with an object in old space. 4858 // functions which may leave us with an object in old space.
4825 if (always_allocate()) { 4859 if (always_allocate()) {
4826 { MaybeObject* maybe_clone = 4860 { MaybeObject* maybe_clone =
4827 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); 4861 AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE);
4828 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 4862 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
4829 } 4863 }
(...skipping 18 matching lines...) Expand all
4848 SLOW_ASSERT(InNewSpace(clone)); 4882 SLOW_ASSERT(InNewSpace(clone));
4849 // Since we know the clone is allocated in new space, we can copy 4883 // Since we know the clone is allocated in new space, we can copy
4850 // the contents without worrying about updating the write barrier. 4884 // the contents without worrying about updating the write barrier.
4851 CopyBlock(HeapObject::cast(clone)->address(), 4885 CopyBlock(HeapObject::cast(clone)->address(),
4852 source->address(), 4886 source->address(),
4853 object_size); 4887 object_size);
4854 4888
4855 if (site != NULL) { 4889 if (site != NULL) {
4856 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>( 4890 AllocationMemento* alloc_memento = reinterpret_cast<AllocationMemento*>(
4857 reinterpret_cast<Address>(clone) + object_size); 4891 reinterpret_cast<Address>(clone) + object_size);
4858 alloc_memento->set_map_no_write_barrier(allocation_memento_map()); 4892 InitializeAllocationMemento(alloc_memento, site);
4859 ASSERT(site->map() == allocation_site_map());
4860 alloc_memento->set_allocation_site(site, SKIP_WRITE_BARRIER);
4861 HeapProfiler* profiler = isolate()->heap_profiler(); 4893 HeapProfiler* profiler = isolate()->heap_profiler();
4862 if (profiler->is_tracking_allocations()) { 4894 if (profiler->is_tracking_allocations()) {
4863 profiler->UpdateObjectSizeEvent(HeapObject::cast(clone)->address(), 4895 profiler->UpdateObjectSizeEvent(HeapObject::cast(clone)->address(),
4864 object_size); 4896 object_size);
4865 profiler->NewObjectEvent(alloc_memento->address(), 4897 profiler->NewObjectEvent(alloc_memento->address(),
4866 AllocationMemento::kSize); 4898 AllocationMemento::kSize);
4867 } 4899 }
4868 } 4900 }
4869 } 4901 }
4870 4902
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 static_cast<int>(object_sizes_last_time_[index])); 8000 static_cast<int>(object_sizes_last_time_[index]));
7969 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 8001 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7970 #undef ADJUST_LAST_TIME_OBJECT_COUNT 8002 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7971 8003
7972 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 8004 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7973 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 8005 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7974 ClearObjectStats(); 8006 ClearObjectStats();
7975 } 8007 }
7976 8008
7977 } } // namespace v8::internal 8009 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698