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

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

Issue 8826007: First bits of external debugger API (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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/dart_api_impl.h ('k') | runtime/vm/debugger.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"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
12 #include "vm/dart_api_state.h" 12 #include "vm/dart_api_state.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/debugger.h"
15 #include "vm/debuginfo.h" 14 #include "vm/debuginfo.h"
16 #include "vm/exceptions.h" 15 #include "vm/exceptions.h"
17 #include "vm/growable_array.h" 16 #include "vm/growable_array.h"
18 #include "vm/longjump.h" 17 #include "vm/longjump.h"
19 #include "vm/native_entry.h" 18 #include "vm/native_entry.h"
20 #include "vm/object.h" 19 #include "vm/object.h"
21 #include "vm/object_store.h" 20 #include "vm/object_store.h"
22 #include "vm/port.h" 21 #include "vm/port.h"
23 #include "vm/resolver.h" 22 #include "vm/resolver.h"
24 #include "vm/snapshot.h" 23 #include "vm/snapshot.h"
(...skipping 21 matching lines...) Expand all
46 return dart_handle; \ 45 return dart_handle; \
47 } else { \ 46 } else { \
48 return Api::Error("%s expects argument '%s' to be of type %s.", \ 47 return Api::Error("%s expects argument '%s' to be of type %s.", \
49 CURRENT_FUNC, #dart_handle, #Type); \ 48 CURRENT_FUNC, #dart_handle, #Type); \
50 } \ 49 } \
51 } while (0) 50 } while (0)
52 51
53 52
54 // Return error if isolate is in an inconsistent state. 53 // Return error if isolate is in an inconsistent state.
55 // Return NULL when no error condition exists. 54 // Return NULL when no error condition exists.
56 static const char* CheckIsolateState( 55 const char* CheckIsolateState(Isolate* isolate, bool generating_snapshot) {
57 Isolate* isolate,
58 bool generating_snapshot = ClassFinalizer::kNotGeneratingSnapshot) {
59 bool success = (generating_snapshot) ? 56 bool success = (generating_snapshot) ?
60 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() : 57 ClassFinalizer::FinalizePendingClassesForSnapshotCreation() :
61 ClassFinalizer::FinalizePendingClasses(); 58 ClassFinalizer::FinalizePendingClasses();
62 if (success && !generating_snapshot) { 59 if (success && !generating_snapshot) {
63 success = isolate->object_store()->PreallocateObjects(); 60 success = isolate->object_store()->PreallocateObjects();
64 } 61 }
65 if (success) { 62 if (success) {
66 return NULL; 63 return NULL;
67 } else { 64 } else {
68 // Make a copy of the error message as the original message string 65 // 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. 66 // may get deallocated when we return back from the Dart API call.
70 const String& err = 67 const String& err =
71 String::Handle(isolate->object_store()->sticky_error()); 68 String::Handle(isolate->object_store()->sticky_error());
72 const char* errmsg = err.ToCString(); 69 const char* errmsg = err.ToCString();
73 intptr_t errlen = strlen(errmsg) + 1; 70 intptr_t errlen = strlen(errmsg) + 1;
74 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen)); 71 char* msg = reinterpret_cast<char*>(Api::Allocate(errlen));
75 OS::SNPrint(msg, errlen, "%s", errmsg); 72 OS::SNPrint(msg, errlen, "%s", errmsg);
76 return msg; 73 return msg;
77 } 74 }
78 } 75 }
79 76
80 77
81 static void SetupErrorResult(Dart_Handle* handle) { 78 void SetupErrorResult(Dart_Handle* handle) {
82 // Make a copy of the error message as the original message string 79 // Make a copy of the error message as the original message string
83 // may get deallocated when we return back from the Dart API call. 80 // may get deallocated when we return back from the Dart API call.
84 const String& error = String::Handle( 81 const String& error = String::Handle(
85 Isolate::Current()->object_store()->sticky_error()); 82 Isolate::Current()->object_store()->sticky_error());
86 const Object& obj = Object::Handle(ApiError::New(error)); 83 const Object& obj = Object::Handle(ApiError::New(error));
87 *handle = Api::NewLocalHandle(obj); 84 *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) {
98 ASSERT(isolate != NULL); 95 ASSERT(isolate != NULL);
99 LongJump* base = isolate->long_jump_base(); 96 LongJump* base = isolate->long_jump_base();
100 LongJump jump; 97 LongJump jump;
101 isolate->set_long_jump_base(&jump); 98 isolate->set_long_jump_base(&jump);
102 if (setjmp(*jump.Set()) == 0) { 99 if (setjmp(*jump.Set()) == 0) {
103 isolate->debugger()->Initialize(isolate);
104 const Array& kNoArgumentNames = Array::Handle(); 100 const Array& kNoArgumentNames = Array::Handle();
105 const Instance& retval = Instance::Handle( 101 const Instance& retval = Instance::Handle(
106 DartEntry::InvokeStatic(function, args, kNoArgumentNames)); 102 DartEntry::InvokeStatic(function, args, kNoArgumentNames));
107 if (retval.IsUnhandledException()) { 103 if (retval.IsUnhandledException()) {
108 *result = Api::ErrorFromException(retval); 104 *result = Api::ErrorFromException(retval);
109 } else { 105 } else {
110 *result = Api::NewLocalHandle(retval); 106 *result = Api::NewLocalHandle(retval);
111 } 107 }
112 } else { 108 } else {
113 SetupErrorResult(result); 109 SetupErrorResult(result);
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 } 2470 }
2475 delete debug_region; 2471 delete debug_region;
2476 } else { 2472 } else {
2477 *buffer = NULL; 2473 *buffer = NULL;
2478 *buffer_size = 0; 2474 *buffer_size = 0;
2479 } 2475 }
2480 } 2476 }
2481 2477
2482 2478
2483 } // namespace dart 2479 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698