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

Side by Side Diff: src/heap/heap.cc

Issue 1298113003: [api,heap] Fix external GC callbacks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Got rid of too many V8::Type vs Isolate::Type casts Created 5 years, 4 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
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | 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 // 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/heap/heap.h" 5 #include "src/heap/heap.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 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 GCTracer::Scope gc_scope(tracer(), 765 GCTracer::Scope gc_scope(tracer(),
766 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE); 766 GCTracer::Scope::MC_INCREMENTAL_WEAKCLOSURE);
767 767
768 { 768 {
769 GCCallbacksScope scope(this); 769 GCCallbacksScope scope(this);
770 if (scope.CheckReenter()) { 770 if (scope.CheckReenter()) {
771 AllowHeapAllocation allow_allocation; 771 AllowHeapAllocation allow_allocation;
772 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); 772 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
773 VMState<EXTERNAL> state(isolate_); 773 VMState<EXTERNAL> state(isolate_);
774 HandleScope handle_scope(isolate_); 774 HandleScope handle_scope(isolate_);
775 // TODO(mlippautz): Report kGCTypeIncremental once blink updates its
776 // filtering.
haraken 2015/08/19 13:11:21 CL uploaded here: https://codereview.chromium.org/
775 CallGCPrologueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags); 777 CallGCPrologueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags);
776 } 778 }
777 } 779 }
778 incremental_marking()->MarkObjectGroups(); 780 incremental_marking()->MarkObjectGroups();
779 { 781 {
780 GCCallbacksScope scope(this); 782 GCCallbacksScope scope(this);
781 if (scope.CheckReenter()) { 783 if (scope.CheckReenter()) {
782 AllowHeapAllocation allow_allocation; 784 AllowHeapAllocation allow_allocation;
783 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); 785 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL);
784 VMState<EXTERNAL> state(isolate_); 786 VMState<EXTERNAL> state(isolate_);
785 HandleScope handle_scope(isolate_); 787 HandleScope handle_scope(isolate_);
788 // TODO(mlippautz): Report kGCTypeIncremental once blink updates its
789 // filtering.
786 CallGCEpilogueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags); 790 CallGCEpilogueCallbacks(kGCTypeMarkSweepCompact, kNoGCCallbackFlags);
787 } 791 }
788 } 792 }
789 } 793 }
790 794
791 795
792 void Heap::CollectAllGarbage(int flags, const char* gc_reason, 796 void Heap::CollectAllGarbage(int flags, const char* gc_reason,
793 const v8::GCCallbackFlags gc_callback_flags) { 797 const v8::GCCallbackFlags gc_callback_flags) {
794 // Since we are ignoring the return value, the exact choice of space does 798 // Since we are ignoring the return value, the exact choice of space does
795 // not matter, so long as we do not specify NEW_SPACE, which would not 799 // not matter, so long as we do not specify NEW_SPACE, which would not
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 } 1285 }
1282 #endif 1286 #endif
1283 1287
1284 return freed_global_handles > 0; 1288 return freed_global_handles > 0;
1285 } 1289 }
1286 1290
1287 1291
1288 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { 1292 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
1289 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 1293 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
1290 if (gc_type & gc_prologue_callbacks_[i].gc_type) { 1294 if (gc_type & gc_prologue_callbacks_[i].gc_type) {
1291 if (!gc_prologue_callbacks_[i].pass_isolate_) { 1295 if (!gc_prologue_callbacks_[i].pass_isolate) {
1292 v8::GCPrologueCallback callback = 1296 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1293 reinterpret_cast<v8::GCPrologueCallback>( 1297 gc_prologue_callbacks_[i].callback);
1294 gc_prologue_callbacks_[i].callback);
1295 callback(gc_type, flags); 1298 callback(gc_type, flags);
1296 } else { 1299 } else {
1297 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1300 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1298 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags); 1301 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags);
1299 } 1302 }
1300 } 1303 }
1301 } 1304 }
1302 } 1305 }
1303 1306
1304 1307
1305 void Heap::CallGCEpilogueCallbacks(GCType gc_type, 1308 void Heap::CallGCEpilogueCallbacks(GCType gc_type,
1306 GCCallbackFlags gc_callback_flags) { 1309 GCCallbackFlags gc_callback_flags) {
1307 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 1310 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
1308 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { 1311 if (gc_type & gc_epilogue_callbacks_[i].gc_type) {
1309 if (!gc_epilogue_callbacks_[i].pass_isolate_) { 1312 if (!gc_epilogue_callbacks_[i].pass_isolate) {
1310 v8::GCPrologueCallback callback = 1313 v8::GCCallback callback = reinterpret_cast<v8::GCCallback>(
1311 reinterpret_cast<v8::GCPrologueCallback>( 1314 gc_epilogue_callbacks_[i].callback);
1312 gc_epilogue_callbacks_[i].callback);
1313 callback(gc_type, gc_callback_flags); 1315 callback(gc_type, gc_callback_flags);
1314 } else { 1316 } else {
1315 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate()); 1317 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1316 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags); 1318 gc_epilogue_callbacks_[i].callback(isolate, gc_type, gc_callback_flags);
1317 } 1319 }
1318 } 1320 }
1319 } 1321 }
1320 } 1322 }
1321 1323
1322 1324
(...skipping 4621 matching lines...) Expand 10 before | Expand all | Expand 10 after
5944 5946
5945 StrongRootsList* next = NULL; 5947 StrongRootsList* next = NULL;
5946 for (StrongRootsList* list = strong_roots_list_; list; list = next) { 5948 for (StrongRootsList* list = strong_roots_list_; list; list = next) {
5947 next = list->next; 5949 next = list->next;
5948 delete list; 5950 delete list;
5949 } 5951 }
5950 strong_roots_list_ = NULL; 5952 strong_roots_list_ = NULL;
5951 } 5953 }
5952 5954
5953 5955
5954 void Heap::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, 5956 void Heap::AddGCPrologueCallback(v8::Isolate::GCCallback callback,
5955 GCType gc_type, bool pass_isolate) { 5957 GCType gc_type, bool pass_isolate) {
5956 DCHECK(callback != NULL); 5958 DCHECK(callback != NULL);
5957 GCPrologueCallbackPair pair(callback, gc_type, pass_isolate); 5959 GCCallbackPair pair(callback, gc_type, pass_isolate);
5958 DCHECK(!gc_prologue_callbacks_.Contains(pair)); 5960 DCHECK(!gc_prologue_callbacks_.Contains(pair));
5959 return gc_prologue_callbacks_.Add(pair); 5961 return gc_prologue_callbacks_.Add(pair);
5960 } 5962 }
5961 5963
5962 5964
5963 void Heap::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback) { 5965 void Heap::RemoveGCPrologueCallback(v8::Isolate::GCCallback callback) {
5964 DCHECK(callback != NULL); 5966 DCHECK(callback != NULL);
5965 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 5967 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
5966 if (gc_prologue_callbacks_[i].callback == callback) { 5968 if (gc_prologue_callbacks_[i].callback == callback) {
5967 gc_prologue_callbacks_.Remove(i); 5969 gc_prologue_callbacks_.Remove(i);
5968 return; 5970 return;
5969 } 5971 }
5970 } 5972 }
5971 UNREACHABLE(); 5973 UNREACHABLE();
5972 } 5974 }
5973 5975
5974 5976
5975 void Heap::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, 5977 void Heap::AddGCEpilogueCallback(v8::Isolate::GCCallback callback,
5976 GCType gc_type, bool pass_isolate) { 5978 GCType gc_type, bool pass_isolate) {
5977 DCHECK(callback != NULL); 5979 DCHECK(callback != NULL);
5978 GCEpilogueCallbackPair pair(callback, gc_type, pass_isolate); 5980 GCCallbackPair pair(callback, gc_type, pass_isolate);
5979 DCHECK(!gc_epilogue_callbacks_.Contains(pair)); 5981 DCHECK(!gc_epilogue_callbacks_.Contains(pair));
5980 return gc_epilogue_callbacks_.Add(pair); 5982 return gc_epilogue_callbacks_.Add(pair);
5981 } 5983 }
5982 5984
5983 5985
5984 void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback) { 5986 void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCCallback callback) {
5985 DCHECK(callback != NULL); 5987 DCHECK(callback != NULL);
5986 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 5988 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
5987 if (gc_epilogue_callbacks_[i].callback == callback) { 5989 if (gc_epilogue_callbacks_[i].callback == callback) {
5988 gc_epilogue_callbacks_.Remove(i); 5990 gc_epilogue_callbacks_.Remove(i);
5989 return; 5991 return;
5990 } 5992 }
5991 } 5993 }
5992 UNREACHABLE(); 5994 UNREACHABLE();
5993 } 5995 }
5994 5996
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
6901 *object_type = "CODE_TYPE"; \ 6903 *object_type = "CODE_TYPE"; \
6902 *object_sub_type = "CODE_AGE/" #name; \ 6904 *object_sub_type = "CODE_AGE/" #name; \
6903 return true; 6905 return true;
6904 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6906 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6905 #undef COMPARE_AND_RETURN_NAME 6907 #undef COMPARE_AND_RETURN_NAME
6906 } 6908 }
6907 return false; 6909 return false;
6908 } 6910 }
6909 } // namespace internal 6911 } // namespace internal
6910 } // namespace v8 6912 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698