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 |
709 void Heap::HandleGCRequest() { | 729 void Heap::HandleGCRequest() { |
710 if (incremental_marking()->request_type() == | 730 if (incremental_marking()->request_type() == |
711 IncrementalMarking::COMPLETE_MARKING) { | 731 IncrementalMarking::COMPLETE_MARKING) { |
712 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 732 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
713 return; | 733 return; |
714 } | 734 } |
715 DCHECK(FLAG_overapproximate_weak_closure); | 735 DCHECK(FLAG_overapproximate_weak_closure); |
716 if (!incremental_marking()->weak_closure_was_overapproximated()) { | 736 if (!incremental_marking()->weak_closure_was_overapproximated()) { |
717 OverApproximateWeakClosure("GC interrupt"); | 737 OverApproximateWeakClosure("GC interrupt"); |
718 } | 738 } |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 } | 1285 } |
1266 } | 1286 } |
1267 | 1287 |
1268 | 1288 |
1269 void Heap::MarkCompactEpilogue() { | 1289 void Heap::MarkCompactEpilogue() { |
1270 gc_state_ = NOT_IN_GC; | 1290 gc_state_ = NOT_IN_GC; |
1271 | 1291 |
1272 isolate_->counters()->objs_since_last_full()->Set(0); | 1292 isolate_->counters()->objs_since_last_full()->Set(0); |
1273 | 1293 |
1274 incremental_marking()->Epilogue(); | 1294 incremental_marking()->Epilogue(); |
| 1295 |
| 1296 PreprocessStackTraces(); |
1275 } | 1297 } |
1276 | 1298 |
1277 | 1299 |
1278 void Heap::MarkCompactPrologue() { | 1300 void Heap::MarkCompactPrologue() { |
1279 // At any old GC clear the keyed lookup cache to enable collection of unused | 1301 // At any old GC clear the keyed lookup cache to enable collection of unused |
1280 // maps. | 1302 // maps. |
1281 isolate_->keyed_lookup_cache()->Clear(); | 1303 isolate_->keyed_lookup_cache()->Clear(); |
1282 isolate_->context_slot_cache()->Clear(); | 1304 isolate_->context_slot_cache()->Clear(); |
1283 isolate_->descriptor_lookup_cache()->Clear(); | 1305 isolate_->descriptor_lookup_cache()->Clear(); |
1284 RegExpResultsCache::Clear(string_split_cache()); | 1306 RegExpResultsCache::Clear(string_split_cache()); |
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3075 | 3097 |
3076 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); | 3098 set_materialized_objects(*factory->NewFixedArray(0, TENURED)); |
3077 | 3099 |
3078 // Handling of script id generation is in Factory::NewScript. | 3100 // Handling of script id generation is in Factory::NewScript. |
3079 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); | 3101 set_last_script_id(Smi::FromInt(v8::UnboundScript::kNoScriptId)); |
3080 | 3102 |
3081 Handle<PropertyCell> cell = factory->NewPropertyCell(); | 3103 Handle<PropertyCell> cell = factory->NewPropertyCell(); |
3082 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); | 3104 cell->set_value(Smi::FromInt(Isolate::kArrayProtectorValid)); |
3083 set_array_protector(*cell); | 3105 set_array_protector(*cell); |
3084 | 3106 |
| 3107 set_weak_stack_trace_list(Smi::FromInt(0)); |
| 3108 |
3085 set_allocation_sites_scratchpad( | 3109 set_allocation_sites_scratchpad( |
3086 *factory->NewFixedArray(kAllocationSiteScratchpadSize, TENURED)); | 3110 *factory->NewFixedArray(kAllocationSiteScratchpadSize, TENURED)); |
3087 InitializeAllocationSitesScratchpad(); | 3111 InitializeAllocationSitesScratchpad(); |
3088 | 3112 |
3089 // Initialize keyed lookup cache. | 3113 // Initialize keyed lookup cache. |
3090 isolate_->keyed_lookup_cache()->Clear(); | 3114 isolate_->keyed_lookup_cache()->Clear(); |
3091 | 3115 |
3092 // Initialize context slot cache. | 3116 // Initialize context slot cache. |
3093 isolate_->context_slot_cache()->Clear(); | 3117 isolate_->context_slot_cache()->Clear(); |
3094 | 3118 |
(...skipping 16 matching lines...) Expand all Loading... |
3111 case kNonMonomorphicCacheRootIndex: | 3135 case kNonMonomorphicCacheRootIndex: |
3112 case kPolymorphicCodeCacheRootIndex: | 3136 case kPolymorphicCodeCacheRootIndex: |
3113 case kEmptyScriptRootIndex: | 3137 case kEmptyScriptRootIndex: |
3114 case kSymbolRegistryRootIndex: | 3138 case kSymbolRegistryRootIndex: |
3115 case kMaterializedObjectsRootIndex: | 3139 case kMaterializedObjectsRootIndex: |
3116 case kAllocationSitesScratchpadRootIndex: | 3140 case kAllocationSitesScratchpadRootIndex: |
3117 case kMicrotaskQueueRootIndex: | 3141 case kMicrotaskQueueRootIndex: |
3118 case kDetachedContextsRootIndex: | 3142 case kDetachedContextsRootIndex: |
3119 case kWeakObjectToCodeTableRootIndex: | 3143 case kWeakObjectToCodeTableRootIndex: |
3120 case kRetainedMapsRootIndex: | 3144 case kRetainedMapsRootIndex: |
| 3145 case kWeakStackTraceListRootIndex: |
3121 // Smi values | 3146 // Smi values |
3122 #define SMI_ENTRY(type, name, Name) case k##Name##RootIndex: | 3147 #define SMI_ENTRY(type, name, Name) case k##Name##RootIndex: |
3123 SMI_ROOT_LIST(SMI_ENTRY) | 3148 SMI_ROOT_LIST(SMI_ENTRY) |
3124 #undef SMI_ENTRY | 3149 #undef SMI_ENTRY |
3125 // String table | 3150 // String table |
3126 case kStringTableRootIndex: | 3151 case kStringTableRootIndex: |
3127 return true; | 3152 return true; |
3128 | 3153 |
3129 default: | 3154 default: |
3130 return false; | 3155 return false; |
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6381 static_cast<int>(object_sizes_last_time_[index])); | 6406 static_cast<int>(object_sizes_last_time_[index])); |
6382 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6407 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6383 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6408 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6384 | 6409 |
6385 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6410 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6386 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6411 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6387 ClearObjectStats(); | 6412 ClearObjectStats(); |
6388 } | 6413 } |
6389 } | 6414 } |
6390 } // namespace v8::internal | 6415 } // namespace v8::internal |
OLD | NEW |