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

Side by Side Diff: runtime/lib/isolate.cc

Issue 9314053: Revert Dart_PropagateError until I can track down the problems in (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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/include/dart_api.h ('k') | runtime/vm/ast.cc » ('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) 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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart.h" 8 #include "vm/dart.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 name ^= String::New(":"); 74 name ^= String::New(":");
75 str ^= String::Concat(str, name); 75 str ^= String::Concat(str, name);
76 name ^= String::NewSymbol(class_name); 76 name ^= String::NewSymbol(class_name);
77 str ^= String::Concat(str, name); 77 str ^= String::Concat(str, name);
78 GrowableArray<const Object*> arguments(1); 78 GrowableArray<const Object*> arguments(1);
79 arguments.Add(&str); 79 arguments.Add(&str);
80 Exceptions::ThrowByType(type, arguments); 80 Exceptions::ThrowByType(type, arguments);
81 } 81 }
82 82
83 83
84 // TODO(turnidge): Move to DartLibraryCalls. 84 RawInstance* ReceivePortCreate(intptr_t port_id) {
85 RawObject* ReceivePortCreate(intptr_t port_id) {
86 const String& class_name = 85 const String& class_name =
87 String::Handle(String::NewSymbol("ReceivePortImpl")); 86 String::Handle(String::NewSymbol("ReceivePortImpl"));
88 const String& function_name = 87 const String& function_name =
89 String::Handle(String::NewSymbol("_get_or_create")); 88 String::Handle(String::NewSymbol("_get_or_create"));
90 const int kNumArguments = 1; 89 const int kNumArguments = 1;
91 const Array& kNoArgumentNames = Array::Handle(); 90 const Array& kNoArgumentNames = Array::Handle();
92 const Function& function = Function::Handle( 91 const Function& function = Function::Handle(
93 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 92 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
94 class_name, 93 class_name,
95 function_name, 94 function_name,
96 kNumArguments, 95 kNumArguments,
97 kNoArgumentNames, 96 kNoArgumentNames,
98 Resolver::kIsQualified)); 97 Resolver::kIsQualified));
99 GrowableArray<const Object*> arguments(kNumArguments); 98 GrowableArray<const Object*> arguments(kNumArguments);
100 arguments.Add(&Integer::Handle(Integer::New(port_id))); 99 arguments.Add(&Integer::Handle(Integer::New(port_id)));
101 const Object& result = Object::Handle( 100 const Instance& result = Instance::Handle(
102 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 101 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
103 if (!result.IsError()) { 102 if (result.IsError()) {
103 ProcessError(result);
104 } else {
104 PortMap::SetLive(port_id); 105 PortMap::SetLive(port_id);
105 } 106 }
106 return result.raw(); 107 return result.raw();
107 } 108 }
108 109
109 110
110 // TODO(turnidge): Move to DartLibraryCalls. 111 static RawInstance* SendPortCreate(intptr_t port_id) {
111 static RawObject* SendPortCreate(intptr_t port_id) {
112 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); 112 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
113 const String& function_name = String::Handle(String::NewSymbol("_create")); 113 const String& function_name = String::Handle(String::NewSymbol("_create"));
114 const int kNumArguments = 1; 114 const int kNumArguments = 1;
115 const Array& kNoArgumentNames = Array::Handle(); 115 const Array& kNoArgumentNames = Array::Handle();
116 const Function& function = Function::Handle( 116 const Function& function = Function::Handle(
117 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), 117 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
118 class_name, 118 class_name,
119 function_name, 119 function_name,
120 kNumArguments, 120 kNumArguments,
121 kNoArgumentNames, 121 kNoArgumentNames,
122 Resolver::kIsQualified)); 122 Resolver::kIsQualified));
123 GrowableArray<const Object*> arguments(kNumArguments); 123 GrowableArray<const Object*> arguments(kNumArguments);
124 arguments.Add(&Integer::Handle(Integer::New(port_id))); 124 arguments.Add(&Integer::Handle(Integer::New(port_id)));
125 const Object& result = Object::Handle( 125 const Instance& result = Instance::Handle(
126 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 126 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
127 return result.raw(); 127 return result.raw();
128 } 128 }
129 129
130 130
131 static void RunIsolate(uword parameter) { 131 static void RunIsolate(uword parameter) {
132 IsolateStartData* data = reinterpret_cast<IsolateStartData*>(parameter); 132 IsolateStartData* data = reinterpret_cast<IsolateStartData*>(parameter);
133 Isolate* isolate = data->isolate_; 133 Isolate* isolate = data->isolate_;
134 char* library_url = data->library_url_; 134 char* library_url = data->library_url_;
135 char* class_name = data->class_name_; 135 char* class_name = data->class_name_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 ASSERT(result.IsNull()); 178 ASSERT(result.IsNull());
179 } 179 }
180 180
181 // Invoke the "_run" method. 181 // Invoke the "_run" method.
182 const Function& target_function = Function::Handle(Resolver::ResolveDynamic( 182 const Function& target_function = Function::Handle(Resolver::ResolveDynamic(
183 target, String::Handle(String::NewSymbol("_run")), 2, 0)); 183 target, String::Handle(String::NewSymbol("_run")), 2, 0));
184 // TODO(iposva): Proper error checking here. 184 // TODO(iposva): Proper error checking here.
185 ASSERT(!target_function.IsNull()); 185 ASSERT(!target_function.IsNull());
186 // TODO(iposva): Allocate the proper port number here. 186 // TODO(iposva): Allocate the proper port number here.
187 const Object& local_port = Object::Handle(ReceivePortCreate(port_id)); 187 const Instance& local_port = Instance::Handle(ReceivePortCreate(port_id));
188 if (local_port.IsError()) {
189 ProcessError(local_port);
190 }
191 GrowableArray<const Object*> arguments(1); 188 GrowableArray<const Object*> arguments(1);
192 arguments.Add(&local_port); 189 arguments.Add(&local_port);
193 const Array& kNoArgumentNames = Array::Handle(); 190 const Array& kNoArgumentNames = Array::Handle();
194 result = DartEntry::InvokeDynamic(target, 191 result = DartEntry::InvokeDynamic(target,
195 target_function, 192 target_function,
196 arguments, 193 arguments,
197 kNoArgumentNames); 194 kNoArgumentNames);
198 if (result.IsError()) { 195 if (result.IsError()) {
199 ProcessError(result); 196 ProcessError(result);
200 } 197 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 320
324 // Switch back to the original isolate and return. 321 // Switch back to the original isolate and return.
325 Isolate::SetCurrent(preserved_isolate); 322 Isolate::SetCurrent(preserved_isolate);
326 if (spawned_isolate == NULL) { 323 if (spawned_isolate == NULL) {
327 // Unable to spawn isolate correctly, throw exception. 324 // Unable to spawn isolate correctly, throw exception.
328 ThrowErrorException(Exceptions::kIllegalArgument, 325 ThrowErrorException(Exceptions::kIllegalArgument,
329 error, 326 error,
330 library_url, 327 library_url,
331 class_name); 328 class_name);
332 } 329 }
333 330 const Instance& port = Instance::Handle(SendPortCreate(port_id));
334 // TODO(turnidge): Move this code up before we launch the new
335 // thread. That way we won't have a thread hanging around that we
336 // can't talk to.
337 const Object& port = Object::Handle(SendPortCreate(port_id));
338 if (port.IsError()) { 331 if (port.IsError()) {
339 Exceptions::PropagateError(port); 332 if (port.IsUnhandledException()) {
333 ThrowErrorException(Exceptions::kInternalError,
334 "Unable to create send port to isolate",
335 library_url,
336 class_name);
337 } else {
338 ProcessError(port);
339 }
340 } 340 }
341 arguments->SetReturn(port); 341 arguments->SetReturn(port);
342 } 342 }
343 343
344 344
345 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) { 345 DEFINE_NATIVE_ENTRY(ReceivePortImpl_factory, 1) {
346 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull()); 346 ASSERT(AbstractTypeArguments::CheckedHandle(arguments->At(0)).IsNull());
347 intptr_t port_id = 347 intptr_t port_id =
348 PortMap::CreatePort(arguments->isolate()->message_handler()); 348 PortMap::CreatePort(arguments->isolate()->message_handler());
349 const Object& port = Object::Handle(ReceivePortCreate(port_id)); 349 const Instance& port = Instance::Handle(ReceivePortCreate(port_id));
350 if (port.IsError()) {
351 Exceptions::PropagateError(port);
352 }
353 arguments->SetReturn(port); 350 arguments->SetReturn(port);
354 } 351 }
355 352
356 353
357 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { 354 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) {
358 intptr_t id = Smi::CheckedHandle(arguments->At(0)).Value(); 355 intptr_t id = Smi::CheckedHandle(arguments->At(0)).Value();
359 PortMap::ClosePort(id); 356 PortMap::ClosePort(id);
360 } 357 }
361 358
362 359
363 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { 360 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) {
364 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value(); 361 intptr_t send_id = Smi::CheckedHandle(arguments->At(0)).Value();
365 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); 362 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value();
366 // TODO(iposva): Allow for arbitrary messages to be sent. 363 // TODO(iposva): Allow for arbitrary messages to be sent.
367 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); 364 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
368 365
369 // TODO(turnidge): Throw an exception when the return value is false? 366 // TODO(turnidge): Throw an exception when the return value is false?
370 PortMap::PostMessage(new Message( 367 PortMap::PostMessage(new Message(
371 send_id, reply_id, data, Message::kNormalPriority)); 368 send_id, reply_id, data, Message::kNormalPriority));
372 } 369 }
373 370
374 } // namespace dart 371 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698