| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Return error if isolate is in an inconsistent state. | 56 // Return error if isolate is in an inconsistent state. |
| 57 // Return NULL when no error condition exists. | 57 // Return NULL when no error condition exists. |
| 58 const char* CheckIsolateState(Isolate* isolate, bool generating_snapshot) { | 58 const char* CheckIsolateState(Isolate* isolate, bool generating_snapshot) { |
| 59 bool success = true; | 59 bool success = true; |
| 60 if (!ClassFinalizer::AllClassesFinalized()) { | 60 if (!ClassFinalizer::AllClassesFinalized()) { |
| 61 success = (generating_snapshot) ? | 61 success = (generating_snapshot) ? |
| 62 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() : | 62 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() : |
| 63 ClassFinalizer::FinalizePendingClasses(); | 63 ClassFinalizer::FinalizePendingClasses(); |
| 64 } | 64 } |
| 65 if (success && !generating_snapshot) { | 65 if (success) { |
| 66 success = isolate->object_store()->PreallocateObjects(); | 66 success = isolate->object_store()->PreallocateObjects(); |
| 67 if (success) { |
| 68 return NULL; |
| 69 } |
| 67 } | 70 } |
| 68 if (success) { | 71 // Make a copy of the error message as the original message string |
| 69 return NULL; | 72 // may get deallocated when we return back from the Dart API call. |
| 70 } else { | 73 const Error& err = Error::Handle(isolate->object_store()->sticky_error()); |
| 71 // Make a copy of the error message as the original message string | 74 const char* errmsg = err.ToErrorCString(); |
| 72 // may get deallocated when we return back from the Dart API call. | 75 intptr_t errlen = strlen(errmsg) + 1; |
| 73 const Error& err = | 76 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); |
| 74 Error::Handle(isolate->object_store()->sticky_error()); | 77 OS::SNPrint(msg, errlen, "%s", errmsg); |
| 75 const char* errmsg = err.ToErrorCString(); | 78 return msg; |
| 76 intptr_t errlen = strlen(errmsg) + 1; | |
| 77 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); | |
| 78 OS::SNPrint(msg, errlen, "%s", errmsg); | |
| 79 return msg; | |
| 80 } | |
| 81 } | 79 } |
| 82 | 80 |
| 83 | 81 |
| 84 void SetupErrorResult(Dart_Handle* handle) { | 82 void SetupErrorResult(Dart_Handle* handle) { |
| 85 const Error& error = Error::Handle( | 83 const Error& error = Error::Handle( |
| 86 Isolate::Current()->object_store()->sticky_error()); | 84 Isolate::Current()->object_store()->sticky_error()); |
| 87 *handle = Api::NewLocalHandle(error); | 85 *handle = Api::NewLocalHandle(error); |
| 88 } | 86 } |
| 89 | 87 |
| 90 | 88 |
| (...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 *buffer = NULL; | 2710 *buffer = NULL; |
| 2713 } | 2711 } |
| 2714 delete debug_region; | 2712 delete debug_region; |
| 2715 } else { | 2713 } else { |
| 2716 *buffer = NULL; | 2714 *buffer = NULL; |
| 2717 *buffer_size = 0; | 2715 *buffer_size = 0; |
| 2718 } | 2716 } |
| 2719 } | 2717 } |
| 2720 | 2718 |
| 2721 } // namespace dart | 2719 } // namespace dart |
| OLD | NEW |