| 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 "lib/stacktrace.h" | 9 #include "lib/stacktrace.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 NoSafepointScope no_safepoint_scope; | 1015 NoSafepointScope no_safepoint_scope; |
| 1016 ASSERT(isolate == Isolate::Current()); | 1016 ASSERT(isolate == Isolate::Current()); |
| 1017 ApiState* state = isolate->api_state(); | 1017 ApiState* state = isolate->api_state(); |
| 1018 ASSERT(state != NULL); | 1018 ASSERT(state != NULL); |
| 1019 FinalizablePersistentHandle* weak_ref = | 1019 FinalizablePersistentHandle* weak_ref = |
| 1020 FinalizablePersistentHandle::Cast(object); | 1020 FinalizablePersistentHandle::Cast(object); |
| 1021 weak_ref->EnsureFreeExternal(isolate); | 1021 weak_ref->EnsureFreeExternal(isolate); |
| 1022 state->weak_persistent_handles().FreeHandle(weak_ref); | 1022 state->weak_persistent_handles().FreeHandle(weak_ref); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 // --- Garbage Collection Callbacks -- | |
| 1026 | |
| 1027 DART_EXPORT Dart_Handle | |
| 1028 Dart_SetGcCallbacks(Dart_GcPrologueCallback prologue_callback, | |
| 1029 Dart_GcEpilogueCallback epilogue_callback) { | |
| 1030 Thread* thread = Thread::Current(); | |
| 1031 Isolate* isolate = thread->isolate(); | |
| 1032 CHECK_ISOLATE(isolate); | |
| 1033 DARTSCOPE(thread); | |
| 1034 if (prologue_callback != NULL) { | |
| 1035 if (isolate->gc_prologue_callback() != NULL) { | |
| 1036 return Api::NewError( | |
| 1037 "%s permits only one gc prologue callback to be registered, please " | |
| 1038 "remove the existing callback and then add this callback", | |
| 1039 CURRENT_FUNC); | |
| 1040 } | |
| 1041 } else { | |
| 1042 if (isolate->gc_prologue_callback() == NULL) { | |
| 1043 return Api::NewError( | |
| 1044 "%s expects 'prologue_callback' to be present in the callback set.", | |
| 1045 CURRENT_FUNC); | |
| 1046 } | |
| 1047 } | |
| 1048 if (epilogue_callback != NULL) { | |
| 1049 if (isolate->gc_epilogue_callback() != NULL) { | |
| 1050 return Api::NewError( | |
| 1051 "%s permits only one gc epilogue callback to be registered, please " | |
| 1052 "remove the existing callback and then add this callback", | |
| 1053 CURRENT_FUNC); | |
| 1054 } | |
| 1055 } else { | |
| 1056 if (isolate->gc_epilogue_callback() == NULL) { | |
| 1057 return Api::NewError( | |
| 1058 "%s expects 'epilogue_callback' to be present in the callback set.", | |
| 1059 CURRENT_FUNC); | |
| 1060 } | |
| 1061 } | |
| 1062 isolate->set_gc_prologue_callback(prologue_callback); | |
| 1063 isolate->set_gc_epilogue_callback(epilogue_callback); | |
| 1064 return Api::Success(); | |
| 1065 } | |
| 1066 | |
| 1067 // --- Initialization and Globals --- | 1025 // --- Initialization and Globals --- |
| 1068 | 1026 |
| 1069 DART_EXPORT const char* Dart_VersionString() { | 1027 DART_EXPORT const char* Dart_VersionString() { |
| 1070 return Version::String(); | 1028 return Version::String(); |
| 1071 } | 1029 } |
| 1072 | 1030 |
| 1073 DART_EXPORT char* Dart_Initialize(Dart_InitializeParams* params) { | 1031 DART_EXPORT char* Dart_Initialize(Dart_InitializeParams* params) { |
| 1074 if (params == NULL) { | 1032 if (params == NULL) { |
| 1075 return strdup( | 1033 return strdup( |
| 1076 "Dart_Initialize: " | 1034 "Dart_Initialize: " |
| (...skipping 5664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6741 #endif | 6699 #endif |
| 6742 } | 6700 } |
| 6743 | 6701 |
| 6744 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6702 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6745 #ifndef PRODUCT | 6703 #ifndef PRODUCT |
| 6746 Profiler::DumpStackTrace(context); | 6704 Profiler::DumpStackTrace(context); |
| 6747 #endif | 6705 #endif |
| 6748 } | 6706 } |
| 6749 | 6707 |
| 6750 } // namespace dart | 6708 } // namespace dart |
| OLD | NEW |