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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 #ifdef DEBUG | 699 #ifdef DEBUG |
700 ReportStatisticsAfterGC(); | 700 ReportStatisticsAfterGC(); |
701 #endif // DEBUG | 701 #endif // DEBUG |
702 | 702 |
703 // Remember the last top pointer so that we can later find out | 703 // Remember the last top pointer so that we can later find out |
704 // whether we allocated in new space since the last GC. | 704 // whether we allocated in new space since the last GC. |
705 new_space_top_after_last_gc_ = new_space()->top(); | 705 new_space_top_after_last_gc_ = new_space()->top(); |
706 } | 706 } |
707 | 707 |
708 | 708 |
709 void Heap::PreprocessStackTraces() { | |
710 if (!weak_stack_trace_list()->IsWeakFixedArray()) return; | |
711 WeakFixedArray* array = WeakFixedArray::cast(weak_stack_trace_list()); | |
712 int length = array->Length(); | |
713 for (int i = 0; i < length; i++) { | |
714 if (array->IsEmptySlot(i)) continue; | |
715 FixedArray* elements = FixedArray::cast(array->Get(i)); | |
716 for (int j = 1; j < elements->length(); j += 4) { | |
717 Code* code = Code::cast(elements->get(j + 2)); | |
718 int offset = Smi::cast(elements->get(j + 3))->value(); | |
719 Address pc = code->address() + offset; | |
720 int pos = code->SourcePosition(pc); | |
721 elements->set(j + 2, Smi::FromInt(pos)); | |
722 } | |
723 array->Clear(i); | |
724 } | |
725 array->Compact(); | |
726 } | |
727 | |
728 | |
729 void Heap::HandleGCRequest() { | 709 void Heap::HandleGCRequest() { |
730 if (incremental_marking()->request_type() == | 710 if (incremental_marking()->request_type() == |
731 IncrementalMarking::COMPLETE_MARKING) { | 711 IncrementalMarking::COMPLETE_MARKING) { |
732 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 712 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
733 return; | 713 return; |
734 } | 714 } |
735 DCHECK(FLAG_overapproximate_weak_closure); | 715 DCHECK(FLAG_overapproximate_weak_closure); |
736 if (!incremental_marking()->weak_closure_was_overapproximated()) { | 716 if (!incremental_marking()->weak_closure_was_overapproximated()) { |
737 OverApproximateWeakClosure("GC interrupt"); | 717 OverApproximateWeakClosure("GC interrupt"); |
738 } | 718 } |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 } | 1265 } |
1286 } | 1266 } |
1287 | 1267 |
1288 | 1268 |
1289 void Heap::MarkCompactEpilogue() { | 1269 void Heap::MarkCompactEpilogue() { |
1290 gc_state_ = NOT_IN_GC; | 1270 gc_state_ = NOT_IN_GC; |
1291 | 1271 |
1292 isolate_->counters()->objs_since_last_full()->Set(0); | 1272 isolate_->counters()->objs_since_last_full()->Set(0); |
1293 | 1273 |
1294 incremental_marking()->Epilogue(); | 1274 incremental_marking()->Epilogue(); |
1295 | |
1296 PreprocessStackTraces(); | |
1297 } | 1275 } |
1298 | 1276 |
1299 | 1277 |
1300 void Heap::MarkCompactPrologue() { | 1278 void Heap::MarkCompactPrologue() { |
1301 // At any old GC clear the keyed lookup cache to enable collection of unused | 1279 // At any old GC clear the keyed lookup cache to enable collection of unused |
1302 // maps. | 1280 // maps. |
1303 isolate_->keyed_lookup_cache()->Clear(); | 1281 isolate_->keyed_lookup_cache()->Clear(); |
1304 isolate_->context_slot_cache()->Clear(); | 1282 isolate_->context_slot_cache()->Clear(); |
1305 isolate_->descriptor_lookup_cache()->Clear(); | 1283 isolate_->descriptor_lookup_cache()->Clear(); |
1306 RegExpResultsCache::Clear(string_split_cache()); | 1284 RegExpResultsCache::Clear(string_split_cache()); |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3097 | 3075 |
3098 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); | 3076 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); |
3099 | 3077 |
3100 // Handling of script id generation is in Factory::NewScript. | 3078 // Handling of script id generation is in Factory::NewScript. |
3101 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); | 3079 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); |
3102 | 3080 |
3103 Handle<PropertyCell> cell = factory->NewPropertyCell(); | 3081 Handle<PropertyCell> cell = factory->NewPropertyCell(); |
3104 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); | 3082 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); |
3105 set_array_protector(*cell); | 3083 set_array_protector(*cell); |
3106 | 3084 |
3107 set_weak_stack_trace_list(Smi::FromInt(0)); | |
3108 | |
3109 set_allocation_sites_scratchpad( | 3085 set_allocation_sites_scratchpad( |
3110 *factory->NewFixedArray(kAllocationSiteScratchpadSize, TENURED)); | 3086 *factory->NewFixedArray(kAllocationSiteScratchpadSize, TENURED)); |
3111 InitializeAllocationSitesScratchpad(); | 3087 InitializeAllocationSitesScratchpad(); |
3112 | 3088 |
3113 // Initialize keyed lookup cache. | 3089 // Initialize keyed lookup cache. |
3114 isolate_->keyed_lookup_cache()->Clear(); | 3090 isolate_->keyed_lookup_cache()->Clear(); |
3115 | 3091 |
3116 // Initialize context slot cache. | 3092 // Initialize context slot cache. |
3117 isolate_->context_slot_cache()->Clear(); | 3093 isolate_->context_slot_cache()->Clear(); |
3118 | 3094 |
(...skipping 16 matching lines...) Expand all Loading... |
3135 case kNonMonomorphicCacheRootIndex: | 3111 case kNonMonomorphicCacheRootIndex: |
3136 case kPolymorphicCodeCacheRootIndex: | 3112 case kPolymorphicCodeCacheRootIndex: |
3137 case kEmptyScriptRootIndex: | 3113 case kEmptyScriptRootIndex: |
3138 case kSymbolRegistryRootIndex: | 3114 case kSymbolRegistryRootIndex: |
3139 case kMaterializedObjectsRootIndex: | 3115 case kMaterializedObjectsRootIndex: |
3140 case kAllocationSitesScratchpadRootIndex: | 3116 case kAllocationSitesScratchpadRootIndex: |
3141 case kMicrotaskQueueRootIndex: | 3117 case kMicrotaskQueueRootIndex: |
3142 case kDetachedContextsRootIndex: | 3118 case kDetachedContextsRootIndex: |
3143 case kWeakObjectToCodeTableRootIndex: | 3119 case kWeakObjectToCodeTableRootIndex: |
3144 case kRetainedMapsRootIndex: | 3120 case kRetainedMapsRootIndex: |
3145 case kWeakStackTraceListRootIndex: | |
3146 // Smi values | 3121 // Smi values |
3147 #define SMI_ENTRY(type, name, Name) case k##Name##RootIndex: | 3122 #define SMI_ENTRY(type, name, Name) case k##Name##RootIndex: |
3148 SMI_ROOT_LIST(SMI_ENTRY) | 3123 SMI_ROOT_LIST(SMI_ENTRY) |
3149 #undef SMI_ENTRY | 3124 #undef SMI_ENTRY |
3150 // String table | 3125 // String table |
3151 case kStringTableRootIndex: | 3126 case kStringTableRootIndex: |
3152 return true; | 3127 return true; |
3153 | 3128 |
3154 default: | 3129 default: |
3155 return false; | 3130 return false; |
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6406 static_cast<int>(object_sizes_last_time_[index])); | 6381 static_cast<int>(object_sizes_last_time_[index])); |
6407 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6382 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6408 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6383 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6409 | 6384 |
6410 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6385 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6411 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6386 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6412 ClearObjectStats(); | 6387 ClearObjectStats(); |
6413 } | 6388 } |
6414 } | 6389 } |
6415 } // namespace v8::internal | 6390 } // namespace v8::internal |
OLD | NEW |