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

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

Issue 9186058: Make the "sticky error" an Error instead of a String. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator_x64.cc ('k') | runtime/vm/longjump.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 LongJump jump; 506 LongJump jump;
510 isolate->set_long_jump_base(&jump); 507 isolate->set_long_jump_base(&jump);
511 if (setjmp(*jump.Set()) == 0) { 508 if (setjmp(*jump.Set()) == 0) {
512 Dart::InitializeIsolate(snapshot, callback_data); 509 Dart::InitializeIsolate(snapshot, callback_data);
513 START_TIMER(time_total_runtime); 510 START_TIMER(time_total_runtime);
514 isolate->set_long_jump_base(base); 511 isolate->set_long_jump_base(base);
515 return reinterpret_cast<Dart_Isolate>(isolate); 512 return reinterpret_cast<Dart_Isolate>(isolate);
516 } else { 513 } else {
517 { 514 {
518 DARTSCOPE_NOCHECKS(isolate); 515 DARTSCOPE_NOCHECKS(isolate);
519 const String& errmsg = 516 const Error& error_obj =
520 String::Handle(isolate->object_store()->sticky_error()); 517 Error::Handle(isolate->object_store()->sticky_error());
521 *error = strdup(errmsg.ToCString()); 518 *error = strdup(error_obj.ToErrorCString());
522 } 519 }
523 Dart::ShutdownIsolate(); 520 Dart::ShutdownIsolate();
524 } 521 }
525 return reinterpret_cast<Dart_Isolate>(NULL); 522 return reinterpret_cast<Dart_Isolate>(NULL);
526 } 523 }
527 524
528 525
529 DART_EXPORT void Dart_ShutdownIsolate() { 526 DART_EXPORT void Dart_ShutdownIsolate() {
530 CHECK_ISOLATE(Isolate::Current()); 527 CHECK_ISOLATE(Isolate::Current());
531 STOP_TIMER(time_total_runtime); 528 STOP_TIMER(time_total_runtime);
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 } 2464 }
2468 delete debug_region; 2465 delete debug_region;
2469 } else { 2466 } else {
2470 *buffer = NULL; 2467 *buffer = NULL;
2471 *buffer_size = 0; 2468 *buffer_size = 0;
2472 } 2469 }
2473 } 2470 }
2474 2471
2475 2472
2476 } // namespace dart 2473 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_x64.cc ('k') | runtime/vm/longjump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698