OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 ClassFinalizer::FinalizePendingClasses(); | 60 ClassFinalizer::FinalizePendingClasses(); |
61 } | 61 } |
62 if (success && !generating_snapshot) { | 62 if (success && !generating_snapshot) { |
63 success = isolate->object_store()->PreallocateObjects(); | 63 success = isolate->object_store()->PreallocateObjects(); |
64 } | 64 } |
65 if (success) { | 65 if (success) { |
66 return NULL; | 66 return NULL; |
67 } else { | 67 } else { |
68 // Make a copy of the error message as the original message string | 68 // Make a copy of the error message as the original message string |
69 // may get deallocated when we return back from the Dart API call. | 69 // may get deallocated when we return back from the Dart API call. |
70 const String& err = | 70 const Error& err = |
71 String::Handle(isolate->object_store()->sticky_error()); | 71 Error::Handle(isolate->object_store()->sticky_error()); |
72 const char* errmsg = err.ToCString(); | 72 const char* errmsg = err.ToErrorCString(); |
73 intptr_t errlen = strlen(errmsg) + 1; | 73 intptr_t errlen = strlen(errmsg) + 1; |
74 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); | 74 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); |
75 OS::SNPrint(msg, errlen, "%s", errmsg); | 75 OS::SNPrint(msg, errlen, "%s", errmsg); |
76 return msg; | 76 return msg; |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 void SetupErrorResult(Dart_Handle* handle) { | 81 void SetupErrorResult(Dart_Handle* handle) { |
82 // Make a copy of the error message as the original message string | 82 const Error& error = Error::Handle( |
83 // may get deallocated when we return back from the Dart API call. | |
84 const String& error = String::Handle( | |
85 Isolate::Current()->object_store()->sticky_error()); | 83 Isolate::Current()->object_store()->sticky_error()); |
86 const Object& obj = Object::Handle(LanguageError::New(error)); | 84 *handle = Api::NewLocalHandle(error); |
87 *handle = Api::NewLocalHandle(obj); | |
88 } | 85 } |
89 | 86 |
90 | 87 |
91 // NOTE: Need to pass 'result' as a parameter here in order to avoid | 88 // NOTE: Need to pass 'result' as a parameter here in order to avoid |
92 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' | 89 // warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
93 // which shows up because of the use of setjmp. | 90 // which shows up because of the use of setjmp. |
94 static void InvokeStatic(Isolate* isolate, | 91 static void InvokeStatic(Isolate* isolate, |
95 const Function& function, | 92 const Function& function, |
96 GrowableArray<const Object*>& args, | 93 GrowableArray<const Object*>& args, |
97 Dart_Handle* result) { | 94 Dart_Handle* result) { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 LongJump jump; | 494 LongJump jump; |
498 isolate->set_long_jump_base(&jump); | 495 isolate->set_long_jump_base(&jump); |
499 if (setjmp(*jump.Set()) == 0) { | 496 if (setjmp(*jump.Set()) == 0) { |
500 Dart::InitializeIsolate(snapshot, callback_data); | 497 Dart::InitializeIsolate(snapshot, callback_data); |
501 START_TIMER(time_total_runtime); | 498 START_TIMER(time_total_runtime); |
502 isolate->set_long_jump_base(base); | 499 isolate->set_long_jump_base(base); |
503 return reinterpret_cast<Dart_Isolate>(isolate); | 500 return reinterpret_cast<Dart_Isolate>(isolate); |
504 } else { | 501 } else { |
505 { | 502 { |
506 DARTSCOPE_NOCHECKS(isolate); | 503 DARTSCOPE_NOCHECKS(isolate); |
507 const String& errmsg = | 504 const Error& error_obj = |
508 String::Handle(isolate->object_store()->sticky_error()); | 505 Error::Handle(isolate->object_store()->sticky_error()); |
509 *error = strdup(errmsg.ToCString()); | 506 *error = strdup(error_obj.ToErrorCString()); |
510 } | 507 } |
511 Dart::ShutdownIsolate(); | 508 Dart::ShutdownIsolate(); |
512 } | 509 } |
513 return reinterpret_cast<Dart_Isolate>(NULL); | 510 return reinterpret_cast<Dart_Isolate>(NULL); |
514 } | 511 } |
515 | 512 |
516 | 513 |
517 DART_EXPORT void Dart_ShutdownIsolate() { | 514 DART_EXPORT void Dart_ShutdownIsolate() { |
518 CHECK_ISOLATE(Isolate::Current()); | 515 CHECK_ISOLATE(Isolate::Current()); |
519 STOP_TIMER(time_total_runtime); | 516 STOP_TIMER(time_total_runtime); |
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2453 } | 2450 } |
2454 delete debug_region; | 2451 delete debug_region; |
2455 } else { | 2452 } else { |
2456 *buffer = NULL; | 2453 *buffer = NULL; |
2457 *buffer_size = 0; | 2454 *buffer_size = 0; |
2458 } | 2455 } |
2459 } | 2456 } |
2460 | 2457 |
2461 | 2458 |
2462 } // namespace dart | 2459 } // namespace dart |
OLD | NEW |