Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 | 757 |
| 758 WeakReferenceSet* reference_set = new WeakReferenceSet(keys, num_keys, | 758 WeakReferenceSet* reference_set = new WeakReferenceSet(keys, num_keys, |
| 759 values, num_values); | 759 values, num_values); |
| 760 state->DelayWeakReferenceSet(reference_set); | 760 state->DelayWeakReferenceSet(reference_set); |
| 761 return Api::Success(); | 761 return Api::Success(); |
| 762 } | 762 } |
| 763 | 763 |
| 764 | 764 |
| 765 // --- Garbage Collection Callbacks -- | 765 // --- Garbage Collection Callbacks -- |
| 766 | 766 |
| 767 DART_EXPORT Dart_Handle Dart_AddGcPrologueCallback( | 767 DART_EXPORT Dart_Handle Dart_AddGcPrologueCallback( |
|
Ivan Posva
2014/03/12 21:06:41
We might want to follow the other functions in the
siva
2014/03/12 22:38:54
Done, Added Dart_SetGcCallbacks(prologue, epilogue
| |
| 768 Dart_GcPrologueCallback callback) { | 768 Dart_GcPrologueCallback callback) { |
| 769 Isolate* isolate = Isolate::Current(); | 769 Isolate* isolate = Isolate::Current(); |
| 770 CHECK_ISOLATE(isolate); | 770 CHECK_ISOLATE(isolate); |
| 771 GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks(); | 771 if (isolate->gc_prologue_callback() != NULL) { |
| 772 if (callbacks.Contains(callback)) { | |
| 773 return Api::NewError( | 772 return Api::NewError( |
| 774 "%s permits only one instance of 'callback' to be present in the " | 773 "%s permits only one gc prologue callback to be registered, please " |
| 775 "prologue callback list.", | 774 "remove the existing callback using Dart_RemoveGcPrologueCallback " |
| 775 "and then add this callback", | |
| 776 CURRENT_FUNC); | 776 CURRENT_FUNC); |
| 777 } | 777 } |
| 778 callbacks.Add(callback); | 778 isolate->set_gc_prologue_callback(callback); |
| 779 return Api::Success(); | 779 return Api::Success(); |
| 780 } | 780 } |
| 781 | 781 |
| 782 | 782 |
| 783 DART_EXPORT Dart_Handle Dart_RemoveGcPrologueCallback( | 783 DART_EXPORT Dart_Handle Dart_RemoveGcPrologueCallback( |
| 784 Dart_GcPrologueCallback callback) { | 784 Dart_GcPrologueCallback callback) { |
| 785 Isolate* isolate = Isolate::Current(); | 785 Isolate* isolate = Isolate::Current(); |
| 786 CHECK_ISOLATE(isolate); | 786 CHECK_ISOLATE(isolate); |
| 787 GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks(); | 787 if (isolate->gc_prologue_callback() != callback) { |
| 788 if (!callbacks.Contains(callback)) { | |
| 789 return Api::NewError( | 788 return Api::NewError( |
| 790 "%s expects 'callback' to be present in the prologue callback list.", | 789 "%s expects 'callback' to be the currently registered gc prologue " |
| 790 "callback .", | |
| 791 CURRENT_FUNC); | 791 CURRENT_FUNC); |
| 792 } | 792 } |
| 793 callbacks.Remove(callback); | 793 isolate->set_gc_prologue_callback(NULL); |
| 794 return Api::Success(); | 794 return Api::Success(); |
| 795 } | 795 } |
| 796 | 796 |
| 797 | 797 |
| 798 DART_EXPORT Dart_Handle Dart_AddGcEpilogueCallback( | 798 DART_EXPORT Dart_Handle Dart_AddGcEpilogueCallback( |
| 799 Dart_GcEpilogueCallback callback) { | 799 Dart_GcEpilogueCallback callback) { |
| 800 Isolate* isolate = Isolate::Current(); | 800 Isolate* isolate = Isolate::Current(); |
| 801 CHECK_ISOLATE(isolate); | 801 CHECK_ISOLATE(isolate); |
| 802 GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks(); | 802 if (isolate->gc_epilogue_callback() != NULL) { |
| 803 if (callbacks.Contains(callback)) { | |
| 804 return Api::NewError( | 803 return Api::NewError( |
| 805 "%s permits only one instance of 'callback' to be present in the " | 804 "%s permits only one gc epilogue callback to be registered, please " |
| 806 "epilogue callback list.", | 805 "remove the existing callback using Dart_RemoveGcEpilogueCallback " |
| 806 "and then add this callback", | |
| 807 CURRENT_FUNC); | 807 CURRENT_FUNC); |
| 808 } | 808 } |
| 809 callbacks.Add(callback); | 809 isolate->set_gc_epilogue_callback(callback); |
| 810 return Api::Success(); | 810 return Api::Success(); |
| 811 } | 811 } |
| 812 | 812 |
| 813 | 813 |
| 814 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback( | 814 DART_EXPORT Dart_Handle Dart_RemoveGcEpilogueCallback( |
| 815 Dart_GcEpilogueCallback callback) { | 815 Dart_GcEpilogueCallback callback) { |
| 816 Isolate* isolate = Isolate::Current(); | 816 Isolate* isolate = Isolate::Current(); |
| 817 CHECK_ISOLATE(isolate); | 817 CHECK_ISOLATE(isolate); |
| 818 GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks(); | 818 if (isolate->gc_epilogue_callback() != callback) { |
| 819 if (!callbacks.Contains(callback)) { | |
| 820 return Api::NewError( | 819 return Api::NewError( |
| 821 "%s expects 'callback' to be present in the epilogue callback list.", | 820 "%s expects 'callback' to be present in the epilogue callback list.", |
|
Ivan Posva
2014/03/12 21:06:41
Still referencing list.
siva
2014/03/12 22:38:54
Done.
| |
| 822 CURRENT_FUNC); | 821 CURRENT_FUNC); |
| 823 } | 822 } |
| 824 callbacks.Remove(callback); | 823 isolate->set_gc_epilogue_callback(NULL); |
| 825 return Api::Success(); | 824 return Api::Success(); |
| 826 } | 825 } |
| 827 | 826 |
| 828 | 827 |
| 829 // --- Initialization and Globals --- | 828 // --- Initialization and Globals --- |
| 830 | 829 |
| 831 DART_EXPORT const char* Dart_VersionString() { | 830 DART_EXPORT const char* Dart_VersionString() { |
| 832 return Version::String(); | 831 return Version::String(); |
| 833 } | 832 } |
| 834 | 833 |
| (...skipping 3820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4655 | 4654 |
| 4656 | 4655 |
| 4657 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4656 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 4658 const char* name, | 4657 const char* name, |
| 4659 Dart_ServiceRequestCallback callback, | 4658 Dart_ServiceRequestCallback callback, |
| 4660 void* user_data) { | 4659 void* user_data) { |
| 4661 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4660 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 4662 } | 4661 } |
| 4663 | 4662 |
| 4664 } // namespace dart | 4663 } // namespace dart |
| OLD | NEW |