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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 2281193002: Treat background finalization as another GC task so it won't run in parallel with the marker. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | runtime/vm/dart_api_impl_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 ApiState* state = Isolate::Current()->api_state(); 723 ApiState* state = Isolate::Current()->api_state();
724 ASSERT(state->IsValidWeakPersistentHandle(handle)); 724 ASSERT(state->IsValidWeakPersistentHandle(handle));
725 #endif 725 #endif
726 return reinterpret_cast<FinalizablePersistentHandle*>(handle); 726 return reinterpret_cast<FinalizablePersistentHandle*>(handle);
727 } 727 }
728 728
729 729
730 void FinalizablePersistentHandle::Finalize( 730 void FinalizablePersistentHandle::Finalize(
731 Isolate* isolate, FinalizablePersistentHandle* handle) { 731 Isolate* isolate, FinalizablePersistentHandle* handle) {
732 if (!handle->raw()->IsHeapObject()) { 732 if (!handle->raw()->IsHeapObject()) {
733 return; 733 return; // Free handle.
734 } 734 }
735 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); 735 Dart_WeakPersistentHandleFinalizer callback = handle->callback();
736 ASSERT(callback != NULL); 736 ASSERT(callback != NULL);
737 void* peer = handle->peer(); 737 void* peer = handle->peer();
738 Dart_WeakPersistentHandle object = handle->apiHandle(); 738 Dart_WeakPersistentHandle object = handle->apiHandle();
739 (*callback)(isolate->init_callback_data(), object, peer); 739 (*callback)(isolate->init_callback_data(), object, peer);
740 ApiState* state = isolate->api_state(); 740 ApiState* state = isolate->api_state();
741 ASSERT(state != NULL); 741 ASSERT(state != NULL);
742 state->weak_persistent_handles().FreeHandle(handle); 742 state->weak_persistent_handles().FreeHandle(handle);
743 } 743 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1027
1028 static Dart_WeakPersistentHandle AllocateFinalizableHandle( 1028 static Dart_WeakPersistentHandle AllocateFinalizableHandle(
1029 Thread* thread, 1029 Thread* thread,
1030 Dart_Handle object, 1030 Dart_Handle object,
1031 void* peer, 1031 void* peer,
1032 intptr_t external_allocation_size, 1032 intptr_t external_allocation_size,
1033 Dart_WeakPersistentHandleFinalizer callback) { 1033 Dart_WeakPersistentHandleFinalizer callback) {
1034 REUSABLE_OBJECT_HANDLESCOPE(thread); 1034 REUSABLE_OBJECT_HANDLESCOPE(thread);
1035 Object& ref = thread->ObjectHandle(); 1035 Object& ref = thread->ObjectHandle();
1036 ref = Api::UnwrapHandle(object); 1036 ref = Api::UnwrapHandle(object);
1037 if (!ref.raw()->IsHeapObject()) {
1038 return NULL;
1039 }
1037 FinalizablePersistentHandle* finalizable_ref = 1040 FinalizablePersistentHandle* finalizable_ref =
1038 FinalizablePersistentHandle::New(thread->isolate(), 1041 FinalizablePersistentHandle::New(thread->isolate(),
1039 ref, 1042 ref,
1040 peer, 1043 peer,
1041 callback, 1044 callback,
1042 external_allocation_size); 1045 external_allocation_size);
1043 return finalizable_ref->apiHandle(); 1046 return finalizable_ref->apiHandle();
1044 } 1047 }
1045 1048
1046 1049
(...skipping 5533 matching lines...) Expand 10 before | Expand all | Expand 10 after
6580 6583
6581 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6584 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6582 #if defined(DART_PRECOMPILED_RUNTIME) 6585 #if defined(DART_PRECOMPILED_RUNTIME)
6583 return true; 6586 return true;
6584 #else 6587 #else
6585 return false; 6588 return false;
6586 #endif 6589 #endif
6587 } 6590 }
6588 6591
6589 } // namespace dart 6592 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | runtime/vm/dart_api_impl_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698