| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 | 424 |
| 425 void Heap::IncrementDeferredCount(v8::Isolate::UseCounterFeature feature) { | 425 void Heap::IncrementDeferredCount(v8::Isolate::UseCounterFeature feature) { |
| 426 deferred_counters_[feature]++; | 426 deferred_counters_[feature]++; |
| 427 } | 427 } |
| 428 | 428 |
| 429 | 429 |
| 430 void Heap::GarbageCollectionPrologue() { | 430 void Heap::GarbageCollectionPrologue() { |
| 431 { | 431 { |
| 432 AllowHeapAllocation for_the_first_part_of_prologue; | 432 AllowHeapAllocation for_the_first_part_of_prologue; |
| 433 ClearJSFunctionResultCaches(); | |
| 434 gc_count_++; | 433 gc_count_++; |
| 435 unflattened_strings_length_ = 0; | 434 unflattened_strings_length_ = 0; |
| 436 | 435 |
| 437 if (FLAG_flush_code) { | 436 if (FLAG_flush_code) { |
| 438 mark_compact_collector()->EnableCodeFlushing(true); | 437 mark_compact_collector()->EnableCodeFlushing(true); |
| 439 } | 438 } |
| 440 | 439 |
| 441 #ifdef VERIFY_HEAP | 440 #ifdef VERIFY_HEAP |
| 442 if (FLAG_verify_heap) { | 441 if (FLAG_verify_heap) { |
| 443 Verify(); | 442 Verify(); |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1126 |
| 1128 void Heap::EnsureFromSpaceIsCommitted() { | 1127 void Heap::EnsureFromSpaceIsCommitted() { |
| 1129 if (new_space_.CommitFromSpaceIfNeeded()) return; | 1128 if (new_space_.CommitFromSpaceIfNeeded()) return; |
| 1130 | 1129 |
| 1131 // Committing memory to from space failed. | 1130 // Committing memory to from space failed. |
| 1132 // Memory is exhausted and we will die. | 1131 // Memory is exhausted and we will die. |
| 1133 V8::FatalProcessOutOfMemory("Committing semi space failed."); | 1132 V8::FatalProcessOutOfMemory("Committing semi space failed."); |
| 1134 } | 1133 } |
| 1135 | 1134 |
| 1136 | 1135 |
| 1137 void Heap::ClearJSFunctionResultCaches() { | |
| 1138 if (isolate_->bootstrapper()->IsActive()) return; | |
| 1139 | |
| 1140 Object* context = native_contexts_list(); | |
| 1141 while (!context->IsUndefined()) { | |
| 1142 // Get the caches for this context. GC can happen when the context | |
| 1143 // is not fully initialized, so the caches can be undefined. | |
| 1144 Object* caches_or_undefined = | |
| 1145 Context::cast(context)->get(Context::JSFUNCTION_RESULT_CACHES_INDEX); | |
| 1146 if (!caches_or_undefined->IsUndefined()) { | |
| 1147 FixedArray* caches = FixedArray::cast(caches_or_undefined); | |
| 1148 // Clear the caches: | |
| 1149 int length = caches->length(); | |
| 1150 for (int i = 0; i < length; i++) { | |
| 1151 JSFunctionResultCache::cast(caches->get(i))->Clear(); | |
| 1152 } | |
| 1153 } | |
| 1154 // Get the next context: | |
| 1155 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | |
| 1156 } | |
| 1157 } | |
| 1158 | |
| 1159 | |
| 1160 void Heap::ClearNormalizedMapCaches() { | 1136 void Heap::ClearNormalizedMapCaches() { |
| 1161 if (isolate_->bootstrapper()->IsActive() && | 1137 if (isolate_->bootstrapper()->IsActive() && |
| 1162 !incremental_marking()->IsMarking()) { | 1138 !incremental_marking()->IsMarking()) { |
| 1163 return; | 1139 return; |
| 1164 } | 1140 } |
| 1165 | 1141 |
| 1166 Object* context = native_contexts_list(); | 1142 Object* context = native_contexts_list(); |
| 1167 while (!context->IsUndefined()) { | 1143 while (!context->IsUndefined()) { |
| 1168 // GC can happen when the context is not fully initialized, | 1144 // GC can happen when the context is not fully initialized, |
| 1169 // so the cache can be undefined. | 1145 // so the cache can be undefined. |
| (...skipping 5772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6942 *object_type = "CODE_TYPE"; \ | 6918 *object_type = "CODE_TYPE"; \ |
| 6943 *object_sub_type = "CODE_AGE/" #name; \ | 6919 *object_sub_type = "CODE_AGE/" #name; \ |
| 6944 return true; | 6920 return true; |
| 6945 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6921 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6946 #undef COMPARE_AND_RETURN_NAME | 6922 #undef COMPARE_AND_RETURN_NAME |
| 6947 } | 6923 } |
| 6948 return false; | 6924 return false; |
| 6949 } | 6925 } |
| 6950 } // namespace internal | 6926 } // namespace internal |
| 6951 } // namespace v8 | 6927 } // namespace v8 |
| OLD | NEW |