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

Side by Side Diff: src/heap.cc

Issue 110573004: Merge bleeding_edge 17696:18016. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 allocation_timeout_(0), 107 allocation_timeout_(0),
108 disallow_allocation_failure_(false), 108 disallow_allocation_failure_(false),
109 #endif // DEBUG 109 #endif // DEBUG
110 new_space_high_promotion_mode_active_(false), 110 new_space_high_promotion_mode_active_(false),
111 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit), 111 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit),
112 size_of_old_gen_at_last_old_space_gc_(0), 112 size_of_old_gen_at_last_old_space_gc_(0),
113 external_allocation_limit_(0), 113 external_allocation_limit_(0),
114 amount_of_external_allocated_memory_(0), 114 amount_of_external_allocated_memory_(0),
115 amount_of_external_allocated_memory_at_last_global_gc_(0), 115 amount_of_external_allocated_memory_at_last_global_gc_(0),
116 old_gen_exhausted_(false), 116 old_gen_exhausted_(false),
117 inline_allocation_disabled_(false),
117 store_buffer_rebuilder_(store_buffer()), 118 store_buffer_rebuilder_(store_buffer()),
118 hidden_string_(NULL), 119 hidden_string_(NULL),
119 gc_safe_size_of_old_object_(NULL), 120 gc_safe_size_of_old_object_(NULL),
120 total_regexp_code_generated_(0), 121 total_regexp_code_generated_(0),
121 tracer_(NULL), 122 tracer_(NULL),
122 young_survivors_after_last_gc_(0), 123 young_survivors_after_last_gc_(0),
123 high_survival_rate_period_length_(0), 124 high_survival_rate_period_length_(0),
124 low_survival_rate_period_length_(0), 125 low_survival_rate_period_length_(0),
125 survival_rate_(0), 126 survival_rate_(0),
126 previous_survival_rate_trend_(Heap::STABLE), 127 previous_survival_rate_trend_(Heap::STABLE),
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 lo_space_->SizeOfObjects() / KB, 405 lo_space_->SizeOfObjects() / KB,
405 lo_space_->Available() / KB, 406 lo_space_->Available() / KB,
406 lo_space_->CommittedMemory() / KB); 407 lo_space_->CommittedMemory() / KB);
407 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB" 408 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB"
408 ", available: %6" V8_PTR_PREFIX "d KB" 409 ", available: %6" V8_PTR_PREFIX "d KB"
409 ", committed: %6" V8_PTR_PREFIX "d KB\n", 410 ", committed: %6" V8_PTR_PREFIX "d KB\n",
410 this->SizeOfObjects() / KB, 411 this->SizeOfObjects() / KB,
411 this->Available() / KB, 412 this->Available() / KB,
412 this->CommittedMemory() / KB); 413 this->CommittedMemory() / KB);
413 PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n", 414 PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n",
414 amount_of_external_allocated_memory_ / KB); 415 static_cast<intptr_t>(amount_of_external_allocated_memory_ / KB));
415 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_); 416 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_);
416 } 417 }
417 418
418 419
419 // TODO(1238405): Combine the infrastructure for --heap-stats and 420 // TODO(1238405): Combine the infrastructure for --heap-stats and
420 // --log-gc to avoid the complicated preprocessor and flag testing. 421 // --log-gc to avoid the complicated preprocessor and flag testing.
421 void Heap::ReportStatisticsAfterGC() { 422 void Heap::ReportStatisticsAfterGC() {
422 // Similar to the before GC, we use some complicated logic to ensure that 423 // Similar to the before GC, we use some complicated logic to ensure that
423 // NewSpace statistics are logged exactly once when --log-gc is turned on. 424 // NewSpace statistics are logged exactly once when --log-gc is turned on.
424 #if defined(DEBUG) 425 #if defined(DEBUG)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 #ifdef DEBUG 458 #ifdef DEBUG
458 ASSERT(!AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC); 459 ASSERT(!AllowHeapAllocation::IsAllowed() && gc_state_ == NOT_IN_GC);
459 460
460 if (FLAG_gc_verbose) Print(); 461 if (FLAG_gc_verbose) Print();
461 462
462 ReportStatisticsBeforeGC(); 463 ReportStatisticsBeforeGC();
463 #endif // DEBUG 464 #endif // DEBUG
464 465
465 store_buffer()->GCPrologue(); 466 store_buffer()->GCPrologue();
466 467
467 if (FLAG_concurrent_osr) { 468 if (isolate()->concurrent_osr_enabled()) {
468 isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs(); 469 isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs();
469 } 470 }
470 } 471 }
471 472
472 473
473 intptr_t Heap::SizeOfObjects() { 474 intptr_t Heap::SizeOfObjects() {
474 intptr_t total = 0; 475 intptr_t total = 0;
475 AllSpaces spaces(this); 476 AllSpaces spaces(this);
476 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { 477 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) {
477 total += space->SizeOfObjects(); 478 total += space->SizeOfObjects();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // not matter, so long as we do not specify NEW_SPACE, which would not 655 // not matter, so long as we do not specify NEW_SPACE, which would not
655 // cause a full GC. 656 // cause a full GC.
656 // Major GC would invoke weak handle callbacks on weakly reachable 657 // Major GC would invoke weak handle callbacks on weakly reachable
657 // handles, but won't collect weakly reachable objects until next 658 // handles, but won't collect weakly reachable objects until next
658 // major GC. Therefore if we collect aggressively and weak handle callback 659 // major GC. Therefore if we collect aggressively and weak handle callback
659 // has been invoked, we rerun major GC to release objects which become 660 // has been invoked, we rerun major GC to release objects which become
660 // garbage. 661 // garbage.
661 // Note: as weak callbacks can execute arbitrary code, we cannot 662 // Note: as weak callbacks can execute arbitrary code, we cannot
662 // hope that eventually there will be no weak callbacks invocations. 663 // hope that eventually there will be no weak callbacks invocations.
663 // Therefore stop recollecting after several attempts. 664 // Therefore stop recollecting after several attempts.
664 if (FLAG_concurrent_recompilation) { 665 if (isolate()->concurrent_recompilation_enabled()) {
665 // The optimizing compiler may be unnecessarily holding on to memory. 666 // The optimizing compiler may be unnecessarily holding on to memory.
666 DisallowHeapAllocation no_recursive_gc; 667 DisallowHeapAllocation no_recursive_gc;
667 isolate()->optimizing_compiler_thread()->Flush(); 668 isolate()->optimizing_compiler_thread()->Flush();
668 } 669 }
669 mark_compact_collector()->SetFlags(kMakeHeapIterableMask | 670 mark_compact_collector()->SetFlags(kMakeHeapIterableMask |
670 kReduceMemoryFootprintMask); 671 kReduceMemoryFootprintMask);
671 isolate_->compilation_cache()->Clear(); 672 isolate_->compilation_cache()->Clear();
672 const int kMaxNumberOfAttempts = 7; 673 const int kMaxNumberOfAttempts = 7;
673 const int kMinNumberOfAttempts = 2; 674 const int kMinNumberOfAttempts = 2;
674 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { 675 for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 incremental_marking()->WorthActivating() && 756 incremental_marking()->WorthActivating() &&
756 NextGCIsLikelyToBeFull()) { 757 NextGCIsLikelyToBeFull()) {
757 incremental_marking()->Start(); 758 incremental_marking()->Start();
758 } 759 }
759 760
760 return next_gc_likely_to_collect_more; 761 return next_gc_likely_to_collect_more;
761 } 762 }
762 763
763 764
764 int Heap::NotifyContextDisposed() { 765 int Heap::NotifyContextDisposed() {
765 if (FLAG_concurrent_recompilation) { 766 if (isolate()->concurrent_recompilation_enabled()) {
766 // Flush the queued recompilation tasks. 767 // Flush the queued recompilation tasks.
767 isolate()->optimizing_compiler_thread()->Flush(); 768 isolate()->optimizing_compiler_thread()->Flush();
768 } 769 }
769 flush_monomorphic_ics_ = true; 770 flush_monomorphic_ics_ = true;
770 AgeInlineCaches(); 771 AgeInlineCaches();
771 return ++contexts_disposed_; 772 return ++contexts_disposed_;
772 } 773 }
773 774
774 775
775 void Heap::PerformScavenge() { 776 void Heap::PerformScavenge() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); 932 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX);
932 if (!cache->IsUndefined()) { 933 if (!cache->IsUndefined()) {
933 NormalizedMapCache::cast(cache)->Clear(); 934 NormalizedMapCache::cast(cache)->Clear();
934 } 935 }
935 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); 936 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
936 } 937 }
937 } 938 }
938 939
939 940
940 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) { 941 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) {
942 if (start_new_space_size == 0) return;
943
941 double survival_rate = 944 double survival_rate =
942 (static_cast<double>(young_survivors_after_last_gc_) * 100) / 945 (static_cast<double>(young_survivors_after_last_gc_) * 100) /
943 start_new_space_size; 946 start_new_space_size;
944 947
945 if (survival_rate > kYoungSurvivalRateHighThreshold) { 948 if (survival_rate > kYoungSurvivalRateHighThreshold) {
946 high_survival_rate_period_length_++; 949 high_survival_rate_period_length_++;
947 } else { 950 } else {
948 high_survival_rate_period_length_ = 0; 951 high_survival_rate_period_length_ = 0;
949 } 952 }
950 953
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { 1777 void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) {
1775 // We don't record weak slots during marking or scavenges. 1778 // We don't record weak slots during marking or scavenges.
1776 // Instead we do it once when we complete mark-compact cycle. 1779 // Instead we do it once when we complete mark-compact cycle.
1777 // Note that write barrier has no effect if we are already in the middle of 1780 // Note that write barrier has no effect if we are already in the middle of
1778 // compacting mark-sweep cycle and we have to record slots manually. 1781 // compacting mark-sweep cycle and we have to record slots manually.
1779 bool record_slots = 1782 bool record_slots =
1780 gc_state() == MARK_COMPACT && 1783 gc_state() == MARK_COMPACT &&
1781 mark_compact_collector()->is_compacting(); 1784 mark_compact_collector()->is_compacting();
1782 ProcessArrayBuffers(retainer, record_slots); 1785 ProcessArrayBuffers(retainer, record_slots);
1783 ProcessNativeContexts(retainer, record_slots); 1786 ProcessNativeContexts(retainer, record_slots);
1787 // TODO(mvstanton): AllocationSites only need to be processed during
1788 // MARK_COMPACT, as they live in old space. Verify and address.
1784 ProcessAllocationSites(retainer, record_slots); 1789 ProcessAllocationSites(retainer, record_slots);
1785 } 1790 }
1786 1791
1787 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer, 1792 void Heap::ProcessNativeContexts(WeakObjectRetainer* retainer,
1788 bool record_slots) { 1793 bool record_slots) {
1789 Object* head = 1794 Object* head =
1790 VisitWeakList<Context>( 1795 VisitWeakList<Context>(
1791 this, native_contexts_list(), retainer, record_slots); 1796 this, native_contexts_list(), retainer, record_slots);
1792 // Update the head of the list of contexts. 1797 // Update the head of the list of contexts.
1793 native_contexts_list_ = head; 1798 native_contexts_list_ = head;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 struct WeakListVisitor<AllocationSite> { 1884 struct WeakListVisitor<AllocationSite> {
1880 static void SetWeakNext(AllocationSite* obj, Object* next) { 1885 static void SetWeakNext(AllocationSite* obj, Object* next) {
1881 obj->set_weak_next(next); 1886 obj->set_weak_next(next);
1882 } 1887 }
1883 1888
1884 static Object* WeakNext(AllocationSite* obj) { 1889 static Object* WeakNext(AllocationSite* obj) {
1885 return obj->weak_next(); 1890 return obj->weak_next();
1886 } 1891 }
1887 1892
1888 static void VisitLiveObject(Heap* heap, 1893 static void VisitLiveObject(Heap* heap,
1889 AllocationSite* array_buffer, 1894 AllocationSite* site,
1890 WeakObjectRetainer* retainer, 1895 WeakObjectRetainer* retainer,
1891 bool record_slots) {} 1896 bool record_slots) {}
1892 1897
1893 static void VisitPhantomObject(Heap* heap, AllocationSite* phantom) {} 1898 static void VisitPhantomObject(Heap* heap, AllocationSite* phantom) {}
1894 1899
1895 static int WeakNextOffset() { 1900 static int WeakNextOffset() {
1896 return AllocationSite::kWeakNextOffset; 1901 return AllocationSite::kWeakNextOffset;
1897 } 1902 }
1898 }; 1903 };
1899 1904
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
2472 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); 2477 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map());
2473 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); 2478 reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
2474 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); 2479 reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
2475 reinterpret_cast<Map*>(result)->set_visitor_id( 2480 reinterpret_cast<Map*>(result)->set_visitor_id(
2476 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); 2481 StaticVisitorBase::GetVisitorId(instance_type, instance_size));
2477 reinterpret_cast<Map*>(result)->set_inobject_properties(0); 2482 reinterpret_cast<Map*>(result)->set_inobject_properties(0);
2478 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); 2483 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0);
2479 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); 2484 reinterpret_cast<Map*>(result)->set_unused_property_fields(0);
2480 reinterpret_cast<Map*>(result)->set_bit_field(0); 2485 reinterpret_cast<Map*>(result)->set_bit_field(0);
2481 reinterpret_cast<Map*>(result)->set_bit_field2(0); 2486 reinterpret_cast<Map*>(result)->set_bit_field2(0);
2482 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) | 2487 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
2483 Map::OwnsDescriptors::encode(true); 2488 Map::OwnsDescriptors::encode(true);
2484 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3); 2489 reinterpret_cast<Map*>(result)->set_bit_field3(bit_field3);
2485 return result; 2490 return result;
2486 } 2491 }
2487 2492
2488 2493
2489 MaybeObject* Heap::AllocateMap(InstanceType instance_type, 2494 MaybeObject* Heap::AllocateMap(InstanceType instance_type,
2490 int instance_size, 2495 int instance_size,
2491 ElementsKind elements_kind) { 2496 ElementsKind elements_kind) {
2492 Object* result; 2497 Object* result;
(...skipping 11 matching lines...) Expand all
2504 map->set_inobject_properties(0); 2509 map->set_inobject_properties(0);
2505 map->set_pre_allocated_property_fields(0); 2510 map->set_pre_allocated_property_fields(0);
2506 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); 2511 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER);
2507 map->set_dependent_code(DependentCode::cast(empty_fixed_array()), 2512 map->set_dependent_code(DependentCode::cast(empty_fixed_array()),
2508 SKIP_WRITE_BARRIER); 2513 SKIP_WRITE_BARRIER);
2509 map->init_back_pointer(undefined_value()); 2514 map->init_back_pointer(undefined_value());
2510 map->set_unused_property_fields(0); 2515 map->set_unused_property_fields(0);
2511 map->set_instance_descriptors(empty_descriptor_array()); 2516 map->set_instance_descriptors(empty_descriptor_array());
2512 map->set_bit_field(0); 2517 map->set_bit_field(0);
2513 map->set_bit_field2(1 << Map::kIsExtensible); 2518 map->set_bit_field2(1 << Map::kIsExtensible);
2514 int bit_field3 = Map::EnumLengthBits::encode(Map::kInvalidEnumCache) | 2519 int bit_field3 = Map::EnumLengthBits::encode(kInvalidEnumCacheSentinel) |
2515 Map::OwnsDescriptors::encode(true); 2520 Map::OwnsDescriptors::encode(true);
2516 map->set_bit_field3(bit_field3); 2521 map->set_bit_field3(bit_field3);
2517 map->set_elements_kind(elements_kind); 2522 map->set_elements_kind(elements_kind);
2518 2523
2519 return map; 2524 return map;
2520 } 2525 }
2521 2526
2522 2527
2523 MaybeObject* Heap::AllocateCodeCache() { 2528 MaybeObject* Heap::AllocateCodeCache() {
2524 CodeCache* code_cache; 2529 CodeCache* code_cache;
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 Heap::CreateJSConstructEntryStub(); 3113 Heap::CreateJSConstructEntryStub();
3109 3114
3110 // Create stubs that should be there, so we don't unexpectedly have to 3115 // Create stubs that should be there, so we don't unexpectedly have to
3111 // create them if we need them during the creation of another stub. 3116 // create them if we need them during the creation of another stub.
3112 // Stub creation mixes raw pointers and handles in an unsafe manner so 3117 // Stub creation mixes raw pointers and handles in an unsafe manner so
3113 // we cannot create stubs while we are creating stubs. 3118 // we cannot create stubs while we are creating stubs.
3114 CodeStub::GenerateStubsAheadOfTime(isolate()); 3119 CodeStub::GenerateStubsAheadOfTime(isolate());
3115 } 3120 }
3116 3121
3117 3122
3123 void Heap::CreateStubsRequiringBuiltins() {
3124 HandleScope scope(isolate());
3125 CodeStub::GenerateStubsRequiringBuiltinsAheadOfTime(isolate());
3126 }
3127
3128
3118 bool Heap::CreateInitialObjects() { 3129 bool Heap::CreateInitialObjects() {
3119 Object* obj; 3130 Object* obj;
3120 3131
3121 // The -0 value must be set before NumberFromDouble works. 3132 // The -0 value must be set before NumberFromDouble works.
3122 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); 3133 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED);
3123 if (!maybe_obj->ToObject(&obj)) return false; 3134 if (!maybe_obj->ToObject(&obj)) return false;
3124 } 3135 }
3125 set_minus_zero_value(HeapNumber::cast(obj)); 3136 set_minus_zero_value(HeapNumber::cast(obj));
3126 ASSERT(std::signbit(minus_zero_value()->Number()) != 0); 3137 ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
3127 3138
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after
4591 } 4602 }
4592 4603
4593 4604
4594 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor, 4605 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
4595 Handle<AllocationSite> allocation_site) { 4606 Handle<AllocationSite> allocation_site) {
4596 ASSERT(constructor->has_initial_map()); 4607 ASSERT(constructor->has_initial_map());
4597 // Allocate the object based on the constructors initial map, or the payload 4608 // Allocate the object based on the constructors initial map, or the payload
4598 // advice 4609 // advice
4599 Map* initial_map = constructor->initial_map(); 4610 Map* initial_map = constructor->initial_map();
4600 4611
4601 Smi* smi = Smi::cast(allocation_site->transition_info()); 4612 ElementsKind to_kind = allocation_site->GetElementsKind();
4602 ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
4603 AllocationSiteMode mode = TRACK_ALLOCATION_SITE; 4613 AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
4604 if (to_kind != initial_map->elements_kind()) { 4614 if (to_kind != initial_map->elements_kind()) {
4605 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); 4615 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind);
4606 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; 4616 if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
4607 // Possibly alter the mode, since we found an updated elements kind 4617 // Possibly alter the mode, since we found an updated elements kind
4608 // in the type info cell. 4618 // in the type info cell.
4609 mode = AllocationSite::GetMode(to_kind); 4619 mode = AllocationSite::GetMode(to_kind);
4610 } 4620 }
4611 4621
4612 MaybeObject* result; 4622 MaybeObject* result;
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
6566 return old_pointer_space_->SizeOfObjects() 6576 return old_pointer_space_->SizeOfObjects()
6567 + old_data_space_->SizeOfObjects() 6577 + old_data_space_->SizeOfObjects()
6568 + code_space_->SizeOfObjects() 6578 + code_space_->SizeOfObjects()
6569 + map_space_->SizeOfObjects() 6579 + map_space_->SizeOfObjects()
6570 + cell_space_->SizeOfObjects() 6580 + cell_space_->SizeOfObjects()
6571 + property_cell_space_->SizeOfObjects() 6581 + property_cell_space_->SizeOfObjects()
6572 + lo_space_->SizeOfObjects(); 6582 + lo_space_->SizeOfObjects();
6573 } 6583 }
6574 6584
6575 6585
6576 intptr_t Heap::PromotedExternalMemorySize() { 6586 bool Heap::AdvanceSweepers(int step_size) {
6587 ASSERT(isolate()->num_sweeper_threads() == 0);
6588 bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size);
6589 sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size);
6590 return sweeping_complete;
6591 }
6592
6593
6594 int64_t Heap::PromotedExternalMemorySize() {
6577 if (amount_of_external_allocated_memory_ 6595 if (amount_of_external_allocated_memory_
6578 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; 6596 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0;
6579 return amount_of_external_allocated_memory_ 6597 return amount_of_external_allocated_memory_
6580 - amount_of_external_allocated_memory_at_last_global_gc_; 6598 - amount_of_external_allocated_memory_at_last_global_gc_;
6581 } 6599 }
6582 6600
6583 6601
6602 void Heap::EnableInlineAllocation() {
6603 ASSERT(inline_allocation_disabled_);
6604 inline_allocation_disabled_ = false;
6605
6606 // Update inline allocation limit for new space.
6607 new_space()->UpdateInlineAllocationLimit(0);
6608 }
6609
6610
6611 void Heap::DisableInlineAllocation() {
6612 ASSERT(!inline_allocation_disabled_);
6613 inline_allocation_disabled_ = true;
6614
6615 // Update inline allocation limit for new space.
6616 new_space()->UpdateInlineAllocationLimit(0);
6617
6618 // Update inline allocation limit for old spaces.
6619 PagedSpaces spaces(this);
6620 for (PagedSpace* space = spaces.next();
6621 space != NULL;
6622 space = spaces.next()) {
6623 space->EmptyAllocationInfo();
6624 }
6625 }
6626
6627
6584 V8_DECLARE_ONCE(initialize_gc_once); 6628 V8_DECLARE_ONCE(initialize_gc_once);
6585 6629
6586 static void InitializeGCOnce() { 6630 static void InitializeGCOnce() {
6587 InitializeScavengingVisitorsTables(); 6631 InitializeScavengingVisitorsTables();
6588 NewSpaceScavenger::Initialize(); 6632 NewSpaceScavenger::Initialize();
6589 MarkCompactCollector::Initialize(); 6633 MarkCompactCollector::Initialize();
6590 } 6634 }
6591 6635
6592 6636
6593 bool Heap::SetUp() { 6637 bool Heap::SetUp() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
6686 set_hash_seed(Smi::FromInt(FLAG_hash_seed)); 6730 set_hash_seed(Smi::FromInt(FLAG_hash_seed));
6687 } 6731 }
6688 } 6732 }
6689 6733
6690 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); 6734 LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity()));
6691 LOG(isolate_, IntPtrTEvent("heap-available", Available())); 6735 LOG(isolate_, IntPtrTEvent("heap-available", Available()));
6692 6736
6693 store_buffer()->SetUp(); 6737 store_buffer()->SetUp();
6694 6738
6695 if (FLAG_concurrent_recompilation) relocation_mutex_ = new Mutex; 6739 if (FLAG_concurrent_recompilation) relocation_mutex_ = new Mutex;
6696 #ifdef DEBUG
6697 relocation_mutex_locked_by_optimizer_thread_ = false;
6698 #endif // DEBUG
6699 6740
6700 return true; 6741 return true;
6701 } 6742 }
6702 6743
6703 6744
6704 bool Heap::CreateHeapObjects() { 6745 bool Heap::CreateHeapObjects() {
6705 // Create initial maps. 6746 // Create initial maps.
6706 if (!CreateInitialMaps()) return false; 6747 if (!CreateInitialMaps()) return false;
6707 if (!CreateApiObjects()) return false; 6748 if (!CreateApiObjects()) return false;
6708 6749
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
6833 delete lo_space_; 6874 delete lo_space_;
6834 lo_space_ = NULL; 6875 lo_space_ = NULL;
6835 } 6876 }
6836 6877
6837 store_buffer()->TearDown(); 6878 store_buffer()->TearDown();
6838 incremental_marking()->TearDown(); 6879 incremental_marking()->TearDown();
6839 6880
6840 isolate_->memory_allocator()->TearDown(); 6881 isolate_->memory_allocator()->TearDown();
6841 6882
6842 delete relocation_mutex_; 6883 delete relocation_mutex_;
6884 relocation_mutex_ = NULL;
6843 } 6885 }
6844 6886
6845 6887
6846 void Heap::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, 6888 void Heap::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback,
6847 GCType gc_type, 6889 GCType gc_type,
6848 bool pass_isolate) { 6890 bool pass_isolate) {
6849 ASSERT(callback != NULL); 6891 ASSERT(callback != NULL);
6850 GCPrologueCallbackPair pair(callback, gc_type, pass_isolate); 6892 GCPrologueCallbackPair pair(callback, gc_type, pass_isolate);
6851 ASSERT(!gc_prologue_callbacks_.Contains(pair)); 6893 ASSERT(!gc_prologue_callbacks_.Contains(pair));
6852 return gc_prologue_callbacks_.Add(pair); 6894 return gc_prologue_callbacks_.Add(pair);
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
7767 old_space_strings_.Trim(); 7809 old_space_strings_.Trim();
7768 #ifdef VERIFY_HEAP 7810 #ifdef VERIFY_HEAP
7769 if (FLAG_verify_heap) { 7811 if (FLAG_verify_heap) {
7770 Verify(); 7812 Verify();
7771 } 7813 }
7772 #endif 7814 #endif
7773 } 7815 }
7774 7816
7775 7817
7776 void ExternalStringTable::TearDown() { 7818 void ExternalStringTable::TearDown() {
7819 for (int i = 0; i < new_space_strings_.length(); ++i) {
7820 heap_->FinalizeExternalString(ExternalString::cast(new_space_strings_[i]));
7821 }
7777 new_space_strings_.Free(); 7822 new_space_strings_.Free();
7823 for (int i = 0; i < old_space_strings_.length(); ++i) {
7824 heap_->FinalizeExternalString(ExternalString::cast(old_space_strings_[i]));
7825 }
7778 old_space_strings_.Free(); 7826 old_space_strings_.Free();
7779 } 7827 }
7780 7828
7781 7829
7782 void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) { 7830 void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) {
7783 chunk->set_next_chunk(chunks_queued_for_free_); 7831 chunk->set_next_chunk(chunks_queued_for_free_);
7784 chunks_queued_for_free_ = chunk; 7832 chunks_queued_for_free_ = chunk;
7785 } 7833 }
7786 7834
7787 7835
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 counters->size_of_CODE_AGE_##name()->Decrement( \ 7960 counters->size_of_CODE_AGE_##name()->Decrement( \
7913 static_cast<int>(object_sizes_last_time_[index])); 7961 static_cast<int>(object_sizes_last_time_[index]));
7914 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) 7962 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT)
7915 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7963 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7916 7964
7917 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7965 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7918 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7966 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7919 ClearObjectStats(); 7967 ClearObjectStats();
7920 } 7968 }
7921 7969
7922
7923 Heap::RelocationLock::RelocationLock(Heap* heap) : heap_(heap) {
7924 if (FLAG_concurrent_recompilation) {
7925 heap_->relocation_mutex_->Lock();
7926 #ifdef DEBUG
7927 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7928 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7929 #endif // DEBUG
7930 }
7931 }
7932
7933 } } // namespace v8::internal 7970 } } // namespace v8::internal
OLDNEW
« include/v8-platform.h ('K') | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698